function isValidEMail(theEMail) {
	var regexp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	return regexp.test(theEMail);
}

function trim(theString){
	while(theString.substr(0,1)==" ")
		theString=theString.substr(1);

	while(theString.substr(theString.length-1,1)==" ")
		theString=theString.substr(0,theString.length-1);

	return theString;
}

function chkEmail(theForm, theType){

	var msg="";
	var j=0;
	
	var eml=theForm.Email.value=trim(theForm.Email.value);
	eml=theForm.Email.value=eml==theForm.Email.defaultValue?"":eml;
	msg+=eml==""?(++j)+". 請輸入E-Mail\n":isValidEMail(eml)?"":(++j)+". 請輸入正確的E-Mail\n";

if(msg!=""){
		alert("請檢查以下項目\n\n"+msg);
	}
	else{
		theForm.Status.value = theType;
		theForm.submit();   
	}
}

