<!--

var noiseWords = new Array(); //an array of noise words
noiseWords[0]="about";
noiseWords[1]="1";
noiseWords[2]="after";
noiseWords[3]="2";
noiseWords[4]="all";
noiseWords[5]="also";
noiseWords[6]="3";
noiseWords[7]="an";
noiseWords[8]="4";
noiseWords[9]="and";
noiseWords[10]="5";
noiseWords[11]="another";
noiseWords[12]="6";
noiseWords[13]="any";
noiseWords[14]="7";
noiseWords[15]="are";
noiseWords[16]="8";
noiseWords[17]="as";
noiseWords[18]="9";
noiseWords[19]="at";
noiseWords[20]="0";
noiseWords[21]="be";
noiseWords[22]="$";
noiseWords[23]="because";
noiseWords[24]="been";
noiseWords[25]="before";
noiseWords[26]="being";
noiseWords[27]="between";
noiseWords[28]="both";
noiseWords[29]="but";
noiseWords[30]="by";
noiseWords[31]="came";
noiseWords[32]="can";
noiseWords[33]="come";
noiseWords[34]="could";
noiseWords[35]="did";
noiseWords[36]="do";
noiseWords[37]="each";
noiseWords[38]="for";
noiseWords[39]="from";
noiseWords[40]="get";
noiseWords[41]="got";
noiseWords[42]="has";
noiseWords[43]="had";
noiseWords[44]="he";
noiseWords[45]="have";
noiseWords[46]="her";
noiseWords[47]="here";
noiseWords[48]="him";
noiseWords[49]="himself";
noiseWords[50]="his";
noiseWords[51]="how";
noiseWords[52]="if";
noiseWords[53]="in";
noiseWords[54]="into";
noiseWords[55]="is";
noiseWords[56]="it";
noiseWords[57]="like";
noiseWords[58]="make";
noiseWords[59]="many";
noiseWords[60]="me";
noiseWords[61]="might";
noiseWords[62]="more";
noiseWords[63]="most";
noiseWords[64]="much";
noiseWords[65]="must";
noiseWords[66]="my";
noiseWords[67]="never";
noiseWords[68]="now";
noiseWords[69]="of";
noiseWords[70]="on";
noiseWords[71]="only";
noiseWords[72]="or";
noiseWords[73]="other";
noiseWords[74]="our";
noiseWords[75]="out";
noiseWords[76]="over";
noiseWords[77]="said";
noiseWords[78]="same";
noiseWords[79]="see";
noiseWords[80]="should";
noiseWords[81]="since";
noiseWords[82]="some";
noiseWords[83]="still";
noiseWords[84]="such";
noiseWords[85]="take";
noiseWords[86]="than";
noiseWords[87]="that";
noiseWords[88]="the";
noiseWords[89]="their";
noiseWords[90]="them";
noiseWords[91]="then";
noiseWords[92]="there";
noiseWords[93]="these";
noiseWords[94]="they";
noiseWords[95]="this";
noiseWords[96]="those";
noiseWords[97]="through";
noiseWords[98]="to";
noiseWords[99]="too";
noiseWords[100]="under";
noiseWords[101]="up";
noiseWords[102]="very";
noiseWords[103]="was";
noiseWords[104]="way";
noiseWords[105]="we";
noiseWords[106]="well";
noiseWords[107]="were";
noiseWords[108]="what";
noiseWords[109]="where";
noiseWords[110]="which";
noiseWords[111]="while";
noiseWords[112]="who";
noiseWords[113]="with";
noiseWords[114]="would";
noiseWords[115]="you";
noiseWords[116]="your";
noiseWords[117]="a";
noiseWords[118]="b";
noiseWords[119]="c";
noiseWords[120]="d";
noiseWords[121]="e";
noiseWords[122]="f";
noiseWords[123]="g";
noiseWords[124]="h";
noiseWords[125]="i";
noiseWords[126]="j";
noiseWords[127]="k";
noiseWords[128]="l";
noiseWords[129]="m";
noiseWords[130]="n";
noiseWords[131]="o";
noiseWords[132]="p";
noiseWords[133]="q";
noiseWords[134]="r";
noiseWords[135]="s";
noiseWords[136]="t";
noiseWords[137]="u";
noiseWords[138]="v";
noiseWords[139]="w";
noiseWords[140]="x";
noiseWords[141]="y";
noiseWords[142]="not";

function textSearch(goToThisSearchPage, main) {

 //alert("Sorry.... we are performing a server migration and the search feature will be temporarily unavailable\n\n");
 //return false;
   
 if(main) { //main is signified by passing a "1" to the function
  var tempString = String(document.mainTextSearchDatabase.searchValue.value); //this is a call from the site wide search box
  var testPassed = true; //assume the string is OK 
 }else{ //this is a call from an orgs or links (for instance) search box
  var tempString = String(document.textSearchDatabase.searchValue.value); //the form name when searching an individual database, links orgs etc.
  var testPassed = true; //assume the string is OK
 }//close if(main == 1)
 
 tempString = tempString.replace(/\s+/g," "); //remove instances of multiple white space
 
 if(tempString.charAt(0) == " ") { //check just in case we have a leading or trailing space left over
  tempString = tempString.substr(1);
 }
 
 if(tempString.charAt(tempString.length-1) == " ") {
  tempString = tempString.substr(0, tempString.length-1);
 }
  
 tempString = tempString.replace(/"/g, "");  //strip away any quotes in the text string as this confuses the "exact search"
 tempString = tempString.replace(/'/g, "''");  //escape single apostrophe's for the database 
     
 if(isBlank(tempString)) {
  testPassed = false;  //test has failed
  alert("You must enter some text before executing the search"); 
  return false;
 }//close if(isBlank(tempString)) 
   
 if(testPassed) {

 var exactSearch = false;  //assume this is not an exact search

  if(main) {  
   //nothing has to happen here at this time, there isn't an option to search for an exact phrase for the site wide search.
  }else{  
   if(String(document.textSearchDatabase.exactPhrase) != "undefined") {
    if(document.textSearchDatabase.exactPhrase.checked) {
     tempString = '"' + tempString + '"'; //add double quotes to identify this as an "exactSearch"
	 exactSearch = true;
    }//close if(document.textSearchDatabase.exactPhrase.checked) 
   }//close if(document.textSearchDatabase.exactPhrase != "undefined")
  }//close if(main)
    
  var textString = tempString;

  //create a string free of noise words and formatted for full-text search if searching for a non-exact string
    
  if(!exactSearch) { //do only if not an exact search string 
     
   textString = String(textString.toLowerCase()); //change to lower case for comparison against noiseWord array
   var tSearch = "";
   var foundMatch = "";
   var splitString = textString.split(' '); //create an array of separate words from the textString
   for(i=0; i<splitString.length; i++) { //compare values in the splitString array to the noiseWord array
    foundMatch = false; // re-initialize the variable to each time through the loop
    for(j=0; j<noiseWords.length; j++) {
     if(splitString[i] == noiseWords[j]) {
      foundMatch = true;
     }//close if(splitString[i] == noiseWords[j])
    }//close for(j=0; j<noiseWords.length; j++)
    if(foundMatch == false) { //add the value to the search string if a match was NOT found
     tSearch += " OR " + splitString[i];
    }//close if(foundMatch == false) 
   }//close for(i=0; i<splitString.length; i++)
   
   if(tSearch != "") { //valid search words were found
    tSearch = tSearch.substring(4); //remove the leading OR
   }//close if(!isBlank(String(tSearch)))
   
   textString = tSearch; //the new massaged string, this may be an empty string
   
  }//close if(!exactSearch)
  
  if(!isBlank(String(textString))) {
   if(main) {
    document.mainTextSearchDatabase.searchText.value = textString;  
    document.mainTextSearchDatabase.action = goToThisSearchPage;
    document.mainTextSearchDatabase.submit();  
   }else{
    document.textSearchDatabase.searchText.value = textString;  
    document.textSearchDatabase.action = goToThisSearchPage;
    document.textSearchDatabase.submit();
   }//close if(main)
  }else{
   alert("This search has failed. \n\n The search field contains only \"noise words\"\n which will be ignored by the search engine \n\n Please enter a new value");  
  }//close if(!isBlank(String(textString)))
 }//close if(testPassed)
}//close the textSearch function

//-->

