{
/////////////////////////////////////////////////////////////////////////////////////
// hasValue() checks 'curField' for a value
//    if 'curField' is not null or not empty then it returns true
//    if not it alerts the user with an error 'message' and returns false
/////////////////////////////////////////////////////////////////////////////////////
function hasValue(curField,message)
	{
	var curValue = trim(curField.value);
	if((curValue == "") || (curValue == null))
		{
		if((message != "") && (message != null))
			{
			alert(message);
			curField.focus();
			}
		return(false);
		}
	else
		{
		var tempChar;
		for(i = 0; i < curValue.length; i++)	
			{
			tempChar = curValue.charAt(i);
			if(tempChar != " ")
				return(true);
			}
		return(false);
		}
	return(true);
	}

/////////////////////////////////////////////////////////////////////////////////////
// radioHasValue() checks 'curField' for a value, for 'numOptions' options
//    if 'curField' is not null or not empty then it returns true
//    if not it alerts the user with an error 'message' and returns false
/////////////////////////////////////////////////////////////////////////////////////
function radioHasValue(curField,numOptions,message)
	{
	for(i = 0; i < numOptions; i++)
		{
		if(curField[i].checked)
			return(true);
		}
	if((message != "") && (message != null))
		{
		alert(message);
		}
	return(false);
	}

/////////////////////////////////////////////////////////////////////////////////////
// isNumeric() checks 'curField' to make sure it contains a numeric value
//   if it does it returns true
//   if not it alerts the user with an error message indicating a numeric value is required
//     IF specChars is turned on (is passes a value of 1) THEN
//     (checks each character in string for a value in {0..9 | , | .})
//     ELSE
//		(checks each character in string for a value in {0..9}
/////////////////////////////////////////////////////////////////////////////////////
function isNumeric(curField,specChars)
	{
	var tempVal;
	var curValue = curField.value;
	for(i = 0; i < curValue.length; i++)
		{
		tempVal = curValue.charAt(i);
		if(!(((tempVal >= 0) && (tempVal <= 9)) || ((tempVal == ",") && (specChars == 1)) || ((tempVal == "-") && (specChars == 1)) || ((tempVal == ".") && (specChars == 1))))
			{
			alert("This field must contain a number");
			curField.select();
			curField.focus();
			return(false);
			}
		}
	return(true);
	}
}

/////////////////////////////////////////////////////////////////////////////////////
// validateEmail() makes sure the entered email address is valid
//		- you can choose not to show the alert message if showAlert = false
/////////////////////////////////////////////////////////////////////////////////////
function validateEmail(curField) {
	var emailad = curField.value;
	var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
	var check=/@[\w\-]+\./;
	var checkend=/\.[a-zA-Z]{2,3}$/;
	if(((emailad.search(exclude) != -1)||(emailad.search(check)) == -1)||(emailad.search(checkend) == -1)){
		alert("You have entered an invalid email address.");
		curField.value = "";
		curField.focus();
		return(false);
	}
	else {
		return(true);
	}
}
//*****************************************************************//
// function dropdown validates drop down menus and is compatible   //
// with netscape and IE											   //
//*****************************************************************//

function dropdown(curField,message){
	with(document.ContactUs)
	var curValue = curField.selectedIndex;
	if(curValue == 0) {
		if((message != "") && (message != null)){
			alert(message);
			curField.focus();	
		}		
		return(false);
	}	
	return(true);
}
//////////////////////////////////////////////////////////////////////////////////////
// isLength() checks 'curField' to make sure it contains 'allowedLength' characters //
//   if it does it returns true														//
//   if not it alerts the user with an error 'message' and returns false			//
//////////////////////////////////////////////////////////////////////////////////////
function isLength(curField,allowedLength,message){
	var curValue = curField.value;
	if(curValue.length != allowedLength){
		alert(message);
		curField.focus();
		return(false);
	}
	else
		return(true);
}


function isLength2(curField,maxLength,minLength,message){
	var curValue = curField.value;
	if((curValue.length > maxLength) || (curValue.length < minLength)){
		alert(message);
		curField.focus();
		return(false);
	}
	else
		return(true);
}
//////////////////////////////////////////////////////////////////////////////
// isValidDate() checks 'curField' for a proper date = mm/dd/yyyy			//
//   if it does it returns true												//
//   if not it alerts the user with an error 'message' and returns false	//
//////////////////////////////////////////////////////////////////////////////
function isValidDate(curField){
	var curValue = curField.value;
	// check for 10 characters
	if(!isLength(curField,10,'Invalid Date, must be in the format: mm/dd/yyyy')){
		curField.focus();
		return(false);
	}
	// check for '/' in character positions 3 & 5 (or 2 & 4 starting with 0)
	else if((curValue.charAt(2) != "/") || (curValue.charAt(5) != "/")){
		alert("Invalid Date Format, must be in format: mm/dd/yyyy");
		curField.focus();
		return(false);
	}
	else{
		// make sure month is in range (1..12)
		var monthChar1 = curValue.charAt(0);
		var monthChar2 = curValue.charAt(1);
		if(monthChar1 == 0){
			if(monthChar2 < 1){
				alert("Invalid Date: month is out of range");
				curField.select();
				curField.focus();
				return(false);
			}
		}
		else if(monthChar1 == 1){
			if(monthChar2 > 2){
				alert("Invalid Date: month is out of range");
				curField.select();
				curField.focus();
				return(false);
			}
		}
		else{
			alert("Invalid Date: month is out of range");
			curField.select();
			curField.focus();
			return(false);
		}
		
		// make sure day is in range (1..31)
		var dayChar1 = curValue.charAt(3);
		var dayChar2 = curValue.charAt(4);
		
		var maxDay1;
		var maxDay2;
		var month = monthChar1.concat(monthChar2);
		switch(month){
			case "01","03","05","07","08","10","12":
				maxDay1 = "3";
				maxDay2 = "1";
				break;
			case "02":
				maxDay1 = "2";
				maxDay2 = "9";
				break;
			case "04","06","09","11":
				maxDay1 = "3";
				maxDay2 = "0";
				break;
		}
		
		//don't allow 00 as day
		if(dayChar1 == 0){
			if(dayChar2 < 1){
				alert("Invalid Date: day is out of range");
				curField.select();
				curField.focus();
				return(false);
			}
		}
		if((dayChar1 > maxDay1) || ((dayChar1 == maxDay1) && (dayChar2 > maxDay2))){
			alert("Invalid Date: day is out of range");
			curField.select()
			curField.focus();
			return(false);
		}
		// make sure year is in range
		var yearString = curValue.substring(6);
		var year = parseInt(yearString);
		if((year < 1900) || (year > 2100)){
			alert("Invalid Date: year is out of range");
			curField.focus();
			return(false);
		}
	}
	return(true);
}


function ltrim ( s ){
	return s.replace( /^\s*/, "" )
}
function rtrim ( s ){
	return s.replace( /\s*$/, "" );
}
function trim ( s ){
	return rtrim(ltrim(s));
}