<!--
function ValidateText(formfield, DisplayMsg) {
	if (formfield) {
		if (formfield.value == "") {
			alert('Please enter ' + DisplayMsg);
			formfield.focus();
			return false;
		}
	}
	return true;
}

function ValidateSelect(FormField, DisplayMsg) {
	if (FormField) {
		if (FormField[0].selected) {
			alert('Please select ' + DisplayMsg);
			FormField.focus();
			return false;
		}
	}
	return true;
}

function ValidateMultiSelect(FormField, DisplayMsg) {
	if (FormField) {
		for (i=0; i<FormField.length; i++) {
			if (FormField[i].selected) { return true; }
		}
		alert('Please select ' + DisplayMsg);
		FormField.focus();
		return false;
	}
}

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;
	if (formfield) {
		var thisFieldVal = formfield.value;
		if (thisFieldVal != "") {
			if (thisFieldVal.length < MinLength){
				alert('Please enter ' + DisplayMsg + 'You entered ' + thisFieldVal.length + ' characters.');
				formfield.focus();
				foundError = true;
			}
			
			
			if ((MaxLength) && (thisFieldVal.length > MaxLength)) {
				//alert('Please enter ' + DisplayMsg);
				alert('Please enter ' + DisplayMsg + '  You entered ' + thisFieldVal.length + ' characters.');
				formfield.focus();
				foundError = true;
			}
		}
	}
	
	if (foundError == false) {
		return true;
	}
	else{
		return false;
	}
}

function ValidateNum(formfield, DisplayMsg, MinValue, MaxValue) {
	if (formfield){
		//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(formfield.value)) {
			alert('Please enter a valid number for ' + DisplayMsg);
			formfield.focus();
			return false;
		}
		
		if (!foundError && (MinValue) && (formfield.value < MinValue)) {
			alert(DisplayMsg + ' must be at least ' + MinValue);
			formfield.focus();
			return false;
		}
		
		if (!foundError && (MaxValue) && (formfield.value > MaxValue)) {
			alert(DisplayMsg + ' cannot be greater than ' + MaxValue);
			formfield.focus();
			return false;
		}
	}
	return true;
}

function ValidateInt(formfield, DisplayMsg, required, MinValue, MaxValue) {
	if (!formfield) { return true;}
	if (!ValidateNum(formfield, DisplayMsg, required, MinValue, MaxValue)) { return false; }

	if (formfield.value.indexOf("\.") != -1) {
		alert('Please enter a valid integer for ' + DisplayMsg);
		formfield.focus();
		return false;
	}
	return true;
}

// checks to see if one of several radio buttons is selected
function ValidateRadio(FormField, DisplayName) {
	if (FormField) {
		for (i = 0; i < FormField.length ; i++) {
				if (FormField[i].checked) {
					return true;
				} 
		}
		if (FormField.checked) { return true; }
		alert('Please select ' + DisplayName + '.');
		return false;
	}
	return true;
}


function ValidateMultiCheck(FormField, DisplayMsg) {
	if (FormField) {

		for (i=0; i<FormField.length; i++) {
			alert (FormField[i].checked);
			if (FormField[i].checked) { return true; }
		}
		alert('Please select ' + DisplayMsg);
		return false;
	}
}

function DisplayAlert(formfield, msg) {
	alert(msg);
	formfield.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) {
	if (!formfield) {return true;}

	email = formfield.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;	
}

// checks for a valid date entered in 'mm/dd/yyyy' format
// 		formfield	- is the formfield object, (ie. form.StartDate)
//		DateName	- is the name of date field FOR DISPLAY,
//		Required	- boolean flag, (true or false) to indicate if a date is required
function ChkDate(formfield, DateName, required) {
	if (!formfield) {return true;}

	// if desired, we can pop an alert and return false if the date is required here
	if (formfield.value == "" && required) {
		alert('Please enter a valid  \'' + DateName + '\'.');
		formfield.focus();
		return false;
	} else if (formfield.value == "") { return true; }

	FirstSlash = formfield.value.indexOf("\/",0)
	if (FirstSlash == -1) {
		alert('Invalid date entry for the ' + DateName + '.\n\nPlease enter this date in \'mm/dd/yyyy\' format.');
		formfield.focus();
		return false;
	}
	SecondSlash = formfield.value.indexOf("\/",FirstSlash+1)
	if (SecondSlash == -1) {
		alert('Invalid date entry for the ' + DateName + '.\n\nPlease enter this date in \'mm/dd/yyyy\' format.');
		formfield.focus();
		return false;
	}

	month="";
	for (i=0; i<FirstSlash; i++) {
		month = month + formfield.value.charAt(i);
	}
	if (isNaN(month) || month > 12 || month < 1) {
		alert('Invalid Month of   \'' + month + '\'   entered for the ' + DateName + '.');
		formfield.focus();
		return false;
	}

	// Days are validated as numbers with values of 1-31
	// Validation does not accomodate month specific max days. IE. 2/31/1999 could be specified
	day="";
	for (i=(FirstSlash+1); i<SecondSlash; i++) {
		day = day + formfield.value.charAt(i);
	}
	
	// years are validated as numbers with a length of 4 digits
	year="";
	for (i=(SecondSlash+1); i<formfield.value.length; i++) {
		year = year + formfield.value.charAt(i);
	}
	if (isNaN(year) || year.length != 4 || year.indexOf("\-",0) != -1) {
		alert('Invalid year of   \'' + year + '\'   entered for the ' + DateName + '.');
		formfield.focus();
		return false;
	}

	if (isNaN(day) || day > getDaysMonth(month, year) || day < 1) {
		alert('Invalid Day of   \'' + day + '\'   entered for the ' + DateName + '.');
		formfield.focus();
		return false;
	}
	
	return true;
}

// checks for a valid time in 'hh:mm tt' format
// 		formfield	- is the formfield object, (ie. form.StartDate)
//		TimeName	- is the user-friendly name of formfield for output in error messages,
//		Required	- boolean to indicate if a time is required
function ChkTime(formfield, TimeName, required) {
	if (!formfield) {alert("time form field not found"); return true;}
	var timeVal = formfield.value;
	
	if (timeVal == "" && required) {
		alert('Please enter a valid ' + TimeName + ' in hh:mm tt format.');
		formfield.focus();
		return false;
	} else if (timeVal == "") { return true; }
	
	var T
	if ((T = /^(\d\d):(\d\d)\s?(([ap])\.?m\.?)$/i.exec(timeVal)) == null) { 
		alert('Please enter a valid ' + TimeName + ' in hh:mm tt format.');
		formfield.focus();
		return false; 
		}
	
	return true;
	
}

//-->
