	//proc to test if value is empty or not	function isEmpty (testValue) {		for (var i = 0; i < testValue.length; i++) {			var c = testValue.charAt(i);			if ((c != ' ') && (c != '\\n') && (c != '\\t')) return false;		}		return true;	}	//proc to return a string containing newlines	function NewLines (count) {		var retString = '';		for (var i = 0; i < count; i++) {			retString = retString + '\n';		}		return retString;	}	//proc to return true if email is valid or returns false if email is invalid	function ValidateEmailAddress(testEmail) {		if (testEmail != '') {			var atIndex = testEmail.indexOf('@');			var dotIndex = testEmail.lastIndexOf('.');			var spaceIndex = testEmail.indexOf(' ');			if ((atIndex < 1) || (dotIndex == -1) || ( spaceIndex != -1) || (dotIndex - atIndex < 2) || (testEmail.length - dotIndex < 2))				return false;		}		return true;	}		var submitcount=0;	//function to validate a form 	//the form name may be passed in by the form, in which case the form may have any name. However, if the form name 	//is not passed in, the form must be called theForm; this proc uses the requiredEntryFieldList hidden variable 	//in the Form to know what fields to validate and what type of validation to perform	//requiredEntryFieldsList must be of the following format	//fieldName|fieldType|fieldCaption^fieldName|fieldType|fieldCaption^fieldName|fieldType|fieldCaption...	//valid fieldType values are email and text all other fieldType values are treated as text		function ValidateForm(formName) {			//if a form name was not passed in then assume the form name is "theForm"		if (arguments.length < 1) {			formName = "theForm";		}								//get the form object from the document		var aForm = eval('document.'+ formName);		//get list of required fields and split string value into an array of fields		var reqFieldList = aForm.requiredEntryFieldsList.value;		reqFieldList = reqFieldList.split('^');						var fieldInfo;		//to store the fieldInfo element		var fieldName;		//to store the fieldName			var fieldType;		//to store the fieldType (text or email)		var field;		//to get the field object itself from the form		var fieldValue;		//to store the field value		var i;			//counter		var confirmEmail;	//to store if the email is confirmed or not		var errorMsg = '';	//to store the erro message		//get the flag from the form to indicate if email is confirmed or not		if (aForm.confirmEmail) {			confirmEmail = aForm.confirmEmail.value;		} else { 			//if the form has no confirmEmail field then email is not confirmed			confirmEmail = 0;		}		//for each field in the required field list, check that the field is indeed valid		for (i=0; i < reqFieldList.length; i++) {			//get the information for the current field and split the info into an array			fieldInfo = reqFieldList[i].split('|');						//get the field name and type from the field info array			fieldName = fieldInfo[0];			fieldType = fieldInfo[1];						//use the field name to pull the field object from the form			field = eval('aForm.' + fieldName);						//if an email field is confirmed then it will be an array value but other values will not			//so if the field is an array then get the first value; otherwise just get the value			if (field.length > 1)				fieldValue = field[0].value;			else				fieldValue = field.value;							//if the field has no value then an error message is needed			if (fieldValue == '') {				//append message indicating the missing field using the field label				errorMsg = errorMsg + NewLines(1)+'You must enter your '+fieldInfo[2];			} else {				//the field contains a value but is the value valid?				//if the field is an email field then ensure it is a valid email				if (fieldType == 'email') {					//if the email is invalid then an error message is needed					if (!ValidateEmailAddress(fieldValue)) {						errorMsg = errorMsg + NewLines(1) + fieldInfo[2] + ' must be a valid email address.';					}										//if the email is to be confirmed then confirm it					if (confirmEmail == 1) {						//if we don't have 2 values in confirmEmail or the two values don't match then give an error						if (!(field.length && field[0].value == field[1].value))  {							errorMsg = errorMsg + NewLines(1) + fieldInfo[2] + ' does not match its confirmation field.';						}					}				}			}					} //end for i < reqFieldList size		if (errorMsg == '') {			//no errors but verify we have not submitted already			if (submitcount == 0) {				submitcount++;				return true;			} else {				return false;			}					} else {			//an error has occurred; display error messages and return false so the transaction is not processed			alert(errorMsg);			return false;		}			}	//end ValidateForm	