<!-- // hide from non-js browsers

//*****************************************************************************
//	Javascript Functions
//*****************************************************************************

//-------------------------------------------------------------------------------

/*	Email Validation	*/

function checkEmail (strng, FieldName) {
	var error="";
	if (strng == "") {
		error = "You didn't enter an email address.\n\n";
		}
	var emailFilter=/^.+@.+\..{2,3}$/;
	if (!(emailFilter.test(strng))) {
		error = "The email address you supplied in the " + FieldName + " field doesn't seem to be valid.\nPlease check that you have the correct spelling.\n\n";
		}
	else {

//test email for illegal characters

		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
		if (strng.match(illegalChars)) {
			error = "The email address you supplied in the " + FieldName + " field contains illegal characters.\nPlease revise the entry.\n\n";
			}
		}
	return error;
	}

//-------------------------------------------------------------------------------

/*	Phone Number - Strip out delimiters and check for 10 digits	*/

function checkPhone (strng, FieldName){
	var error = "";
	if (strng == "") {
		error = "You didn't enter a phone number in the " + FieldName + " field.\nPlease revise the entry.\n\n";
		}
	var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
	if (isNaN(parseInt(stripped))) {
		error = "You didn't enter a valid phone number in the " + FieldName + " field.\nPlease revise the entry.\n\n";
		}

/*
	if (!(stripped.length == 10)) {
		error = "The phone number is the wrong length. Make sure you included an area code.\n";
		}
*/
return error;
}

//-------------------------------------------------------------------------------

/*	Four Digit Year - Check for invalid characters and invalid length	*/

function checkYear (strng){
	var error = "";
	if (strng == "") {
		error = "You didn't enter a year.\n";
		}

	var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
	if (isNaN(parseInt(stripped))) {
		error = "The year value contains illegal characters.";
		}
	if (!(stripped.length == 4)) {
		error = "Please enter the year value in four-digit format.\n";
		}
	return error;
	}

//-------------------------------------------------------------------------------

/*	Password - Between 3-12 chars, uppercase, lowercase, and numeral	*/

function checkPassword (strng) {
	var error = "";
	if (strng == "") {
		error = "You didn't enter a password.\n\n";
		}
	var illegalChars = /[\W_]/; // allow only letters and numbers
	if ((strng.length < 3) || (strng.length > 12)) {
		error = "The password is the wrong length.\n\n";
		}
	else if (illegalChars.test(strng)) {
		error = "The password contains illegal characters.\n\n";
		}
/*
	else if (!((strng.search(/(a-z)+/)) && (strng.search(/(A-Z)+/)) && (strng.search(/(0-9)+/)))) {
		error = "The password must contain at least one uppercase letter, one lowercase letter, and one numeral.\n\n";
		}
*/
	return error;
	}

//-------------------------------------------------------------------------------

/*	Password duplicates	*/

function checkPassDup(strng1,strng2) {
	var error = "";
	if (strng1 != strng2) {
		error = "The passwords you entered did not match.\n\n";
		}
	return error;
	}

//-------------------------------------------------------------------------------

/*	Username - 4-12 chars, uc, lc, and underscore only	*/

function checkUsername (strng) {
	var error = "";
	if (strng == "") {
		error = "You didn't enter a username.\n\n";
		}
	var illegalChars = /\W/; // allow letters, numbers, and underscores
	if ((strng.length < 4) || (strng.length > 12)) {
		error = "The username is the wrong length.\n\n";
		}
	else if (illegalChars.test(strng)) {
		error = "The username contains illegal characters.\n\n";
		}
	return error;
	}

//-------------------------------------------------------------------------------

/*	String (approximately) resembles a URL	*/

function checkURL(strng) {
	var error	= "";
	var Proto	= strng.indexOf('http://');
	var Period	= strng.lastIndexOf('.');
	var Space	= strng.indexOf(' ');
	var Length	= strng.length - 1;

	if ((Proto != 0) || (Period <= (Proto + 1)) ||  (Period == Length) || (Space  != -1)) {
		error = "The website address you supplied doesn't seem to be valid.\nPlease check that you have the correct spelling.\n\n";
		}
	return error;
	}

//-------------------------------------------------------------------------------

/*	String contains only letters (and spaces if selected).	*/

function isAlphabetic(string, ignoreWhiteSpace, FieldName) {
	var error = "";
	if (string.search) {
		if ((ignoreWhiteSpace && string.search(/[^a-zA-Z\s]/) != -1) ||
			(!ignoreWhiteSpace && string.search(/[^a-zA-Z]/) != -1)) {
			error = "The " + FieldName + " field contains invalid characters.\n\n";
			}
		}
	return error;
}

//-------------------------------------------------------------------------------

/*	Non-Empty Textbox	*/

function isEmpty(strng) {
	var error = "";
		if (strng.length == 0) {
			error = "The mandatory text area has not been filled in.\n\n"
			}
	return error;
	}

//-------------------------------------------------------------------------------

/*	Was Textbox Altered	*/

function isDifferent(strng) {
	var error = "";
	if (strng != "Can\'t touch this!") {
		error = "You altered the inviolate text area.\n\n";
		}
	return error;
	}

//-------------------------------------------------------------------------------

/*	Exactly one radio button is chosen	*/

function checkRadio(checkvalue) {
	var error = "";
	if (!(checkvalue)) {
		error = "Please check a radio button.\n\n";
		}
	return error;
	}

//-------------------------------------------------------------------------------

/*	Valid selector from dropdown list	*/

function checkDropdown(choice) {
	var error = "";
	if (choice == 0) {
		error = "You didn't choose an option from the drop-down list.\n\n";
		}
	return error;
	}

//-------------------------------------------------------------------------------

/*	Valid selector from multiple list	*/

function checkMultiple(choice, FieldName) {
	var error = "";
	if (choice == 0) {
		error = "You need to select at least one option from the " + FieldName + " list.\n\n";
		}
	return error;
	}


//-------------------------------------------------------------------------------

/*	Check String for non-numeric characters	*/

function checkNonNumeric(strng, FieldName) {
	var error = "";
	var strFilter = /[^0-9]/g
	if (strFilter.test(strng)) {
		error = "The " + FieldName + " field contains non-numeric characters.\nPlease enter only numbers in this field.\n\n";
		}
	return error;
	}
	
//-------------------------------------------------------------------------------	

/*	Check String for system-invalid characters	*/

function checkInvalid(strng, FieldName) {
	var error = "";
	var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
	if (strng.match(illegalChars)) {
		error = "The " + FieldName + " field contains invalid characters.\nPlease try again.\n\n";
		}
	return error;
	}
	
//-------------------------------------------------------------------------------

/*	Check Decimal value for invalid characters	*/

function checkisDecimal(strng, FieldName) {
	var i;
	var error = "";
	if(strng == "") {
		error = "There seems to be no value entered for the " + FieldName + "field.\nPlease try again.\n\n";
		}
	else {
		for(i = 0; i < strng.length;i++) {
			if( ((strng.charAt(i) < "0") || (strng.charAt(i) > "9")) && ((strng.charAt(i) != ".") && (strng.charAt(i) != ",")) ) {
				error = "The " + FieldName + " field doesn't seem to be a valid decimal number.\nPlease try again.\n\n";
				}
			}
		}
	return error;
    }

//-------------------------------------------------------------------------------

// -->