//jb函数会根据不同的浏览器初始化个xmlhttp对象
function jb(){
	var objType = false;
	try {
		objType = new ActiveXObject('Msxml2.XMLHTTP');
	} catch(e) {
		try {
			objType = new ActiveXObject('Microsoft.XMLHTTP');
		} catch(e) {
			objType = new XMLHttpRequest();
		}
	}
	return objType;
}

//下面Go函数是父列表框改变的时候调用，参数是选择的条目
function Go(obj,childCom){
	//得到选择框的下拉列表的value
	var svalue = obj.value;
	//定义要处理数据的页面
	var weburl = "indexComUpdate.php?parent_id="+svalue;
	//初始化个xmlhttp对象
	var xmlhttp = jb();
	//提交数据，第一个参数最好为get，第三个参数最好为true
	xmlhttp.open("get",weburl,true);
	// alert(xmlhttp.responseText);
	//如果已经成功的返回了数据
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
			//4代表成功返回数据
			var result = xmlhttp.responseText;//得到服务器返回的数据
			//先清空dListChild的所有下拉项
			document.getElementById(childCom).length = 0;
			//给dListChild加个全部型号的,注意是Option不是option
			if(result!=""){
				//如果返回的数据不是空
				//把收到的字符串按照，分割成数组
				var allArray = result.split(",");
				//循环这个数组，注意是从1开始，因为收到的字符串第一个字符是，号，所以分割后第一个数组为空
				for(var i=1;i<allArray.length;i++){
					//在把这个字符串按照|分割成数组
					var thisArray = allArray[i].split("|");
					//为dListChild添加条目
					document.getElementById(childCom).options.add(new Option(thisArray[0].toString(),thisArray[1].toString()));
				}
			}
		}
	}
	//发送数据，请注意顺序和参数，参数一定为null或者""
	xmlhttp.send(null);
}
function document.onclick(){
	showSel1(false);
	showSel2(false);
}
function showSel1(flag){
	if (document.all.dListChild1.options.length>0){
		document.all.dListChild1.style.display=(flag?"block":"none");
		window.event.cancelBubble=true;
	}
}
function showSel2(flag){
	if (document.all.dListChild2.options.length>0){
		document.all.dListChild2.style.display=(flag?"block":"none");
		window.event.cancelBubble=true;
	}
}
function selText1(){
	var toValue=document.all.dListChild1.options[document.all.dListChild1.selectedIndex].value;
	window.open(toValue);
	//showSel(false)
}
function selText2(){
	var toValue=document.all.dListChild2.options[document.all.dListChild2.selectedIndex].value;
	window.open(toValue);
	//showSel(false)
}