
function increase( value ) {

var obj = document.getElementById("more");
var c = document.getElementById("count").value;
var excity = document.getElementById("examcity").value ;
var r = document.getElementById("reduce");
var i = parseInt(c)+1;
document.getElementById("tablerow"+i).style.display='';
/*
var strHTML = "";
strHTML += "<table id=\"t"+i+"\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";

strHTML += "<tr >";
strHTML += "<td width=\"28%\" class=\"text\">Mailing Option:</td>";
if(value=='1')
{
	strHTML += " <td class=\"text\"   ><select name=\"way"+i+"\" id=\"way"+i+"\" onChange=\"wayselect(this,document.reg_form,'"+i+"');\"><option value=\"\" selected=\"selected\">please select</option><option value=\"1\">E-TRF</option><option value=\"2\">Air Mail</option><option value=\"3\">Express-DHL</option></select><span >*</span></td>";
}
else
{
	strHTML += " <td class=\"text\" ><select name=\"way"+i+"\" id=\"way"+i+"\" onChange=\"wayselect(this,document.reg_form,'"+i+"');\"><option value=\"\" selected=\"selected\">please select</option><option value=\"1\">E-TRF</option><option value=\"2\">Air Mail</option><option value=\"3\">Express-DHL</option><option value=\"4\">Express-EMS</option></select><span >*</span></td>";
}
strHTML += "</tr>";


strHTML += "<tr id=\"country_exams"+i+"\" style=\"display:\">";
strHTML += "<td  valign=\"top\" class=\"text\">Country or Region:</td>";
strHTML += "<td class=\"text\"><select id=\"country"+i+"\"  name=\"country"+i+"\" onChange=\"comm(this.value,'"+i+"');\">";
strHTML += "<option value=>please select</option></select><span>*</span>";
strHTML += "</td>";
strHTML += "</tr>";

strHTML += "<tr id=\"country_other_tr"+i+"\"  style=\"display:none\" >";
strHTML += "<td></td>";
strHTML += "<td class=\"text\">";
strHTML += "<strong>Please input country name:</strong><br/><input type=\"text\" name=\"country_other"+i+"\" id=\"country_other"+i+"\" class=\"f-text\" /><span>*</span>";
strHTML += "</td></tr>";


strHTML += "<tr id=\"citys_exams_tr"+i+"\" style=\"display:none\">";
strHTML += "<td class=\"text\">City:</td>"
strHTML += "<td class=\"text\"><input type=\"text\" name=\"citys_exams"+i+"\"  id=\"citys_exams"+i+"\" class=\"f-text\"/><span>*</span></td>";
strHTML += "</tr>";

strHTML += "<tr  id=\"school_exams"+i+"\" style=\"display:none\">";
strHTML += "<td valign=\"top\" class=\"text\">Organization:</td><td class=\"text\"><select name=\"school"+i+"\"  id=\"school"+i+"\" onChange=\"schoolselect(this,document.reg_form,'"+i+"');\" style=\"font-family:Arial;\"><option value=\"\">please select</option></select><span >*</span></td>";
strHTML += "</tr>";

strHTML += "<tr >";
strHTML += " <td class=\"text\">Name of Person/Department:</td>";
strHTML += "<td class=\"text\"><textarea type=\"text\" name=\"pname"+i+"\" id=\"pname"+i+"\" wrap=\"VIRTUAL\" class=\"f-textares\" /></textarea><span >*</span></td>";
strHTML += "</tr>";

strHTML += "<tr >";
strHTML += "<td class=\"text\">Name of Receiving Organization:</td>";
strHTML += "<td class=\"text\"><textarea type=\"text\" name=\"orgname"+i+"\" id=\"orgname"+i+"\"  wrap=\"VIRTUAL\" id=\"orgname0\"  class=\"f-textares\" /></textarea><span >*</span></td>";
strHTML += "</tr>";

strHTML += "<tr >";
strHTML += "<td class=\"text\">Address:</td>";
strHTML += "<td class=\"text\"><textarea type=\"text\" name=\"orgAddress"+i+"\" id=\"orgAddress"+i+"\"  wrap=\"VIRTUAL\" id=\"orgAddress0\"   class=\"f-textares\" /></textarea><span >*</span></td>";
strHTML += "</tr>";

strHTML += "<tr >";
strHTML += "<td class=\"text\">Postcodes:</td>";
strHTML += "<td class=\"text\"><textarea type=\"text\" name=\"zip"+i+"\" id=\"zip"+i+"\" wrap=\"VIRTUAL\" class=\"f-text\" /></textarea><span >*</span></td>";
strHTML += "</tr>";

strHTML += "<tr >";
strHTML += "<td class=\"text\">Reference Number:</td>";
strHTML += "<td class=\"text\"><input type=\"text\" name=\"fileNo"+i+"\" id=\"fileNo"+i+"\"  class=\"f-text\" /></td>";
strHTML += "</tr>";
strHTML += "<tr >";
strHTML += "<td class=\"text\">Remark:</td>";
strHTML += "<td class=\"text\"><input name=\"remark"+i+"\"  id=\"remark"+i+"\"  class=\"f-text\"></textarea></td>";
strHTML += "</tr>";
strHTML += "<tr >";



if( excity  == "035" )
{
	strHTML += "<td class=\"text\" id=\"trfa"+i+"\">Extra TRF Fee(USD):</td>";
	strHTML += "<td class=\"text\"><input name=\"hcharge"+i+"\" id=\"hcharge"+i+"\" type=\"text\"  class=\"f-text\" value=\"9\" readonly=\"true\" onBlur=\"getTotalCharge();\"><span >*</span></td>";
	strHTML += "</tr>";
	strHTML += "<tr >";
	strHTML += "<td class=\"text\" id=\"trfb"+i+"\" >Express Service Fee(USD):</td>";
	strHTML += "<td class=\"text\"><input name=\"echarge"+i+"\" id=\"echarge"+i+"\" type=\"text\"  class=\"f-text\" onBlur=\"getTotalCharge();\"><span >*</span><div id=\"dhl_info"+i+"\"  style=\"display:none\">(Fuel surcharge included, the price is rounded up or down to the nearest whole number)</div><div id=\"ems_info"+i+"\"  style=\"display:none\">(Packaging and customs clearance surcharge included, the price is rounded up or down to the nearest whole number)</div></td>";
	strHTML += "</tr>";	
}
else
{
	strHTML += "<td class=\"text\" id=\"trfa"+i+"\">Extra TRF Fee(RMB):</td>";
	strHTML += "<td class=\"text\"><input name=\"hcharge"+i+"\" id=\"hcharge"+i+"\" type=\"text\"  class=\"f-text\" value=\"60\" readonly=\"true\" onBlur=\"getTotalCharge();\"><span >*</span></td>";
	strHTML += "</tr>";
	strHTML += "<tr >";
	strHTML += "<td class=\"text\" id=\"trfb"+i+"\" >Express Service Fee(RMB):</td>";
	strHTML += "<td class=\"text\"><input name=\"echarge"+i+"\" id=\"echarge"+i+"\" type=\"text\"  class=\"f-text\" onBlur=\"getTotalCharge();\"><span >*</span><div id=\"dhl_info"+i+"\"  style=\"display:none\">(Fuel surcharge included, the price is rounded up or down to the nearest whole number)</div><div id=\"ems_info"+i+"\"  style=\"display:none\">(Packaging and customs clearance surcharge included, the price is rounded up or down to the nearest whole number)</div></td>";
	strHTML += "</tr>";
}
strHTML += "</table>";

obj.innerHTML += strHTML;
*/
document.getElementById("count").value = i;

if(i>0){
	r.style.display='';
}
if(i>=19)
	document.getElementById("increase").style.display="none";

getTotalCharge();
}



function reduce() 
{
	try{
	var obj = document.getElementById("more");
	var c = document.getElementById("count").value;
	var r = document.getElementById("reduce");

	var tobj = document.getElementById("t"+c);

	if(c!='0')
	{
		//tobj.parentNode.removeChild(tobj);
		document.getElementById("count").value = parseInt(c)-1;
		document.getElementById("tablerow"+parseInt(c)).style.display='none';
		document.getElementById("echarge"+parseInt(c)).value='0';
	}
	if(c==1)
	{
		r.style.display='none';
	}
	getTotalCharge();
	document.getElementById("increase").style.display="";
	
	
}catch(es){alert(es.message);}
}

function doCheck()
{
try
{	
	var frm = document.getElementById("reg_form");
	var c = document.getElementById("count").value;
	for(i=0;i<checkcharter.length;i++){
		if(!checkcharter[i]){
			alert('字符不符合要求。');
			return false;
		}	
	}

	if(frm.firstname.value==''){
		alert('Family name must be filled in!');
		frm.firstname.focus();
		return false;
	}else{
		if(!isTrueName(frm.firstname.value)){
			alert('Cannot include non alphabetic character or blank in your Given Name, Please enter again.');
			frm.firstname.focus();
			return false;
		}
	}
	if(frm.lastname.value==''){
		alert('Given name must be filled in! ');
		frm.lastname.focus();
		return false;
	}else{
		if(!isTrueName(frm.lastname.value)){
			alert('Cannot include non alphabetic character or blank in your Given Name, Please enter again.');
			frm.lastname.focus();
			return false;
		}
	}
	if(frm.examNo.value==''){
		alert('Candidate number must be filled in!');
		frm.examNo.focus();
		return false;
	}else{
		var l=fucCheckLength(frm.examNo.value);
		var f=fucPWDchk(frm.examNo.value);
		if(l==6){
			if(f==0){
				alert('Candidate number mistakes.');
				frm.examNo.focus();
				return false;
			}
		}else{
			alert('Candidate number must be 6 numbers or letters.');
			frm.examNo.focus();
			return false;
		}
	}
	/*
	if(frm.neeaNo.value==''){
		alert('NEEA user ID must be filled in!');
		frm.neeaNo.focus();
		return false;
	}*/
	if(frm.examarea.value==''){
		alert('Please select test region!');
		frm.examarea.focus();
		return false;
	}
	if(frm.examcity.value==''||frm.examcity.value=='null'){
		alert('Please select test centre!');
		frm.examcity.focus();
		return false;
	}
	if(frm.year.value==''||frm.month.value==''||frm.month.value=='please select'||frm.day.value==''||frm.day.value=='please select'){
		alert('Please select test date!');
		frm.year.focus();
		return false;
	}
	if(frm.domesticTel.value==''){
		alert('Candidate’s contact telephone number in China must be filled in!');
		frm.domesticTel.focus();
		return false;
	}
	if(frm.email.value==''){
		alert('Candidate’s e-mail address must be filled in!');
		frm.email.focus();
		return false;
	}

	//添加到session用于firefox start 2009-6-9
	var urll  = "addForm.jsp?count="+c+"&";
	
	var colList2 = new Array(13);
	

	for(var i=0;i<=c;i++){
		//var orgname = document.getElementById("orgname"+i);
		var orgAddress = document.getElementById("orgAddress"+i);
		var way = document.getElementById("way"+i);
		var hc = document.getElementById("hcharge"+i);
		var ec = document.getElementById("echarge"+i);
		var pname = document.getElementById("pname"+i);
		var zip = document.getElementById("zip"+i);
		var country_other = document.getElementById("country_other"+i);
		var country = document.getElementById("country"+i);
		var school_other = document.getElementById("school_other"+i);
		var orgcityaddress = document.getElementById("orgcityaddress"+i);
		var orgcitytelephone = document.getElementById("orgcitytelephone"+i);

		//添加到session用于firefox start 2009-6-9	
		/*
		colList2[0]="pname"+i;
		colList2[1]="orgname"+i;
		colList2[2]="orgAddress"+i;
		colList2[3]="way"+i;
		colList2[4]="fileNo"+i;
		colList2[5]="remark"+i;
		colList2[6]="hcharge"+i;
		colList2[7]="echarge"+i;
		colList2[8]="country"+i;
		colList2[9]="school"+i;
		colList2[10]="zip"+i;
		colList2[11]="country_other"+i;
		colList2[12]="citys_exams"+i;

		//alert(way.value);
		
		for (var j = 0 ; j <colList2.length ; j++ )
		{
			if( document.getElementById(colList2[j]) != null  ) 
			{
				urll = urll + colList2[j]+"="+ document.getElementById(colList2[j]).value+"&"
			}

		}
		*/

		if(way){
			if(way.value==''){ 
				alert('请选择寄送方式。');
				way.focus();
				return false;
			}

			var country = document.getElementById("country"+i);
			if(country && document.getElementById("country_exams"+i).style.display!='none'){
				if(country.value=='0'){ alert('Please select Country!');country.focus();return false;}
			}
			if(document.getElementById("school_other_tr"+i).style.display!='none'){
				var country = document.getElementById("school_other"+i);
				if(country.value==''){ alert('Country must be filled in!');country.focus();return false;}
			}
			/*
			var school = document.getElementById("school"+i);
			if(school){
				if(school.value=='0' ){ alert('请选择院校名称。');school.focus();return false;}
			}
			*/
			
			if(way.value=='1'){

				
				var school = document.getElementById("school"+i);
				if(school && document.getElementById("school_exams"+i).style.display!='none'){
					if(school.value=='0'){ alert('Please select Organization!');school.focus();return false;}
				}
			}
			
			if(way.value=='2'){
				

				//other
				if(document.getElementById("country_exams"+i).style.display!='none' && country.value=='27'){
					if(country_other){
						if(country_other.value==''){
							alert('Country name must be filled in!');country_other.focus();return false;
						}
					}
				}
				if(pname){
					try{
						if(pname.value=='' && pname.readOnly!=true){ alert('Name of Person/Department must be filled in!');pname.focus();return false;}
					}catch(ess){}
				}
				if(zip && document.getElementById("trzip"+i).style.display==''){
					try{
						if(zip.value=='' && zip.readOnly!=true){ alert('Postcodes must be filled in!');zip.focus();return false;}
					}catch(ess){}
				}
			}
			if(way.value=='3' ){
				//other
				if(document.getElementById("country_exams"+i).style.display!='none' && country.value=='27'){
					if(country_other){
						if(country_other.value==''){
							alert('Country name must be filled in!');country_other.focus();return false;
						}
					}
				}
                                
				var citys_exams = document.getElementById("citys_exams"+i);
				if(citys_exams  && document.getElementById("citys_exams_tr"+i).style.display==''){
					if(citys_exams.value=='0'){ alert('Please select City');citys_exams.focus();return false;}
				}
				if(document.getElementById("trorgcityaddress"+i).style.display=='' && orgcityaddress.value==''){
					alert('City of Receiving Organization must be filled in!');orgcityaddress.focus();return false;	
				}
				if(orgcitytelephone.value==''){
					alert('Telephone number of Receiving Organization must be filled in!');orgcitytelephone.focus();return false;	
				}
			}
			if(way.value=='4' ){
				//other
				if(document.getElementById("country_exams"+i).style.display!='none' && country.value=='27'){
					if(country_other){
						if(country_other.value==''){
							alert('Country name must be filled in!');country_other.focus();return false;
						}
					}
				}
				var citys_exams = document.getElementById("citys_exams"+i);
				if(citys_exams && document.getElementById("citys_exams_tr"+i).style.display==''){
					if(citys_exams.value=='0'){ alert('Please select City');citys_exams.focus();return false;}
				}
			}
		}

		//if(document.getElementById("orgname"+i+"_dis").style.display==''){
			//try{
			//if(orgname.value=='' && orgname.readOnly!=true){ alert('Name of receiving organization must be filled in!');orgname.focus();return false;}
			//}catch(ess){}
		//}
		if(orgAddress){
			try{
				if(orgAddress.value=='' && orgAddress.readOnly!=true){alert('Address of receiving organization must be filled in!');orgAddress.focus();return false;}
			}catch(ess){}
		}
		
		if(hc){
			if(hc.value==''){ alert('Extra TRF fee must be filled in!');hc.focus();return false;}
		}
		if(ec && document.getElementById("trecharge"+i).style.display==''){
			if(ec.value==''){ alert('Express Service Fee must be filled in!');ec.focus();return false;}
		}

		//if(school_other && school_other.value=='如果您申请的院校或机构不在选择列表中，请填写此项。'){
 			//school_other.value='';
 		//}
	}
/*	
	if(frm.money.value==''){
		alert('应付款项为必填项。');
		frm.money.focus();
		return false;
	}
	
	if(frm.EMSMoney.value==''){
		alert('请选择应付款项。');
		frm.pay.focus();
		return false;
	}
*/

	if(frm.payway.value==0){
		alert('Please select payment method!');
		frm.payway.focus();
		return false;
	}

    if(frm.payway.value==1){
	  if(frm.receipt.value==''){
		alert('Please fill in the receipt number!');
		frm.receipt.focus();
		return false;
	  }
	  if(frm.receipt.value!=''){
		if(frm.receipt.value.length!=7||(!BASEisNotNum(frm.receipt.value))){
		  alert('The receipt number must be 7 numbers!');
		  frm.receipt.focus();
		  return false;
		}
	  }
	  
	}
	if(frm.payway.value==2){
	  if(frm.moneyOrder.value==''){
		alert('Please fill in the remittance number!');
		frm.moneyOrder.focus();
		return false;
	  }
	  if(frm.moneyOrder.value!=''){
		if(frm.moneyOrder.value.length!=14||(!BASEisNotNum(frm.moneyOrder.value))){
		  alert('The remittance number must be 14 numbers!');
		  frm.moneyOrder.focus();
		  return false;
		}
	  }
	}

	if(frm.verify.checked==false){
		alert('Please checked certify button!。');
		frm.verify.focus();
		return false;
	}

	//2009-6-9
	//alert(urll);
	//startRequest(urll);
	//alert(document.getElementById('way0').value);
	frm.submit();

}
catch (e )
{
	alert(e.message);
}

}

function BASEisNotNum(theNum){
//判断是否为数字
for(var i=0;i<theNum.length;i++){
oneNum=theNum.substring(i,i+1);
if (oneNum<"0" || oneNum>"9")
  return false;
}
  return true;
  
}

function fucCheckLength(strTemp){
 var i,sum;
 sum=0;
 for(i=0;i<strTemp.length;i++)
 {
  if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255))
   sum=sum+1;
  else
   sum=sum+2;
 }
 return sum;
}
function fucPWDchk(str){
  var strSource ="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var ch;
  var i;
  var temp;
  
  for (i=0;i<=(str.length-1);i++)
  {
  
    ch = str.charAt(i);
    temp = strSource.indexOf(ch);
    if (temp==-1) 
    {
     return 0;
    }
  }
  if (strSource.indexOf(ch)==-1)
  {
    return 0;
  }
  else
  {
    return 1;
  } 
}

function isTrueName(s){
var patrn=/^[a-zA-Z]+$/;
if (!patrn.test(s)) return false;
return true;
}
