function chkSignUpForm(){
	if(isEmpty(document.frmSignUp.name.value)){
		alert("Please enter your name.");
		document.frmSignUp.name.focus();
		return false;
	}
	if(!isEmpty(document.frmSignUp.email.value) && !isEmail(document.frmSignUp.email.value)){
		alert("Please enter valid email address.");
		document.frmSignUp.email.select();
		return false;
	}
	if(isEmpty(document.frmSignUp.dob_year.value)){
		alert("Please enter your year of birth.");
		document.frmSignUp.dob_year.focus();
		return false;
	}
	if(!isInteger(document.frmSignUp.dob_year.value)){
		alert("Your year of birth must be integer.");
		document.frmSignUp.dob_year.focus();
		return false;
	}
	if(isEmpty(document.frmSignUp.dob_month.value)){
		alert("Please enter your month of birth.");
		document.frmSignUp.dob_month.focus();
		return false;
	}
	if(!isInteger(document.frmSignUp.dob_month.value)){
		alert("Your month of birth must be integer.");
		document.frmSignUp.dob_month.focus();
		return false;
	}
	if(isEmpty(document.frmSignUp.dob_day.value)){
		alert("Please enter your day of birth.");
		document.frmSignUp.dob_day.focus();
		return false;
	}
	if(!isInteger(document.frmSignUp.dob_day.value)){
		alert("Your day of birth must be integer.");
		document.frmSignUp.dob_day.focus();
		return false;
	}
	if(isEmpty(document.frmSignUp.password.value)){
		alert("Please enter your password.");
		document.frmSignUp.password.focus();
		return false;
	}
	if(isEmpty(document.frmSignUp.confirm_password.value)){
		alert("Please confirm your password.");
		document.frmSignUp.confirm_password.focus();
		return false;
	}
	if(document.frmSignUp.password.value != document.frmSignUp.confirm_password.value){
		alert("Please confirm you have enter the same passwords.");
		document.frmSignUp.confirm_password.select();
		return false;
	}
	if(!document.frmSignUp.agreement.checked){
		alert("You must read, understand and agree with the terms and conditions.");
		return false;
	}
	return true;
}

function chkLoginForm(){
	if(isEmpty(document.frmLogin.ac_id.value)){
		alert("Please enter your Account ID.");
		document.frmLogin.ac_id.focus();
		return false;
	}
	if(isEmpty(document.frmLogin.password.value)){
		alert("Please enter your password.");
		document.frmLogin.password.focus();
		return false;
	}
	return true;
}

function chkRetrievePasswordForm(){
	if(isEmpty(document.frmRetrievePassword.ac_id.value)){
		alert("Please enter your Account ID.");
		document.frmRetrievePassword.ac_id.focus();
		return false;
	}
	return true;
}

function chkMyProfileForm(){
	if(isEmpty(document.frmMyProfile.name.value)){
		alert("Please enter your name.");
		document.frmMyProfile.name.focus();
		return false;
	}
	if(!isEmpty(document.frmMyProfile.email.value) && !isEmail(document.frmMyProfile.email.value)){
		alert("Please enter valid email address.");
		document.frmMyProfile.email.select();
		return false;
	}
	return true;
}

function chkChangePasswordForm(){
	if(isEmpty(document.frmChangePassword.password.value)){
		alert("Please enter your new password.");
		document.frmChangePassword.password.focus();
		return false;
	}
	if(isEmpty(document.frmChangePassword.confirm_password.value)){
		alert("Please confirm your password.");
		document.frmChangePassword.confirm_password.focus();
		return false;
	}
	if(document.frmChangePassword.password.value != document.frmChangePassword.confirm_password.value){
		alert("Please confirm you have enter the same passwords.");
		document.frmChangePassword.confirm_password.select();
		return false;
	}
	return true;
}

function isEmpty(strString) {
	if (strString != null) {
		for (i=0; i<strString.length; i++) {
			strChar = strString.charAt(i);
			if ((strChar!=" ") && (strChar != "\\n") && (strChar != "\\t") && (strChar != "\\r"))
				return false;
		}
	}
	return true;	
}

function isNumber(strString) {
	var strValidChars = "0123456789.-";
	var blnResult = true;
	for (i=0; i <strString.length && blnResult == true;i++) {
		strChar = strString.charAt(i);
		if(strValidChars.indexOf(strChar) == -1)
			blnResult = false;
	}
	return blnResult;
}

function isInteger(strString) {
	for (i=0; i <strString.length;i++) {
		strChar = strString.charAt(i);
		if(((strChar < "0") || (strChar > "9")))
			return false;
	}
	return true;
}

function isEmail(strString) {
	return (strString.indexOf(".",strString.indexOf("@")) > strString.indexOf("@")) && (strString.indexOf("@") > 0);
}

function isDate(date){ 
	if(!isInteger(date.substring(0,4)) || date.substring(4,5) != "-" || !isInteger(date.substring(5,7)) || date.substring(7,8) != "-" || !isInteger(date.substring(8,10))){
		return false; 
	} 
	var i; 
	i = 0; 
	while(date.substring(i,i+1) == "0" && i <= 4){  i++;    } 
	var year = parseInt(date.substring(i,4)); 
	i = 5; 
	while(date.substring(i,i+1) == "0" && i <= 7){  i++;    } 
	var month = parseInt(date.substring(i,7)); 
	i = 8; 
	while(date.substring(i,i+1) == "0" && i <= 10){ i++;    } 
	var day = parseInt(date.substring(i,10)); 
	
	if(year < 1 || month < 1 || month > 12 || day < 1 || day > 31){ 
		return false; 
	}else if(month == 2){ 
		if((((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))){ // is leap year? 
			if(day > 29){ 
				return false; 
			} 
		}else if(day > 28){
			return false; 
		} 
	}else if((month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) && day > 31){
		return false; 
	}else if(day > 30){ 
		return false; 
	} 
	return true; 
} 

