	function trim(value) {
		var temp = value;
		var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
		if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
		var obj = /  /g;
		while (temp.match(obj)) { temp = temp.replace(obj, " "); }
		return temp;
	}
	function CheckData(form) {	
		form.SRCH.value=trim(form.SRCH.value);
		if (form.SRCH.value.length < 3 && (form.fabricant==null || form.fabricant.value == "NoPref"))
		{	
			if (document.forms['Keyword']==form) {
				if (form.fabricant.value.length > 0 && form.fabricant.value != "NoPref" && form.SRCH.value.length == 0)
				{
					form.submit();
					return true;
				}
			}
			
			//test pour rechercher seulement avec la listbox
			alert("Veuillez saisir au moins 3 caractères. Cliquez sur le point d’interrogation pour plus de détails.");
			return false;
		}
		else
		{				
			form.submit();
			return true;
		}
	}
	function CheckDataNRO(form) 
	{	//New function made by NRO to handle the string writted in the TextSearch box
		form.SRCH.value=trim(form.SRCH.value);
		
		if (form.SRCH.value.length < 3 && (form.fabricant==null || form.fabricant.value == "NoPref"))
		{	
			if (document.forms['Keyword']==form) {
				
				if (form.fabricant.value.length > 0 && form.fabricant.value != "NoPref" && form.SRCH.value.length == 0)
				{
					form.submit();
					return true;
				}
			}
			
			//test pour rechercher seulement avec la listbox
			alert("Veuillez saisir au moins 3 caractères. Cliquez sur le point d’interrogation pour plus de détails.");
			return false;
		}
		else
		{	
			if (form.fabricant.value.length > 0 && form.fabricant.value != "NoPref" && form.SRCH.value.length == 0)
				{
					form.submit();
					return true;
				}
			else
				{
					var aString = new String
					var splitter= "\"";
					var stringArray = new Array();
					var TheChar=""
				
					aString = form.SRCH.value;
					form.SRCH.value='';
				
					//Check to eliminate all the characters not contained into the isAccepted function			
					for(i=0;i<aString.length ;i++)
					{
						TheChar = aString.charAt(i);
						if(isAccepted(TheChar))
						{
							form.SRCH.value = form.SRCH.value  + TheChar;
						} else {
							form.SRCH.value = form.SRCH.value  + ' ';
						}
					}
					
					form.SRCH.value=trim(form.SRCH.value);
					
					//check now for quoted sequence
					splitter= "\"";
					aString = form.SRCH.value;
					form.SRCH.value="";
					stringArray = aString.split(splitter) ;
					if (stringArray.length==3)
					{
						form.SRCH.value = "\"" + stringArray[1] + "\""; 
						
					}
					else
					{
						for(var i=0;i<stringArray.length ;i++)
						{	
							form.SRCH.value = form.SRCH.value + stringArray[i];
						}
						
						//check to see if all space separated parts of the query make at least 3 char
						splitter= " ";
						aString = form.SRCH.value;
						
						stringArray = aString.split(splitter) ;
									
						for(var i=0;i<stringArray.length ;i++)
						{	
							if (stringArray[i].length <3)
							{
								alert('Chaque entrée distincte doit comporter au moins 3 caractères ou les mettre entre guillemets. Cliquez sur le point d’interrogation pour plus de détails. ')
								return false;
							}
							
						}
					}
										
					form.submit();
					return true;
				}
		}
	}
	
	function nCheckDataNRO(form) {
		CheckDataNRO(form);
	}
	function nCheckData(form) {
		CheckData(form);
	}
	
	
	function isAccepted(theChar)
	{
		//Blank space is considered a character
		var charArray = new Array(
			' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 
			'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 
			'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 
			'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 
			'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 
			'é', 'è', 'à', 'ù', 'ç', '1', '2', '3', '4',
			'5', '6', '7', '8', '9', '0', '"', '°', 'â',
			'ô', 'û', 'î', 'ê', 'ä', 'ï', 'ö', 'ë', 'ü',
			's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ',',
			'\'','-', '/', '.');


			for (j = 0; j < charArray.length; j++)
				if (theChar == charArray[j])
					return true;
		return false;
	}
