function getHttpRequest() {
	var xmlreq = false;
	if (window.XMLHttpRequest) {
		xmlreq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		try {
		  xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
		  try {
		    xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (e2) {
		     xmlreq = false;
		  }
		}
	}
	return xmlreq;
}
function showCity(nameCN, uri, elementId){

	if('0'!=nameCN){
		var req = getHttpRequest();
		if(req ){
			req.onreadystatechange = getCitys(req,elementId);
			var url = uri+'?pId='+nameCN
			req.open("POST",url,true );
				req.send(null);
		}
	}
}
function getCitys(req,elementId){
	return function(){
		if (req.readyState == 4) {
			if (req.status == 200) {
				var xmlDoc=req.responseXML.getElementsByTagName("city");
	            var select_root=document.getElementById(elementId);
	            select_root.options.length=0;
	            
	            var opt1 = new Option('-请选择-','');
	            //加options支持IE和火狐
	            select_root.options.add(opt1);
	            for(var i=0;i< xmlDoc.length;i++)
	            {
	                var xText=xmlDoc[i].childNodes[0].firstChild.nodeValue;
	                var xValue=xmlDoc[i].childNodes[1].firstChild.nodeValue;
	                var option=new Option(xText,xValue);
	                try{
	                	//加options支持IE和火狐
	                    select_root.options.add(option);
	                }catch(e){
	                }
	            }
			}
		}
	}
}


function showAdZone(addirectory_id,input_id,default_value,post_url){//没有“请选择”选项，全部是具体数据
	if(addirectory_id != 0){
		var req = getHttpRequest();
		if(req ){
			req.onreadystatechange = getAdZone(req,input_id,default_value);
			var url = post_url+'?AdDirectoryId='+addirectory_id;
			req.open("POST",url,true );
			req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			req.send(null);
		}
	}
	else{
		var select_root=document.getElementById(input_id);
	  
	  // 清空Select中全部Option
	  var ln = select_root.options.length;
	  for (var i = 0; i < ln; i++)
	  {
	      select_root.options[select_root.selectedIndex] = null;
	  }
	  
	  var opt1 = new Option('请选择','0');
	  select_root.options.add(opt1, 0);
	}
}
function getAdZone(req,input_id,default_value){//没有“请选择”选项，全部是具体数据
	return function(){
		if (req.readyState == 4) {
			if (req.status == 200) {
	    	var select_root=document.getElementById(input_id);
	      // 清空Select中全部Option
	      var ln = select_root.options.length;
	      for (var i = 0; i < ln; i++)
	      {
	        select_root.options[select_root.selectedIndex] = null;
	      }
	      if(req.responseXML.getElementsByTagName("zone") != null){
		      var xmlDoc=req.responseXML.getElementsByTagName("zone");
		      for(var i=0;i< xmlDoc.length;i++)
		      {
		        var xText=xmlDoc[i].childNodes[0].firstChild.nodeValue;
		        var xValue=xmlDoc[i].childNodes[1].firstChild.nodeValue;
		        var ad_option=new Option(xText,xValue);
						select_root.options.add(ad_option, i+1);
		        if(default_value == xValue||default_value == xText){
		          ad_option.selected = true;
		        }
		      }
				}
				else{
					var opt1 = new Option('请选择','0');
					select_root.options.add(opt1, 0);
				}
			}
		}
	}
}


function showDictionary(page_id,input_id,default_value,post_url){//没有“请选择”选项，全部是具体数据
	
	if(page_id != 0){
		var req = getHttpRequest();
		if(req ){
			req.onreadystatechange = getDictionary(req,input_id,default_value);
			var url = post_url+'?AdPageId='+page_id;
			
			req.open("POST",url,true );
			req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			req.send(null);
		}
	}
	else{
		var select_root=document.getElementById(input_id);
	  
	  // 清空Select中全部Option
	  var ln = select_root.options.length;
	  for (var i = 0; i < ln; i++)
	  {
	      select_root.options[select_root.selectedIndex] = null;
	  }
	  
	  var opt1 = new Option('请选择','0');
	  select_root.options.add(opt1, 0);
	}
}
function getDictionary(req,input_id,default_value){//没有“请选择”选项，全部是具体数据
	return function(){
		if (req.readyState == 4) {
			if (req.status == 200) {
	    	var select_root=document.getElementById(input_id);
	      // 清空Select中全部Option
	      var ln = select_root.options.length;
	      for (var i = 0; i < ln; i++)
	      {
	        select_root.options[select_root.selectedIndex] = null;
	      }
	      if(req.responseXML.getElementsByTagName("dictionary") != null){
		      var xmlDoc=req.responseXML.getElementsByTagName("dictionary");
			  
		      for(var i=0;i< xmlDoc.length;i++)
		      {
		        var xText=xmlDoc[i].childNodes[0].firstChild.nodeValue;
		        var xValue=xmlDoc[i].childNodes[1].firstChild.nodeValue;
		        var ad_option=new Option(xText,xValue);
						select_root.options.add(ad_option, i+1);
		        if(default_value == xValue||default_value == xText){
		          ad_option.selected = true;
		        }
		      }
				}
				else{
					var opt1 = new Option('请选择','0');
					select_root.options.add(opt1, 0);
				}
			}
		}
	}
}


function getTopic(req,input_id,default_value){//没有“请选择”选项，全部是具体数据
	return function(){
		if (req.readyState == 4) {
			if (req.status == 200) {
	    	var select_root=document.getElementById(input_id);
	      // 清空Select中全部Option
	      var ln = select_root.options.length;
	      for (var i = 0; i < ln; i++)
	      {
	        select_root.options[select_root.selectedIndex] = null;
	      }
	      if(req.responseXML.getElementsByTagName("topic") != null){
		      var xmlDoc=req.responseXML.getElementsByTagName("topic");
			  
		      for(var i=0;i< xmlDoc.length;i++)
		      {
		        var xText=xmlDoc[i].childNodes[0].firstChild.nodeValue;
		        var xValue=xmlDoc[i].childNodes[1].firstChild.nodeValue;
		        var ad_option=new Option(xText,xValue);
						select_root.options.add(ad_option, i+1);
		        if(default_value == xValue||default_value == xText){
		          ad_option.selected = true;
		        }
		      }
				}
				else{
					var opt1 = new Option('请选择','0');
					select_root.options.add(opt1, 0);
				}
			}
		}
	}
}

function showExamTopic(page_id,input_id,default_value,post_url){//没有“请选择”选项，全部是具体数据
	
	if(page_id != 0){
		var req = getHttpRequest();
		if(req ){
			req.onreadystatechange = getTopic(req,input_id,default_value);
			var url = post_url+'?ExamPaperId='+page_id;
			
			req.open("POST",url,true );
			req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			req.send(null);
		}
	}
	else{
		var select_root=document.getElementById(input_id);
	  
	  // 清空Select中全部Option
	  var ln = select_root.options.length;
	  for (var i = 0; i < ln; i++)
	  {
	      select_root.options[select_root.selectedIndex] = null;
	  }
	  
	  var opt1 = new Option('请选择','0');
	  select_root.options.add(opt1, 0);
	}
}