var domList = new Array(".com",".org",".gov",".net",".mil",".edu",".cc",".biz",".sh",".zj",".js",".sd",".gd",".fj",".it",".gs",".yzjs",".hn",".co",".ln",".xj",".ne",".sn",".xa",".sx",".or",".he",".be",".cn",".ha",".de",".ah",".icn",".jx");

function submit_form(theForm)
{
	theForm.action = theForm.action + "?username=" + theForm.uName.value;
	theForm.submit();
}

function reset_form(theForm)
{
	theForm.reset();
}

function afterlogin(theForm)
{
	theForm.action = theForm.action + "?username=" + theForm.uName.value;
	return true;
}

function check_pwd(theForm)
{
	if (theForm.OlduPwd.value == "")
  	{
    		alert("請輸入 \"舊密碼\".");
    		theForm.OlduPwd.focus();
    		return (false);
  	}
  		
	if (theForm.uPwd.value == "")
  	{
    		alert("請輸入 \"新密碼\".");
    		theForm.uPwd.focus();
    		return (false);
  	}
	else
	{
		if (checkMinLen(theForm.uPwd, '新密碼', 6) == false)
	    		return (false);
	}

	if (theForm.uConfirm.value == "")
  	{
    		alert("請輸入 \"密碼確認\".");
    		theForm.uConfirm.focus();
    		return (false);
  	}
	else
	{
		if (checkPwd(theForm.uConfirm,theForm.uPwd, '密碼確認', '新密碼') == false)
	    		return (false);
	}
}

function validate_userinfo(theForm,atWhere)
{
	// check choices
	if (atWhere == 0)
	{
		theForm.prod_list.value = "";
		
		// compose the product list for saving
		for (j=0; j < theForm.myptype.length; j++)
		{
			if (theForm.myptype.options[j].selected)
			{
	  			if (theForm.prod_list.value != "")
	  				theForm.prod_list.value += ",";
	
				theForm.prod_list.value += theForm.myptype.options[j].value;  						
			}
		}
		
		ChkChoice = 0;
	  	for (i=1; i <= 3; i++)
	  	{
	  		tmpV = "theForm.ch"+i+".checked";
	  		if (eval(tmpV))
				ChkChoice = 1;
		}
	  	
	  	if (ChkChoice == 0)
	  	{
		    	alert("請註明\"欲查詢事項\".");
		    	theForm.ch1.focus();
		    	return (false);  		
		}
	}
		
	// check aes enquiry
	if (atWhere == 1)
	{
		theForm.prod_list.value = "";
				
	  	// compose the product list for saving
		for (j=0; j < theForm.myptype.length; j++)
		{
			if (theForm.myptype.options[j].selected)
			{
	  			if (theForm.prod_list.value != "")
	  				theForm.prod_list.value += ",";
	
				theForm.prod_list.value += theForm.myptype.options[j].value;  						
			}
		}
				
		theForm.show_list.value = "";
	
		ChkExh1 = 0;
	  	for (i=1; i <= 2; i++)
	  	{
	  		tmpV = "theForm.exhc"+i+".checked";
	  		if (eval(tmpV))
				ChkExh1 = 1;
		}
	  	
	  	if (ChkExh1 == 0)
	  	{
		    	alert("請註明\"興趣\".");
		    	theForm.exhc1.focus();
		    	return (false);  		
		}
	}

	// check aes enquiry event
	if (atWhere == 7)
	{
		theForm.prod_list.value = "";
				
	  	// compose the product list for saving
		for (j=0; j < theForm.myptype.length; j++)
		{
			if (theForm.myptype.options[j].selected)
			{
	  			if (theForm.prod_list.value != "")
	  				theForm.prod_list.value += ",";
	
				theForm.prod_list.value += theForm.myptype.options[j].value;  						
			}
		}
	}
	
	// check aes enquiry
	if (atWhere == 6)
	{
		theForm.prod_list.value = "";
				
	  	// compose the product list for saving
		for (j=0; j < theForm.myptype.length; j++)
		{
			if (theForm.myptype.options[j].selected)
			{
	  			if (theForm.prod_list.value != "")
	  				theForm.prod_list.value += ",";
	
				theForm.prod_list.value += theForm.myptype.options[j].value;  						
			}
		}
				
		ChkExh1 = 0;
	  	for (i=1; i <= 2; i++)
	  	{
	  		tmpV = "theForm.exhc"+i+".checked";
	  		if (eval(tmpV))
				ChkExh1 = 1;
		}
	  	
	  	if (ChkExh1 == 0)
	  	{
		    	alert("請註明\"興趣\".");
		    	theForm.exhc1.focus();
		    	return (false);  		
		}
		else
		{
			if (theForm.exhc1.checked)
			{
				ChkExh1a = 0;
			  	for (i=1; i <= 3; i++)
			  	{
			  		tmpV = "theForm.exhc1"+i+".checked";
			  		if (eval(tmpV))
						ChkExh1a = 1;
				}
			  	
			  	if (ChkExh1a == 0)
			  	{
				    	alert("請註明\"展覽會\".");
				    	theForm.exhc11.focus();
				    	return (false);  		
				}
			}
			
			if (theForm.exhc2.checked)
			{
				ChkExh1b = 0;
			  	for (i=1; i <= 3; i++)
			  	{
			  		tmpV = "theForm.exhc2"+i+".checked";
			  		if (eval(tmpV))
						ChkExh1b = 1;
				}
			  	
			  	if (ChkExh1b == 0)
			  	{
				    	alert("請註明\"展覽會\".");
				    	theForm.exhc21.focus();
				    	return (false);  		
				}
			}			
		}
	}
	
	// check pub enquiry
	if (atWhere == 2)
	{
		ChkPub1 = 0;
	  	for (i=1; i <= 5; i++)
	  	{
	  		tmpV = "theForm.pubi"+i+".checked";
	  		if (eval(tmpV))
				ChkPub1 = 1;
		}
	  	
	  	if (ChkPub1 == 0)
	  	{
		    	alert("請註明\"您感興趣的工業資訊\".");
		    	theForm.pubi1.focus();
		    	return (false);  		
		}
	
		ChkPub2 = 0;
	  	for (i=1; i <= 4; i++)
	  	{
	  		tmpV = "theForm.pubc"+i+".checked";
	  		if (eval(tmpV))
				ChkPub2 = 1;
		}
	  	
	  	if (ChkPub2 == 0)
	  	{
		    	alert("請註明\"興趣\".");
		    	theForm.pubc1.focus();
		    	return (false);  		
		}	
	}

	// check pub magazine enquiry
	if (atWhere == 3 || atWhere == 4)
	{
		ChkCh1 = 0;
		for (i=0; i < theForm.mylnofbiz.length; i++)
		{
			if (theForm.mylnofbiz.options[i].selected)
			{
				ChkCh1 = 1;					
			}
		}
	  	
	  	if (ChkCh1 == 0)
	  	{
		    	alert("請註明\"經營範圍\".");
		    	theForm.mylnofbiz.focus();
		    	return (false);  		
		}
	  	else
	  	{
	  		theForm.lnofbiz_list.value = "";
	  		
			for (j=0; j < theForm.mylnofbiz.length; j++)
			{
				if (theForm.mylnofbiz.options[j].selected)
				{
		  			if (theForm.lnofbiz_list.value != "")
		  				theForm.lnofbiz_list.value += ",";
		
					theForm.lnofbiz_list.value += theForm.mylnofbiz.options[j].value;  						
				}
			}  	
	  	}

	  	theForm.purchase_list.value = "";
	  		
		for (j=0; j < theForm.mypurchase.length; j++)
		{
			if (theForm.mypurchase.options[j].selected)
			{
		  		if (theForm.purchase_list.value != "")
		  			theForm.purchase_list.value += ",";
		
				theForm.purchase_list.value += theForm.mypurchase.options[j].value;  						
			}
		}

		if (atWhere == 3)
		{	  		  				
			ChkPub2 = 0;
		  	for (i=1; i <= 4; i++)
		  	{
		  		tmpV = "theForm.pubc"+i+".checked";
		  		if (eval(tmpV))
					ChkPub2 = 1;
			}
		  	
		  	if (ChkPub2 == 0)
		  	{
			    	alert("請註明\"興趣\".");
			    	theForm.pubc1.focus();
			    	return (false);  		
			}
		}	
	}

	if (atWhere == 5)
	{
		theForm.prod_list.value = "";
				
	  	// compose the product list for saving
		for (j=0; j < theForm.myptype.length; j++)
		{
			if (theForm.myptype.options[j].selected)
			{
	  			if (theForm.prod_list.value != "")
	  				theForm.prod_list.value += ",";
	
				theForm.prod_list.value += theForm.myptype.options[j].value;  						
			}
		}
				
		ChkWeb1 = 0;
	  	for (i=1; i <= 2; i++)
	  	{
	  		tmpV = "theForm.webc"+i+".checked";
	  		if (eval(tmpV))
				ChkWeb1 = 1;
		}
	  	
	  	if (ChkWeb1 == 0)
	  	{
		    	alert("請註明\"您欲接收的資料\".");
		    	theForm.webc1.focus();
		    	return (false);  		
		}		
	}
		
	// company information
	if (theForm.mLName.value == "")
  	{
    		alert("請輸入 \"姓氏\".");
    		theForm.mLName.focus();
    		return (false);
  	}
	else
	{
		if (checkNameN(theForm.mLName, '姓氏', 1) == false)
	    		return (false);
	}  	

	if (theForm.mFName.value == "")
  	{
    		alert("請輸入 \"姓名\".");
    		theForm.mFName.focus();
    		return (false);
  	}
	else
	{
		if (checkNameN(theForm.mFName, '姓名', 1) == false)
	    		return (false);
	} 

	if (atWhere == 5)
	{
		if (theForm.Gender_id.options[theForm.Gender_id.selectedIndex].value == "")	
	  	{
	    		alert("請輸入 \"稱謂\".");
	    		theForm.Gender_id.focus();
	    		return (false);
	  	}
  	}		
  	
	if (theForm.mEmail.value == "")
  	{
    		alert("請輸入 \"電郵地址\".");
    		theForm.mEmail.focus();
    		return (false);
  	}
	else
	{
		if(!Validate_Email(theForm.mEmail))
		{
			alert('請輸入有效的\"電郵地址\".');
			theForm.mEmail.focus();
			return(false);
		}
	}
  			
	if (theForm.mCname.value == "")
  	{
    		alert("請輸入 \"單位名稱\".");
    		theForm.mCname.focus();
    		return (false);
  	}

	if (theForm.mCadd1.value == "")
  	{
    		alert("請輸入 \"單位地址\".");
    		theForm.mCadd1.focus();
    		return (false);
  	}
  	else if (checkaddr(theForm.mCadd1) == false)
  	{
  		return false;
  	}

	if (theForm.Country_id.options[theForm.Country_id.selectedIndex].value == "")	
  	{
    		alert("請輸入 \"國家\".");
    		theForm.Country_id.focus();
    		return (false);
  	}
  	else if (theForm.Country_id.selectedIndex == 44)	
  	{
  		if (theForm.Province_id.options[theForm.Province_id.selectedIndex].value == 0)
  		{
	    		alert("請輸入 \"省份\".");
	    		theForm.Province_id.focus();
	    		return (false);
  		} 
  		
		if (theForm.mCpostal.value == "")
	  	{
	    		alert("請輸入 \"郵編\".");
	    		theForm.mCpostal.focus();
	    		return (false);
	  	}  		
	}
  	else if (theForm.Country_id.selectedIndex == 223)	
  	{
		if (theForm.mCpostal.value == "")
	  	{
	    		alert("請輸入 \"郵編\".");
	    		theForm.mCpostal.focus();
	    		return (false);
	  	}  		
	}

	// telephone number
	if (theForm.Country_id.selectedIndex != 96)
	{	
		if (theForm.mTelAC.value == "")
	  	{
	    		alert("請輸入 \"地區編碼\".");
	    		theForm.mTelAC.focus();
	    		return (false);
	  	}
	  	else
	  	{
			if (!isNum(theForm.mTelAC)) {
	          		alertBox("請用(0-9) 的數字", theForm.mTelAC)
	          		return false;
	    		}  		
	  	}
	}
	
	if (theForm.mTel.value == "")
  	{
    		alert("請輸入 \"電話號碼\".");
    		theForm.mTel.focus();
    		return (false);
  	}
  	else
	{
		if (checkTel(theForm.mTel) == false)
	    		return (false);
	}  	  	

	if (theForm.Title_id.options[theForm.Title_id.selectedIndex].value == "")	
  	{
    		alert("請輸入 \"職銜/職位\".");
    		theForm.Title_id.focus();
    		return (false);
  	}
  	else if (theForm.Title_id.selectedIndex == (theForm.Title_id.length-1))
  	{
  		// select others, but didn't fill in the text box
  		if (theForm.Title_other.value == "")
  		{
	    		alert("請註明您的 \"職銜/職位\".");
	    		theForm.Title_other.focus();
	    		return (false);
  		}
  	}

	if (theForm.department.options[theForm.department.selectedIndex].value == "")	
  	{
    		alert("請輸入 \"部門\".");
    		theForm.department.focus();
    		return (false);
  	}
  	else if (theForm.department.selectedIndex == (theForm.department.length-1))
  	{
  		// select others, but didn't fill in the text box
  		if (theForm.Dept_other.value == "")
  		{
	    		alert("請註明您的 \"部門\".");
	    		theForm.Dept_other.focus();
	    		return (false);
  		}
  	}
  	  	  	
	if (theForm.bizNature.options[theForm.bizNature.selectedIndex].value == "")	
  	{
    		alert("請輸入 \"業務性質\".");
    		theForm.bizNature.focus();
    		return (false);
  	}
  	else if (theForm.bizNature.selectedIndex == (theForm.bizNature.length-1))
  	{
  		// select others, but didn't fill in the text box
  		if (theForm.bizNature_other.value == "")
  		{
	    		alert("請輸入 \"業務性質\".");
	    		theForm.bizNature_other.focus();
	    		return (false);
  		}
  	}

	if (theForm.Ownership.options[theForm.Ownership.selectedIndex].value == "")	
  	{
    		alert("請輸入 \"所有制性質\".");
    		theForm.Ownership.focus();
    		return (false);
  	}
  	else if (theForm.Ownership.selectedIndex == (theForm.Ownership.length-1))
  	{
  		// select others, but didn't fill in the text box
  		if (theForm.Owner_other.value == "")
  		{
	    		alert("請輸入 \"所有制性質\".");
	    		theForm.Owner_other.focus();
	    		return (false);
  		}
  	}

	if (theForm.noemp.options[theForm.noemp.selectedIndex].value == "")	
  	{
    		alert("請輸入 \"單位僱員總人數\".");
    		theForm.noemp.focus();
    		return (false);
  	}
		
	return (true);
}

function validate_form2info(theForm)
{
	if (theForm.ch1.value == "1")
	{
		theForm.show_list.value = "";
	
		ChkExh1 = 0;
	  	for (i=1; i <= 2; i++)
	  	{
	  		tmpV = "theForm.exhc"+i+".checked";
	  		if (eval(tmpV))
				ChkExh1 = 1;
		}
	  	
	  	if (ChkExh1 == 0)
	  	{
		    	alert("請註明\"興趣\".");
		    	theForm.exhc1.focus();
		    	return (false);  		
		}
	
		ChkExh2 = 0;
		for (i=0; i < theForm.myshow.length; i++)
		{
			if (theForm.myshow.options[i].selected)
			{
				ChkExh2 = 1;					
			}
		}
	  	
	  	if (ChkExh2 == 0)
	  	{
		    	alert("請註明\"您感興趣的展覽會\".");
		    	theForm.myshow.focus();
		    	return (false);  		
		}
	  	else
	  	{
			for (j=0; j < theForm.myshow.length; j++)
			{
				if (theForm.myshow.options[j].selected)
				{
		  			if (theForm.show_list.value != "")
		  				theForm.show_list.value += ",";
		
					theForm.show_list.value += theForm.myshow.options[j].value;  						
				}
			}  	
	  	}
	}

	if (theForm.ch2.value == "1")
	{
		ChkPub1 = 0;
	  	for (i=1; i <= 5; i++)
	  	{
	  		tmpV = "theForm.pubi"+i+".checked";
	  		if (eval(tmpV))
				ChkPub1 = 1;
		}
	  	
	  	if (ChkPub1 == 0)
	  	{
		    	alert("請註明\"您感興趣的工業資訊\".");
		    	theForm.pubi1.focus();
		    	return (false);  		
		}
	
		ChkPub2 = 0;
	  	for (i=1; i <= 3; i++)
	  	{
	  		tmpV = "theForm.pubc"+i+".checked";
	  		if (eval(tmpV))
				ChkPub2 = 1;
		}
	  	
	  	if (ChkPub2 == 0)
	  	{
		    	alert("請註明\"興趣\".");
		    	theForm.pubc1.focus();
		    	return (false);  		
		}
	}

	if (theForm.ch3.value == "1")
	{
		ChkWeb1 = 0;
	  	for (i=1; i <= 2; i++)
	  	{
	  		tmpV = "theForm.webc"+i+".checked";
	  		if (eval(tmpV))
				ChkWeb1 = 1;
		}
	  	
	  	if (ChkWeb1 == 0)
	  	{
		    	alert("請註明\"您欲接收的資料\".");
		    	theForm.webc1.focus();
		    	return (false);  		
		}
	}
			
	return (true);
}

function validate_referral(theForm)
{
	if (theForm.rfLName.value == "")
  	{
    		alert("請輸入 \"姓氏\".");
    		theForm.rfLName.focus();
    		return (false);
  	}
	else
	{
		if (checkNameN(theForm.rfLName, '姓氏', 1) == false)
	    		return (false);
	}  	

	if (theForm.rfFName.value == "")
  	{
    		alert("請輸入 \"姓名\".");
    		theForm.rfFName.focus();
    		return (false);
  	}
	else
	{
		if (checkNameN(theForm.rfFName, '姓名', 1) == false)
	    		return (false);
	} 

	if (theForm.rfGender_id.options[theForm.rfGender_id.selectedIndex].value == "")	
  	{
    		alert("請輸入 \"稱謂\".");
    		theForm.rfGender_id.focus();
    		return (false);
  	}
  			
	if (theForm.rfCname.value == "")
  	{
    		alert("請輸入 \"單位名稱\".");
    		theForm.rfCname.focus();
    		return (false);
  	}

	ChkR = 0;
	for (i=1; i <= 5; i++)
	{
		tmpV = "theForm.pubbk"+i+".checked";
		if (eval(tmpV))
			ChkR = 1;
	}
	  	
	if (ChkR == 0)
	{
	    	alert("請註明\"您欲推薦的雜誌\".");
	    	theForm.pubbk1.focus();
	    	return (false);  		
	}
  	else
  	{
  		theForm.refer_list.value = "";
  		
		for (i=1; i <= 5; i++)
		{
			tmpV = "theForm.pubbk"+i+".checked";
			if (eval(tmpV))
			{
	  			if (theForm.refer_list.value != "")
	  				theForm.refer_list.value += ",";
	
				theForm.refer_list.value += i; 				
			}
		}
  	}
	  	
	return (true);
}

function validate_search(theForm)
{
	FormInput = 0
	if (theForm.myIndustry_id.options[theForm.myIndustry_id.selectedIndex].value != "")	
		FormInput = 1;
	if (theForm.myCountry_id.options[theForm.myCountry_id.selectedIndex].value != "")	
		FormInput = 1;
	if (theForm.smonth.options[theForm.smonth.selectedIndex].value != "")	
		FormInput = 1;
	if (theForm.syear.options[theForm.syear.selectedIndex].value != "")	
		FormInput = 1;
	if (theForm.emonth.options[theForm.emonth.selectedIndex].value != "")	
		FormInput = 1;
	if (theForm.eyear.options[theForm.eyear.selectedIndex].value != "")	
		FormInput = 1;
		
	if (FormInput == 0)
	{
		    alert("請選擇搜索條件.");
		    theForm.myIndustry_id.focus();
		    return (false);		
	}
	else		
		return (true);
}

function validate_press(theForm)
{
	// company information
	if (theForm.mLName.value == "")
  	{
    		alert("請輸入 \"姓氏\".");
    		theForm.mLName.focus();
    		return (false);
  	}
	else
	{
		if (checkNameN(theForm.mLName, '姓氏', 1) == false)
	    		return (false);
	}  	

	if (theForm.mFName.value == "")
  	{
    		alert("請輸入 \"姓名\".");
    		theForm.mFName.focus();
    		return (false);
  	}
	else
	{
		if (checkNameN(theForm.mFName, '姓名', 1) == false)
	    		return (false);
	} 
	
	if (theForm.mEmail.value == "")
  	{
    		alert("請輸入 \"電郵地址\".");
    		theForm.mEmail.focus();
    		return (false);
  	}
	else
	{
		if(!Validate_Email(theForm.mEmail))
		{
			alert('請輸入有效的\"電郵地址\".');
			theForm.mEmail.focus();
			return(false);
		}
	}
  			
	if (theForm.mCname.value == "")
  	{
    		alert("請輸入 \"媒體名稱\".");
    		theForm.mCname.focus();
    		return (false);
  	}

	if (theForm.mCadd1.value == "")
  	{
    		alert("請輸入 \"地址\".");
    		theForm.mCadd1.focus();
    		return (false);
  	}
  	else if (checkaddr(theForm.mCadd1) == false)
  	{
  		return false;
  	}

	if (theForm.Country_id.options[theForm.Country_id.selectedIndex].value == "")	
  	{
    		alert("請輸入 \"國家\".");
    		theForm.Country_id.focus();
    		return (false);
  	}
  	else if (theForm.Country_id.selectedIndex == 44)	
  	{
  		if (theForm.Province_id.options[theForm.Province_id.selectedIndex].value == 0)
  		{
	    		alert("請輸入 \"省份\".");
	    		theForm.Province_id.focus();
	    		return (false);
  		} 
  		
		if (theForm.mCpostal.value == "")
	  	{
	    		alert("請輸入 \"郵編\".");
	    		theForm.mCpostal.focus();
	    		return (false);
	  	}  		
	}
  	else if (theForm.Country_id.selectedIndex == 223)	
  	{
		if (theForm.mCpostal.value == "")
	  	{
	    		alert("請輸入 \"郵編\".");
	    		theForm.mCpostal.focus();
	    		return (false);
	  	}  		
	}

	// telephone number
	if (theForm.mTelAC.value == "")
  	{
    		alert("請輸入 \"地區編碼\".");
    		theForm.mTelAC.focus();
    		return (false);
  	}
  	else
  	{
		if (!isNum(theForm.mTelAC)) {
          		alertBox("請用(0-9) 的數字", theForm.mTelAC)
          		return false;
    		}  		
  	}

	if (theForm.mTel.value == "")
  	{
    		alert("請輸入 \"電話號碼\".");
    		theForm.mTel.focus();
    		return (false);
  	}
  	else
	{
		if (checkTel(theForm.mTel) == false)
	    		return (false);
	}  

	ChkChoice = 0;
  	for (i=1; i <= 8; i++)
  	{
  		tmpV = "theForm.m"+i+".checked";
  		if (eval(tmpV))
			ChkChoice = 1;
	}
  	
  	if (ChkChoice == 0)
  	{
	    	alert("請註明 \"媒體類別\".");
	    	theForm.m1.focus();
	    	return (false);  		
	}

	ChkChoice2 = 0;
  	for (i=1; i <= 3; i++)
  	{
  		tmpV = "theForm.lm"+i+".checked";
  		if (eval(tmpV))
			ChkChoice2 = 1;
	}
  	
  	if (ChkChoice2 == 0)
  	{
	    	alert("請註明 \"媒體語言\".");
	    	theForm.lm1.focus();
	    	return (false);  		
	}

	ChkChoice3 = 0;
  	for (i=1; i <= 3; i++)
  	{
  		tmpV = "theForm.exhc"+i+".checked";
  		if (eval(tmpV))
			ChkChoice3 = 1;
	}
  	
  	if (ChkChoice3 == 0)
  	{
	    	alert("請註明 \"您的興趣\".");
	    	theForm.exhc1.focus();
	    	return (false);  		
	}
			
	return (true);
}

function validate_prereg(theForm)
{
	// company information
	if (theForm.mCname.value == "")
  	{
    		alert("請輸入 \"公司名稱\".");
    		theForm.mCname.focus();
    		return (false);
  	}
  		
	if (theForm.mContact.value == "")
  	{
    		alert("請輸入 \"買家姓名\".");
    		theForm.mContact.focus();
    		return (false);
  	}

	if (theForm.mTitle.value == "")
  	{
    		alert("請輸入 \"職位\".");
    		theForm.mTitle.focus();
    		return (false);
  	}

	if (theForm.department.options[theForm.department.selectedIndex].value == "")	
  	{
    		alert("請輸入 \"職位範圍\".");
    		theForm.department.focus();
    		return (false);
  	}
  	else if (theForm.department.selectedIndex == (theForm.department.length-1))
  	{
  		// select others, but didn't fill in the text box
  		if (theForm.Dept_other.value == "")
  		{
	    		alert("請註明您的 \"職位範圍\".");
	    		theForm.Dept_other.focus();
	    		return (false);
  		}
  	}
  	
	// telephone number
	if (theForm.mTelAC.value == "")
  	{
    		alert("請輸入 \"地區編碼\".");
    		theForm.mTelAC.focus();
    		return (false);
  	}
  	else
  	{
		if (!isNum(theForm.mTelAC)) {
          		alertBox("請用(0-9) 的數字", theForm.mTelAC)
          		return false;
    		}  		
  	}

	if (theForm.mTel.value == "")
  	{
    		alert("請輸入 \"電話號碼\".");
    		theForm.mTel.focus();
    		return (false);
  	}
  	else
	{
		if (checkTel(theForm.mTel) == false)
	    		return (false);
	} 

	// fax number
	if (theForm.mFaxAC.value == "")
  	{
    		alert("請輸入 \"地區編碼\".");
    		theForm.mFaxAC.focus();
    		return (false);
  	}
  	else
  	{
		if (!isNum(theForm.mFaxAC)) {
          		alertBox("請用(0-9) 的數字", theForm.mFaxAC)
          		return false;
    		}  		
  	}

	if (theForm.mFax.value == "")
  	{
    		alert("請輸入 \"電話號碼\".");
    		theForm.mFax.focus();
    		return (false);
  	}
  	else
	{
		if (checkTel(theForm.mFax) == false)
	    		return (false);
	} 

	if (theForm.mEmail.value == "")
  	{
    		alert("請輸入 \"電郵\".");
    		theForm.mEmail.focus();
    		return (false);
  	}
	else
	{
		ChkEmail1 = 0;
		ChkEmail2 = 0;
		for (j=0; j < theForm.mEmail.value.length; j++)
		{
			if (theForm.mEmail.value.charAt(j) == "@")
				ChkEmail1 = 1;
			if (theForm.mEmail.value.charAt(j) == ".")
				ChkEmail2 = 1;				
		}
		
	  	if (ChkEmail1 == 0 || ChkEmail2 == 0)
	  	{
		    	alert("不是有效的電郵地址.");
		    	theForm.mEmail.focus();
		    	return (false);  		
		}  			
	}
	
	if (theForm.mCadd1.value == "")
  	{
    		alert("請輸入 \"地址\".");
    		theForm.mCadd1.focus();
    		return (false);
  	}
  	else if (checkaddr(theForm.mCadd1) == false)
  	{
  		return false;
  	}

	if (theForm.Country_id.options[theForm.Country_id.selectedIndex].value == "")	
  	{
    		alert("請輸入 \"國家\".");
    		theForm.Country_id.focus();
    		return (false);
  	}
  	
	if (theForm.mScope.value == "")
  	{
    		alert("請輸入 \"產品範圍\".");
    		theForm.mScope.focus();
    		return (false);
  	}	  	
  	
	ChkChoice = 0;
  	for (i=1; i <= theForm.bn_no.value; i++)
  	{
  		tmpV = "theForm.b"+i+".checked";
  		if (eval(tmpV))
			ChkChoice = 1;
	}
  	
  	if (ChkChoice == 0)
  	{
	    	alert("請註明 \"貴單位經營產品/服務\".");
	    	theForm.b1.focus();
	    	return (false);  		
	}
	else
	{
	  	tmpV = "theForm.b"+theForm.bn_no.value+".checked";
	  	if (eval(tmpV))
	  	{
	  		if (theForm.BOthers.value == "")
	  		{
		    		alert("請註明您的 \"貴單位經營產品/服務\".");
		    		theForm.BOthers.focus();
		    		return (false);  			
	  		}
	  	}
	  	
	  	theForm.bn_list.value = "";
	  	for (j=1; j <= theForm.bn_no.value; j++)
	  	{
	  		tmpV1 = "theForm.b"+j+".checked";
	  		if (eval(tmpV1))
	  		{
	  			if (theForm.bn_list.value != "")
	  				theForm.bn_list.value += ",";
	  			
	  			tmpV2 = "theForm.b"+j+".value";
				theForm.bn_list.value += eval(tmpV2);  			
	  		}
		}		
	}

	if (theForm.Owner_id.options[theForm.Owner_id.selectedIndex].value == "")	
  	{
    		alert("請輸入 \"所有制性質\".");
    		theForm.Owner_id.focus();
    		return (false);
  	}
  	else if (theForm.Owner_id.selectedIndex == (theForm.Owner_id.length-1))
  	{
  		// select others, but didn't fill in the text box
  		if (theForm.Owner_other.value == "")
  		{
	    		alert("請註明您的 \"所有制性質\".");
	    		theForm.Owner_other.focus();
	    		return (false);
  		}
  	}
  		
	if (theForm.PreregBizNature.options[theForm.PreregBizNature.selectedIndex].value == "")	
  	{
    		alert("請輸入 \"業務性質\".");
    		theForm.PreregBizNature.focus();
    		return (false);
  	}
  	else if (theForm.PreregBizNature.selectedIndex == (theForm.PreregBizNature.length-1))
  	{
  		// select others, but didn't fill in the text box
  		if (theForm.bizNature_other.value == "")
  		{
	    		alert("請輸入 \"業務性質\".");
	    		theForm.bizNature_other.focus();
	    		return (false);
  		}
  	}

	  theForm.expList.value = "";
	  for (j=1; j <= theForm.exp_no.value; j++)
	  {
	  	tmpV1 = "theForm.expc"+j+".checked";
	  	if (eval(tmpV1))
	  	{
	  		if (theForm.expList.value != "")
	  			theForm.expList.value += ",";
	  		
	  		tmpV2 = "theForm.expc"+j+".value";
			theForm.expList.value += eval(tmpV2);  			
	  	}
	}
	  	
	return (true);	
}

function validate_survey(theForm)
{
	// company information
	if (theForm.mCname.value == "")
  	{
    		alert("請輸入 \"公司名稱\".");
    		theForm.mCname.focus();
    		return (false);
  	}
  		
	if (theForm.mContact.value == "")
  	{
    		alert("請輸入 \"買家姓名\".");
    		theForm.mContact.focus();
    		return (false);
  	}

	if (theForm.mTitle.value == "")
  	{
    		alert("請輸入 \"職位\".");
    		theForm.mTitle.focus();
    		return (false);
  	}

	if (theForm.department.options[theForm.department.selectedIndex].value == "")	
  	{
    		alert("請輸入 \"職位範圍\".");
    		theForm.department.focus();
    		return (false);
  	}
  	else if (theForm.department.selectedIndex == (theForm.department.length-1))
  	{
  		// select others, but didn't fill in the text box
  		if (theForm.Dept_other.value == "")
  		{
	    		alert("請註明您的 \"職位範圍\".");
	    		theForm.Dept_other.focus();
	    		return (false);
  		}
  	}
  	
	// telephone number
	if (theForm.mTelAC.value == "")
  	{
    		alert("請輸入 \"地區編碼\".");
    		theForm.mTelAC.focus();
    		return (false);
  	}
  	else
  	{
		if (!isNum(theForm.mTelAC)) {
          		alertBox("請用(0-9) 的數字", theForm.mTelAC)
          		return false;
    		}  		
  	}

	if (theForm.mTel.value == "")
  	{
    		alert("請輸入 \"電話號碼\".");
    		theForm.mTel.focus();
    		return (false);
  	}
  	else
	{
		if (checkTel(theForm.mTel) == false)
	    		return (false);
	} 

	// fax number
	if (theForm.mFaxAC.value == "")
  	{
    		alert("請輸入 \"地區編碼\".");
    		theForm.mFaxAC.focus();
    		return (false);
  	}
  	else
  	{
		if (!isNum(theForm.mFaxAC)) {
          		alertBox("請用(0-9) 的數字", theForm.mFaxAC)
          		return false;
    		}  		
  	}

	if (theForm.mFax.value == "")
  	{
    		alert("請輸入 \"電話號碼\".");
    		theForm.mFax.focus();
    		return (false);
  	}
  	else
	{
		if (checkTel(theForm.mFax) == false)
	    		return (false);
	} 

	if (theForm.mEmail.value == "")
  	{
    		alert("請輸入 \"電郵\".");
    		theForm.mEmail.focus();
    		return (false);
  	}
  		
	if (theForm.mCadd1.value == "")
  	{
    		alert("請輸入 \"地址\".");
    		theForm.mCadd1.focus();
    		return (false);
  	}
  	else if (checkaddr(theForm.mCadd1) == false)
  	{
  		return false;
  	}

	ChkChoice1 = 0;
	  for (j=1; j <= theForm.bn_no.value; j++)
	  {
	  	tmpV1 = "theForm.b"+j+".checked";
	  	if (eval(tmpV1))
	  	{
	  		ChkChoice1 = 1;	
	  	}
	}

	if (ChkChoice1 == 0)
	{
    		alert("請回答 \"問題1\".");
    		theForm.b1.focus();
    		return (false);		
	}
	else
	{
		  theForm.bn_list.value = "";
		  for (j=1; j <= theForm.bn_no.value; j++)
		  {
		  	tmpV1 = "theForm.b"+j+".checked";
		  	if (eval(tmpV1))
		  	{
		  		if (theForm.bn_list.value != "")
		  			theForm.bn_list.value += ",";
		  		
		  		tmpV2 = "theForm.b"+j+".value";
				theForm.bn_list.value += eval(tmpV2);  			
		  	}
		}	
	}

	if (theForm.bizNature.options[theForm.bizNature.selectedIndex].value == "")	
  	{
    		alert("請回答 \"問題2\".");
    		theForm.bizNature.focus();
    		return (false);
  	}
  	
	ChkChoice2 = 0;
	  for (j=1; j <= theForm.exp_no.value; j++)
	  {
	  	tmpV1 = "theForm.expc"+j+".checked";
	  	if (eval(tmpV1))
	  	{
	  		ChkChoice2 = 1;	
	  	}
	}

	if (ChkChoice2 == 0)
	{
    		alert("請回答 \"問題3\".");
    		theForm.expc1.focus();
    		return (false);		
	}
	else
	{
		  theForm.expList.value = "";
		  for (j=1; j <= theForm.exp_no.value; j++)
		  {
		  	tmpV1 = "theForm.expc"+j+".checked";
		  	if (eval(tmpV1))
		  	{
		  		if (theForm.expList.value != "")
		  			theForm.expList.value += ",";
		  		
		  		tmpV2 = "theForm.expc"+j+".value";
				theForm.expList.value += eval(tmpV2);  			
		  	}
		}
	}

	if (theForm.q3ans.value == "")
  	{
    		alert("請回答 \"問題4\".");
    		theForm.q3ans.focus();
    		return (false);
  	}

	if ((theForm.q4ans1.value == "") && (theForm.q4ans2.value == ""))
  	{
    		alert("請回答 \"問題5\".");
    		theForm.q4ans1.focus();
    		return (false);
  	}

	if ((!theForm.q5chk1.checked) && (!theForm.q5chk2.checked))
  	{
    		alert("請回答 \"問題6\".");
    		theForm.q5chk1.focus();
    		return (false);
  	}

	if ((!theForm.q6chk[0].checked) && (!theForm.q6chk[1].checked))
  	{
    		alert("請回答 \"問題7\".");
    		theForm.q6chk[0].focus();
    		return (false);
  	}

	if ((!theForm.q7chk[0].checked) && (!theForm.q7chk[1].checked))
  	{
    		alert("請回答 \"問題8\".");
    		theForm.q7chk[0].focus();
    		return (false);
  	}
  	  	  	  	  	  	
	return (true);	
}

function Validate_Email(obj) {
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		return filter.test(obj.value);
}
