﻿// JScript 文件
//导航菜单开始
function showheadxl(dlid)
{ 
 var whichheadxl = document.getElementById("headxl"+dlid);
 whichheadxl.style.display="block"; 
} 
function hiddenheadxl(dlid)
{ 
 var whichheadxl = document.getElementById("headxl"+dlid);
 whichheadxl.style.display="none"; 
}
function showleftxl(id)
{ 
 var leftxl = document.getElementById("leftxl"+id);
 leftxl.style.display="block"; 
} 
function hiddenleftxl(id)
{ 
 var leftxl = document.getElementById("leftxl"+id);
 leftxl.style.display="none"; 
}
//detail_right
function showrightxl(id)
{
var whichdiv=document.getElementById("leftxl"+id);
if(whichdiv.style.display=="none")
	whichdiv.style.display="block";
else
	whichdiv.style.display="none";
} 
function showcolor(colorid)
{ 
 var colorid = document.getElementById("color"+colorid);
 colorid.style.color="#ffffff";
}
function hiddencolor(colorid)
{ 
 var colorid = document.getElementById("color"+colorid);
 colorid.style.color="#B11212";
}
//导航菜单结束
//左侧菜单
function showdiv(divid)
{
    var whichdiv=document.getElementById(divid);
    if(whichdiv.style.display=="none")
    {whichdiv.style.display="block";}
    else
    {whichdiv.style.display="none";}
}
function showthree(id)
{ 
 var whichthree = document.getElementById("three"+id);
 if (whichthree.innerHTML!="")
 	whichthree.style.display="block"; 
} 
function hiddenthree(id)
{ 
 var whichthree = document.getElementById("three"+id);
 whichthree.style.display="none"; 
}
function showheadthree(id)
{ 
 var whichthree = document.getElementById("headthree"+id);
 if (whichthree.innerHTML!="")
 	whichthree.style.display="block"; 
} 
function hiddenheadthree(id)
{ 
 var whichthree = document.getElementById("headthree"+id);
 whichthree.style.display="none"; 
}

function showxxla(id)
{ 
 var whichxxl = document.getElementById("xxla"+id);
 whichxxl.style.display="block"; 
} 
function hiddenxxla(id)
{ 
 var whichxxl = document.getElementById("xxla"+id);
 whichxxl.style.display="none"; 
}

function showxxlhead(id)
{ 
 var whichxxl = document.getElementById("xxlhead"+id);
 whichxxl.style.display="block"; 
} 
function hiddenxxlhead(id)
{ 
 var whichxxl = document.getElementById("xxlhead"+id);
 whichxxl.style.display="none"; 
}
//描述显示/隐藏简要描述及切换
function showico(pid)
{
    var whichleftxl = document.getElementById(pid);
    if (pid=="divdata")
    {
         whichleftxl.style.display="block";
         document.getElementById("dataico").style.background="url(images/product/ico_open.gif) no-repeat";
         document.getElementById("divall").style.display="none";
         document.getElementById("allico").style.background="url(images/product/ico_close.gif) no-repeat";
    }
    else if(pid=="divall")
    {
         whichleftxl.style.display="block";
         document.getElementById("allico").style.background="url(images/product/ico_open.gif) no-repeat";
         document.getElementById("divdata").style.display="none";
         document.getElementById("dataico").style.background="url(images/product/ico_close.gif) no-repeat";
    }
}
//左侧菜单
function selectall()
{
    var divselect=document.getElementById('gvall');
    var cbx=divselect.getElementsByTagName('input');
    for(var i=0;i<cbx.length;i++)
    {
        if(!cbx[i].checked)
        {
            cbx[i].checked = true;                
        }
        else
        {
            cbx[i].checked = false;
        }
    }
}
//鼠标移上显示大图开始
function openimg(scr,imgid,divid)
{
    document.getElementById(imgid).src=scr.src; 
    if (imgid=='newimg')
    {           
        document.getElementById("divnew").style.display="block";
    }
    else if (imgid=='recommendimg')
    {
        document.getElementById("divrecommend").style.display="block";
    }
    else if (imgid=='moveimg')
    {
        document.getElementById("divmove").style.display="block";
    }
    var mX=scr.offsetTop; 
    var mY=scr.offsetLeft;  
    var mY1=scr.offsetWidth;
    var x=document.body.offsetWidth;
    var y=document.body.offsetHeight;
    var gx=document.body.scrollTop;
    while(scr=scr.offsetParent)
    {  
        mX+=scr.offsetTop;  
        mY+=scr.offsetLeft;  
    }  
     var xx=x-mY-mY1;
     var yy=y-mX+gx;
    if(xx<document.getElementById(divid).clientWidth)
    {
        var mY2=mY-document.getElementById(divid).clientWidth;
        document.getElementById(divid).style.left=mY2;
    }
    else
    {
        document.getElementById(divid).style.left=mY+mY1;
    }
    if(yy<document.getElementById(divid).clientHeight)
    {
        var mX2=mX-document.getElementById(divid).clientHeight;
        document.getElementById(divid).style.top=mX2;
    }
    else
    {
        document.getElementById(divid).style.top=mX+30;
    }
}
function closeimg(divid)
{
    document.getElementById(divid).style.display="none";
}
//鼠标移上显示大图结束

//正整数正则表达式
function isInteger() //by zergling
{
    var patrn=/^[0-9]*[1-9][0-9]*$/;
    if (!patrn.exec(num))
	{
		alert("请输入正整数");
		return false;
	}
}
