<!--
function ValidateText(formfield, DisplayMsg) {
	var formfieldByID = document.getElementById(''+formfield+'');
	if (formfieldByID) {
		if (formfieldByID.value == "") {
			alert('Please enter ' + DisplayMsg);
			formfieldByID.focus();
			return false;
		}
	}
	return true;
}

function ValidateSelect(formfield, DisplayMsg) {
	var formfieldByID = document.getElementById(''+formfield+'');
	if (formfieldByID) {
		if (formfieldByID[0].selected) {
			alert('Please select ' + DisplayMsg);
			formfieldByID.focus();
			return false;
		}
	}
	return true;
}

function ValidateLength(formfield, DisplayMsg, MinLength, MaxLength) {
	//MinLength is required, but can be set to 0.
	//for a required specific length, set MinLength 
	//and MaxLength to the same value
	var foundError = false;
	var formfieldByID = document.getElementById(''+formfield+'');
	if (formfieldByID) {
		var thisFieldVal = formfieldByID.value;
		if (thisFieldVal != "") {
			if (thisFieldVal.length < MinLength){
				alert('Please enter ' + DisplayMsg + 'You entered ' + thisFieldVal.length + ' characters.');
				formfieldByID.focus();
				foundError = true;
			}
			
			
			if ((MaxLength) && (thisFieldVal.length > MaxLength)) {
				//alert('Please enter ' + DisplayMsg);
				alert('Please enter ' + DisplayMsg + '  You entered ' + thisFieldVal.length + ' characters.');
				formfieldByID.focus();
				foundError = true;
			}
		}
	}
	
	if (foundError == false) {
		return true;
	}
	else{
		return false;
	}
}

function ValidateNum(formfield, DisplayMsg, MinValue, MaxValue) {
	var formfieldByID = document.getElementById(''+formfield+'');
	if (formfieldByID){
		//if ((formfield.value == "") && (!required)) { return true; }
	
		/*if (formfield.value == "") {
			alert('Please enter ' + DisplayMsg + '\n\n\(This must be a valid number.\)');
			formfield.focus();
			return false;
		}*/
		var foundError = false;
		if (!foundError && isNaN(formfieldByID.value)) {
			alert('Please enter a valid number for ' + DisplayMsg);
			formfieldByID.focus();
			return false;
		}
		
		if (!foundError && (MinValue) && (formfieldByID.value < MinValue)) {
			alert(DisplayMsg + ' must be at least ' + MinValue);
			formfieldByID.focus();
			return false;
		}
		
		if (!foundError && (MaxValue) && (formfieldByID.value > MaxValue)) {
			alert(DisplayMsg + ' cannot be greater than ' + MaxValue);
			formfieldByID.focus();
			return false;
		}
	}
	return true;
}

function DisplayAlert(formfield, msg) {
	var formfieldByID = document.getElementById(''+formfield+'');
	alert(msg);
	formfieldByID.focus();
	return false;
}

// checks for a Valid Email Address structure
// 		formfield	- is the email formfield object, (ie. form.Email)
//		EmailName	- is the name of date field FOR DISPLAY in the Alert Box,
//		required	- boolean flag, (true or false) to indicate if Email Address is required
function ChkEmail(formfield, EmailName, required) {
	var formfieldByID = document.getElementById(''+formfield+'');
	if (!formfieldByID) {return true;}

	email = formfieldByID.value;
	EmailName = 'Please enter a valid ' + EmailName + ' in the format You@YourEmailProvider.zzz';
	invalidChars = " /:,;"
	if (email == "" && required) { return DisplayAlert(formfield, EmailName); }
	if (email == "") { return true; }

	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) != -1) { return DisplayAlert(formfield, EmailName); }
	}

	atPos = email.indexOf("@",1)
	if (atPos == -1) { return DisplayAlert(formfield, EmailName); }
	if (email.indexOf("@",atPos+1) != -1) { return DisplayAlert(formfield, EmailName); }

	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) { return DisplayAlert(formfield, EmailName); }
	if (periodPos+3 > email.length) { return DisplayAlert(formfield, EmailName); }
	return true;
}


// Checks to see if the year passed is a leap year.
function isLeapYear(chkYear) {
	if (chkYear % 4 != 0) {return false;}
	if (chkYear % 400 == 0) {return true;}
	if (chkYear % 100 == 0) {return false;}
	return true;
}

// Gets the max number of days available in a month.  isLeapYear() is called to
// determine the number of days in February.
function getDaysMonth(theMonth, theYear) {
	if (theMonth == 1) {return 31;}
	if (theMonth == 2 && isLeapYear(theYear)) {return 29;}
	if (theMonth == 2 && (!isLeapYear(theYear))) {return 28;}
	if (theMonth == 3) {return 31;}
	if (theMonth == 4) {return 30;}
	if (theMonth == 5) {return 31;}
	if (theMonth == 6) {return 30;}
	if (theMonth == 7) {return 31;}
	if (theMonth == 8) {return 31;}
	if (theMonth == 9) {return 30;}
	if (theMonth == 10) {return 31;}
	if (theMonth == 11) {return 30;}
	if (theMonth == 12) {return 31;}
	alert('invalid month!');
	return false;	
}
//-->
