
//"http://www.apacsource.com" ; // http://localhost:8091

var xml ; 
var xmlcity ; 
var prov;
var city;
///*
function GetProvinceList(m_prov)
{
	prov = m_prov ;
	xml = createXmlHttp() ;
	if(xml!=null)
	{   
		var countryID = _("country_id");
		xml.onreadystatechange = ProvinceResponse;
		xml.open("GET", "http://www.apacsource.com/ajax/GetProvince.aspx?cid="+countryID.value,  true);
		xml.send(null);         
	}
	return false;
}
function ProvinceResponse()
{
	if(xml.readyState == 4)
	{
		if(xml.status == 200)
		{
			var sCity=xml.responseXML; 
			//alert(sCity);
			FillProvinceList(sCity);
		 }
		 else
		 {
			alert("数据检索出错!" );
		 }
	}
}
		
function FillProvinceList(xml)
{
	var sRoot=xml.documentElement;

	var ddlprov = _("prov_id");
	//清除“城市”下拉列表中的原有项目
	for (var count = ddlprov.options.length-1; count >-1; count--)
	{
		ddlprov.options[count] = null;
	}
	
	//获取“城市名称”数组和“城市ID”数组
	var nameItems = sRoot.getElementsByTagName('name_cn');
	var idItems = sRoot.getElementsByTagName('prov_id');
	var text; 
	var id;
	var listItem;
	for (var count = 0; count < nameItems.length; count++)
	{
		text = (nameItems[count].textContent || nameItems[count].text);
		id = (idItems[count].textContent || idItems[count].text)
		listItem = new Option(text, id,  false, false);
		ddlprov.options[ddlprov.length] = listItem;
		if (prov!=null){
			if (prov==id){
				ddlprov.options[ddlprov.length-1].selected=true;
			}
		}
	}
	GetCityList('');
}
//*/
function GetCityList(m_city)
{
	city = m_city ;
	xmlcity = createXmlHttp() ;
	if(xmlcity!=null)
	{   
		var provinceID = _("prov_id");
		if (provinceID==null) return false;
		xmlcity.onreadystatechange = CityResponse;
		xmlcity.open("GET", "http://www.apacsource.com/ajax/GetCity.aspx?pid="+provinceID.value,  true);
		xmlcity.send(null);         
	}
	return false;
}

function CityResponse()
{
	if(xmlcity.readyState == 4)
	{
		if(xmlcity.status == 200)
		{
			var sCity=xmlcity.responseXML; 
			FillCityList(sCity);
		 }
		 else
		 {
			alert("数据检索出错!" );
		 }
	}
}
		
function FillCityList(xmlcity)
{
	var sRoot=xmlcity.documentElement;

	var ddlcity = _("city_id");
	//清除“城市”下拉列表中的原有项目
	for (var count = ddlcity.options.length-1; count >-1; count--)
	{
		ddlcity.options[count] = null;
	}
	
	//获取“城市名称”数组和“城市ID”数组
	var nameItems = sRoot.getElementsByTagName('name_cn');
	var idItems = sRoot.getElementsByTagName('city_id');
	var text; 
	var id;
	var listItem;
	for (var count = 0; count < nameItems.length; count++)
	{
		text = (nameItems[count].textContent || nameItems[count].text);
		id = (idItems[count].textContent || idItems[count].text)
		listItem = new Option(text, id,  false, false);
		ddlcity.options[ddlcity.length] = listItem;
		if (city!=null){
			if (city==id){
				ddlcity.options[ddlcity.length-1].selected=true;
			}
		}
	}
}