// JavaScript Document
//设定图片显示尺寸
function StanFormatImg(thisid,picwidth,picheight)
{
	var thisimgs=new Image();
	myimgid=document.getElementById(thisid);
	thisimgs.src=myimgid.src;
	if(thisimgs.width<picwidth)
	{
		if(thisimgs.height<picheight)
		{
			myimgid.width=thisimgs.width;
			myimgid.height=thisimgs.height;
		}else{
			myimgid.width=picheight*thisimgs.width/thisimgs.height;
			myimgid.height=picheight;
		}
	}else{
		if(thisimgs.height<picheight)
		{
			myimgid.height=picwidth*thisimgs.height/thisimgs.width;
			myimgid.width=picwidth;
		}else{
			if(thisimgs.width/thisimgs.height>picwidth/picheight)
			{
				myimgid.height=picwidth*thisimgs.height/thisimgs.width;
				myimgid.width=picwidth;
			}else{
				myimgid.width=picheight*thisimgs.width/thisimgs.height;
 				myimgid.height=picheight;
			}
		}
	}
}
//判断是否为数字类型
function IsDigit()
{
	return ((event.keyCode >= 46) && (event.keyCode <=57));
}
//动态获取页面信息
function StanXmlHttp(DivId,StanUrl)
{
	//document.getElementById(DivId).innerHTML="请等待...";
	var Url=StanUrl;
	var XmlHttp;
	if(window.ActiveXObject)
	{
		XmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	}else{
		XmlHttp=new XMLHttpRequest();
	}
	XmlHttp.open("GET",Url,true);
	XmlHttp.onreadystatechange=function()
	{
		if(XmlHttp.readyState==4 && XmlHttp.status==200 || XmlHttp.readyState==4 && XmlHttp.status==0 )
	 	{
			document.getElementById(DivId).innerHTML=XmlHttp.responseText;
	 	}
	}
	XmlHttp.send(null);
 }
 
function StanIndexXmlHttp(DivId,StanUrl)
{
	//document.getElementById(DivId).innerHTML="请等待...";
	var Url=StanUrl;
	var XmlHttp;
	if(window.ActiveXObject)
	{
		XmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	}else{
		XmlHttp=new XMLHttpRequest();
	}
	XmlHttp.open("GET",Url,true);
	XmlHttp.onreadystatechange=function()
	{
		if(XmlHttp.readyState==4 && XmlHttp.status==200 || XmlHttp.readyState==4 && XmlHttp.status==0 )
	 	{
			document.getElementById(DivId).innerHTML=XmlHttp.responseText;
			$(function()
			{
				// this initialises the demo scollpanes on the page.
				$('#pane1').jScrollPane();
				
			
			});
	 	}
	}
	XmlHttp.send(null);
 }

var  highlightcolor='#d5f4fe';
//此处clickcolor只能用win系统颜色代码才能成功,如果用#xxxxxx的代码就不行,还没搞清楚为什么:(
var  clickcolor='#51b2f6';
function  changeto(){
source=event.srcElement;
if  (source.tagName=="TR"||source.tagName=="TABLE")
return;
while(source.tagName!="TD")
source=source.parentElement;
source=source.parentElement;
cs  =  source.children;
//alert(cs.length);
if  (cs[1].style.backgroundColor!=highlightcolor&&source.id!="nc"&&cs[1].style.backgroundColor!=clickcolor)
for(i=0;i<cs.length;i++){
	cs[i].style.backgroundColor=highlightcolor;
}
}

function  changeback(){
if  (event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="nc")
return
if  (event.toElement!=source&&cs[1].style.backgroundColor!=clickcolor)
//source.style.backgroundColor=originalcolor
for(i=0;i<cs.length;i++){
	cs[i].style.backgroundColor="";
}
}

function  clickto(){
source=event.srcElement;
if  (source.tagName=="TR"||source.tagName=="TABLE")
return;
while(source.tagName!="TD")
source=source.parentElement;
source=source.parentElement;
cs  =  source.children;
//alert(cs.length);
if  (cs[1].style.backgroundColor!=clickcolor&&source.id!="nc")
for(i=0;i<cs.length;i++){
	cs[i].style.backgroundColor=clickcolor;
}
else
for(i=0;i<cs.length;i++){
	cs[i].style.backgroundColor="";
}
} 	 
//Select下拉菜单对应事件
function ChangeLocation(divId,id)
{
	if(document.getElementById(divId))
	{
		document.getElementById(divId).style.visibility="visible";
		document.getElementById(divId).length = 1; 
    	var locationid=locationid;
    	var i,j;
		j=0;
    	for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == id)
            { 
			 j=j+1;
             document.getElementById(divId).options[document.getElementById(divId).length] = new Option(subcat[i][0], subcat[i][2]);
            }        
        }
		if(j==0)
		{
			document.getElementById(divId).style.visibility="hidden";
		}	
	}
}
function HideSelect(divId)
{
	if(document.getElementById(divId))
	{
		document.getElementById(divId).style.visibility="hidden";
	}
}
//图片显示
function PreShowImgUrl(ImgSrc)
{
	NewImgSrc=ImgSrc;
	NewImg=new Image();
	NewImg.src=NewImgSrc;
	NewImgSize=NewImg.fileSize;
	NewImgWidth=NewImg.width;
	NewImgHeight=NewImg.height;
	NewImgSizeFormat=Math.round(NewImgSize*100/1024)/100;
	if(NewImgSrc=="")NewImgSrc="../images/nopic.gif"
	document.getElementById("PreImg").src=NewImgSrc;
	document.getElementById("StanImgSize").innerHTML="大小:"+NewImgSizeFormat+"K&nbsp;&nbsp;宽高:"+NewImgWidth+"*"+NewImgHeight;
}	
//多级显示CSS
function ListCss(ulId)
{
	var ulId=ulId;
	var listnum=9;   //N级类别
	var liststr="";
	document.write("<style>");
	document.write("ul{list-style:none;margin:0px;padding:0px;}");
	document.write("#"+ulId+"{position:absolute;font-size:14px;}");
	document.write("#"+ulId+" a{display:block;width:150px;height:15px;padding:5px 5px 10px;background:#666;color:#fff;text-decoration:none;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}");
	document.write("#"+ulId+" a:hover{background:#333;}");
	document.write("#"+ulId+" li{float:left;clear:left;width:170px;background: #ccc;padding-bottom:3px;}");
	//document.write("#"+ulId+" li.childs{background:url(inc/qq/icon.gif) right no-repeat #ccc;}");
	document.write("#"+ulId+" ul{position:absolute;margin-left:165px;margin-top:-30px;display: none;}");
	document.write("#"+ulId+" li.show ul{display:block;}");
	for(i=1;i<=listnum;i++)
	{
		document.write("#"+ulId+liststr+" li.show li ul{display:none;}");
		document.write("#"+ulId+liststr+" li li.show ul{display:block;}");
		liststr=liststr+" li";
	}
	document.write("</style>");	
}
//多级显示事件处理
function menuFix(ulId) 
{
	ListCss(ulId);
	if(document.getElementById(ulId))
	{
		var sfEls = document.getElementById(ulId).getElementsByTagName("li");
		for (var i=0; i<sfEls.length; i++) 
		{
			sfEls[i].onmouseover=function() 
			{
			document.getElementById(ulId).parentNode.style.zIndex=100;
			this.className+=(this.className.length>0? " ": "") + "show";
			}
			sfEls[i].onmouseout=function() 
			{
				document.getElementById(ulId).parentNode.style.zIndex=0;
				this.className=this.className.replace(new RegExp("( ?|^)show\\b"), "");
			}
		}
		
	}
}	

function showPicList(num)
{
	for(i=1;i<=2;i++)
	{
		if(document.getElementById("mylist"+i))
		{
			if(parseInt(num)==i)
			{
				document.getElementById("mylist"+i).style.display="block";	
			}else{
				document.getElementById("mylist"+i).style.display="none";	
			}
		}
	}
	
}
function hidePicList()
{
	for(i=1;i<=2;i++)
	{
		if(document.getElementById("mylist"+i))
		{
			document.getElementById("mylist"+i).style.display="none";	
		}
	}
}
