﻿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;}
    //alert(obj.scrollWidth);
}
//首页公司简介动画
function ShowIntro1()
{
   var obj=$('ShowIntro1');
   if (obj==null)
   {return;}
   if (obj.scrollHeight<55)
   {return;}
   obj.innerHTML+="<br /><br />"+obj.innerHTML+"<br /><br />";
   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="";
  //probar.innerHTML="读取数据中 •";
 // timer1=setInterval("updateprogressbar()",50);
  timer2=setTimeout("cleargressbar()",10000);
  updating=true;
  return false;
}

//进度条更改文字
function updateprogressbar()
{
    $("ShowMsgBox").innerHTML +="•";
    if ($("ShowMsgBox").innerHTML.length>20)
    {$("ShowMsgBox").innerHTML="读取数据中 •";}
}
//清除进度条
function cleargressbar()
{
   updating=false;
//    clearInterval(timer1);
//    $("ShowMsgBox").innerHTML="";
//    $("ShowMsgBox").className="";   
    $("ShowMsgBox").style.display="none";
}
//当前页面
function onpage(str1)
{
   if ($('MenuBar1'))
   {
//       var obj=$('MenuBar1').getElementsByTagName('li');
       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';}
           }
       }
   }
}
//****************************************************************//
var shopRules=new function()//可修改的样式表对象
{  
  var obj=document.styleSheets[0]; 
  return obj.rules||obj.cssRules;  
}
function showFlash(link,bgcValue)
{
    shopRules[0].style.cssText='overflow: hidden;';
    shopRules[1].style.cssText='overflow: hidden;';
    var vWidth,vHeight,vWidth2,vHeight2;
    if (isIE())
    {
        vWidth = document.documentElement.clientWidth;  //1003 浏览器有效宽度 //html {overflow: hidden;}1020
        vHeight = document.documentElement.clientHeight; //542/564
        if (vWidth>1020){vWidth2=1020;}else{vWidth2=vWidth;}      
    }
    else
    {
        vWidth = window.innerWidth;  //1024  浏览器有效宽度
        vHeight = window.innerHeight; //597
        if (vWidth>1024){vWidth2=1024;}else{vWidth2=vWidth;}     
    }    
    if (vHeight>600){vHeight2=600;}else{vHeight2=vHeight;}   
    $('TempShowFlashDiv').innerHTML=getFlashPlayerString(link,vWidth,vHeight,vWidth2,vHeight2,bgcValue);
    setTimeout('correctShowWelComeSwf()',100);
}
function correctShowWelComeSwf()
{    
    if ($("TempShowFlashDiv"))
    {
        var hNum=document.documentElement.scrollTop;
        $("TempShowFlashDiv").style.top=hNum+'px';
        var obj=$("TempShowFlashDiv2");
        var obj1=$("TempShowFlashDiv1");
        var vWidth,vHeight,vWidth2,vHeight2;
        if (isIE())
        {
            vWidth = document.documentElement.clientWidth;  //1003 浏览器有效宽度 //html {overflow: hidden;}1020
            vHeight = document.documentElement.clientHeight; //542/564
            if (vWidth>1020){vWidth2=1020;}else{vWidth2=vWidth;}      
        }
        else
        {
            vWidth = window.innerWidth;  //1024  浏览器有效宽度
            vHeight = window.innerHeight; //597
            if (vWidth>1024){vWidth2=1024;}else{vWidth2=vWidth;}     
        }    
        if (vHeight>600){vHeight2=600;}else{vHeight2=vHeight;}           
        obj.style.width=vWidth2+'px';
        obj.style.height=vHeight2+'px';        
        obj1.style.width=vWidth+'px';
        obj1.style.height=vHeight+'px';        
        setTimeout('correctShowWelComeSwf()',100);
    }
}
function getFlashPlayerString(link,wNum,hNum,wNum2,hNum2,bgcValue)
{  
    var jg = '<table id="TempShowFlashDiv1" border="0" cellpadding="0" cellspacing="0" style="position:absolute;z-index:90010;top:0px;left:0px;width:'+wNum+'px;height:'+hNum+'px;background:'+bgcValue+';"><tr><td style="vertical-align:middle; text-align:center;"><div id="TempShowFlashDiv2" style="width:'+wNum2+'px;height:'+hNum2+'px;margin:0px auto 0px auto;"><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="100%" height="100%" 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="100%" height="100%" ></embed>';
    jg +='</object></div></td></tr></table>';
    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'));} 
    shopRules[0].style.cssText='';
    shopRules[1].style.cssText='';
    closeCompHead1();
}
//****************************************************************//
//function showFlash(link,bgcValue)
//{
//    var tempEditDiv=document.createElement('div');
//    tempEditDiv.id='TempShowFlashDiv';   
//    var bWidth,bHeight;
//    var vWidth,vHeight,vWidth2,vHeight2;
//    var aWidth,aHeight;
//    if (isIE())
//    {
//        vWidth = document.documentElement.clientWidth;  //1003
//        vHeight = document.documentElement.clientHeight; //590
//    }
//    else
//    {
//        vWidth = window.innerWidth;  //1024
//        vHeight = window.innerHeight; //597
//    }
//    if (vWidth>1003)
//    {vWidth2=1000;vHeight2=570;}
//    else
//    {vWidth2=vWidth;vHeight2=vHeight;}
//    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,vWidth2,vHeight2);
//    document.body.appendChild(tempEditDiv);       
//    setTimeout('correctShowWelComeSwf()',500);
//}
//function correctShowWelComeSwf()
//{
//    if ($("TempShowFlashDiv"))
//    {
//       var hNum=document.documentElement.scrollTop;
//       $("TempShowFlashDiv").style.top=hNum+'px';
//       setTimeout('correctShowWelComeSwf()',50);
//    }
//}
//function getFlashPlayerString(link,wNum,hNum,wNum2,hNum2)
//{
//    var jg = '<div style="position:relative;width:'+wNum2+'px;height:'+hNum2+'px;margin:0px auto 0px auto;"><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="' + wNum2 + '" height="' + hNum2 + '" 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="' + wNum2 + '" height="' + hNum2 + '" </embed>';
//    jg +='</object></div>';
//    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 ($('TempShowFlashDiv0'))
//  { $('TempShowFlashDiv0').parentNode.removeChild($('TempShowFlashDiv0'));} 
//  
//  
//  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;
}