//::Trim String Function
function Trim(str){
	str = str.replace(/\s+/,'');
	str = str.replace(/\s+$/,'');
	return str;
}

//::IsNumeric Function
function IsNumeric(val){
	for (i=0; i<val.length; i++){
		if (isNaN(val.charAt(i))){
			return false;
		}
	}
	return true;
}

//::Valid E-Mail
function ValidEmail(str){
	AccPos = str.indexOf('@');
	AccStr = str.substr(0,AccPos);
	AccLen = AccStr.length;
	DomPos = str.lastIndexOf('.');
	DomStr = str.substr(AccPos+1,(DomPos-AccPos)-1);
	DomLen = DomStr.length;
	ExtPos = DomPos + 1;
	ExtLen = str.length - ExtPos;
	ExtStr = str.substr(ExtPos,ExtLen);
	if(	   (AccPos != -1)
		&& (DomPos != -1)
		&& (AccLen >= 2)
		&& (DomLen >= 2)
		&& (ExtLen >= 2)
		&& (ExtLen <= 3)){
		return true;
	}
	else{return false}
}

//::Valid Phone
function ValidPhone(PhoneArea,PhonePre,PhoneSuf){
	if ((Trim(PhoneArea) == "") || 
		(Trim(PhonePre) == "") ||
		(Trim(PhoneSuf) == "") ||
		(PhoneArea.length != 3) || 
		(PhonePre.length != 3) ||
		(PhoneSuf.length != 4)){
		return false;
	}else{
		if (IsNumeric(PhoneArea) &&
			IsNumeric(PhonePre) &&
			IsNumeric(PhoneSuf) &&
			(PhoneArea.length == 3) && 
			(PhonePre.length == 3) &&
			(PhoneSuf.length == 4)){
			return true;
		}
	}
}

//::Validate Login Form
function ValidateLoginForm() {
	missinginfo = "";
	var objForm = document.forms[0];

	/*
	if (!ValidEmail(objForm.email.value)) {
	missinginfo += "\n     »  E-Mail";
	}
	*/
	if (objForm.email.value == "") {
	missinginfo += "\n     »  E-Mail";
	}

	if (missinginfo != "") {
	missinginfo = "The following information was entered incorrectly:\n" +
	missinginfo + "\n\nPlease re-enter the information and try again...";
	alert(missinginfo);
	return false;
	}
	else return true;
}