// JavaScript Document
	/*复选框函数：aboxname---一组复选框的名字
				aquestiontitle---该组复选框的问题名字
				aterm---假如选中复选框的某一项，该项对应的文本域变成必填，格式：该复选框的值-对应的文本域id|该复选框的值-对应的文本域id,
						多个用|分开。
				anumber---该组复选框必选的数量
	*/
	function boxtextisempty(aboxname,aquestiontitle,anumber)
	{
		var strchoice="";
		var nowCtrl = document.getElementsByName(aboxname);
		for(var i=0;i<nowCtrl.length;i++) 
		{ 
			if (nowCtrl[i].checked) 
			{
				strchoice=strchoice+nowCtrl[i].value+","; 
			}
		}
		//截取最后的逗号 
		strchoice=strchoice.substring(0,strchoice.length-1);
		if(strchoice=="")
		{
			alert("Please choose "+aquestiontitle);
			nowCtrl[0].focus();
			return false;
		}
		
		countstrchoice = strchoice.split(",");
		if(anumber != 1 && countstrchoice.length < anumber)
		{
			alert("Please choose "+anumber+" or above items in "+aquestiontitle);
			nowCtrl[0].focus();
			return false;
		}
	}

// JavaScript Document
function checkboothapplication(obj_form)
{
	if(boxtextisempty("edtMul1[]","Please choose what you like to know","1")==false)
	{
		return false;
	}
	
	if(obj_form.edtMul3.checked == false && obj_form.edtMul4.checked == false) {
		alert("Please choose your enquiry!");
		obj_form.edtMul3.focus();
		return false;
	}
	
	if(obj_form.edtCompany.value == "") {
		alert("Please fill in Company!");
		obj_form.edtCompany.focus();
		return false;
	}	

	if(obj_form.edtAddress.value == "" && obj_form.edtAddress2.value == ""  && obj_form.edtAddress3.value == "") {
		alert("Please fill in Company Address!");
		obj_form.edtAddress.focus();
		return false;
	}
	
	var edtState = document.getElementById("State");
	if(edtState.value == "0") {
		alert("Please choose Country / Region !");
		edtState.focus();
		return false;
	}
	else if(edtState.value == "354")
	{
		//省份選擇
		var Province = document.getElementById("Province");
		if(Province.value == "") {
			alert("Please choose Province!");
			Province.focus();
			return false;
		}		
	}

	var edtPhone1 = document.getElementById("Phone1");
	if(edtPhone1.value == "") {
		alert("Please fill in country code!");
		edtPhone1.focus();
		return false;
	}
	
	if(obj_form.edtTel2.value == "") {
		alert("Please fill in area code!");
		obj_form.edtTel2.focus();
		return false;
	}
	
	if(obj_form.edtTel3.value == "") {
		alert("Please fill in number!");
		obj_form.edtTel3.focus();
		return false;
	}
	
	//var edtFax1 = document.getElementById("Fax1");
	if(obj_form.Fax1.value == "") {
		alert("Please fill in country code!");
		obj_form.Fax1.focus();
		return false;
	}
	
	if(obj_form.edtFax2.value == "") {
		alert("Please fill in area code!");
		obj_form.edtFax2.focus();
		return false;
	}
	
	if(obj_form.edtFax3.value == "") {
		alert("Please fill in number!");
		obj_form.edtFax3.focus();
		return false;
	}
	
	var reg =/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
	if(obj_form.edtEmail.value == "") {
		alert("Please fill in Email");
		obj_form.edtEmail.focus();
		return false;
	}
	else if (reg.test(obj_form.edtEmail.value)==false)
	{
		alert("Email is wrong!");
		obj_form.edtEmail.focus();
		return false;
	}
	
	if(obj_form.edtContactor.value == "") {
		alert("Please choose Contact Person!");
		obj_form.edtContactor.focus();
		return false;
	}
	
	if(obj_form.edtPosition.value == "0") {
		alert("Please choose Position!");
		obj_form.edtPosition.focus();
		return false;
	}
	
	if(obj_form.edtPosition.value == "14" && obj_form.edtPositionOther.value == "") {
		alert("Please fill in other position!");
		obj_form.edtPositionOther.focus();
		return false;
	}
	
	if(obj_form.edtDepartment.value == "0") {
		alert("Please fill in Department!");
		obj_form.edtDepartment.focus();
		return false;
	}
	
	if(obj_form.edtDepartment.value == "11" && obj_form.edtDepartmentOther.value == "") {
		alert("Please fill in other Department!");
		obj_form.edtDepartmentOther.focus();
		return false;
	}
	// 隐私条款
	if( document.getElementById('privacy_chk').checked == false){
		alert("You have not agreed to the Privacy Policy!");
		return false;
	}
	
	var A1 = document.getElementById("A1[]");
	var A2 = document.getElementById("A2[]");
	var A3 = document.getElementById("A3[]");
	var A4 = document.getElementById("A4[]");
	var A5 = document.getElementById("A5[]");
	var A6 = document.getElementById("A6[]");
	var A7 = document.getElementById("A7[]");
	var A8 = document.getElementById("A8[]");
	var A9 = document.getElementById("A9[]");
	var A10 = document.getElementById("A10[]");
	var A11 = document.getElementById("A11[]");
	var A12 = document.getElementById("A12[]");
	var A13 = document.getElementById("A13[]");
	var A14 = document.getElementById("A14[]");
	var A15 = document.getElementById("A15[]");
	var A16 = document.getElementById("A16[]");
	if(A1.checked == false && A2.checked == false && A3.checked == false && A4.checked == false && A5.checked == false && A6.checked == false && A7.checked == false && A8.checked == false && A9.checked == false && A10.checked == false && A11.checked == false && A12.checked == false && A13.checked == false && A14.checked == false && A15.checked == false && A16.checked == false) {
		alert("Please select your company product type!");
		A1.focus();
		return false;
	}
	//目標客戶
	var nowCtrl = document.getElementsByName('TargetClient[]');
	var targetOther = document.getElementById('TargetClientOther');
	var aClick = false;
	for(i=0;i<nowCtrl.length;i++)
	{							
		if(nowCtrl[i].checked) 
		{
			aClick = true;
			if(nowCtrl[i].value==5 && targetOther.value=="")
			{
				alert("請輸入其他項");
				targetOther.focus();
				return false;
			}
			break;
		}
	}
	if(aClick==false)
	{
		alert("請選擇目標客戶");
		return false;
	}

	return true;
}
