// JavaScript Document
var xmlHttp;
function createRequestobj(){//创建请求对象
	if(window.XMLHttpRequest){//其它浏览器
		//other browser
		xmlHttp = new XMLHttpRequest();
		return xmlHttp;
	}else if(window.ActiveXObject){//IE浏览器
		//IE browser
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		return xmlHttp;
	}
	throw new Error("XMLHttp object coulde be created!");
}
function processindex(url,xmlHttp,div){
	document.getElementById(div).innerHTML="<img src='image/dark/loading.gif' align='right' valign='top' border=0>";
	xmlHttp = createRequestobj();
	xmlHttp.open("POST",url,true);//
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState==4){//
			//alert(xmlHttp.responseText);				
			if(xmlHttp.status==200){
				//alert(xmlHttp.responseText);
				document.getElementById(div).innerHTML=xmlHttp.responseText;
				//document.getElementById(div).className='';
			}
			else{
				alert('An error occurred:'+xmlHttp.statusText);//服务器端发生错误
				}
		}
	}
	xmlHttp.send(null);
}
function processRequest(url,cid,h,from){//处理客户发来的请求
	xmlHttp = createRequestobj();
	xmlHttp.open("POST",url,true);//
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState==4){//
			//alert(xmlHttp.responseText);				
			if(xmlHttp.status==200){
				//alert(xmlHttp.getAllResponseHeaders());
				showinfo(cid,xmlHttp.responseText,h,from);//正常响应
			}
			else{
				
				alert('An error occurred:'+xmlHttp.statusText);//服务器端发生错误
				}
		}
	}
	xmlHttp.send(null);
}
function inceptclient(url,obj,obj1){//接收客户的请求
	document.getElementById(obj1).style.display="";
	xmlHttp = createRequestobj();
	xmlHttp.open("POST",url,true);//
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState==4){//
			//alert(xmlHttp.responseText);
			if(xmlHttp.status==200){
				showinfo1(obj,xmlHttp.responseText,obj1);//正常响应
			}
			else
				alert('An error occurred:'+xmlHttp.statusText);//服务器端发生错误
		}
	}
	xmlHttp.send(null);
}
function showpro(url,cid,d,h,from){//接收客户的请求
	var d1=0;
	if(document.getElementById("chn_"+cid).style.display=="")
		d1=1;
	else
		d1=0;
	if(d!=2){
		if(from==1){
			for(i=0;i<subcat.length;i++){
				if(subcat[i]!=cid){
					document.getElementById("chn_"+subcat[i]).style.display="none";
						document.getElementById("btn_"+subcat[i]).disabled=true;
					document.getElementById("d"+subcat[i]).style.display="none";
					document.getElementById("h"+subcat[i]).style.display="none";
				}
			}
		}
	}
	if(d==1 && h==2 && document.getElementById("chn_"+cid).innerHTML!=""){
		//if(d!=2)
		document.getElementById("d"+cid).style.display="none";
		document.getElementById("h"+cid).style.display="none";
		show(cid,d1,from);
	}
	else{
		if(h==0 || h==2)
			document.getElementById("d"+cid).style.display="";
		else
			document.getElementById("h"+cid).style.display="";
		processRequest(url,cid,h,from);	
	}
}
function show(cid,d,from){
	if(from){
		for(i=0;i<subcat.length;i++){
				document.getElementById("btn_"+subcat[i]).disabled=false;
		}
	}
	if(d==0){
		document.getElementById("chn_"+cid).style.display="";
	}	
	else{
		document.getElementById("chn_"+cid).style.display="none";
	}
}

function showinfo(cid,text,h,from){//显示服务器端返回的消息
	if(from==1)
	{
		for(i=0;i<subcat.length;i++)
		{
			document.getElementById("btn_"+subcat[i]).disabled=false;
		}
	}
	document.getElementById("chn_"+cid).style.display="";
	document.getElementById("chn_"+cid).innerHTML=text;
		document.getElementById("d"+cid).style.display="none";
		document.getElementById("h"+cid).style.display="none";
}
function showinfo1(obj,text,obj1){//显示服务器端返回的消息
	document.getElementById(obj).innerHTML=text;
	document.getElementById(obj1).style.display="none";
}
