﻿


function ShowCateSyte(index)
{
   var Count=6;//该板块的Item个数
   for(var i=1;i<=Count;i++)
   {
     var obj=window.document.getElementById("divHomeBar"+i.toString ());
     var subobj=window.document.getElementById("divSubBar"+i.toString ());
     if(obj !=null )
     {
       if(i==index)
       { 
         obj.className="item_2";
       }
       else 
       {
           obj.className="item_1";
       }
      
     }
     if(subobj!=null )
     {
      if(i==index)
       {
         subobj.style.display="inline";
       }
       else 
       {
           subobj.style.display="none";
       }
     
     }
   
   }
}

 function InitCateStyle()
 {
    var index=1;
    var strUrl=location.href.toString().toLowerCase();
     if(strUrl.indexOf("product/default.aspx")>-1)
    {
       index=3;
    } 
       else if(strUrl.indexOf("product/productdetail.aspx")>-1)
    {
       index=3;
    } 
    
    else if(strUrl.indexOf("news/default.aspx")>-1)
    {
       index=5;
    } 
    else if(strUrl.indexOf("news/newsdetail.aspx")>-1)
    {
       index=5;
    }  
    else if(strUrl.indexOf("server/default.aspx")>-1)
    {
       index=4;
    }  
     else if(strUrl.indexOf("server/warranty.aspx")>-1)
    {
       index=4;
    } 
    else if(strUrl.indexOf("default.aspx")>-1)
    {
       index=1;
    }
   else if(strUrl.indexOf("aboutus.aspx")>-1)
    {
       index=2;
    } 
    
    else if(strUrl.indexOf("contactus.aspx")>-1)
    {
       index=6;
    }
    else 
    {
      index=1;
    }
    ShowCateSyte(index);
  }
  InitCateStyle();
  //图片缩放
function DownImage(ImgD,MaxWidth,MaxHeight,alignX,alignY)
{
	alignX=alignX||1;
	alignY=alignY||1;
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0)
	{
		var rate = (MaxWidth/image.width < MaxHeight/image.height)?MaxWidth/image.width:MaxHeight/image.height;
		var wid=0;
		var hid=0;
		if(rate <= 1)
		{
			wid=ImgD.width=image.width*rate;
			hid=ImgD.height=image.height*rate;
		}
		else
		{
			wid=ImgD.width=image.width;
			hid=ImgD.height=image.height;
		}
		if(alignX==1)
		{
			var ii=(MaxWidth-wid)/2;
			ImgD.style.marginLeft=ImgD.style.marginRight=ii+"px";
		}
		if(alignY==1)
		{
			var ii=(MaxHeight-hid)/2;
			ImgD.style.marginTop=ImgD.style.marginBottom=ii+"px";
		}
    }
}
 function GetXmlHttpRequest()
     {
    	var xmlHttp;
    	if(window.ActiveXObject)//IE5、IE6
    	{
    		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	else if(window.XMLHttpRequest)//Firefor 、IE7、Others
    	{
	    	xmlHttp=new XMLHttpRequest();
    	}
    	return xmlHttp;
    }
        function QueryString(item)
    {
     var sValue=location.search.match(new RegExp("[\?\&]"+item+"=([^\&]*)(\&?)","i"))
     return sValue?sValue[1]:"9Y3OJdj2xZ4%3d";
    }



