<!-- //hiding the JavaScript code from old browsers

//
//	2007 MAR 15 JSK - replaced language filter with country filter, changed enable/disable per request 3406
// 2007 APR 30 JSK - changed getfilterarray to test for default United States instead of US
//

//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
}

///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
///
///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
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



//******************************************************************************************//
//	Function Name:	getFilterArray(strDrpSelection)
//	Description:	Filters the Search Type drop down menu based on the document type menu selection
//	Created:		051216 by MTW for Nye
//	Last Edit:		051227 MTW add the language dropdown: disable/enable functionality
//******************************************************************************************//
function getFilterArray(strDrpSelection, strSelected)
{
	//get current selected value
	//selectValue = document.search.search_type.value;
	//alert(strDrpSet);
	//alert(strDrpSelection);
	if ( strDrpSelection == "TDS")
	{
		document.search.country.disabled = false;
		document.search.search_type.disabled = true;	
		document.search.search_type.selectedIndex = 0;	
		document.search.search_type.value = "Product";	
	}
	else if (strDrpSelection == "Product MSDS")
	{
		document.search.country.disabled = false;
		document.search.search_type.disabled = true;	
		document.search.search_type.selectedIndex = 0;	
		document.search.search_type.value = "Product";	
	}
	else if (strDrpSelection == "Raw Material MSDS")
	{
		document.search.country.disabled = true;	
		document.search.search_type.disabled = false;
		for( var i = 0; i < document.search.country.options.length; i ++)
		{
			if(document.search.country.options[i].value == "United States")
			{
				document.search.country.selectedIndex = i;
			}
		}
	
	}

}
//ends JavaScript hiding -->
