﻿	//alert("init");
	function xmlRemoteList(objNodeList)
	{	alert("1");
		this.m_objList=objNodeList;
		this.GetListCount=GetListCount;
		this.GetListItemText=GetListItemText;
		this.GetListItemValue=GetListItemValue;
	}
	function GetListCount()
	{	alert("2");
		return this.m_objList.length;
	}
	function GetListItemText(intIndex)
	{	alert("3");
		var obj=this.m_objList.item(intIndex);
		return obj.getAttribute("IT");
	}
	function GetListItemValue(intIndex)
	{	alert("4");
		var obj=this.m_objList.item(intIndex);
		return obj.getAttribute("IV");
	}

	
	function xmlRemoteObject(strURL)
	{	alert("5");
		this.m_strURL=strURL;	
		this.m_objHTTP=new ActiveXObject("Msxml2.XMLHTTP");
		this.m_objReturned=null;
		this.m_objRootE=null;
		this.GetData=GetData;
		this.GetStringAtt=GetStringAtt;
		this.GetIntAtt=GetIntAtt;
		this.GetFloatAtt=GetFloatAtt;
		this.GetList=GetList;

	}
	
	
	function GetList(strName)
	{	alert("6");
		if (this.m_objRootE==null ) return null;
		var currNodeList = this.m_objRootE.selectSingleNode(strName);
		if (currNodeList==null) return null;
		var objNodes=currNodeList.selectNodes("ITEM");
		return objNodes;
	}
	
	function GetIntAtt(strName)
	{	alert("7");
		var strV=this.GetStringAtt(strName);
		if (strV==null) return 0;
		return parseInt(strV);
	}	

	function GetFloatAtt(strName)
	{	alert("8");
		var strV=this.GetStringAtt(strName);
		if (strV==null) return 0;
		return parseFloat(strV);
	}	
	
	function GetStringAtt(strName)
	{	alert("9");
		if (this.m_objRootE==null ) return null;
		var currNode = this.m_objRootE.selectSingleNode(strName);
		if (currNode==null) return null;
		return currNode.text;
	}
	
	function GetData(strURL)
	{	alert("10");
		if (strURL!=null)
		{
			this.m_strURL=strURL;				
		}
		
		var strTempURL=this.m_strURL;
		
		/*
		disable the refreshing function
		if (strTempURL.indexOf("?")>0)
		{
			strTempURL=strTempURL+"&r"+Math.random();
		}
		else
		{
			strTempURL=strTempURL+"?r"+Math.random();
		}*/
	
		this.m_objHTTP.Open("GET", strTempURL, false);
		this.m_objHTTP.send();

		//window.alert(strTempURL);
		//window.alert(this.m_objHTTP.responseText);

		if (this.m_objHTTP.responseXML!=null)
		{
			this.m_objReturned=this.m_objHTTP.responseXML;
			this.m_objRootE=this.m_objReturned.documentElement;
			return (true);
		}
		else
		{
			return (false);
		}
	}
	
	//zhaobg Modify
	function ChangeToCacheURL(strURL,strID)
	{	alert("11");
		strURL=strURL.toLowerCase();
		strURL=strURL.replace("searchcenter","searchcenter/xmlcache");
		strURL=strURL+"."+strID+".xml";
		return strURL;
	}
	
	function BindDataforSelectControl_old(objSelect, strDataURL,strID)
	{	alert("12");
		while(objSelect.options.length>0)
		{
			objSelect.options.remove(0);
		}
		
		var oOption;
		var intCounts=0;		
		if (strID=="")
		{
			oOption = document.createElement("OPTION");
			oOption.text=" ";
			oOption.value="";
			objSelect.add(oOption);
		}
		else
		{
			//alert(strDataURL+"?catid="+strID);
			//alert(strDataURL);
			strDataURL=ChangeToCacheURL(strDataURL,strID);
			//alert(strDataURL);
			var obj=new xmlRemoteObject(strDataURL);
			obj.GetData(null);
			
			var objList = new xmlRemoteList(obj.GetList("cat"));
			var intcount= objList.GetListCount();
			intCounts=intcount
			for(var i=0;i<intcount;i++)
			{
				oOption = document.createElement("OPTION");
				oOption.text=objList.GetListItemText(i);
				oOption.value=objList.GetListItemValue(i);
				objSelect.add(oOption);
			}
		}
		objSelect.selectIndex=0;
		if(intCounts>1)
		{
			objSelect.style.display="inline";
		}
		else
		{
			objSelect.style.display="none";
		}
	}
function BindDataforSelectControl_old_22(objSelect, strDataURL,strID)
	{	alert("13");
		while(objSelect.options.length>0)
		{
			objSelect.options.remove(0);
		}
		
		var oOption;
		var intCounts=0;		
		if (strID=="")
		{
			oOption = document.createElement("OPTION");
		//	oOption.text=" ";
		//	oOption.value="";
		//	objSelect.add(oOption);
		}
		else
		{
			//alert(strDataURL+"?catid="+strID);
			//alert(strDataURL);
			strDataURL=ChangeToCacheURL(strDataURL,strID);
			//alert(strDataURL);
			var obj=new xmlRemoteObject(strDataURL);
			obj.GetData(null);
			
			var objList = new xmlRemoteList(obj.GetList("cat"));
			var intcount= objList.GetListCount();
			intCounts=intcount
			for(var i=0;i<intcount;i++)
			{
				oOption = document.createElement("OPTION");
				oOption.text=objList.GetListItemText(i);
				oOption.value=objList.GetListItemValue(i);
				objSelect.add(oOption);
			}
		}
		objSelect.selectIndex=0;
		if(intCounts>1)
		{
			objSelect.style.display="inline";
		}
		else
		{
			objSelect.style.display="none";
		}
	}

	function BindDataforSelectControl2_old(objSelect, strDataURL,strID)
	{	alert("14");
		if (objSelect.options.length<=1 && strID=="") return;
		
		while(objSelect.options.length>1)
		{
			objSelect.options.remove(1);
		}
		
		var oOption;
		
		if (strID=="")
		{
			return;
		}
		else
		{
			//alert(strDataURL+"?catid="+strID);
			strDataURL=ChangeToCacheURL(strDataURL,strID);
			var obj=new xmlRemoteObject(strDataURL);
			obj.GetData(null);
			
			var objList = new xmlRemoteList(obj.GetList("cat"));
			var intcount= objList.GetListCount();

			if (intcount>0)
			{
				for(var i=1;i<intcount;i++)
				{
					oOption = document.createElement("OPTION");
					oOption.text=objList.GetListItemText(i);
					oOption.value=objList.GetListItemValue(i);
					objSelect.add(oOption);
				}
			}
		}
		objSelect.selectIndex=0;
	}

	function CheckJSCache(strID)
	{
		alert("15");
		
		if (strID=="") return undefined;
		var chrF=strID.charAt(0);
		
		var ret=undefined;		
		
		if (chrF=='A' || chrF=='a')
		{
			if (typeof(arrtype)!=undefined)	    ret=arrtype;
		}
		if (chrF=='G' || chrF=='g')
		{
			if (typeof(arrarea)!=undefined) 	ret=arrarea;
		}

		if (chrF=='U' || chrF=='u')
		{
			if (typeof(arruni)!=undefined) 	ret=arruni;
		}
			
		return ret;
			
		
	}
	function IsLeaveID(strID)
	{	alert("16");
		//判断是否是叶子类别	
		var objlist=CheckJSCache(strID);
		
		if (objlist==undefined)
		{
			return false;
		}

		var intIndex=objlist[strID];
		if (strID=="" || intIndex==undefined)
		{
			return true;
		}
		else
		{
			var objcat=objlist[intIndex];
			var intSubIndex	=objcat[2]; //the start index of subcat list
			var intcount=objcat[3]; //the size of sub-cat list
			if (intcount<=0 && intSubIndex < 0)
			  return true;
			else
			  return false;
		}
	}
	
	function BindDataforSelectControl(objSelect, strDataURL,strID)
	{
		alert("17");
		var objlist=CheckJSCache(strID);
		
		if (objlist==undefined)
		{
			BindDataforSelectControl_old(objSelect, strDataURL,strID);
			return;
		}
		
		while(objSelect.options.length>0)
		{
			objSelect.options.remove(0);
		}
		
		var oOption;
		var intCounts=0;

		oOption = document.createElement("OPTION");
		oOption.text="";
		oOption.value="";
		objSelect.add(oOption);

		var intIndex=objlist[strID];
		if (strID=="" || intIndex==undefined)
		{
			return;
		}
		else
		{
			var objcat=objlist[intIndex];
			var intSubIndex	=objcat[2]; //the start index of subcat list
			var intcount=objcat[3]; //the size of sub-cat list
			intCounts=intcount;
			for(var i=0;i<intcount;i++)
			{
				intIndex=intSubIndex+i;
				objcat=objlist[intIndex];
				//alert(objlist[intIndex]);
				oOption = document.createElement("OPTION");
				oOption.text=objcat[1]; //name				
				oOption.value=objcat[0];//id
				objSelect.add(oOption);
			}
		}
		objSelect.selectIndex=0;
		if(intCounts>=1)
		{
			objSelect.style.display="inline";
		}
		else
		{
			objSelect.style.display="none";
		}

	}




	function BindDataforSelectControl_22(objSelect, strDataURL,strID)
	{
		alert("18");
		var objlist=CheckJSCache(strID);
		
		if (objlist==undefined)
		{
			BindDataforSelectControl_old_22(objSelect, strDataURL,strID);
			return;
		}
		
		while(objSelect.options.length>0)
		{
			objSelect.options.remove(0);
			
		}
		
		var oOption;
		var intCounts=0;

		oOption = document.createElement("OPTION");
	//	oOption.text="";
	//	oOption.value="";
	//	objSelect.add(oOption);

		var intIndex=objlist[strID];
		if (strID=="" || intIndex==undefined)
		{
			return;
		}
		else
		{
			var objcat=objlist[intIndex];
			var intSubIndex	=objcat[2]; //the start index of subcat list
			var intcount=objcat[3]; //the size of sub-cat list
			intCounts=intcount;
			for(var i=0;i<intcount;i++)
			{
				intIndex=intSubIndex+i;
				objcat=objlist[intIndex];
				//alert(objlist[intIndex]);
				oOption = document.createElement("OPTION");
				oOption.text=objcat[1]; //name				
				oOption.value=objcat[0];//id
				objSelect.add(oOption);
			}
		}
		objSelect.selectIndex=0;
		if(intCounts>=1)
		{
			objSelect.style.display="inline";
		}
		else
		{
			objSelect.style.display="none";
		}

	}
	function BindDataforSelectControl2(objSelect, strDataURL,strID)
	{
		alert("19");//alert("abc");
		var objlist=CheckJSCache(strID);
		
		
		if (objlist==undefined)
		{
			BindDataforSelectControl2_old(objSelect, strDataURL,strID);
			return;
		}
		
		if (objSelect.options.length<=1 && strID=="") return;
		
		while(objSelect.options.length>1)
		{
			objSelect.options.remove(1);
		}
		
		if (strID=="")
		{
			return;
		}
		else
		{
			var oOption;
			var intIndex=objlist[strID];
			if (strID=="" || intIndex==undefined)
			{
				return;
			}
			else
			{
				var objcat=objlist[intIndex];
				var intSubIndex	=objcat[2]; //the start index of subcat list
				var intcount=objcat[3]; //the size of sub-cat list
				
				for(var i=0;i<intcount;i++)
				{
					intIndex=intSubIndex+i;
					objcat=objlist[intIndex];
					//alert(objlist[intIndex]);
					oOption = document.createElement("OPTION");
					oOption.text=objcat[1]; //name				
					oOption.value=objcat[0];//id
					objSelect.add(oOption);
				}
			}
		}
		objSelect.selectIndex=0;
	}

