
// gIgnoredWords is the list of words that you don't want included in the search
var gIgnoredWords = ["0","1","2","3","4","5","6","7","8","9","a","b","d","f","g","h","i","k","l","m",
"n","o","p","q","r","s","t","u","v","w","y","z an","as","at",
"be","do","he","if","in","is","it","my","of","on","or","to","up",
"we","all","any","are","and","but","can","did","for","get","got",
"has","had","her","him","his","how","now","our","out","see","the",
"too","was","way","who","you","also","been","both","came","come",
"each","from","have","here","into","like","make","many","more",
"most","much","must","only","over","said","same","some","such",
"take","than","that","them","then","they","this","very","well",
"were","what","with","your","it's","about","after","being","could",
"might","never","other","since","still","their","there","these",
"those","under","where","which","while","would","before","should",
"another","because","between","himself","through","not","and",
"near","about","after","all","also","another","as","at","be","$",
"because","been","before","being","between","both","but","by",
"came","can","come","could","do","he","have","here","himself",
"if","in","into","might","must","my","never","now","our","out",
"see","should","since","still","the","their","there","these",
"those","through","too","under","was","way","where","which",
"while","who","would","you","an","'" ];

// is a specified word in the list of ignored words?

function isIgnoredWord( sWord ) 
{
var ix;
sWord = sWord.toLowerCase();
for ( ix = 0; ix < gIgnoredWords.length; ix++ ) 
	{
	if ( gIgnoredWords[ ix ] == sWord )
	return true;
	}
return false;
}


// check the contents of a single form element
function checkTextElement( elementObj ) 
{
var searchString = elementObj.value;
var s = "";
var oneWord, c;
var aWords, aKeepWords = new Array();
var flLastWasSpace = false;
var i, j;

//loop through the words in the text of the element,
//remove those which are listed in gIgnoreWords
	for ( i = 0; i <= searchString.length; i++ ) 
	{
	c = searchString.charAt( i );
	if ( ( c >= 'A' && c <= 'Z' ) || ( c >= 'a' && c <= 'z' ) || ( c >= '0' && c <= '9' ) || ( c == '\'' ) || (c=="*")) {
	s += c;
	flLastWasSpace = false;
	}
	else 
	{
	// only add one space between words
	if ( ! flLastWasSpace )
	s += ' ';
	flLastWasSpace = true;
	}
	}
	
	
	aWords = s.split( ' ' );
	
	for ( i = 0; i < aWords.length; i++ ) {
		oneWord = aWords[ i ].toLowerCase();
		
		// remove trailing s
		
		//if ( oneWord.charAt( oneWord.length - 1 ) == 's' ) 
		//{
		//	oneWord = oneWord.substring( 0, oneWord.length - 1 );
		//}
		
		if ( ( oneWord.length > 0 ) && ! isIgnoredWord( oneWord ) )
			aKeepWords[ aKeepWords.length ] = oneWord;
	}
	
	
	if ( aKeepWords.length > 0 ) {
		elementObj.value = aKeepWords.join( ' ' );
		return true;
	}
	else {
		elementObj.value = '';
		alert("Try with Correct Word(s)");
		return false;
	}
}


// this script runs when the search form is submitted
function preSubmitSearchForm( formObj ) 
{
var flOneGoodField;
flOneGoodField = checkTextElement( formObj.txtsearchFor);
return flOneGoodField;
}

