
	var arrCountryID = new Array("1","2","3","4");
	var arrCountryName = new Array("中国","中国香港","中国澳门","中国台湾");
	var arrProvinceID = new Array("2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32");
	var arrProvinceTO = new Array("1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1");
	var arrProvinceName = new Array("安徽","北京","福建","甘肃","广东","广西","贵州","海南","河北","河南","黑龙江","湖北","湖南","吉林","江苏","江西","辽宁","内蒙古","宁夏","青海","山东","山西","陕西","上海","四川","天津","西藏","新疆","云南","浙江","重庆");
	var arrCityID = new Array("363","364","365","366","367","368","369","370","371","372","373","374","375","376","377","378","379","380","381","382","383","384","385","386","387","388","389","390","391","392","393","394","395","396","397","398","399","400","401","402","403","404","405","406","407","408","409","410","411","412","413","414","415","416","417","418","419","420","421","422","423","424","425","426","427","428","429","430","431","432","433","434","435","436","437","438","439","440","441","442","443","444","445","446","447","448","449","450","451","452","453","454","455","456","457","458","459","460","461","462","463","464","465","466","467","468","469","470","471","472","473","474","475","476","477","478","479","480","481","482","483","484","485","486","487","488","489","490","491","492","493","494","495","496","497","498","499","500","501","502","503","504","505","506","507","508","509","510","511","512","513","514","515","516","517","518","519","520","521","522","523","524","525","526","527","528","529","530","531","532","533","534","535","536","537","538","539","540","541","542","543","544","545","546","547","548","549","550","551","552","553","554","555","556","557","558","559","560","561","562","563","564","565","566","567","568","569","570","571","572","573","574","575","576","577","578","579","580","581","582","583","584","585","586","587","588","589","590","591","592","593","594","595","596","597","598","599","600","601","602","603","604","605","606","607","608","609","610","611","612","613","614","615","616","617","618","619","620","621","622","623","624","625","626","627","628","629","630","631","632","633","634","635","636","637","638","639","640","641","642","643","644","645","646","647","648","649","650","651","652","653","654","655","656","657","658","659","660","661","662","663","664","665","666","667","668","669","670","671","672","673","674","675","676","677","678","679","680","681","682","683","684","685","686","687","688","689","690","691","692","693","694","695","696","697","698","699","700","701","702","703","704","705","706","707","708","709","710","711","712","713","714","715","716","717","718","719","720","721","722","723","724","725","726","727","728","729","730","731","732","733","734","735","736","737","738","739","740","741","742","743","745","746","747","748","749","750","751","752","753","754","755","756","757","758");
	var arrCityTO = new Array("2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","4","4","4","4","4","4","4","4","4","5","5","5","5","5","5","5","5","5","5","5","5","5","5","6","6","6","6","6","6","6","6","6","6","6","6","6","6","6","6","6","6","6","6","6","7","7","7","7","7","7","7","7","7","7","7","7","7","7","8","8","8","8","8","8","8","8","8","9","9","9","9","9","9","9","9","9","9","9","9","9","9","9","9","9","9","10","10","10","10","10","10","10","10","10","10","10","11","11","11","11","11","11","11","11","11","11","11","11","11","11","11","11","11","11","12","12","12","12","12","12","12","12","12","12","12","12","12","13","13","13","13","13","13","13","13","13","13","13","13","13","13","13","13","13","14","14","14","14","14","14","14","14","14","14","14","14","14","14","15","15","15","15","15","15","15","15","15","16","16","16","16","16","16","16","16","16","16","16","16","16","17","17","17","17","17","17","17","17","17","17","17","18","18","18","18","18","18","18","18","18","18","18","18","18","18","19","19","19","19","19","19","19","19","19","19","19","19","20","20","20","20","21","21","21","21","21","21","21","21","22","22","22","22","22","22","22","22","22","22","22","22","22","22","22","22","22","23","23","23","23","23","23","23","23","23","23","23","24","24","24","24","24","24","24","24","24","24","26","26","26","26","26","26","26","26","26","26","26","26","26","26","26","26","26","26","26","26","26","28","28","28","28","28","28","28","29","29","29","29","29","29","29","29","29","29","29","29","30","30","30","30","30","30","30","30","30","30","30","30","30","30","30","30","31","31","31","31","31","31","31","31","31","31","31","11","22","30","10","15","19","10","16","18","11","15","16","17","17","17","11","11","22","10","19","22","29","24","8","4","13","22","31","16","16","31","2","2","31","11","24","15","23","22","19","5","19","26","31");
	var arrCityName = new Array("安庆","蚌埠","巢湖","池州","滁州","阜阳","合肥","淮北","淮南","黄山","六安","马鞍山","宿州","铜陵","芜湖","宣城","亳州","福州","龙岩","南平","宁德","莆田","泉州","三明","厦门","漳州","白银","定西","甘南自治州","嘉峪关","金昌","酒泉","兰州","临夏自治州","陇南","平凉","庆阳","天水","武威","张掖","潮州","东莞","佛山","广州","河源","惠州","江门","揭阳","茂名","梅州","清远","汕头","汕尾","韶关","深圳","阳江","云浮","湛江","肇庆","中山","珠海","百色","北海","崇左","防城港","桂林","贵港","河池","贺州","来宾","柳州","南宁","钦州","梧州","玉林","安顺","毕节","贵阳","六盘水","黔东南自治州","黔南自治州","黔西南自治州","铜仁","遵义","白沙自治县","保亭自治县","昌江自治县","澄迈县","定安县","东方","海口","乐东自治县","临高县","陵水自治县","琼海","琼中自治县","三亚","屯昌县","万宁","文昌","五指山","儋州","保定","沧州","承德","邯郸","衡水","廊坊","秦皇岛","石家庄","唐山","邢台","张家口","安阳","鹤壁","济源","焦作","开封","洛阳","南阳","平顶山","三门峡","商丘","新乡","信阳","许昌","郑州","周口","驻马店","漯河","濮阳","大庆","大兴安岭","哈尔滨","鹤岗","黑河","鸡西","佳木斯","牡丹江","七台河","齐齐哈尔","双鸭山","绥化","伊春","鄂州","恩施自治州","黄冈","黄石","荆门","荆州","潜江","神农架林区","十堰","随州","天门","武汉","仙桃","咸宁","襄樊","孝感","宜昌","常德","长沙","郴州","衡阳","怀化","娄底","邵阳","湘潭","湘西自治州","益阳","永州","岳阳","张家界","株洲","白城","白山","长春","吉林","辽源","四平","松原","通化","延边自治州","常州","淮安","连云港","南京","南通","苏州","宿迁","泰州","无锡","徐州","盐城","扬州","镇江","抚州","赣州","吉安","景德镇","九江","南昌","萍乡","上饶","新余","宜春","鹰潭","鞍山","本溪","朝阳","大连","丹东","抚顺","阜新","葫芦岛","锦州","辽阳","盘锦","沈阳","铁岭","营口","阿拉善盟","巴彦淖尔盟","包头","赤峰","鄂尔多斯","呼和浩特","呼伦贝尔","通辽","乌海","乌兰察布盟","锡林郭勒盟","兴安盟","固原","石嘴山","吴忠","银川","果洛自治州","海北自治州","海东","海南自治州","海西自治州","黄南自治州","西宁","玉树自治州","滨州","德州","东营","菏泽","济南","济宁","莱芜","聊城","临沂","青岛","日照","泰安","威海","潍坊","烟台","枣庄","淄博","长治","大同","晋城","晋中","临汾","吕梁","朔州","太原","忻州","阳泉","运城","安康","宝鸡","汉中","商洛","铜川","渭南","西安","咸阳","延安","榆林","阿坝自治州","巴中","成都","达州","德阳","甘孜自治州","广安","广元","乐山","凉山自治州","眉山","绵阳","南充","内江","攀枝花","遂宁","雅安","宜宾","资阳","自贡","泸州","阿里","昌都","拉萨","林芝","那曲","日喀则","山南","阿克苏","阿拉尔","昌吉自治州","哈密","和田","喀什","克拉玛依","石河子","图木舒克","吐鲁番","乌鲁木齐","五家渠","保山","楚雄自治州","大理自治州","德宏自治州","迪庆自治州","红河自治州","昆明","丽江","临沧","怒江自治州","曲靖","思茅","文山自治州","西双版纳","玉溪","昭通","杭州","湖州","嘉兴","金华","丽水","宁波","绍兴","台州","温州","舟山","衢州","荥阳","滕州","个旧","霸州","榆树","临河","泊头","启东","大石桥","光山","梅河口","东台","樟树","临川","南康","济源","孟州","青州","怀来","包头","文登","伊犁","安康","仁怀","晋江","丹江口","蓬莱","湖州","宜兴","江阴","瑞安","宁国","无为","义乌","卧龙","长安","珲春","离石","海阳","集宁","静宁","海拉尔","西昌","余姚");

	var nIndex=0;				//作为数组的下标
	var oOption;				//作为类别的新建选项
	var strCountryID = "";		//用户选择的国家的ID
	var strProvinceID = "";		//用户选择的省份的ID
	var strCityID = "";			//用户选择的城市的ID
	if ( document.readyState)
		SetCountry();
		
	//设置国家信息
	function SetCountry()
	{
		//清空国家
		for ( nIndex=0; nIndex < document.all.item("CountryProvinceCity_dropCountry").options.length;)
		{
			document.all.item("CountryProvinceCity_dropCountry").remove(0);
		}
		
		//将省和市隐藏
		document.all.item("CountryProvinceCity_dropProvince").style.visibility = "hidden";
		document.all.item("CountryProvinceCity_dropCity").style.visibility = "hidden";
		
		//在产生错误，或者返回时，记录上次选择的值
		strCountryID = document.all.item("CountryProvinceCity_txtCountry").value;
		strProvinceID = document.all.item("CountryProvinceCity_txtProvince").value;
		strCityID = document.all.item("CountryProvinceCity_txtCity").value;

		//根据国家取得CountryID
		for( nIndex = 0 ; nIndex < arrCountryName.length ; nIndex++ )
		{
			if ( arrCountryName[nIndex] == document.all.item("CountryProvinceCity_txtCountryName").value )
			{
				strCountryID = arrCountryID[nIndex];
				break;
			}
		}
		
		//根据省取得ProvinceID
		for ( nIndex = 0 ; nIndex < arrProvinceName.length ; nIndex++ )
		{
			if ( arrProvinceName[nIndex] == document.all.item("CountryProvinceCity_txtProvinceName").value )
			{
				strProvinceID = arrProvinceID[nIndex];
				break;
			}
		}
		
		//根据城市取得CityID
		for ( nIndex = 0 ; nIndex < arrCityName.length ; nIndex++ )
		{
			if ( arrCityName[nIndex] == document.all.item("CountryProvinceCity_txtCityName").value )
			{
				strCityID = arrCityID[nIndex];
				break;
			}
		}

		//为国家添加一个默认项
		oOption = document.createElement("OPTION");
		document.all.item("CountryProvinceCity_dropCountry").add(oOption);
		oOption.innerText = "选择国家";
		oOption.value = "";
		
		//将类中读取的所有国家信息添加到列表中
		for ( nIndex =0 ; nIndex < arrCountryID.length; nIndex++)
		{
			oOption = document.createElement("OPTION");
			document.all.item("CountryProvinceCity_dropCountry").add(oOption);
			oOption.innerText = arrCountryName[nIndex];
			oOption.value = arrCountryID[nIndex];
			if ( arrCountryID[nIndex] == strCountryID )
				oOption.selected = true;
		}
		
		//初始化国家信息
		if ( strCountryID != "")
		{
			document.all.item("CountryProvinceCity_dropCountry").value = strCountryID;
			//取得该国家的省份
			SetProvince();
		}
		
		//初始化省份信息
		if ( strProvinceID != "")
		{
			document.all.item("CountryProvinceCity_dropProvince").value = strProvinceID;
			//取得该省份的城市
			SetCity();
		}
		
		//初始化城市信息
		if ( strCityID != "")
		{
			document.all.item("CountryProvinceCity_dropCity").value = strCityID;
			//返回该城市信息给客户
			SetAddress();
		}
		
	}
	
	//取得省份信息
	function SetProvince()
	{
		//保存选择的国家信息
		document.all.item("CountryProvinceCity_txtCountry").value = document.all.item("CountryProvinceCity_dropCountry").value;
		if ( document.all.item("CountryProvinceCity_txtCountry").value != "")
		{
			document.all.item("CountryProvinceCity_txtCountryName").value = document.all.item("CountryProvinceCity_dropCountry")[document.all.item("CountryProvinceCity_dropCountry").selectedIndex].innerText ;
		}
		else
		{
			document.all.item("CountryProvinceCity_txtProvinceName").value = "";
			document.all.item("CountryProvinceCity_txtCityName").value = "";
			document.all.item("CountryProvinceCity_txtProvince").value = "";
			document.all.item("CountryProvinceCity_txtCity").value = "";
		}
		
		//清空省份
		for ( nIndex=0; nIndex < document.all.item("CountryProvinceCity_dropProvince").options.length;)
		{
			document.all.item("CountryProvinceCity_dropProvince").remove(0);
		}
				
		//为省份添加一个默认项
		oOption = document.createElement("OPTION");
		document.all.item("CountryProvinceCity_dropProvince").add(oOption);
		oOption.innerText = "选择省份";
		oOption.value = "";
		
		//将类中读取的所有属于用户选择的国家的省份信息添加到列表中
		for ( nIndex =0 ; nIndex < arrProvinceID.length; nIndex++)
		{
			if ( arrProvinceTO[nIndex] == document.all.item("CountryProvinceCity_dropCountry").value )
			{
				oOption = document.createElement("OPTION");
				document.all.item("CountryProvinceCity_dropProvince").add(oOption);
				oOption.innerText = arrProvinceName[nIndex];
				oOption.value = arrProvinceID[nIndex];
				if ( arrProvinceID[nIndex] == strProvinceID )
					oOption.selected = true;
			}
		}
		
		//根据Province初始化City
		SetCity();
		
		//如果用户选择的国家有省份信息，则显示出来
		if ( document.all.item("CountryProvinceCity_dropProvince").options.length > 1)
		{
			document.all.item("CountryProvinceCity_dropProvince").style.visibility = "visible";
		}
		else
		{
			document.all.item("CountryProvinceCity_dropProvince").style.visibility = "hidden";
		}
		
		//将用户选择的信息显示给客户
		if ( document.all.item("labAddress") )
		{	
			document.all.item("labAddress").innerText = "";
			if ( document.all.item("CountryProvinceCity_dropCountry").selectedIndex > 0 )
				document.all.item("labAddress").innerText += document.all.item("CountryProvinceCity_dropCountry")[document.all.item("CountryProvinceCity_dropCountry").selectedIndex].innerText ;
			if ( document.all.item("CountryProvinceCity_dropProvince").selectedIndex > 0 )
				document.all.item("labAddress").innerText += document.all.item("CountryProvinceCity_dropProvince")[document.all.item("CountryProvinceCity_dropProvince").selectedIndex].innerText;
			if ( document.all.item("labAddress").innerText != "" )
				document.all.item("labAddress").innerText += "\n";
		}
	}
	
	//取得城市信息
	function SetCity()
	{
		//保存所选择的省份信息
		document.all.item("CountryProvinceCity_txtProvince").value = document.all.item("CountryProvinceCity_dropProvince").value;
		if ( document.all.item("CountryProvinceCity_txtProvince").value != "" && document.all.item("CountryProvinceCity_dropProvince").style.visibility == "visible")
		{
			document.all.item("CountryProvinceCity_txtProvinceName").value = document.all.item("CountryProvinceCity_dropProvince")[document.all.item("CountryProvinceCity_dropProvince").selectedIndex].innerText;
		}
		else
		{
			document.all.item("CountryProvinceCity_txtProvinceName").value = "";
			document.all.item("CountryProvinceCity_txtCityName").value = "";
			//document.all.item("CountryProvinceCity_txtProvince").value = "";
			document.all.item("CountryProvinceCity_txtCity").value = "";
		}
		
		//清空城市信息
		for ( nIndex=0; nIndex < document.all.item("CountryProvinceCity_dropCity").options.length;)
		{
			document.all.item("CountryProvinceCity_dropCity").remove(0);
		}
		
		//为城市添加一个默认项
		oOption = document.createElement("OPTION");
		document.all.item("CountryProvinceCity_dropCity").add(oOption);
		oOption.innerText = "选择城市";
		oOption.value = "";
		
		//将类中读取的属于用户选择的省份的所有城市信息添加到列表中
		for ( nIndex =0 ; nIndex < arrCityID.length; nIndex++)
		{
			if ( arrCityTO[nIndex] == document.all.item("CountryProvinceCity_dropProvince").value )
			{
				oOption = document.createElement("OPTION");
				document.all.item("CountryProvinceCity_dropCity").add(oOption);
				oOption.innerText = arrCityName[nIndex];
				oOption.value = arrCityID[nIndex];
				if ( arrCityID[nIndex] == strCityID )
					oOption.selected = true;
			}
		}
		
		//如果用户选择的省份有城市信息，则显示出来
		if ( document.all.item("CountryProvinceCity_dropCity").options.length > 1)
		{
			document.all.item("CountryProvinceCity_dropCity").style.visibility = "visible";
		}
		else
		{
			document.all.item("CountryProvinceCity_dropCity").style.visibility = "hidden";
		}
		
		//将用户选择的信息显示给客户
		if ( document.all.item("labAddress") )
		{	
			document.all.item("labAddress").innerText = "";
			if ( document.all.item("CountryProvinceCity_dropCountry").selectedIndex > 0 )
				document.all.item("labAddress").innerText += document.all.item("CountryProvinceCity_dropCountry")[document.all.item("CountryProvinceCity_dropCountry").selectedIndex].innerText ;
			if ( document.all.item("CountryProvinceCity_dropProvince").selectedIndex > 0 )
				document.all.item("labAddress").innerText += document.all.item("CountryProvinceCity_dropProvince")[document.all.item("CountryProvinceCity_dropProvince").selectedIndex].innerText;
			if ( document.all.item("CountryProvinceCity_dropCity").selectedIndex > 0 )
				document.all.item("labAddress").innerText += document.all.item("CountryProvinceCity_dropCity")[document.all.item("CountryProvinceCity_dropCity").selectedIndex].innerText;
			if ( document.all.item("labAddress").innerText != "" )
				document.all.item("labAddress").innerText += "\n";
		}
			
	}
	
	//返回最终的选择
	function SetAddress()
	{
		//保存所选择的城市信息
		document.all.item("CountryProvinceCity_txtCity").value = document.all.item("CountryProvinceCity_dropCity").value;
		if ( document.all.item("CountryProvinceCity_dropCity").selectedIndex >0 && document.all.item("CountryProvinceCity_dropCity").style.visibility == "visible")
			document.all.item("CountryProvinceCity_txtCityName").value = document.all.item("CountryProvinceCity_dropCity")[document.all.item("CountryProvinceCity_dropCity").selectedIndex].innerText;
		
		//返回完成的地址
		if ( document.all.item("labAddress") )
		{
			document.all.item("labAddress").innerText = "";
			if ( document.all.item("CountryProvinceCity_dropCountry").selectedIndex > 0 )
				document.all.item("labAddress").innerText += document.all.item("CountryProvinceCity_dropCountry")[document.all.item("CountryProvinceCity_dropCountry").selectedIndex].innerText ;
			if ( document.all.item("CountryProvinceCity_dropProvince").selectedIndex > 0 )
				document.all.item("labAddress").innerText += document.all.item("CountryProvinceCity_dropProvince")[document.all.item("CountryProvinceCity_dropProvince").selectedIndex].innerText;
			if ( document.all.item("CountryProvinceCity_dropCity").selectedIndex > 0 )
				document.all.item("labAddress").innerText += document.all.item("CountryProvinceCity_dropCity")[document.all.item("CountryProvinceCity_dropCity").selectedIndex].innerText;
			if ( document.all.item("labAddress").innerText != "" )
				document.all.item("labAddress").innerText += "\n";
		}
	}
	
	//验证是否选择了准确的地址信息
	function CountryProvinceCity_Check(object,e)
	{
		if ( document.all.item("CountryProvinceCity_txtNeedValid").value != "1" )
		{
			e.IsValid = true;
			return;
		}
		if ( document.all.item("CountryProvinceCity_dropCountry").value == "")		//判断是否选择了国家
		{
			e.IsValid = false;
			return;
		}
		else
		{
			if (document.all.item("CountryProvinceCity_dropProvince").style.visibility == "visible")		//如果给出了所选择的国家的详细省份信息
			{
				if ( document.all.item("CountryProvinceCity_dropProvince").value == "")					//判断是否选择了省份
				{
					e.IsValid = false;
					return;
				}
				else
				{
					if ( document.all.item("CountryProvinceCity_dropCity").style.visibility == "visible")			//如果给出了所选择的国家的详细城市信息
					{
						if ( document.all.item("CountryProvinceCity_dropCity").value == "")						//判断是否选择了城市
							e.IsValid = false;
							return;
					}
				}
			}
		}
		e.IsValid = true;				//如果所在地选择了最为详细的地址，则通过检测
	}
	
