/*
utility.js
Date created: 04/10/2007
This file is created to support the input validation process for the EDO Search procedure. Include file.

*/

function ValidateInput( form )
{
	try
	{
		var arElementsToCheck = document.all("ValidateThisField"); 
				
		for (var i=0; i < arElementsToCheck.length; i++)
		{
			//alert (arElementsToCheck(i).value);
			var strOrigValue = arElementsToCheck(i).value
			var strValidValue = strOrigValue.replace(/<|\>|\/|\"|\%|\;|\(|\)|\+|\[|\]|\*|\^|\{|\}|\=|/g,"")
			if (strValidValue != strOrigValue)
			{
				alert ("The search criteria contain malicious characters." + '\n' +
						"Please remove malicious characters from the search criteria." + '\n' +
						"Malicious characters are: / < > % ; ( ) + [ ] * ^ { } = " + '"');
				return false ;				
			}
			else
			{
				arElementsToCheck(i).value = strOrigValue.replace(/'/g,"''");
			}					
		}
		
		return true;
	}
	catch(err)
	{
		//throw (e);
	}
}

function ValidateInputTS( form )  //text search form
{
	try
	{
		var arElementsToCheck = document.all("ValidateThisField").value; 		
		//alert (arElementsToCheck);			
		var strValidValue = arElementsToCheck.replace(/<|\>|\/|\"|\%|\;|\(|\)|\+|\[\]|\*|\^|\{|\}|\=|/g,"");
		//alert (strValidValue);
		if (strValidValue != arElementsToCheck)
		{
			alert ("The search criteria contains malicious characters." + '\n' +
						"Please remove malicious characters from the search criteria." + '\n' +
						"Malicious characters are: / < > % ; ( ) + [ ] * ^ { } = " + '"');
			return false;
		}		
		return true ;
	}
	catch(err)
	{
		//throw (e);
	}
}