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)
{
	// 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);
  	}
  			
	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);
	}  	  	


	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);
}
