﻿//检查表单填写是否符合要求
function checkSubmit( theform )
{
	if( !checkUsername( theform ) )return false;
	if( !checkPassword( theform ) )return false;
	if( !checkPassword2( theform ) )return false;
	if( !checkEmail( theform ) )return false;
	if( !checkBirth( "birth" ) )return false;
	if( !checkArea( "country" ) )return false;
	if( document.getElementById("areatable").style.display == "" )
	{
		if( !checkArea( "province" ) )return false;
		if( !checkArea( "city" ) )return false;
	}
	return true;
}

function checkUpdate( theform )
{
	if( !checkBirth( "birth" ) )return false;
	if( !checkArea( "country" ) )return false;
	if( document.getElementById("areatable").style.display == "" )
	{
		if( !checkArea( "province" ) )return false;
		if( !checkArea( "city" ) )return false;
	}
	return true;
}

function checkUsername( theform )
{
	var regX = /^([a-zA-Z0-9]+)([a-zA-Z0-9_]*)([a-zA-Z0-9]+)$/;
	if( theform.username.value.length == 0)
	{
			document.getElementById("usernamespan").innerHTML="<br><font color=red>User Name can't be empty</font></br>";
			theform.username.focus();
			return false;
	}
	else if( theform.username.value.length > 20 )
	{
		document.getElementById("usernamespan").innerHTML="<br><font color=red>User Name can't beyond 20 characters</font></br> ";
		theform.username.focus();
		return false;
	}
	else if( !regX.test(theform.username.value) )
	{
		document.getElementById("usernamespan").innerHTML="<br><font color=red>User Name must be formed by A-Z,a-z,0-9! </font></br> ";
		theform.username.focus();
		return false;
	}
	else
	{
		document.getElementById("usernamespan").innerHTML="";
		return true;
	}
}

function checkPassword( theform )
{
	if(theform.password.value.length == 0)
	{
		document.getElementById("passwordspan").innerHTML="<br><font color=red>Password can't be empty</font></br>";
		theform.password.focus();
		return false;
	}
	else if( theform.password.value.length < 6 )
	{
		document.getElementById("passwordspan").innerHTML="<br><font color=red>Password can't less than 6 characters</font></br>";
		theform.password.focus();
		return false;
	}
	else if( theform.username.value.length > 16 )
	{
		document.getElementById("passwordspan").innerHTML="<br><font color=red>Password can't beyond 16 characters</font></br>";
		theform.password.focus();
		return false;
	}
	else
	{
		document.getElementById("passwordspan").innerHTML="";	
		return true;
	}
}

function checkPassword2( theform )
{
	if(theform.password2.value.length == 0)
	{
		document.getElementById("password2span").innerHTML="<br><font color=red>Password can't be empty</font></br>";
		theform.password2.focus();
		return false;
	}
	else if( theform.password2.value != theform.password.value )
	{
		document.getElementById("password2span").innerHTML="<br><font color=red>The Password and the Confirm Password must match.  </font></br>";
		theform.password2.focus();
		return false;
	}
	else
	{
		document.getElementById("password2span").innerHTML="";
		return true;
	}
}

function checkEmail( theform )
{
	var isEmail = /^[\w_-]+[\.\w+]*\w+\@\w+\.\w+/;

		if(theform.email.value.length == 0)
		{
			document.getElementById("emailspan").innerHTML="<br><font color=red>Email can't be empty</font></br>";
			theform.email.focus();
			return false;
		}
		if(!isEmail.test(theform.email.value))
		{
			document.getElementById("emailspan").innerHTML="<br><font color=red>incorrect Email Format</font></br>";
			theform.email.focus();
			return false;
		}
		if(theform.email.value.length > 80)
		{
			document.getElementById("emailspan").innerHTML="<br><font color=red>Email can't beyond 80 characters</font></br>";
			theform.email.focus();
			return false;
		}
		document.getElementById("emailspan").innerHTML="";
		return true;
}

function checkBirth( selectA )
{
	var selObject = document.getElementById( selectA );
	if( selObject.value == "-1" )
	{
		alert( "Birth can't be empty!" );
		document.getElementById( selectA ).focus();
		return false;
	}
	return true;
}
function checkArea( selectA )
{
	var selObject = document.getElementById( selectA );
	if( selObject.value == "-1" )
	{
		if( selObject.name == "country" )
		{
			alert( "Country can't be empty!" );
			document.getElementById( selectA ).focus();
			return false;
		}
		
		if( selObject.name == "province" )
		{
			alert( "Province can't be empty!" );
			document.getElementById( selectA ).focus();
			return false;
		}
		if( selObject.name == "city" )
		{
			alert( "City can't be empty!" );
			document.getElementById( selectA ).focus();
			return false;
		}
	}
	return true;
}
function checkSector( selectA )
{
	var selObject = document.getElementById( selectA );
	if( selObject.value == "-1" )
	{
		alert( "Sector can't be empty" );
		return false;
	}
	return true;
}
function checkAspect( selectA )
{
	var selObject = document.getElementById( selectA );
	if( selObject.value == "-1" )
	{
		alert( "Aspect can't be empty" );
		return false;
	}
	return true;
}
function checkLanguage( theradio )
{
	var selObject = document.getElementsByName ( theradio );

	if( selObject[0].checked )
		return true;
	else if( selObject[1].checked )
		return true;

	alert( "Language can't be empty" );
	return false;
}
function checkFormat( selectA )
{
	var selObject = document.getElementById( selectA );
	if( selObject.value == "-1" )
	{
		alert( "Emailformat can't be empty" );
		return false;
	}
	return true;
}
function checkTruename( thetext )
{
	var selObject = document.getElementById( thetext );
	if( selObject.value == "" )
	{
		alert( "Name can't be empty" );
		return false;
	}
	return true;
}
function checkSex( thetext )
{
	var selObject = document.getElementById( thetext );
	if( selObject.value == "" )
	{
		alert( "Sex can't be empty" );
		return false;
	}
	return true;
}
function checkOrg( thetext )
{
	var selObject = document.getElementById( thetext );
	if( selObject.value == "" )
	{
		alert( "Organisation can't be empty" );
		return false;
	}
	return true;
}
function checkAddress( thetext )
{
	var selObject = document.getElementById( thetext );
	if( selObject.value == "" )
	{
		alert( "Address can't be empty" );
		return false;
	}
	return true;
}
function checkPostcode( thetext )
{
	var selObject = document.getElementById( thetext );
	if( selObject.value == "" )
	{
		alert( "Postcode can't be empty" );
		return false;
	}
	return true;
}
function checkTel( thetext )
{
	var selObject = document.getElementById( thetext );
	if( selObject.value == "" )
	{
		alert( "Telephone can't be empty" );
		return false;
	}
	return true;
}

//检查表单结束

//区域表单开始
//省市表单开始
cityareaname=new Array(35);
cityareacode=new Array(35);

function first(preP,preC,formname,selectP,selectC)
{
a=0;

if (selectP=='01')
  { a=1;tempoption=new Option('Anhui','Anhui',false,true); }
else
  { tempoption=new Option('Anhui','Anhui'); }
eval('document.'+formname+'.'+preP+'.options[1]=tempoption;');
cityareacode[0]=new Array('0101','0102','0103','0104','0105','0106','0107','0108','0109','0110','0111','0112','0113','0114','0115','0116','0117');
cityareaname[0]=new Array('Hefei','Wuhu','Bengbu','Chuzhou','Anqing','Liuan','Huangshan','Xuancheng','Huainan','Suzhou','Maanshan','Tongling','Huaibei','Fuyang','Chizhou','Chaohu','Haozhou');

if (selectP=='02')
  { a=2;tempoption=new Option('Beijing','Beijing',false,true); }
else
  { tempoption=new Option('Beijing','Beijing'); }
eval('document.'+formname+'.'+preP+'.options[2]=tempoption;');
cityareacode[1]=new Array('0201','0202','0203','0204','0205','0206','0207','0208','0209');
cityareaname[1]=new Array('Dongcheng','Xicheng','Chongwen','Xuanwu','Chaoyang','Haidian','Fengtai','Shijingshan','Shunyi','Other');

if (selectP=='03')
  { a=3;tempoption=new Option('Chongqing','Chongqing',false,true); }
else
  { tempoption=new Option('Chongqing','Chongqing'); }
eval('document.'+formname+'.'+preP+'.options[3]=tempoption;');
cityareacode[2]=new Array('0301','0302','0303','0304','0305','0306');
cityareaname[2]=new Array('Yuzhong','Jiangbei','Shapingba','Nanan','Jiulongpo','Dadukou');

if (selectP=='04')
  { a=4;tempoption=new Option('Fujian','Fujian',false,true); }
else
  { tempoption=new Option('Fujian','Fujian'); }
eval('document.'+formname+'.'+preP+'.options[4]=tempoption;');
cityareacode[3]=new Array('0401','0402','0403','0404','0405','0406','0407','0408','0409');
cityareaname[3]=new Array('Fuzhou','Xiamen','Quanzhou','Zhangzhou','Longyan','Nanping','Ningde','Putian','Sanming');

if (selectP=='05')
  { a=5;tempoption=new Option('Gansu','Gansu',false,true); }
else
  { tempoption=new Option('Gansu','Gansu'); }
eval('document.'+formname+'.'+preP+'.options[5]=tempoption;');
cityareacode[4]=new Array('0501','0502','0503','0504','0505','0506','0507','0508','0509','0510','0511','0512','0513','0514');
cityareaname[4]=new Array('Lanzhou','Jinchang','Baiyin','Tianshui','Jiayuguan','Dingxi','Pingliang','Qingyang','Longnan','Wuwei','Zhangye','Jiuquan','Gannan','Linxia');

if (selectP=='06')
  { a=6;tempoption=new Option('Guangdong','Guangdong',false,true); }
else
  { tempoption=new Option('Guangdong','Guangdong'); }
eval('document.'+formname+'.'+preP+'.options[6]=tempoption;');
cityareacode[5]=new Array('0601','0602','0603','0604','0605','0606','0607','0608','0609','0610','0611','0612','0613','0614','0615','0616');
cityareaname[5]=new Array('Guangzhou','Zhuhai','Zhongshan','Foshan','Dongguan','Qingyuan','Zhaoqing','Yangjiang','Zhanjiang','Shaoguan','Huizhou','Heyuan','Shanwei','Shantou','Meizhou','Shenzhen');

if (selectP=='07')
  { a=7;tempoption=new Option('Guangxi','Guangxi',false,true); }
else
  { tempoption=new Option('Guangxi','Guangxi'); }
eval('document.'+formname+'.'+preP+'.options[7]=tempoption;');
cityareacode[6]=new Array('0701','0702','0703','0704','0705','0706','0707','0708','0709','0710','0711','0712');
cityareaname[6]=new Array('Nanning','Liuzhou','Guilin','Wuzhou','Beihai','Fangchenggang','Qinzhou','Guigang','Yulin','Hezhou','Baise','Hechi');

if (selectP=='08')
  { a=8;tempoption=new Option('Guizhou','Guizhou',false,true); }
else
  { tempoption=new Option('Guizhou','Guizhou'); }
eval('document.'+formname+'.'+preP+'.options[8]=tempoption;');
cityareacode[7]=new Array('0801','0802','0803','0804','0805','0806','0807','0808','0809');
cityareaname[7]=new Array('Guiyang','Liupanshui','Zunyi','Tongren','Bijie','Anshun','Qianxinan','Qiandongnan','Qiannan');

if (selectP=='09')
  { a=9;tempoption=new Option('Hainan','Hainan',false,true); }
else
  { tempoption=new Option('Hainan','Hainan'); }
eval('document.'+formname+'.'+preP+'.options[9]=tempoption;');
cityareacode[8]=new Array('0901','0902','0903','0904','0905','0906','0907','0908','0909');
cityareaname[8]=new Array('Haikou ','Sanya','Tongshi','Qionghai','Qiongshan','Wenchang','Wanning','Dongfang','Danzhou');

if (selectP=='10')
  { a=10;tempoption=new Option('Hebei','Hebei',false,true); }
else
  { tempoption=new Option('Hebei','Hebei'); }
eval('document.'+formname+'.'+preP+'.options[10]=tempoption;');
cityareacode[9]=new Array('1001','1002','1003','1004','1005','1006','1007','1008','1009','1010','1011');
cityareaname[9]=new Array('Shijiazhuang','Tangshan','Qinhuangdao','Handan','Xingtai','Zhangjiakou','Chengde','Langfang','Cangzhou','Baoding','Hengshui');

if (selectP=='11')
  { a=11;tempoption=new Option('Heilongjiang','Heilongjiang',false,true); }
else
  { tempoption=new Option('Heilongjiang','Heilongjiang'); }
eval('document.'+formname+'.'+preP+'.options[11]=tempoption;');
cityareacode[10]=new Array('1101','1102','1103','1104','1105','1106','1107','1108','1109','1110','1111','1112','1113');
cityareaname[10]=new Array('Haerbin','Qiqihaer','Mudanjiang','Jiamusi','Daqing','Yichun','Heihe','Jixi','Hegang','Shuangyashan','Qitaihe','Suihua','Daxinganling');

if (selectP=='12')
  { a=12;tempoption=new Option('Henan','Henan',false,true); }
else
  { tempoption=new Option('Henan','Henan'); }
eval('document.'+formname+'.'+preP+'.options[12]=tempoption;');
cityareacode[11]=new Array('1201','1202','1203','1204','1205','1206','1207','1208','1209','1210','1211','1212','1213','1214','1215','1216','1217','1218');
cityareaname[11]=new Array('Zhengzhou','Kaifeng','Luoyang','Pingdingshan','Anyang','Hebi','Xinxiang','Jiaozuo','Puyang','Xuchang','Luohe','Sanmenxia','Nanyang','Shangqiu','Zhoukou','Zhumadian','Xinyang','Jiyuan');

if (selectP=='13')
  { a=13;tempoption=new Option('Hongkong','Hongkong',false,true); }
else
  { tempoption=new Option('Hongkong','Hongkong'); }
eval('document.'+formname+'.'+preP+'.options[13]=tempoption;');
cityareacode[12]=new Array('1301');
cityareaname[12]=new Array('Hongkong');

if (selectP=='14')
  { a=14;tempoption=new Option('Hubei','Hubei',false,true); }
else
  { tempoption=new Option('Hubei','Hubei'); }
eval('document.'+formname+'.'+preP+'.options[14]=tempoption;');
cityareacode[13]=new Array('1401','1402','1403','1404','1405','1406','1407','1408','1409','1410','1411','1412','1413','1414','1415','1416','1417');
cityareaname[13]=new Array('Wuhai','Huangshi','Shiya','Jingzhou','Yichang','Xiangfan','Ezhou','Jingmen','Xiaogan','Huanggang','Xianning','Enshi','Suizhou','Xiantao','Tianmen','Qianjiang','Shenlongjia');

if (selectP=='15')
  { a=15;tempoption=new Option('Hunan','Hunan',false,true); }
else
  { tempoption=new Option('Hunan','Hunan'); }
eval('document.'+formname+'.'+preP+'.options[15]=tempoption;');
cityareacode[14]=new Array('1501','1502','1503','1504','1505','1506','1507','1508','1509','1510','1511','1512','1513');
cityareaname[14]=new Array('Changsha','Zhuzhou','Xiangtan','Hengyang','Shaoyang','Yueyang','Changde','Binzhou','Yiyang','Yongzhou','Huaihua','Loudi','Xiangxi ');

if (selectP=='16')
  { a=16;tempoption=new Option('Jiangsu','Jiangsu',false,true); }
else
  { tempoption=new Option('Jiangsu','Jiangsu'); }
eval('document.'+formname+'.'+preP+'.options[16]=tempoption;');
cityareacode[15]=new Array('1601','1602','1603','1604','1605','1606','1607','1608','1609','1610','1611','1612','1613');
cityareaname[15]=new Array('Nanjing','Suzhou','Wuxi','Changzhou','Zhenjiang','Lianyungang ','Yangzhou','Xuzhou ','Nantong','Yancheng','Huaiyin','Taizhou','Suqian');

if (selectP=='17')
  { a=17;tempoption=new Option('Jiangxi','Jiangxi',false,true); }
else
  { tempoption=new Option('Jiangxi','Jiangxi'); }
eval('document.'+formname+'.'+preP+'.options[17]=tempoption;');
cityareacode[16]=new Array('1701','1702','1703','1704','1705','1706','1707','1708','1709','1710','1711');
cityareaname[16]=new Array('Nanchang','Jingdezhen','Jiujiang','Pingxiang','Xinyu','Yingtan','Ganzhou','Yichun','Jian','Shangrao','Fuzhou');

if (selectP=='18')
  { a=18;tempoption=new Option('Jilin','Jilin',false,true); }
else
  { tempoption=new Option('Jilin','Jilin'); }
eval('document.'+formname+'.'+preP+'.options[18]=tempoption;');
cityareacode[17]=new Array('1801','1802','1803','1804','1805','1806','1807','1808','1809');
cityareaname[17]=new Array('Changchun','Jilin','Siping','Liaoyuan','Tonghua','Baishan','Songyuan','Baicheng','Yanbian');

if (selectP=='19')
  { a=19;tempoption=new Option('Liaoning','Liaoning',false,true); }
else
  { tempoption=new Option('Liaoning','Liaoning'); }
eval('document.'+formname+'.'+preP+'.options[19]=tempoption;');
cityareacode[18]=new Array('1901','1902','1903','1904','1905','1906','1907','1908','1909','1910','1911','1912','1913','1914');
cityareaname[18]=new Array('Shenyang','Dalian','Anshan','Jinzhou','Dandong','Panjin','Tieling','Fushun','Yingkou','Liaoyang','Fuxin','Benxi','Chaoyang','Huludao');

if (selectP=='20')
  { a=20;tempoption=new Option('Macau','Macau',false,true); }
else
  { tempoption=new Option('Macau','Macau'); }
eval('document.'+formname+'.'+preP+'.options[20]=tempoption;');
cityareacode[19]=new Array('2001');
cityareaname[19]=new Array('Macau');

if (selectP=='21')
  { a=21;tempoption=new Option('Neimenggu','Neimenggu',false,true); }
else
  { tempoption=new Option('Neimenggu','Neimenggu'); }
eval('document.'+formname+'.'+preP+'.options[21]=tempoption;');
cityareacode[20]=new Array('2101','2102','2103','2104','2105','2106','2107','2108','2109','2110','2111');
cityareaname[20]=new Array('Huhehaote','Baotou','Wuhai','Linhe','Dongsheng','Jining','Xilinhaote','Tongliao','Chifeng','Hailaer','Wulanhaote');

if (selectP=='22')
  { a=22;tempoption=new Option('Ningxia','Ningxia',false,true); }
else
  { tempoption=new Option('Ningxia','Ningxia'); }
eval('document.'+formname+'.'+preP+'.options[22]=tempoption;');
cityareacode[21]=new Array('2201','2202','2203','2204');
cityareaname[21]=new Array('Yinchuan','Shizuishan','Yinnan','Guyuan');

if (selectP=='23')
  { a=23;tempoption=new Option('Qinghai','Qinghai',false,true); }
else
  { tempoption=new Option('Qinghai','Qinghai'); }
eval('document.'+formname+'.'+preP+'.options[23]=tempoption;');
cityareacode[22]=new Array('2301','2302','2303','2304','2305','2306','2307','2308');
cityareaname[22]=new Array('Xining','Haidong','Haibei','Huangnan','Hainan','Guoluo','Yushu','Haixi');

if (selectP=='24')
  { a=24;tempoption=new Option('Shaanxi','Shaanxi',false,true); }
else
  { tempoption=new Option('Shaanxi','Shaanxi'); }
eval('document.'+formname+'.'+preP+'.options[24]=tempoption;');
cityareacode[23]=new Array('2401','2402','2403','2404','2405','2406','2407','2408','2409','2410');
cityareaname[23]=new Array('Xian','Tongchuan','Baoji','Xianyang','Weinan','Yanan','Hanzhong','Yulin','Shangluo','Ankang');

if (selectP=='25')
  { a=25;tempoption=new Option('Shandong','Shandong',false,true); }
else
  { tempoption=new Option('Shandong','Shandong'); }
eval('document.'+formname+'.'+preP+'.options[25]=tempoption;');
cityareacode[24]=new Array('2501','2502','2503','2504','2505','2506','2507','2508','2509','2510','2511','2512','2513','2514','2515','2516','2517');
cityareaname[24]=new Array('Jinan','Qingdao','Zibo','Dezhou','Yantai','Weifang','Jining','Taian','Linyi','Heze','Weihai','Zaozhuang','Rizhao','Laiwu','Liaocheng','Binzhou','Dongying');

if (selectP=='26')
  { a=26;tempoption=new Option('Shanghai','Shanghai',false,true); }
else
  { tempoption=new Option('Shanghai','Shanghai'); }
eval('document.'+formname+'.'+preP+'.options[26]=tempoption;');
cityareacode[25]=new Array('2601','2602','2603','2604','2605','2606','2607','2608','2609','2610','2611','2612','2613','2614','2615','2616','2617','2618','2619','2620');
cityareaname[25]=new Array('Baoshan','Jinshan','Nanshi','Changning','Jingan','Qingpu','Chongming','Luwan','Songjiang','Fengxian','Pudong','Yangpu','Hongkou','Putuo','Zhabei','Huangpu','Minhang','Xuhui','Jiading','Nanhui');

if (selectP=='27')
  { a=27;tempoption=new Option('Shanxi','Shanxi',false,true); }
else
  { tempoption=new Option('Shanxi','Shanxi'); }
eval('document.'+formname+'.'+preP+'.options[27]=tempoption;');
cityareacode[26]=new Array('2701','2702','2703','2704','2705','2706','2707');
cityareaname[26]=new Array('Taiyuan','Datong','Yangquan','Shuozhou','Changzhi','Linfen','Jincheng');

if (selectP=='28')
  { a=28;tempoption=new Option('Sichuan','Sichuan',false,true); }
else
  { tempoption=new Option('Sichuan','Sichuan'); }
eval('document.'+formname+'.'+preP+'.options[28]=tempoption;');
cityareacode[27]=new Array('2801','2802','2803','2804','2805','2806','2807','2808','2809','2810','2811','2812','2813','2814','2815','2816','2817','2818','2819','2820');
cityareaname[27]=new Array('Chengdu','Zigong','Panzhihua','Luzhou','Deyang','Mianyang','Guangyuan','Suining','Neijiang','Leshan','Nanchong','Yibin','Guangan','Dachuan','Bazhong','Yaan','Meishan','Aba','Ganzi','Liangshan');

if (selectP=='29')
  { a=29;tempoption=new Option('Taiwan','Taiwan',false,true); }
else
  { tempoption=new Option('Taiwan','Taiwan'); }
eval('document.'+formname+'.'+preP+'.options[29]=tempoption;');
cityareacode[28]=new Array('2901');
cityareaname[28]=new Array('Taiwan');

if (selectP=='30')
  { a=30;tempoption=new Option('Tianjin','Tianjin',false,true); }
else
  { tempoption=new Option('Tianjin','Tianjin'); }
eval('document.'+formname+'.'+preP+'.options[30]=tempoption;');
cityareacode[29]=new Array('3001','3002','3003','3004','3005','3006','3007','3008','3009','3010','3011','3012','3013','3014','3015');
cityareaname[29]=new Array('Heping','Hebei','Hexi','Hedong','Nankai','Hongqiao','Tanggu','Hangu','Dagang','Dongli','Xiqing','Jinnan','Beichen','Wuqing','Binhai');

if (selectP=='31')
  { a=31;tempoption=new Option('Xinjiang','Xinjiang',false,true); }
else
  { tempoption=new Option('Xinjiang','Xinjiang'); }
eval('document.'+formname+'.'+preP+'.options[31]=tempoption;');
cityareacode[30]=new Array('3101','3102','3103','3104','3105','3106','3107','3108','3109','3110','3111','3112','3113');
cityareaname[30]=new Array('Wulumuqi','Kelamayi','Shihezi','Tulupan','Hami','Hetian','Akesu','Kashi','Kezilesu','Bayinguoleng','Changji','Boertala','Yili');

if (selectP=='32')
  { a=32;tempoption=new Option('Xizang','Xizang',false,true); }
else
  { tempoption=new Option('Xizang','Xizang'); }
eval('document.'+formname+'.'+preP+'.options[32]=tempoption;');
cityareacode[31]=new Array('3201','3202','3203','3204','3205','3206','3207');
cityareaname[31]=new Array('Lasa','Naqu','Changdu','Shannan','Rikaze','Ali','Linzhi');

if (selectP=='33')
  { a=33;tempoption=new Option('Yunnan','Yunnan',false,true); }
else
  { tempoption=new Option('Yunnan','Yunnan'); }
eval('document.'+formname+'.'+preP+'.options[33]=tempoption;');
cityareacode[32]=new Array('3301','3302','3303','3304','3305','3306','3307','3308','3309','3310','3311','3312','3313','3314','3315','3316','3317');
cityareaname[32]=new Array('Kunming','Dongchuan','Qujing','Yuxi','Zhaotong','Simao','Lincang','Baoshan','Lijiang','Wenshan','Honghe','Xishuangbanna','Chuxiong','Dali','Dehong','Nujiang','Diqing');

if (selectP=='34')
  { a=34;tempoption=new Option('Zhejiang','Zhejiang',false,true); }
else
  { tempoption=new Option('Zhejiang','Zhejiang'); }
eval('document.'+formname+'.'+preP+'.options[34]=tempoption;');
cityareacode[33]=new Array('3401','3402','3403','3404','3405','3406','3407','3408','3409','3410','3411');
cityareaname[33]=new Array('Hangzhou','Huzhou','Lishui','Wenzhou','Shaoxing','Zhoushan','Jiaxing','Jinhua','Taizhou','Quzhou','Ningbo');


eval('document.'+formname+'.'+preP+'.options[a].selected=true;');

cityid=selectP;
    if (cityid!='0')
      {
        b=0;for (i=0;i<cityareaname[cityid-1].length;i++)
           {
         	
             if (selectC==cityareacode[cityid-1][i])
               {b=i+1;tempoption=new Option(cityareaname[cityid-1][i],cityareaname[cityid-1][i],false,true);}
             else
               tempoption=new Option(cityareaname[cityid-1][i],cityareaname[cityid-1][i]);
            eval('document.'+formname+'.'+preC+'.options[i+1]=tempoption;');
           }
        eval('document.'+formname+'.'+preC+'.options[b].selected=true;');
      }
    }
 function selectcityarea(preP,preC,formname)
 {
     cityid=eval('document.'+formname+'.'+preP+'.selectedIndex;');
     j=eval('document.'+formname+'.'+preC+'.length;');
     for (i=1;i<j;i++)
        {eval('document.'+formname+'.'+preC+'.options[j-i]=null;')}
     if (cityid!="0")
       {
         for (i=0;i<cityareaname[cityid-1].length;i++)
            {
             tempoption=new Option(cityareaname[cityid-1][i],cityareaname[cityid-1][i]);
             eval('document.'+formname+'.'+preC+'.options[i+1]=tempoption;');
            }
       }
  }
 //省市表单结束
//区域表单结束

//动态显示区域下拉框开始

//控制区域列表框显示
/*
function hideSel( selectA )
{
  var selAString = selectA.options[selectA.selectedIndex].text;    //selectA的选项文本
  if( selAString != "China" )
  {
    document.getElementById("areatable").style.display = "none";
  }
  else
  {
  	document.getElementById("areatable").style.display = "";
  }
}
*/
function hideSel( selectA )
{
  var selAString = document.regform.country.options[document.regform.country.selectedIndex].text;    //selectA的选项文本
  if( selAString != "China" )
  {
    document.all("areatable").style.display = "none";
  }
  else
  {
  	document.all("areatable").style.display = "";
  }
}

//控制个人信息区域显示
function hideDetail( thecheck )
{
	if( thecheck.checked )
	{
		document.getElementById("detailspan").style.display = "";
	}
	else
	{
		document.getElementById("detailspan").style.display = "none";
	}

}
//控制Email区域显示
function hideEmail( thecheck )
{
	if( thecheck.checked )
	{
		document.getElementById("emailtd").style.display = "";
	}
	else
	{
		document.getElementById("emailtd").style.display = "none";
	}
}

//控制interesting aspect区域信息显示
function hideAspect(selectA)
{
	var selAString = selectA.options[selectA.selectedIndex].text    //selectA的选项文本

	if( selAString != "Others" )
	{
		document.getElementById("aspectspan").style.display = "none";
 		document.getElementById("aspecttipspan").style.display = "none";
  }
  if( selAString == "Others" )
  {
  	document.getElementById("aspectspan").style.display = "";
  	document.getElementById("aspecttipspan").style.display = "";
  }
}

//创建出生日期列表

function createBirth( selectA )
{
	var tempsel = document.getElementById( selectA );

	for( i = 1923; i < 2004; i++ )
	{
		tempoption = new Option( i,i );
		tempsel.options[tempsel.length] = tempoption;
	}
}


//自定义去除空格函数
function trim(str)
{
  return str.ltrim().rtrim();
}

function ltrim()
{
  return this.replace(/ +/,"");
}
String.prototype.ltrim = ltrim;

function rtrim()
{
  return this.replace(/ +$/,"");
}
String.prototype.rtrim = rtrim;
//自定义去除空格函数结束


//检查profile表单填写是否符合要求
function checkPorfileSubmit( theform )
{
	if( !checkBirth( "birth" ) )return false;
	if( document.getElementById("areatable").style.display == "" )
	{
		if( !checkArea( "country" ) )return false;
		if( !checkArea( "province" ) )return false;
		if( !checkArea( "city" ) )return false;
	}
	if( !checkSector( "sector" ) )return false;
	if( !checkAspect( "aspect" ) )return false;

	if( document.getElementById("emailtd").style.display == "" )
	{
		if( !checkLanguage( "language" ) )return false;
		if( !checkFormat( "format" ) )return false;
	}
	if( document.getElementById("detailspan").style.display == "" )
	{
		if( !checkTruename( "truename") )return false;
		if( !checkSex( "gender" ) )return false;
		if( !checkOrg( "organisation" ) )return false;
		if( !checkAddress( "address" ) )return false;
		if( !checkPostcode( "postcode" ) )return false;
		if(!checkCharNum( "postcode",10,"regform.postcode" ))return false;
		if( !checkTel( "telephone" ) )return false;
	}
	return true;
}

//检查修改密码表单是否符合要求
function checkModifyPwd()
{
  if (form3.password.value == "")
  {
    alert("Password can't be empty");
    form3.password.focus();
    return false;
  }
  else if (form3.password.value.length < 6)
  {
    alert("Password can't beyond 6 character");
    form3.password.focus();
    return false;
  }
  else if (form3.password2.value == "")
  {
    alert("Password can't be empty！");
    form3.password2.focus();
    return false;
  }
  else if (form3.password.value != form3.password2.value)
  {
    alert("The Password and the Confirm Password must match.！");
    form3.password2.focus();
    return false;
  }
  else
  {
    return true;
  }
}
//检查修改密码表单结束

//检查文本域输入字数是否符合要求
function checkCharNum( txtA,charN,objname )
{
	var txt = eval( objname + ".value" );
	var len = new Number(txt.length);
	if ( len > charN )
	{
		alert(txtA +" length can't beyond " + charN + " characters!");
		eval( objname + ".focus();" );
		return false;
	}
	return true;
}

//检查上传文件类型

function checkFileType( formname,filename,filetype )
{
	var str = eval( formname + "." + filename + ".value"  );
	var strLength = eval(formname + "." + filename + ".value.length");
	str = str.substring( strLength-4, strLength );
	if( str.toLowerCase() != ("." + filetype) && str.toLowerCase() != ".gif" && str.toLowerCase() != ".png" && 
		str.toLowerCase() != ".bmp")
	{
		alert( "File type is only Image  " );
		return false;
	}
	return true;
}


//检查上传文件类型结束

//检查Checkbox
function checkCBox(  )
{
	var boxObj = document.getElementById( "linkbox" );
	var txtObj = document.getElementById( "linkdetail" );
	if(boxObj.checked)
	{
		if(txtObj.value.length == 0)
		{
			alert("Link can't be empty");
			return false;
		}
	}
	return true;
	
}
//检查Checkbox结束

//检查上传case表单结束


//将SelectA下拉框中选择值导入SelectB下拉框中

function setSelectB( selectA,selectB )
{
	var selObj = document.getElementById(selectA);
	if( selObj.value == "" )
	{
		alert( selectA + " can't be empty" );
		selObj.focus();
		return;
	}
	var objSel = document.getElementById(selectB);

	for(var i=selObj.length-1;i>=0;i--)   //赋值会出现顺序倒置状况，考虑再用一个for循环加一个临时变量将值顺序置回
	{
		if( selObj.options[i].selected )
		{
			tempOption = new Option( selObj.options[i].value,selObj.options[i].value,false,true);
			objSel[objSel.length] = tempOption;
			selObj.options[i]=null;
		}
	}
}

//级联货币金额下拉框
var amountid = new Array(4);
var amountname = new Array(4);
function createCurrecy( selectA,selectB,formname,indexA,indexB )
{
	if (indexA=='01')
  {
  	a=1;
  	tempoption=new Option('A','A',false,true);
  }
	else
	{ tempoption=new Option('A','A'); }
	eval('document.'+formname+'.'+selectA+'.options[1]=tempoption;');
	amountid[0] = new Array("0101","0102","0103","0104");
	amountname[0] = new Array("A","B","C","D");
	if (indexA=='02')
  { a=2;tempoption=new Option('B','B',false,true); }
	else
	{ tempoption=new Option('B','B'); }
	eval('document.'+formname+'.'+selectA+'.options[2]=tempoption;');
	amountid[1] = new Array("0201","0202","0203","0204");
	amountname[1] = new Array("B","C","D","E");
	if (indexA=='03')
  { a=3;tempoption=new Option('C','C',false,true); }
	else
	{ tempoption=new Option('C','C'); }
	eval('document.'+formname+'.'+selectA+'.options[3]=tempoption;');
	amountid[2] = new Array("0301","0302","0303","0304");
	amountname[2] = new Array("D","E","F","G");
	if (indexA=='04')
  { a=4;tempoption=new Option('D','D',false,true); }
	else
	{ tempoption=new Option('D','D'); }
	eval('document.'+formname+'.'+selectA+'.options[4]=tempoption;');
	amountid[3] = new Array("0401","0402","0403","0404");
	amountname[3] = new Array("G","H","T","Y");

	amountid = indexA;
	if( amountid != 0 )
	{
		b=0;
		for (i=0;i<amountname[amountid-1].length;i++)
		{
			 if (indexB==amountname[amountid-1][i])
			 {
				 b=i+1;
				 tempoption=new Option(amountname[amountid-1][i],amountname[amountid-1][i],false,true);
			 }
		 else
			 tempoption=new Option(amountname[amountid-1][i],amountname[amountid-1][i]);
		eval('document.'+formname+'.'+selectB+'.options[i+1]=tempoption;');
		}
		eval('document.'+formname+'.'+selectB+'.options[b].selected=true;');
	}
}

function selectAmount(selectA,selectB,formname)
{

	 amountid=eval('document.'+formname+'.'+selectA+'.selectedIndex;');
	 j=eval('document.'+formname+'.'+selectB+'.length;');
	 for (i=1;i<j;i++)
			{eval('document.'+formname+'.'+selectB+'.options[j-i]=null;')}
	 if (amountid!=0)
		 {
			 for (i=0;i<amountname[amountid-1].length;i++)
				{
				 tempoption=new Option(amountname[amountid-1][i],amountname[amountid-1][i]);
				 eval('document.'+formname+'.'+selectB+'.options[i+1]=tempoption;');
				}
		 }
}

//级联货币金额下拉框结束


//选择下拉框中值

function getSelValue( selectA )
{
	var selObj = document.getElementById(selectA);
	for(var i=0;i<selObj.length;i++)
	{
		selObj.options[i].selected = true;
	}
}

//控制控件是否可用
//用checkBox控制相互关联下拉框是否可用
function enableBoxSel( selectA,objB,selectB )
{
	var objB = document.getElementById(objB);
	var selObj = document.getElementById(selectA);
	var objSel = document.getElementById(selectB);

	if(objB.checked)
	{
		selObj.disabled = false;
		objSel.disabled = false;
	}
	else
	{
		selObj.disabled = true;
		objSel.disabled = true;
	}
}
//用checkbox控制file是否可用
function enableBoxFile( fileA,objB )
{
	var objB = document.getElementById(objB);
	var fileObj = document.getElementById(fileA);
	if(objB.checked)
	{
		fileObj.disabled = false;
	}
	else
	{
		fileObj.disabled = true;
	}
}



//用radio按钮控制关联下拉框是否可用
function enableRadioSel( selectA,selectB )
{
	var selObj = document.getElementById(selectA);
	var objSel = document.getElementById(selectB);

	selObj.disabled = false;
	objSel.disabled = false;
}

//控制文本框是否可用
function enableText( txtA )
{
	var txtObj = document.getElementById(txtA);

	txtObj.readOnly = false;
}

//禁用关联下拉框与文本框

function disableRadioSel( selectA,selectB,selectC,selectD,txtA)
{
  	var selObj = document.getElementById(selectA);
  	var objSel = document.getElementById(selectB);
  	var selObje = document.getElementById(selectC);
  	var objeSel = document.getElementById(selectD);
  	var objTxt = document.getElementById(txtA);
  	if(txtA = "")
  	{
  		objTxt = null;
  	}

			selObj.disabled = true;
			objSel.disabled = true;
			selObje.disabled = true;
			objeSel.disabled = true;
		if( objTxt == null )
		{
			;
		}
		else
		{
			objTxt.readOnly = true;
		}

}

//禁用Radio控制范围内所有下拉框

function disableAllSel( selectA,selectB,selectC,selectD,selectE,selectF )
{
  	var selObj = document.getElementById(selectA);
  	var objSel = document.getElementById(selectB);
  	var selObje = document.getElementById(selectC);
  	var objeSel = document.getElementById(selectD);
  	var selObjec = document.getElementById(selectE);
  	var objecSel = document.getElementById(selectF);

		selObj.disabled = true;
		objSel.disabled = true;
		selObje.disabled = true;
		objeSel.disabled = true;
		selObjec.disabled = true;
		objecSel.disabled = true;
}
//控制控件是否可用结束

//检查hotlink表单是否合要求

function checkLinkSubmit()
{
	if ((regform.address.value) == "")
	{
		alert("Address can't be empty!");
		regform.address.focus();
		return false;
	}
	else if ((regform.about.value) == "")
	{
		alert("Description can't be empty!");
		regform.about.focus();
		return false;
	}
	if (!checkCharNum( "Description",255,"regform.about" ))
	{
		return false;
	}
}

//检查hotlink表单结束

//检查获取密码表单填写是否符合要求

function checkGetPassword()
{
	 if (form3.username.value == "")
  {
    alert("Username can't be empty!");
    form3.username.focus();
    return false;
  }
  else if (form3.email.value == "")
  {
    alert("Email can't be empty!");
    form3.email.focus();
    return false;
  }
  else
  {
    return true;
  }
}

//检查获取密码表单填写结束

//检查提交问题表单
function checkQuestionForm( objName )
{
	var txtObj = document.getElementById(objName);
	if (txtObj.value == "")
	{
		alert("Question can't be empty!");
		document.getElementById(objName).focus();
		return false;
	}
	else if (txtObj.value.length > 200)
	{
		alert("Question can't beyond 200 characters!");
		return false;
	}
	return true;
}

function Interested_change()
{
  var selAString = regform.interested.options[regform.interested.selectedIndex].text;
  if ( selAString != "Others" )
  {
    document.getElementById("other_interested_div").style.display = "none";
  }
  else
  {
  	document.getElementById("other_interested_div").style.display = "";
  }
}