﻿function GetObjID(ObjName){
	for(var ObjID=0; ObjID < document.form.elements.length; ObjID++ )
		if (document.form.elements[ObjID].name == ObjName ){ 
			return(ObjID);
         	break;
      	}
  	return(-1);
}

function ChangeOption(ObjName, DesName){
	//GET OBJECT VALUE, ID OF DESTINATION OBJECT
	ObjID    = GetObjID(ObjName);
	DesObjID = GetObjID(DesName);
	//CLEAR OLD OPTIONS
	document.form.elements[DesObjID].length = 0;
	//Add NEW OPTIONS
	if (ObjID != -1 && DesObjID != -1){
		CatValue = document.form.elements[ObjID].value.substring(0, 2);
		if (CatValue == "00"){
			document.form.elements[DesObjID].length=0;
		}else{
			//PARSING
			document.form.elements[DesObjID].length=0;
			if (ObjName == "LocCat"){
				var tt = AreaCode;
				var SubCategory = tt.split(";");
				//GENERATE OPTIONS
				j=0;
				for (var i=0; i< SubCategory.length; i++){
					pp = SubCategory[i].split(",");
					if(pp[0].substring(0,2) == CatValue){
						if ( pp[0].substring(0,2) == CatValue){
							document.form.elements[DesObjID].options[j]= new Option( pp[1], pp[0]);
							j++;
						}
					}//if
				}//for
			}
		}//if
	}//if
	
}//function

//用于修改的页面函数
function buildLocCat(countryId) {
	document.form.LocCat.length = 0;
	var i;
	var j;
	for (i=0;i <countryArr.length; i++) {
		j=document.form.LocCat.length;
		document.form.LocCat.options[j] = new Option(countryArr[i].split(",")[1],countryArr[i].split(",")[0]);
		
		if(countryArr[i].split(",")[0]==countryId)
		{
			document.form.LocCat.options[j].selected=true;
		}
	}
}

function bulidLoaction(countryId,regionId) {
	document.form.Location.length=0;
	var i;
	var j;
	
	var tt = AreaCode;
	var SubCategory = tt.split(";");
	j=0;
	CatValue = countryId.substring(0, 2);
	for (var i=0; i< SubCategory.length; i++){
		pp = SubCategory[i].split(",");
		if(pp[0].substring(0,2) == CatValue){
			document.form.Location.options[j]= new Option( pp[1], pp[0]);
			
			if(pp[0]==regionId)
			{
				document.form.Location.options[j].selected=true;
			}
			
			j++;
		}//if
	}//for
	
}

var AreaCode='0100,北京市;0200,上海市;0300,广东省;0302,广州市;0303,惠州市;0304,汕头市;0305,珠海市;0306,佛山市;0307,中山市;0308,东莞市;0310,从化市;0314,韶关市;0315,江门市;0316,增城市;0317,湛江市;0318,肇庆市;0319,清远市;0400,深圳市;0500,天津市;0600,重庆市;0700,江苏省;0702,南京市;0703,苏州市;0704,无锡市;0705,常州市;0800,浙江省;0802,杭州市;0803,宁波市;0804,温州市;0900,四川省;0902,成都市;1000,海南省;1002,海口市;1100,福建省;1102,福州市;1103,厦门市;1104,泉州市;1105,漳州市;1200,山东省;1202,济南市;1203,青岛市;1204,烟台市;1300,江西省;1302,南昌市;1400,广西;1402,南宁市;1500,安徽省;1502,合肥市;1600,河北省;1602,石家庄市;1700,河南省;1702,郑州市;1800,湖北省;1802,武汉市;1803,宜昌市;1900,湖南省;1902,长沙市;2000,陕西省;2002,西安市;2100,山西省;2102,太原市;2200,黑龙江省;2202,哈尔滨市;2300,辽宁省;2302,沈阳市;2303,大连市;2400,吉林省;2402,长春市;2403,吉林市;2500,云南省;2502,昆明市;2600,贵州省;2602,贵阳市;2700,甘肃省;2702,兰州市;2800,内蒙古;2802,呼和浩特市;2900,宁夏;2902,银川市;3000,西藏;3002,拉萨市;3100,新疆;3102,乌鲁木齐市;3200,青海省;3202,西宁市;3300,香港;3400,澳门;3500,台湾;3600,新加坡;3700,美国;3800,日本;3900,英国;4000,芬兰;4100,荷兰;4200,法国;4300,德国;4400,意大利;4500,委内瑞拉;4600,瑞士;4700,墨西哥;4800,韩国;4900,挪威;5000,西班牙;5100,巴西;5200,俄罗斯;5300,马来西亚;5400,卢森堡;5500,印度;5600,丹麦;5700,澳大利亚;5800,加拿大;5900,比利时;6000,泰国;6100,沙特阿拉伯;6200,奥地利;6300,土耳其;6400,爱尔兰;6500,瑞典;6600,波兰';

var countryArr=new Array();
countryArr[0]='0100,北京市';
countryArr[1]='0200,上海市';
countryArr[2]='0300,广东省';
countryArr[3]='0400,深圳市';
countryArr[4]='0500,天津市';
countryArr[5]='0600,重庆市';
countryArr[6]='0700,江苏省';
countryArr[7]='0800,浙江省';
countryArr[8]='0900,四川省';
countryArr[9]='1000,海南省';
countryArr[10]='1100,福建省';
countryArr[11]='1200,山东省';
countryArr[12]='1300,江西省';
countryArr[13]='1400,广西';
countryArr[14]='1500,安徽省';
countryArr[15]='1600,河北省';
countryArr[16]='1700,河南省';
countryArr[17]='1800,湖北省';
countryArr[18]='1900,湖南省';
countryArr[19]='2000,陕西省';
countryArr[20]='2100,山西省';
countryArr[21]='2200,黑龙江省';
countryArr[22]='2300,辽宁省';
countryArr[23]='2400,吉林省';
countryArr[24]='2500,云南省';
countryArr[25]='2600,贵州省';
countryArr[26]='2700,甘肃省';
countryArr[27]='2800,内蒙古';
countryArr[28]='2900,宁夏';
countryArr[29]='3000,西藏';
countryArr[30]='3100,新疆';
countryArr[31]='3200,青海省';
countryArr[32]='3300,香港';
countryArr[33]='3400,澳门';
countryArr[34]='3500,台湾';
countryArr[35]='3600,新加坡';
countryArr[36]='3700,美国';

countryArr[37]='3800,日本';
countryArr[38]='3900,英国';
countryArr[39]='4000,芬兰';
countryArr[40]='4100,荷兰';
countryArr[41]='4200,法国';
countryArr[42]='4300,德国';
countryArr[43]='4400,意大利';
countryArr[44]='4500,委内瑞拉';
countryArr[45]='4600,瑞士';
countryArr[46]='4700,墨西哥';
countryArr[47]='4800,韩国';
countryArr[48]='4900,挪威';
countryArr[49]='5000,西班牙';
countryArr[50]='5100,巴西';
countryArr[51]='5200,俄罗斯';
countryArr[52]='5300,马来西亚';
countryArr[53]='5400,卢森堡';       
countryArr[54]='5500,印度';
countryArr[55]='5600,丹麦';
countryArr[56]='5700,澳大利亚';
countryArr[57]='5800,加拿大';
countryArr[58]='5900,比利时';
countryArr[59]='6000,泰国';
countryArr[60]='6100,沙特阿拉伯';
countryArr[61]='6200,奥地利';
countryArr[62]='6300,土耳其';
countryArr[63]='6400,爱尔兰';
countryArr[64]='6500,瑞典';
countryArr[65]='6600,波兰';

