var AreaSearch=createAjaxObj();
var AreaOption="";

function createAjaxObj()
{
	var httprequest=false;
	if(window.XMLHttpRequest)
	{
		httprequest=new XMLHttpRequest();
		if(httprequest.overrideMimeType)
		   httprequest.overrideMimeType('text/xml');
	}
	else if (window.ActiveXObject)
	{
		//IE
		try
		{
			httprequest=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				httprequest=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
			}
		}
	}
	return httprequest
}

/*
ao表单项
id选项值
*/
function CheckArea(ao,id)
{
	    AreaOption=ao;
		url="../Inc/QC.SelectAreaData.asp?id="+id+"&m="+new Date().getTime();
		AreaSearch.open("get",url);
		AreaSearch.onreadystatechange=handleSearchSuggest;
		AreaSearch.send(null);
}

function handleSearchSuggest()
{

	if(AreaSearch.readyState==4)
	{							
				switch(AreaOption)
				{
					case "Area1":
					{
						 document.getElementById("Area1").options[0]=new Option("请选择","0");
						 document.getElementById("Area1").options.selected=true;
						 document.getElementById("Area1").length=1;
					}
					
					case "Area2":
					{
						 document.getElementById("Area2").options[0]=new Option("请选择","0");
						 document.getElementById("Area2").options.selected=true;
						 document.getElementById("Area2").length=1;
					}
					case "Area3":
					{
						 document.getElementById("Area3").options[0]=new Option("请选择","0");
						 document.getElementById("Area3").options.selected=true;
						 document.getElementById("Area3").length=1;
					}
					
				}
				switch (AreaOption)
				{
					case "Area1":name="一级";break;
					case "Area2":name="二级";break;
					case "Area3":name="三级";break;
				}
				xmldoc=AreaSearch.responseXML;
				var message_nodes=xmldoc.getElementsByTagName("message");
				var n_messages=message_nodes.length;
				if (n_messages<=0)
				{
					 document.getElementById(AreaOption).options[0]=new Option("请选择","0");
					 //document.getElementById(AreaOption).options[0]=new Option("请选择"+name,"0");
					 document.getElementById(AreaOption).options.selected=true;
					 document.getElementById(AreaOption).length=1;
				}
			    else
				{
					document.getElementById(AreaOption).options[0]=new Option("请选择","0");
					//document.getElementById(AreaOption).options[0]=new Option("请选择"+name,"0");
					for (i=0;i<n_messages;i++ )
					{
						var cid=message_nodes[i].getElementsByTagName("areaid")[0].firstChild.data;
						var name=message_nodes[i].getElementsByTagName("areaname")[0].firstChild.data;
						document.getElementById(AreaOption).options[i+1]=new Option(name,cid);
					}
				        document.getElementById(AreaOption).options.selected=true;
					document.getElementById(AreaOption).length=i+1;

				}
				
	}
	else
	{
		//alert('网络连接失败');
	}
}