//选取厂商所在地函数
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.load("http://www.humen.com/include/WorldCity.xml");
function viewplace(action,cucity)
{
if(xmlDoc.parseError.errorCode==0)
{
   var xmlDocList = xmlDoc.documentElement.childNodes;
   var cityList = new Array();
   var cityCode = new Array();
   var placeCounter = 0;
   if(action=="country")
   {
	 for(i=0;i<xmlDocList.length;++i)
	 {
	    if((xmlDocList.item(i).attributes.getNamedItem("parentcode").nodeValue==1)&&(xmlDocList.item(i).attributes.getNamedItem("selftcode").nodeValue.substring(0,2)==event.srcElement.value))
        {
		cityList[placeCounter] = xmlDocList.item(i).attributes.getNamedItem("codename").nodeValue;
		cityCode[placeCounter] = xmlDocList.item(i).attributes.getNamedItem("selftcode").nodeValue;
		placeCounter = placeCounter + 1;
		}
	 }
     afrom.cuprovince.options.length = cityList.length;
	 for(var j=0;j<cityList.length;j++)
	 {
	 afrom.cuprovince.options[j].text = cityList[j];
	 afrom.cuprovince.options[j].value = cityCode[j];
	 }
	 if(cityList.length==0)
	 {
	 afrom.cuprovince.options.length = 1;
     afrom.cuprovince.options[0].text = "-选择省份-";
     afrom.cuprovince.options[0].value = "";
	 }
	 afrom.cucity.options.length = 1;
     afrom.cucity.options[0].text = "-选择省份-";
     afrom.cucity.options[0].value = "";
   }
   if(action=="cuprovince")
   {
	 for(i=0;i<xmlDocList.length;++i)
	 {
	    if((xmlDocList.item(i).attributes.getNamedItem("parentcode").nodeValue==2)&&(xmlDocList.item(i).attributes.getNamedItem("selftcode").nodeValue.substring(0,5)==document.all["cuprovince"].value))
        {
		cityList[placeCounter] = xmlDocList.item(i).attributes.getNamedItem("codename").nodeValue;
		cityCode[placeCounter] = xmlDocList.item(i).attributes.getNamedItem("selftcode").nodeValue;
		placeCounter = placeCounter + 1;
		}
	 }	
	 afrom.cucity.options.length=0
     option=document.createElement("OPTION")
     afrom.cucity.add(option)
     option.innerText="-选择城市-";
     option.value=""
	 for(var j=0;j<cityList.length;j++)
	 {
	      option=document.createElement("OPTION")
     afrom.cucity.add(option)
     option.innerText=cityList[j];
     option.value=cityCode[j]
	// afrom.cucity.options[j].text = cityList[j];
	 //afrom.cucity.options[j].value = cityCode[j];
	 if (afrom.cucity.options[j].value==cucity)
	 {
		afrom.cucity.options[j].selected=true 
	 }
	 }	
	 if(document.afrom.cuxian)
	  {
	 afrom.cuxian.options.length = 1;
     afrom.cuxian.options[0].text = "-选择市县-";
     afrom.cuxian.options[0].value = "";
	  }
   }
}

   if(action=="cucity")
   {
	   var cuxian=""
	 for(i=0;i<xmlDocList.length;++i)
	 {
	    if((xmlDocList.item(i).attributes.getNamedItem("parentcode").nodeValue==3)&&(xmlDocList.item(i).attributes.getNamedItem("selftcode").nodeValue.substring(0,9)==document.all["cucity"].value))
        {
		cityList[placeCounter] = xmlDocList.item(i).attributes.getNamedItem("codename").nodeValue;
		cityCode[placeCounter] = xmlDocList.item(i).attributes.getNamedItem("selftcode").nodeValue;
		placeCounter = placeCounter + 1;
		}
	 }
	 afrom.cuxian.options.length=0
     option=document.createElement("OPTION")
     afrom.cuxian.add(option)
     option.innerText="-选择市县-";
     option.value=""
     //afrom.cuxian.options.length = cityList.length;
	 for(var j=0;j<cityList.length;j++)
	 {
	 option=document.createElement("OPTION")
     afrom.cuxian.add(option)
     option.innerText=cityList[j];
     option.value=cityCode[j]
	  if (option.value==cucity)
	 {
		option.selected=true 
	 }
	 //afrom.cuxian.options[j].text = cityList[j];
	// afrom.cuxian.options[j].value = cityCode[j];
	 }
	
   }


}



