/// <summary>
/// 模板中需要用到的公共js
/// </summary>

function SetSize(obj, width, height)
{
    myImage = new Image();
    myImage.src = obj.src;
    if (myImage.width>0 && myImage.height>0)
    {
        var rate = 1;
        if (myImage.width>width || myImage.height>height)
        {
            if (width/myImage.width<height/myImage.height)
            {
                rate = width/myImage.width;
            }
            else
            {
                rate = height/myImage.height;
            }
        }
        if (window.navigator.appName == "Microsoft Internet Explorer")
        {
            obj.style.zoom = rate;
        }
        else
        {
            obj.width = myImage.width*rate;
            obj.height = myImage.height*rate;
        }
    }
}
function ShowHD()
{
    document.getElementById("bangHD").className = "leftTI2";
    document.getElementById("bangPP").className = "leftTI";
    document.getElementById("bangJF").className = "leftTI";
    document.getElementById("bodyHD").className = "leftBodyChange";
    document.getElementById("bodyPP").className = "displayNone";
    document.getElementById("bodyJF").className = "displayNone";
}
function ShowPP()
{
    document.getElementById("bangHD").className = "leftTI";
    document.getElementById("bangPP").className = "leftTI2";
    document.getElementById("bangJF").className = "leftTI";
    document.getElementById("bodyHD").className = "displayNone";
    document.getElementById("bodyPP").className = "leftBodyChange";
    document.getElementById("bodyJF").className = "displayNone";
}
function ShowJF()
{
    document.getElementById("bangHD").className = "leftTI";
    document.getElementById("bangPP").className = "leftTI";
    document.getElementById("bangJF").className = "leftTI2";
    document.getElementById("bodyHD").className = "displayNone";
    document.getElementById("bodyPP").className = "displayNone";
    document.getElementById("bodyJF").className = "leftBodyChange";
}
function ShowHD2()
{
  document.getElementById("yhyy1").className = "yh";
  document.getElementById("yhyy2").className = "yhn";
  document.getElementById("yhyy3").className = "yhn";
  document.getElementById("yh1").className = "rightm1";
  document.getElementById("yh2").className = "hxn";
  document.getElementById("yh3").className = "hxn";
}
function ShowPP2()
{
  document.getElementById("yhyy1").className = "yhn";
  document.getElementById("yhyy2").className = "yh";
  document.getElementById("yhyy3").className = "yhn";
  document.getElementById("yh1").className = "hxn";
  document.getElementById("yh2").className = "rightm1";
  document.getElementById("yh3").className = "hxn";
}
function ShowJF2()
{
  document.getElementById("yhyy1").className = "yhn";
  document.getElementById("yhyy2").className = "yhn";
  document.getElementById("yhyy3").className = "yh";
  document.getElementById("yh1").className = "hxn";
  document.getElementById("yh2").className = "hxn";
  document.getElementById("yh3").className = "rightm1";
}
function Show(numid)
{
    var divs = middlePic.getElementsByTagName("div");
    for (var i=0; i<divs.length; i++ )
    {
        divs[i].className='bigImgNone';
    }
    document.getElementById(numid).className='bigImg';
}
function ShowList(types)
{
        var nowlocation = window.location.href;
	var leftstr = nowlocation.substr(0,nowlocation.lastIndexOf("_") + 1);
	var temp = nowlocation.substr(nowlocation.indexOf("_") + 1, nowlocation.length - nowlocation.indexOf("_"));

	var tempnum = temp.substr(0,temp.indexOf("_"));
	
	
	var rightstr = nowlocation.substr(nowlocation.lastIndexOf("_") + 2, nowlocation.length - nowlocation.lastIndexOf("_"));
 	tempnum ="";
	if(tempnum.length >0)
		window.location.href = leftstr + types + rightstr;
	else
	{   
		temp = temp.substr(1, temp.length - 1);
	
		leftstr ="_1"+ temp.substr(0,temp.lastIndexOf("_") + 1);
		leftstr = "_1_0_";
		 //leftstr ="_1"+ temp.substr(1,temp.length-1);
		rightstr = temp.substr(temp.lastIndexOf("."), temp.length - temp.lastIndexOf("."));
		window.location.href = nowlocation.substr(0,nowlocation.indexOf("_")) + leftstr + types + rightstr;
	}
}

function ShowListDuiHuan(types)
{  
    var nowlocation = window.location.href;
    var temp = nowlocation.substr(0,nowlocation.lastIndexOf("_") + 1);
    temp = temp + types +".aspx";
    window.location.href=temp;
}

function high(which2)
{
    theobject=which2;
    highlighting=setInterval("highlightit(theobject)",50);
}
function low(which2)
{
	clearInterval(highlighting);
	which2.filters.alpha.opacity=40;
}
function highlightit(cur2)
{
	if (cur2.filters.alpha.opacity<100)
	cur2.filters.alpha.opacity+=5;
	else if (window.highlighting)
	clearInterval(highlighting);
}
function PicNone()
{
    var divs = middlePic.getElementsByTagName("div");
    for (var j=0; j<divs.length; j++ )
    {
	    divs[j].className='bigImgNone';
    }
}
var num=1;
var divss;
function NextPic()
{
    PicNone();
	if(num>=divss.length-1)
    {
   		num=1;
    }
    else
    {
   		num = num + 1;	
    }
    divss[num].className="bigImg";
}
var timeID;
function StopPic()
{
    if(timeID==null)
    {
   		timeID=setInterval("NextPic();",1500);
    }
    else
    {
   		clearInterval(timeID);
		timeID=null;
    }
}



//清空一些隐藏框的数据
function JS_ClearHidden(currentID)
{

	var ids = new Array();
	ids.push ("Hid_GroupID");
	ids.push("Hid_IsSupportJS");
	ids.push("Hid_ProductID");
	ids.push("Hid_ToCart");
	ids.push("Hid_RemoveCart");
	ids.push("Hid_ToWishList");
	ids.push("Hid_RemoveWishList");

	ids.push("Hid_BrowseCategoryID");
	ids.push("Hid_IsUpdateQtys");
	ids.push("Hid_IsLogout");
	ids.push("Hid_TargetPage");

	ids.push("Hid_URL");
	
	for(var i=0;i<ids.length;i++)
	{
		if (ids[i] != currentID)
		{
			document.getElementById(ids[i]).value = "";
		}
	}
	return true;
} 
//注销用户登录
function JS_CustomerLogout()
{
	document.getElementById("Hid_IsLogout").value = "1";
	JS_ClearHidden("Hid_IsLogout");
	document.forms[0].submit();
}

//去登录页面
//targetPage:登录成功后跳转的页面
function JS_GoLogin(targetPage,dirPage)
{

	if(dirPage!=undefined)
	location.href =dirPage;
	else 
	location.href ="login.aspx";
	return true;
}