function isValidEMail(theEMail) {
	var regexp=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	return regexp.test(theEMail);
}

function IsOptChecked(theObj,theObjType,theReturnType){
	var blnChecked=false;
	var isSelect=false;
	var objType=theObjType==null?"":theObjType;
	var checkedValue="";
	if(theObj){
		isSelect=theObjType.toLowerCase()=="select";
		if(theObj.length>1){
			for(var i=0;i<theObj.length;i++){
				blnChecked=isSelect?theObj[i].selected:theObj[i].checked;
				if(blnChecked){
					checkedValue=theObj[i].value;
					break;
				}
			}
		}
		else{
			blnChecked=isSelect?theObj.selected:theObj.checked;
			checkedValue=theObj.value
		}
	}
	return theReturnType=="bool"?blnChecked:checkedValue;
}


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 chkAll(theForm){
	var msg="";
	var j=0;

	var acct=theForm.MAccount.value=trim(theForm.MAccount.value);
	acct=theForm.MAccount.value=acct==theForm.MAccount.defaultValue?"":acct;

	msg+=acct==""?(++j)+". 請輸入你的帳號\n":"";


	if(msg!=""){
		alert("請檢查以下項目\n\n"+msg);
	}else{
		theForm.submit();
	}
}

function chkAll1(theForm){
	var msg="";
	var j=0;


	var eml=theForm.MEmail.value=trim(theForm.MEmail.value);
	eml=theForm.MEmail.value=eml==theForm.MEmail.defaultValue?"":eml;

	msg+=eml==""?(++j)+". 請輸入E-Mail\n":isValidEMail(eml)?"":(++j)+". 請輸入正確的E-Mail\n";


	if(msg!=""){
		alert("請檢查以下項目\n\n"+msg);
	}else{
		theForm.submit();
	}
}


