//读取国家、省、市、县
var countrys="";
//读取国家
var Country=function ReadCountry(){
       var country="";
       $.ajax({
			url:"../../TMFile/UUCountryList.xml?r"+Math.random(),
			dataType:"xml",
			type:"GET",
			async:false,
			error:function(xml){
				alert("国家加载失败！");
			   },
			success:function(xml)
				{
				   	$(xml).find("City").each(function(i){
			              country=country+"<option value="+$(this).children("ID").text()+">"+$(this).children("Name").text()+"</option>";
					 });
				}
				
		});
		return country;
}
//读取省
var Sheng=function ReadSheng(CountryID){
     var url="";
     var Sheng="";
      if(CountryID==100)
			{
				url="../../TMFile/Area_CNSheng.xml?r"+Math.random();
			}else
			{
			   url="../../UUTemp/city_"+CountryID+".xml?r"+Math.random();
			}
       $.ajax({
			url:url,
			dataType:"xml",
			type:"GET",
			async:false,
			error:function(Shengxml){
				alert("省加载失败！");
			   },
			success:function(Shengxml)
				{
					$(Shengxml).find("City").each(function(i){
					     
						if(CountryID==100)
						{
							if( $(this).children("Name").text()!="一级行政区")
									{
										Sheng=Sheng+"<option value="+$(this).children("ID").text()+">"+$(this).children("Name").text()+"</option>";
									}
						}else
						{
							if($(this).children("Name").text()!="一级行政区" &&  $(this).children("CityType").text()=="省")
								{
									Sheng=Sheng+"<option value="+$(this).children("ID").text()+">"+$(this).children("Name").text()+"</option>";
								}
						}
				  });
				}
		});
		
		return Sheng;
}
//读取市

var Shi=function ReadShi(CountryID,ShengID){
     var url="";
     var Shi="";
      if(CountryID==100)
			{
				url="../../UUTemp/city_"+ShengID+".xml?r"+Math.random();
			}else
			{
			   url="../../UUTemp/city_"+CountryID+".xml?r"+Math.random();
			}
       $.ajax({
			url:url,
			dataType:"xml",
			type:"GET",
			async:false,
			error:function(Shixml){
				alert("市加载失败！");
			   },
			success:function(Shixml)
				{
					$(Shixml).find("City").each(function(i){
					 if(CountryID==100)
						{
						  if( $(this).children("Name").text()!="请选择" && $(this).children("CityType").text()=="市")
								{
									Shi=Shi+"<option value="+$(this).children("ID").text()+">"+$(this).children("Name").text()+"</option>";
								}
						}else
						{
						   if($(this).children("Name").text()!="二级行政区" &&  $(this).children("CityType").text()=="市" && $(this).children("Sheng").text()==ShengID)
						   {
						     Shi=Shi+"<option value="+$(this).children("ID").text()+">"+$(this).children("Name").text()+"</option>";
						   }
						}
				 });
				}
		});
		return Shi;
}
//读取县
var Xian=function ReadXian(CountryID,ShengID,ShiID){
    var url="";
    var Xian=""
    if(CountryID==100)
			{
				url="../../UUTemp/city_"+ShengID+".xml?r"+Math.random();
			}else
			{
			    url="../../UUTemp/city_"+CountryID+".xml?r"+Math.random();
			}
	 $.ajax({
			url:url,
			dataType:"xml",
			type:"GET",
			async:false,
			error:function(Xianxml){
				alert("县加载失败！");
			   },
			success:function(Xianxml)
				{
				$(Xianxml).find("City").each(function(i){
					 if(CountryID==100)
					 {
						if( $(this).children("Name").text()!="三级行政区" && $(this).children("CityType").text()=="县" && $(this).children("Shi").text()==ShiID)
						{
						    Xian=Xian+"<option value="+$(this).children("ID").text()+">"+$(this).children("Name").text()+"</option>";
						}
					 }else
					{
					  if($(this).children("Name").text()!="三级行政区"  && $(this).children("CityType").text()=="县" && $(this).children("Sheng").text()==ShengID)
					  {
						 Xian=Xian+"<option value="+$(this).children("ID").text()+">"+$(this).children("Name").text()+"</option>";
					  }
					}
					 
				 });
				}
		});
		return Xian;
}
