<!-- //hiding the JavaScript code from old browsers

//The Character search function
// searches the string, strValue, for a  given character, charSearchm 
//returns true if the character is found and false if not
//The function was designed to be used by the email validation function
function CharacterSearch(strValue, charSearch)
{
	//for loop through each char of the string
	for( i = 0; i < strValue.length; i++ )
	{
		//look for the charSearch character and return true if it is found
		if( strValue.charAt(i) == charSearch)
			return true;
	}//end search for loop  //after this point return false because the charSearch character was not found
	return false
}

///<summary> mtw_041130
/// Email Validation Field_Validator function
/// 1.  Check for a specfied max and min length
/// 2.  Special characters check '" < > / & ;
/// 3.  specialTest
///		a. numbers
///		b. emails
///		c. dates
///</summary>
///<parameters>
/// (intMin, intMax, strFieldName, intCharcterTest, strSpecialTest, strFieldValue)
///	intMin = Min number of characters allowed in the field
///	intMax = Max number of characters allowed in the field
///	strFieldName = The name of the input field
///	intCharcterTest = check for special characters
///		0 - no charcter testing
///		1 - </> testing
///		2 - '"
///		3 = &;
///	strSpecialTest = 
///		"numbers" - ensures all characters are numerical
///		"email" - check for a @ and .
///		"date" - checks for valid date entries
/// strFieldValue = the text entered
///</parameters>
function Field_Validator(intMin, intMax, strFieldName, intCharcterTest, strSpecialTest, strFieldValue)
{	
	//get entry length and save it as intLength
	intLength = strFieldValue.length
	// 1.  Check for a specfied max and min length
	if ((intLength < intMin) || (intLength > intMax))
	{
		// Build alert box message showing how many characters entered
		mesg = "You have entered " + intLength + " character(s) in your " + strFieldName + " field. \n";
		mesg = mesg + "Valid entries are between "+ intMin +" and "+ intMax +" characters.\n";
		mesg = mesg + "Please verify your input and submit again.";
		alert(mesg);
		// return false to stop further processing
		return false;
	} //ends TextField_Length_Validator() function
	// 2.  Special characters check '" < > /
		//intCharcterTest = 0 - no charcter testing, 1 - </> testing, 
	if(intCharcterTest > 0)
	{
		if ( (CharacterSearch(strFieldValue, "<")) || (CharacterSearch(strFieldValue, ">")) )
		{
			mesg = "Avoid using < or > in your data entries. \n";
			mesg = mesg + "Please remove < or > from the " +strFieldName+ " field.";
			alert(mesg);
			return false;
		}
	}
	if(intCharcterTest > 1)
	{
		if ( (CharacterSearch(strFieldValue, "\'")) || (CharacterSearch(strFieldValue, "\"")) )
		{
			mesg = "Avoid using special characters, including quotes in your data entries. \n";
			mesg = mesg + "Please remove all special characters from the " +strFieldName+ " field.";
			alert(mesg);
			return false;
		}
	}
	if(intCharcterTest > 2)
	{
		if ( (CharacterSearch(strFieldValue, "&")) || (CharacterSearch(strFieldValue, ";")) )
		{
			mesg = "Avoid using special characters, including semi-colon or & in your data entries. \n";
			mesg = mesg + "Please remove all special characters from the " +strFieldName+ " field.";
			alert(mesg);
			return false;
		}
	}
	// 3.  special Test 
	if(strSpecialTest == "email")
	{
		if ( ( intLength >= 1) && ((!CharacterSearch(strFieldValue, "@")) || (!CharacterSearch(strFieldValue, "."))) )
		{
			mesg = "Please enter a valid email in the " +strFieldName+ " field.";
			alert(mesg);
			return false;
		}
	}
	if(strSpecialTest == "numbers")
	{
		//setup number reg expression
		regularExpressionNumber = /\d+/;
		if (!regularExpressionNumber.test(strFieldValue))
		{
				mesg = mesg + "The " +strFieldName+ " field entry must be a number.";
				alert(mesg)
				return false;
		}
	}
	if(strSpecialTest == "date")
	{
		regularExpressionDate = /^\d\d?\/\d\d?\/\d\d\d\d/;
		if (!regularExpressionDate.test(strFieldValue))
		{
			mesg = "The "+strFieldName+" was entered incorrectly.  All dates must be formatted as mm/dd/yyyy.";
			alert(mesg);
			return false;			
		}
	}
	return true;
} // ends Email Validation Field_Validator function


//ends JavaScript hiding -->