﻿var rolltimer1,rolltimer2;
var rollpause1=false;
var rollpause2=false;
var updating=false;
function ShowOffer1()
{
    var obj=$('OfferBox2');
    if (obj==null)
    {return;}
    var objul=$('OfferBox2').getElementsByTagName('ul');
    if (objul.length<4)
    {return;}
    obj.innerHTML+=obj.innerHTML;
    objul=$('OfferBox2').getElementsByTagName('ul');
    obj.style.width=objul[0].offsetWidth*objul.length+"px";
    if(typeof(rolltimer2)=='number')
    { 
     window.clearInterval(rolltimer2);
    }
     rolltimer2=setInterval("newsScroll2()",40);
}
function newsScroll2()
{
    if (rollpause2==true)
    {return;}
    var obj=$('OfferBox1');
    if (obj==null)
    {return;}
    obj.scrollLeft +=1;
    if (obj.scrollLeft>=(obj.scrollWidth-obj.offsetWidth))
    {obj.scrollLeft=obj.scrollWidth/2-obj.offsetWidth;}
}
function ShowIntro1()
{
   var obj=$('ShowIntro1');
   if (obj==null)
   {return;}
   if (obj.scrollHeight<55)
   {return;}
   obj.innerHTML+="<br /><br />"+obj.innerHTML+"<br /><br />";
  // obj.innerHTML+=obj.innerHTML;
   if(typeof(rolltimer1)=='number')
   { 
     window.clearInterval(rolltimer1);
   }
   rolltimer1=setInterval("newsScroll()",80);
}
function newsScroll()
{
    if (rollpause1==true)
    {return;}
    var obj=$('ShowIntro1');
    if (obj==null)
    {return;}
    obj.scrollTop +=1;
    if (obj.scrollTop>=(obj.scrollHeight-obj.offsetHeight))
    {obj.scrollTop=obj.scrollHeight/2-obj.offsetHeight;}
}
var showstate=false;
var rolltimer3;
var scrollnum=0;
function ShowPhoto()
{
    var obj=$('photointro');
    if (obj==null)
    {return;}  
    scrollnum=obj.scrollHeight;  
    showstate=(showstate==false)?true:false;
    rolltimer3=setInterval("newsScroll3()",20);
}
function newsScroll3()
{
    var obj=$('photointro');
    var obj1=$('ShowPhoto');
    if (obj==null)
    {return;} 
    if (showstate==true)
    {
         if (obj.offsetHeight<obj.scrollHeight)
         {
            obj.style.height=(Number(obj.style.height.replace("px",""))+Math.ceil(scrollnum*0.03))+"px"; 
            if (isIE()){scrollnum=obj.scrollHeight; }         
            scrollnum=Math.ceil(scrollnum*0.97);
         } 
         else
         {
          if (rolltimer3!=null)
          {clearInterval(rolltimer3);   obj1.style.top=(50+document.documentElement.scrollTop)+'px';               }
         }
     }
     else
     {
         if (obj.offsetHeight>1)
         {
           obj.style.height=Math.abs((Number(obj.style.height.replace("px",""))-Math.ceil(scrollnum*0.03)))+"px"; 
           if (isIE()){scrollnum=obj.scrollHeight; } 
           scrollnum=Math.ceil(scrollnum*0.97);
         }
         else
         {
          if (rolltimer3!=null)
          {clearInterval(rolltimer3); obj1.style.top=(50+document.documentElement.scrollTop)+'px';        }
         }
     }
}


function request(paras){ 
    var url = location.href; 
    if (url.toLowerCase().indexOf("showcom.aspx?cid=")<0&&paras=='CID')
    {return cid;}       
    var paraString = url.substring(url.indexOf("?")+1,url.length).split("&"); 
    var paraObj = {} 
    for (i=0; j=paraString[i]; i++){ 
    paraObj[j.substring(0,j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=")+1,j.length); 
    } 
    var returnValue = paraObj[paras.toLowerCase()]; 
    if(typeof(returnValue)=="undefined"){ 
    return ""; 
    }else{ 
    return returnValue; 
    } 
}

function showmsg(str,color,position)
{  
  var showobj=$('msg');
  if (isIE()&&(typeof(showobj.filters)=='undefined'||typeof(showobj.filters)=='unknown'))
  {
     alert(str);
     return;
  }
  if (typeof(showtimer)!='undefined')
  {clearInterval(showtimer);}
  showobj.style.backgroundColor=(color?color:'#f60');
  if (isIE())
  {showobj.filters.alpha.opacity=100;}
  else
  {showobj.style.MozOpacity=1;}
  showobj.innerHTML=str;
  showobj.style.display='block';
  if (typeof(position)!='undefined')
  {  showobj.style.top=Number(screen.height/2+document.documentElement.scrollTop-200+(position))+'px';}
  else
  {  showobj.style.top=Number(screen.height/2+document.documentElement.scrollTop-200)+'px';}
  showobj.style.left=Number(screen.width/2-100)+'px';
  showtimer =setInterval('low()',200);
}
function low()
{
  var showobj=$('msg');
  if (isIE())
  {
      if(showobj.filters.alpha.opacity>0)
      {showobj.filters.alpha.opacity -=5;}
      else
      {
         clearInterval(showtimer);
         showobj.filters.alpha.opacity=100;
         showobj.style.display='none';
      }
  }
  else
  {    
      if(showobj.style.MozOpacity>0)
      {showobj.style.MozOpacity -=0.05;}
      else
      {
         clearInterval(showtimer);
         showobj.style.MozOpacity =1;
         showobj.style.display='none';
      }
  }
}

function ShowProMsg()
{
  if (updating==true)
  {return true;}
  probar=$('ShowMsgBox');
  probar.className ="progressbar";
  probar.style.top=(screen.height/2+document.documentElement.scrollTop-150)+"px";
  probar.style.left=(screen.width/2-50)+"px";
  probar.style.display="";
  timer2=setTimeout("cleargressbar()",10000);
  updating=true;
  return false;
}

function updateprogressbar()
{
    $("ShowMsgBox").innerHTML +="•";
    if ($("ShowMsgBox").innerHTML.length>20)
    {$("ShowMsgBox").innerHTML="In progress •";}
}

function cleargressbar()
{
   updating=false;
    $("ShowMsgBox").style.display="none";
}
function onpage(str1)
{
   if ($('MenuBar1'))
   {
       for (var i=0;i<19;i+=2)
       {
           var obj=$('MBBtn'+i);
           if (obj!=null)
           {
               if (i==str1)
               {
                  obj.className='li2';
                  if ($('SiteNoteTxt'))
                  {                
                     $('SiteNoteTxt').innerHTML=obj.innerHTML;
                  }
               }
               else
               {obj.className='li1';}
           }
       }
   }
}
//****************************************************************//
function showFlash(link,bgcValue)
{
    var tempEditDiv=document.createElement('div');
    tempEditDiv.id='TempShowFlashDiv';   
    var bWidth,bHeight;
    var vWidth,vHeight;
    var aWidth,aHeight;
    if (isIE())
    {
        vWidth = document.documentElement.clientWidth;  //1003
        vHeight = document.documentElement.clientHeight; //590
    }
    else
    {
        vWidth = window.innerWidth;  //1024
        vHeight = window.innerHeight; //597
    }

    bWidth=document.body.scrollWidth; //ie 983 firefox 991
    bHeight=document.body.scrollHeight;  //ie 1586 firefox1590
     
    aWidth=window.screen.availWidth; //1024
    aHeight=window.screen.availHeight; //734
    if (isIE())
    {document.body.scroll='no';    }
    else
    {
        document.body.style.height =vHeight+'px';
        document.body.style.overflow='hidden';
    }   
    var tempStyleStr='position:absolute;top:0px;left:0px;background:'+bgcValue+';width:100%;height:'+aHeight+'px;z-index:10000;';
    tempEditDiv.style.cssText=tempStyleStr;
    tempEditDiv.innerHTML=getFlashPlayerString(link,vWidth,vHeight);
    document.body.appendChild(tempEditDiv);       
    setTimeout('correctShowWelComeSwf()',1000);
}
function correctShowWelComeSwf()
{
    if ($("TempShowFlashDiv"))
    {
       var hNum=document.documentElement.scrollTop;
       $("TempShowFlashDiv").style.top=hNum+'px';
       setTimeout('correctShowWelComeSwf()',100);
    }
}
function getFlashPlayerString(link,wNum,hNum)
{
    var jg = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="' + wNum + '" height="' + hNum + '" id="WelcomeSwf">';
    jg += '<param name="bgcolor" value="#F0F0F0" /><param name="movie" value="' + link + '" /><param name="quality" value="high" /><param name="menu" value="false" />';
    jg +='<param name="wmode" value="transparent"> '
    jg += '<embed src="' + link + '" quality="high"  wmode="transparent"  pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="' + wNum + '" height="' + hNum + '" </embed>';
    jg +='</object>';
    jg +='<div style="width:'+wNum+'px;height:'+hNum+'px;position:absolute;top:0px;left:0px;cursor:pointer;" onclick="closeWelcomeFlash()"></div>';
    return jg;
}
function deleWelcomeFlash()
{
    if ($("WelcomeSwf"))
    {
        if ($("WelcomeSwf").PercentLoaded()==0) 
        { closeWelcomeFlash();}
        else
        {window.setTimeout("deleWelcomeFlash()",50)}
    }
    else
    {closeWelcomeFlash();}
}
function closeWelcomeFlash()
{
  if ($('TempShowFlashDiv'))
  { $('TempShowFlashDiv').parentNode.removeChild($('TempShowFlashDiv'));} 
  if (isIE())
  { document.body.scroll='auto';  }
  else
  {  
     document.body.style.height='auto';
     document.body.style.overflow='';
  }
  closeCompHead1();
}
function hiddenCompHead1()
{ 
    if ($('CompHead1'))
    { $('CompHead1').style.display='none';      }
}
//****************************************************************//
function play1(name)
{
    var bLeft=parseInt(document.documentElement.scrollWidth)/2-250;    
    var bTop=parseInt(document.documentElement.scrollTop)+100;
    var jg=getWmvPlayer(name);
    creatEditBox('UserVideoPlayBox',bTop,bLeft,true,jg,'UserVideoPlayBox','#ffffff')  
}
function play2(name)
{
    var bLeft=parseInt(document.documentElement.scrollWidth)/2-250;    
    var bTop=parseInt(document.documentElement.scrollTop)+100;
    var jg=getFlvPlayer(name);
    creatEditBox('UserVideoPlayBox',bTop,bLeft,true,jg,'UserVideoPlayBox','#ffffff')  
}
function getFlvPlayer(link)
{
return '<div onclick="closePlayBox()" class="closeBtn"></div>\
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="500" height="400">\
<param name="bgcolor" value="#F0F0F0" />\
<param name="movie" value="/Flash/33.swf" />\
<param name="quality" value="high" />\
<param name="menu" value="false" />\
<param name="allowFullScreen" value="true" />\
<param name="FlashVars" value="fname='+link+'&fwidth=500&fheight1=375&fheight2=25" />\
<embed  src="/Flash/33.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="500" height="400"  FlashVars="fname='+link+'&fwidth=500&fheight1=375&fheight2=25"></embed>\
</object>';
}
function getWmvPlayer(link)
{
return '<div onclick="closePlayBox()" class="closeBtn"></div>\
<object ID="MediaPlayer" width="500" height="400" align="absmiddle" border="0" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="正在下载播放控件..." type="application/x-oleobject">\
<param name="FileName" value="'+link+'" />\
<param name="ShowStatusBar" value="True" />\
<param name="AutoStart" value="False" />\
<param name="ShowPositionControls" value="True" />\
<embed  type="application/x-mplayer2" pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/" src="'+link+'" name="MediaPlayer" width="500" height="400" autostart="-1" showstatusbar="-1" showpositioncontrols="0" showcaptioning="-1"> </embed>\
</object>'
}       
function closePlayBox()
{
    clearDiv('UserVideoPlayBox');
}

//****************************************************************//
function setImgAutoSize(img,maxWidth,maxHeight)
{
    var imgWidth=img.offsetWidth;
    var imgHeight=img.offsetHeight;
    if (img.readyState!="complete")
    { return false;    }
    if (imgWidth>maxWidth&&maxWidth!=0)
    { img.width=maxWidth;     }
    if (imgHeight>maxHeight&&maxHeight!=0)
    { img.height=maxHeight;     }
}

var $ = function(id){return document.getElementById(id);}
function isIE()
{
   if(document.all) return true;
   return false;
}
//outerHTML
if(window.HTMLElement) {
    HTMLElement.prototype.__defineSetter__("outerHTML",function(sHTML){
        var r=this.ownerDocument.createRange();
        r.setStartBefore(this);
        var df=r.createContextualFragment(sHTML);
        this.parentNode.replaceChild(df,this);
        return sHTML;
        });

    HTMLElement.prototype.__defineGetter__("outerHTML",function(){
     var attr;
        var attrs=this.attributes;
        var str="<"+this.tagName.toLowerCase();
        for(var i=0;i<attrs.length;i++){
            attr=attrs[i];
            if(attr.specified)
                str+=" "+attr.name+'="'+attr.value+'"';
            }
        if(!this.canHaveChildren)
            return str+">";
        return str+">"+this.innerHTML+"</"+this.tagName.toLowerCase()+">";
        });
        
   HTMLElement.prototype.__defineGetter__("canHaveChildren",function()
   {
      switch(this.tagName.toLowerCase())
      {
            case "area":
            case "base":
            case "basefont":
            case "col":
            case "frame":
            case "hr":
            case "img":
            case "br":
            case "input":
            case "isindex":
            case "link":
            case "meta":
            case "param":
            return false;
        }
        return true;

    });
}

//**************************************************//
function creatEditBox(divid,topY,leftX,addBackGround,divInnerHTML,divClassName,strBGC)
{
    if (addBackGround)
    {
        var bWidth,bHeight;
        if (isIE())
        {
           bWidth=parseInt(window.screen.width)-22; 
           bHeight=parseInt(document.documentElement.scrollHeight);
        }
        else
        {
            bWidth=parseInt(window.screen.width);
            bHeight=parseInt(document.documentElement.scrollHeight)-20;
        }
        var tempiFrame=document.createElement('iframe');
        tempiFrame.id='tempiFrame';
        var tempStyleStr="top:0px;left:0px;position:absolute;background-color:#000000;width:"+bWidth+"px;height:"+bHeight+"px;";
        tempStyleStr+=(isIE())?"filter:alpha(opacity=0);":"opacity:0;";
        tempiFrame.style.cssText=tempStyleStr;
        document.body.appendChild(tempiFrame);
        showBackground(tempiFrame,50);
    }
    var tempEditDiv=document.createElement('div');
    tempEditDiv.id=divid;
    var tempStyleStr='position:absolute;top:'+topY+'px;left:'+leftX+'px;';
    if (strBGC==null)
    {  tempStyleStr+='background:#ffffff;';           }
    else
    {  tempStyleStr+='background:'+strBGC;+';'}
    tempEditDiv.style.cssText=tempStyleStr;
    if(divInnerHTML)
    {  tempEditDiv.innerHTML=divInnerHTML;    }
    if(divClassName)
    {  tempEditDiv.className=divClassName;    }
    document.body.appendChild(tempEditDiv);
}
function showBackground(obj,endInt)
{
    if(isIE())
    {
        if (typeof(obj.filters)=='undefined'||typeof(obj.filters)=='unknown')
        { return;}    
        obj.filters.alpha.opacity+=10;
        if(obj.filters.alpha.opacity<endInt)
        {  setTimeout(function(){showBackground(obj,endInt)},2);        }
    }
    else
    {
        var al=parseFloat(obj.style.opacity);al+=0.05;
        obj.style.opacity=al;
        if(al<(endInt/100))
        {setTimeout(function(){showBackground(obj,endInt)},2);}
    }
}
function clearDiv(divid)
{
    if ($('tempiFrame'))
    {$('tempiFrame').parentNode.removeChild($('tempiFrame'));}
    if ($(divid))
    { $(divid).parentNode.removeChild($(divid));}    
    updating=false;
}
function getXY(obj){
var a = new Array();
var t = obj.offsetTop;
var l = obj.offsetLeft;
var h = obj.offsetHeight;
var w = obj.offsetWidth;
while(obj=obj.offsetParent){
t+=obj.offsetTop;
l+=obj.offsetLeft;
}
a[0] = t;
a[1] = l;
a[2] = h;
a[3] = w;
return a;
}
