//Variables to hold error message
	var msg = "";
	var empty_fields = "";
	
// Function that returns true if a string contains only white space
function isblank(s) {
	for (var i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if ((c != " ") && (c != '\n') && (c != '\t')) return false;
	}
	return false;
}

// Function to determine whether a string contains numeric characters
function isNumeric(aString) {
	if (aString.length == 0) {
		return (false);
	}
	var refString = "1234567890";
	for (count=0; count < aString.length; count++) {
		chkChar = aString.substring (count, count+1);
		if (refString.indexOf (chkChar, 0) == -1)
			return (false);
	}
	return (true)
}

// Function to determine whether a string contains numeric characters or whitespace
function isTelephone(aString) {
	if (aString.length == 0) {
		return (false);
	}
	var refString = "1234567890 +-()[]";
	for (count=0; count < aString.length; count++) {
		chkChar = aString.substring (count, count+1);
		if (refString.indexOf (chkChar, 0) == -1)
			return (false);
	}
	return (true)
}

// Function to determine whether a string contains numeric characters or Alpha chars
function isNumericOrAlpha(aString) {
	if (aString.length == 0) {
		return (false);
	}
	var refString = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	for (count=0; count < aString.length; count++) {
		chkChar = aString.substring (count, count+1);
		if (refString.indexOf (chkChar, 0) == -1)
			return (false);
	}
	return (true)
}
	
// Function to check a Text box
function chkText(e, eValue, minLength) {
	// check if the text line is empty
	if ((e.value == null) || (e.value == "") || isblank(e.value) || (e.value.length <=  minLength - 1 ) ) {
		if  (eValue == "" ) {
			eValue = e.name;
		}
		empty_fields += "\n        " + eValue;
		return empty_fields;
	}
}

// Function to check if a telephone number is valid
function chkNumeric(e, eValue) {
	if ((e.value == null) || (e.value == "") || isblank(e.value) ||  (isNumeric(e.value) == 0)   )  	{
		if  ( eValue == "" ) {
			eValue = e.name;
		}
		empty_fields += "\n        " + eValue;
		return empty_fields;
	}
}

// Function to check if a telephone number is valid
function chkTelephone(e, eValue) {
	if ((e.value == null) || (e.value == "") || isblank(e.value) ||  (isTelephone(e.value) == 0)   )  	{
		if  ( eValue == "" ) {
			eValue = e.name;
		}
		empty_fields += "\n        " + eValue;
		return empty_fields;
	}
}

// Function to check an option has been selected in a Select list
function chkSelect (e, eValue) {
	if (( e.selectedIndex < 0) 
		|| (e.value == "") || (e.value == "NULL")) {
		if  (eValue == "" ) {
			eValue = e.name;
		}
		empty_fields += "\n        " + eValue;
		return empty_fields;
	}
}

function validEmail (e, eValue) {
// Function to check if email is valid - must contain an '@' and a '.'
	var iCount = 0;
	var	cCheck;
	var bContainsAt = false;
	var bContainsDot = false;
	
	if (e.value.length > 0)
	{
		// An email address has been entered.  Make sure that it contains
		// the required characters.
		for (iCount = 0; iCount < e.value.length; iCount++) {
			cCheck = e.value.substring(iCount, (iCount + 1));
			
			if (cCheck == '@'){
				bContainsAt = true;
			}
			
			if (cCheck == '.'){
				bContainsDot = true;
			}
		}
	
		// The string does not contain the required character.
		if (!bContainsDot || !bContainsAt){
			if  (eValue == "" ) {
				eValue = e.name;
			}

			empty_fields += "\n        " + eValue;
			return empty_fields;
		}
	}
}

// Function to check if one of a group of radio buttons has been selected
function chkRadio(e, eValue) {
	for (i = 0; i < e.length; i++) {
		if (e[i].checked) {
			return true;
		}		
	}
	if  (eValue == "" ) {
		eValue = e[0].name;
	}
	empty_fields += "\n        " + eValue;
	return empty_fields;
}

// Show the Errors built up into the error string
function showErr(empty_fields) {
					
	// If errors display messages and return false to stop form submission.
	if (!empty_fields) return true;

	msg = "=================================\n"
	msg += " Before your form can be sent you must enter\n";
	msg += " (acceptable) values in the following fields.\n";
	msg += "=================================\n"
	
	if (empty_fields) {
		msg += empty_fields + "\n";
		msg += "\nPlease correct these fields and send the form again.\n";
		msg += "=================================\n"
		alert(msg);
		return false;
	}
}
// -->

