<!--
//TGP made this globals for isDate2 below.
var mm;
var dd;
var yyyy;
var hr;
var mn;
var sc;
var dt;


/* ======================================================================
** confirmReset
** ====================================================================== */
function confirmReset(objForm, inputStr) {
	var bReset;

	bReset = confirm(inputStr)

	if (bReset) {
		objForm.reset();
	}
}


/* ======================================================================
FUNCTION: replaceString(inputStr,strold,strnew)

PURPOSE:  this is to behave just like VB replace.

INPUT:    inputStr (string) - the string to have replacing done on.
          strold   - string frag to be replaced
          strnew   - string frag to go in place of strold

RETURN:   retString
====================================================================== */
function replaceString(inputStr,strold,strnew) {
	var delim;
	var retString = "";
	var chewString = inputStr;
	while (chewString.length > 0) {
		delim = chewString.indexOf(strold);
		if (delim != -1) {
			retString = retString + chewString.substring(0, delim) + strnew;
			chewString = chewString.substring(delim + strold.length, chewString.length)
		} else {
			retString = retString + chewString;
			chewString = "";
		}
	}
	return retString;
}

/* == String checkers ============================================= */
/* These will not operate on the entire string.  Do not call these
** using objects from form or properties, for example funcName(this)
** Just use funcName(myStr)
**
** NOTE:     NOT Callable from the OnChange() event.
**
** PLATFORMS:Netscape Navigator 3.01 and higher,
**           Microsoft Internet Explorer 3.02 and higher,
**           Netscape Enterprise Server 3.0,
**           Microsoft IIS/ASP 3.0.
*/

/* ======================================================================
FUNCTION: IsAlpha

INPUT:    str (string) - the string to be tested

RETURN:   true, if the string contains only alphabetic characters 
          false, otherwise.
====================================================================== */
function IsAlpha(str)
{
	//Return immediately if an invalid value was passed in.
	if (str + "" == "undefined" || str + "" == "null" || str + "" == "")	
		return false;

	var isValid = true;

	str += "";	// convert to a string for performing string comparisons.

	//Loop through string one character at time,  breaking out of for
	//loop when an non Alpha character is found.
	for (i = 0; i < str.length; i++) {
		//Alpha must be between "A"-"Z", or "a"-"z".
		if (!(((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) || ((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")))) {
			isValid = false;
			break;
		}
	}
	return isValid;
} // end IsAlpha

function IsBlank(str) {
	if (str + "" == "undefined" || str + "" == "null" || str + "" == "") {
		return true;
	} else {
		return false;
	}
}

/* ======================================================================
FUNCTION: StripNonNumeric
 
INPUT:    str (string) - a string to be altered

RETURN:   a string containing only numeric characters 0-9;
          returns null if invalid arguments were passed

DESC:     This function removes all non-numeric characters from a given
          string.  It is useful for removing dashes, parentheses, etc. from input 
          strings such as credit card numbers or phone nubmers.
====================================================================== */
function StripNonNumeric(str)
{
	var resultStr = "";

	//Return immediately if an invalid value was passed in.
	if (str + "" == "undefined" || str == null)
		return null;

	//Make sure the argument is a string.
	str += "";

	//Loop through entire string, adding each character from the original
	//string if it is a number.
	for (var i=0; i < str.length; i++)
	{
		if ( (str.charAt(i) >= "0") && (str.charAt(i) <= "9") )
			resultStr = resultStr + str.charAt(i);
	}

	return resultStr;
} // end StripNonNumeric
/* == ============= ============================================== */


/* == Char checkers ============================================== */
/* These do not operate on the entire string.  Do not call these
** using objects from form or properties, for example funcName(this)
** Just use funcName(myChar)
*/
function isNumeric(theChar) {
	if (theChar>='0' && theChar<='9') {
		return true;
	} else {
		return false;
	}
}

function isPunctuation(theChar) {
	if ((theChar>='!'&&theChar<='/')||(theChar>=":"&&theChar<='@') || (theChar>='['&&theChar<='`')||(theChar<="{"&&theChar<='~')){
		return true;
	} else {
		return false;
	}
}

function isWhiteSpace(theChar) {
	if (theChar=='\r'||theChar=='\n'||theChar=='\t'||theChar==' ') {
		return true;
	} else {
		return false;
	}
}

function isEmailSpecial(theChar) {
	if (theChar=='@'||theChar=='-'||theChar=='.'||theChar=='_') {
		return true;
	} else {
		return false;
	}
}

function isValidChar(theChar) {
	if (theChar==','||theChar=='-'||theChar=='.'||theChar=="'") {
		return true;
	} else {
		return false;
	}
}

function isValidLNameChar(theChar) {
	if (theChar=='-'||theChar=="'"||theChar=="`") {
		return true;
	} else {
		return false;
	}
}

function isHyphen(theChar) {
	if (theChar=='-') {
		return true;
	} else {
		return false;
	}
}
/* == ============= ============================================== */


/* == Form checkers ============================================= */
/* These operate on form objects(fields).  you can call these with
** 'this' in the params, they operate on the objects.
**
** NOTE:     Callable from the OnChange() event.
**
** PLATFORMS:Netscape Navigator 3.01 and higher,
**           Microsoft Internet Explorer 3.02 and higher,
**           Netscape Enterprise Server 3.0,
**           Microsoft IIS/ASP 3.0.
*/

/* ======================================================================
FUNCTION: validEmail
 
INPUT:    form[field] - the control object to be tested.

RETURN:   Nothing.
          If data is entered into the control, it must conform to the following format:
          Begin with a string plus an '@' character followed by another string
          containing at least one '.' and ending in an alpha (non-punctuation) character.
          Otherwise, an alert msg is displayed, the control value is cleared, and focus is
          passed back to the control.

CALLS:    IsAlpha() which is defined elsewhere in the Script Library.
====================================================================== */
function validEmail(form, field, name)
{
	if (form[field].value + '' != '') {	//Data was entered in the control.

		var strValue = form[field].value;

		//Everything before the '@'.
		var strName = strValue.substring(0, strValue.indexOf("@"));

		//Everything after the '@'.
		var strDomain = strValue.substring(strValue.indexOf("@") + 1, strValue.length);

		//strName cannot be empty, or that would indicate no characters before the '@',
		//strDomain must contain a period that is not the first character (i.e. right after
		//the '@').  The last character must be an alpha.
		if (strName.length == 0 || strDomain.indexOf(".") <= 0 || strDomain.indexOf("@") != -1 || !IsAlpha(strValue.charAt(strValue.length - 1))) {
			alert('\nPlease type your email address for ' + name + ' in the following format: username@domain.com.  You must have a valid email address to use online services.');
			form[field].select();	//Select the data in the control.
			form[field].focus();		//Assign focus back to the control.
			return false;
		}
	}
	return true;
} // end validEmail

/* ======================================================================
FUNCTION: validPhone

INPUT:    form[field] - the control object to be tested.
          blnInclAreaCode (boolean)
            - if true, area code is included (10-digits).
            - if false or undefined, area code not included.

RETURN:   Nothing.
          If data is entered into the control, it must conform to digits
          counts defined by blnInclAreaCode (see above), Otherwise, an
          alert msg is displayed, the control value is cleared, and focus
          is passed back to the control.

CALLS:    StripNonNumeric(), which is defined elsewhere in the Script Library.
====================================================================== */
function validPhone(form, field, name, blnInclAreaCode)
{
	if (form[field].value + '' != '') {	//Data was entered in the control.

		var strValue = form[field].value;

		//After stripping out non-numeric characters, such as dashes, the
		//phone number should contain 7 digits (no area code) or 10 digits (area code).
		strValue = StripNonNumeric(strValue + "");
		if (blnInclAreaCode && strValue.length != 10) {
			if (!(strValue.length == 11 && strValue.charAt(0)=='1')) {
				alert('\nPlease type your 10-digit ' + name + ' number, including area code, in the highlighted response box.');
				form[field].select();	//Select the data in the control.
				form[field].focus();		//Assign focus back to the control.
				return false;
			}
		}
		if (!blnInclAreaCode && strValue.length != 7) {
			alert('\nPlease type your 7-digit ' + name + ' number.  Do not include your area code in this response box.');
			form[field].select();	//Select the data in the control.
			form[field].focus();		//Assign focus back to the control.
			return false;
		}
	}
	return true;
} // end validPhone

function validName(form, field, name) {
	var i;
	for(i=0;i < form[field].value.length;i++) {
		if (!(isWhiteSpace(form[field].value.charAt(i)) || IsAlpha(form[field].value.charAt(i)) || isValidLNameChar(form[field].value.charAt(i)))) {
			alert('Please enter only letters and whitespace characters in the "'+name+'" field.');
			form[field].focus();
			return false;
		}
	}
	return true;
}

function validNumber(form, field, name) {
	var i;
	var bolDot;
	bolDot = false;
	for(i=0;i < form[field].value.length;i++) {
		if (!(isNumeric(form[field].value.charAt(i)))) {
			if ((form[field].value.charAt(i)=='.') && !bolDot) {
				bolDot = true;
			} else {
				alert('Please enter only numbers and one "." in the "'+name+'" field.');
				form[field].focus();
				return false;
			}
		}
	}
	return true;
}


function validInt(form, field, name) {
	var i;
	for(i=0;i < form[field].value.length;i++) {
		if (!(isNumeric(form[field].value.charAt(i)))) {
			alert('Please enter only numbers in the "'+name+'" field.');
			form[field].focus();
			return false;
		}
	}
	return true;
}


function validMoney(form, field, name) {
	var i;
	var dotLoc;
	var inputStr;
	var subStr;

	dotLoc = -1;
	inputStr = form[field].value;

	for(i=0;i < inputStr.length;i++) {
		if (!(isNumeric(inputStr.charAt(i)))) {
			if (inputStr.charAt(i)=='.' && dotLoc == -1) {
				dotLoc = i;
			} else {
				alert('"'+name+'" needs to be a monetary value');
				form[field].focus();
				return false;
			}
		}
	}
	if (dotLoc != -1) {
		subStr = inputStr.substring(dotLoc, inputStr.length);
		if(subStr.length != 3){
			alert('"'+name+'" needs to be a monetary value.');
			form[field].focus();
			return false;
		}
	}

	return true;
}


function validFree(form, field, name) {
	var i;
	for(i=0;i < form[field].value.length;i++) {
		if (!(isWhiteSpace(form[field].value.charAt(i)) || isNumeric(form[field].value.charAt(i)) || isPunctuation(form[field].value.charAt(i)) || IsAlpha(form[field].value.charAt(i)))) {
			alert('Please enter only letters, numbers, punctuation and whitespace characters in the "'+name+'" field.');
			form[field].focus();
			return false;
		}
	}
	return true;
}

function validZip(form, field, name) {
	var i;
	for(i=0;i < form[field].value.length;i++) {
		if(!(isNumeric(form[field].value.charAt(i)) || isHyphen(form[field].value.charAt(i)))) {
			alert('Please enter only numeric,-, characters in the  "'+name+'" field.');
			form[field].focus();
			return false;
		}
	}
	return true;
}

function validTime(form, field, name) {
	var i;

	for(i=0;i < form[field].value.length;i++) {
		if (!(isNumeric(form[field].value.charAt(i)) || form[field].value.charAt(i)==":" || form[field].value.charAt(i)=="." || form[field].value.charAt(i)=="/" || form[field].value.charAt(i).toUpperCase()=="P" || form[field].value.charAt(i).toUpperCase()=="A" || form[field].value.charAt(i).toUpperCase()=="M" || form[field].value.charAt(i).toUpperCase()==" ")) {
			alert('Please enter only numbers, ":" and "." characters with "AM" or "PM" for 12 hour format in the "'+name+'" field.');
			form[field].focus();
			return false;
		}
	}

	if (!isTime(form[field]))return false;
		return true;
}

function validDate(form, field, name) {
	var i;

	for(i=0;i < form[field].value.length;i++) {
		if (!(isNumeric(form[field].value.charAt(i)) || form[field].value.charAt(i)=="/")) {
			alert('Please enter only numbers and "/" characters in the "'+name+'" field.');
			form[field].focus();
			return false;
		}
	}

	if (!isDate(form[field]))return false;
		return true;
}

function validRequired(form, field, name) {
	if (form[field].value!="") {
		return true;
	} else {
		alert('Please enter a value for the "'+name+'" field.');
		form[field].focus();
		return false;
	}
}

function validLength(form, field, name, minVal, maxVal) {
	if (form[field].value=="")return true;
	if (minVal!=null&&form[field].value.length<minVal) {
		alert('Please enter at least '+minVal+' characters in the "'+name+'" field.');
		form[field].focus();
		return false;
	}
	if (maxVal!=null&&form[field].value.length>maxVal) {
		alert('Please enter at most '+maxValx+' characters in the "'+name+'" field.');
		form[field].focus();
		return false;
	}
	return true;
}

function validSelect(form, field, name) {
	// 	alert('FieldNameis:'+field)
	//tgp 29jun1002 added the selectedIndex checker
	//tgp 29jun1002 added the selectedIndex.value checker
	var intSelInd= form[field].selectedIndex
	if ((intSelInd<1)&&((form[field].options[intSelInd].text=="") || (form[field].options[intSelInd].value==""))){
		alert('Please select an option for the "'+name+'" field.');
		form[field].focus();
		return false;
	}
	return true;
}

function validChecked(form, field, name) {
	var thisField = form[field];
	for(var i = 0; i < thisField.length; i++) {
		if (thisField[i].checked)
			return true;
	}
	alert('Please select an option for the "'+name+'" field.');
	thisField[0].focus();
	return false;
}

function isTime2(formField, inputStr) {
	var delim1 = inputStr.indexOf(":");
	var delim2 = inputStr.lastIndexOf(":");
	var delim3 = inputStr.indexOf(" ");

	if (delim1 != -1) {
		// there are delimiters; extract component values
		hr = parseInt(inputStr.substring(0,delim1),10);
		if (delim3 != -1) {
			sc = parseInt(inputStr.substring(delim2 + 1, delim3),10);
			dt = inputStr.substring(delim3 + 1, inputStr.length).toUpperCase();
		} else {
			sc = parseInt(inputStr.substring(delim2 + 1, inputStr.length),10);
			dt = "";
		}
		if (delim1 == delim2) {
			mn = parseInt(inputStr.substring(delim1 + 1,delim1 + 3),10);
			sc = "00";
		} else {
			mn = parseInt(inputStr.substring(delim1 + 1,delim2),10);
		}
	} else {
		// there are no delimiters; extract component values
		hr = parseInt(inputStr.substring(0,2),10);
		mn = parseInt(inputStr.substring(2,4),10);
		if (delim3 != -1) {
			sc = parseInt(inputStr.substring(4, delim3),10);
			dt = inputStr.substring(delim3 + 1, inputStr.length).toUpperCase();
		} else {
			sc = parseInt(inputStr.substring(4,inputStr.length),10);
			dt = "";
		}
	}
	if (isNaN(hr) || isNaN(mn) || isNaN(sc)) {
		// there is a non-numeric character in one of the component values
		alert("The time entry is not in an acceptable format.\n\nYou can enter times in the following formats: hhmmss, hh:mm:ss, or hh:mm.ss.  (You can enter AM or PM or 24 hour.  If entering AM or PM precede it with a space.)");
		formField.focus();
		formField.select();
		return false;
	}
	if (!IsBlank(dt)) {
		if (dt != "AM" && dt != "PM") {
			// there is a non-numeric character in one of the component values
			alert("When entering 12 hour format please use ''AM'' or ''PM'' preceded it with a space.)");
			formField.focus();
			formField.select();
			return false;
		} else {
			dt = " " + dt
		}
	}

	// validate year, allowing for checks between year ranges
	// passed as parameters from other validation functions
	if (sc < 0 || sc > 59) {
		// sec value is not 0 thru 59
		alert("Seconds must be entered between the range of 00 and 59.");
		formField.focus();
		formField.select();
		return false;
	}

	if (delim3 != -1) {
		if (hr < 1 || hr > 12) {
			// month value is not 1 thru 12
			alert("Hours must be entered between the range of 1 and 12.");
			formField.focus();
			formField.select();
			return false;
		}
	} else {
		if (hr < 0 || hr > 23) {
			// month value is not 0 thru 23
			alert("Hours must be entered between the range of 0 and 23.");
			formField.focus();
			formField.select();
			return false;
		}
	}
	if (mn < 0 || mn > 59) {
		// sec value is not 0 thru 59
		alert("Minutes must be entered between the range of 00 and 59.");
		formField.focus();
		formField.select();
		return false;
	}

	return true;
}


function isDate2(formField, inputStr) {
	var delim1 = inputStr.indexOf("/");
	var delim2 = inputStr.lastIndexOf("/");
	if (delim1 != -1 && delim1 == delim2) {
		// there is only one delimiter in the string
		alert("The date entry is not in an acceptable format.\n\nYou can enter dates in the following formats: mmddyyyy, mm/dd/yyyy, or mm-dd-yyyy.  (If the month or date data is not available, enter \'01\' in the appropriate location.)");
		formField.focus();
		formField.select();
		return false;
	}
	if (delim1 != -1) {
		// there are delimiters; extract component values
		mm = parseInt(inputStr.substring(0,delim1),10);
		dd = parseInt(inputStr.substring(delim1 + 1,delim2),10);
		yyyy = parseInt(inputStr.substring(delim2 + 1, inputStr.length),10);
	} else {
		// there are no delimiters; extract component values
		mm = parseInt(inputStr.substring(0,2),10);
		dd = parseInt(inputStr.substring(2,4),10);
		yyyy = parseInt(inputStr.substring(4,inputStr.length),10);
	}
	if (isNaN(mm) || isNaN(dd) || isNaN(yyyy)) {
		// there is a non-numeric character in one of the component values
		alert("The date entry is not in an acceptable format.\n\nYou can enter dates in the following formats: mmddyyyy, mm/dd/yyyy, or mm-dd-yyyy.");
		formField.focus();
		formField.select();
		return false;
	}

	// validate year, allowing for checks between year ranges
	// passed as parameters from other validation functions
	if (yyyy < 100) {
		// entered value is two digits, which we allow for 1930-2029
		if (yyyy >= 30) {
			yyyy += 1900;
		} else {
			yyyy += 2000;
		}
	}

	if (mm < 1 || mm > 12) {
		// month value is not 1 thru 12
		alert("Months must be entered between the range of 01 (January) and 12 (December).");
		formField.focus();
		formField.select();
		return false;
	}

	/* TGP 6jul2001 added the day of month check with leapyear modification */
	var arrMonthDaysMax = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

	if (mm == 2) {
		// Change Feb. for leap year.
		if ((yyyy % 4 == 0 && yyyy % 100 != 0) || (yyyy % 400 == 0))
			arrMonthDaysMax[1] = 29;
	}
	if (dd < 1 || dd > arrMonthDaysMax[mm-1]) {
		// date value is not 1 thru 31
		alert("Days must be entered between the range of 01 and a maximum of " + arrMonthDaysMax[mm-1] + ".");
		formField.focus();
		formField.select();
		return false;
	}

	return true;
}

// date field validation (called by other validation functions that specify minYear/maxYear)
function isDate(formField) {
	var inputStr = formField.value;
	// convert hyphen delimiters to slashes
	while (inputStr.indexOf("-") != -1) {
		inputStr = replaceString(inputStr,"-","/");
	}

	var today = new Date();

	var bIamGood = isDate2(formField, inputStr);

	// put the Informix-friendly format back into the field
	//formField.value = monthDayFormat(mm) + "/" + monthDayFormat(dd) + "/" + yyyy
	// put the SQL-friendly format back into the field
	if (bIamGood) {
		formField.value = mm + "/" + dd + "/" + yyyy;
	}

	return bIamGood;
}

// time field validation (called by other validation functions)
function isTime(formField) {
	var inputStr = formField.value
	// convert hyphen delimiters to slashes
	if (inputStr.indexOf("-") != -1) {
		inputStr = replaceString(inputStr,"-",":");
	}
	if (inputStr.indexOf(".") != -1) {
		inputStr = replaceString(inputStr,".",":");
	}
	if (inputStr.indexOf("/") != -1) {
		inputStr = replaceString(inputStr,"/",":");
	}

	var bIamGood = isTime2(formField, inputStr);

	// put the SQL-friendly format back into the field
	if (bIamGood) {
		formField.value = hr + ":" + mn + ":" + sc + dt;
	}

	return bIamGood;
}
/* == ============= ============================================== */

// -->