var strarrSearchStopWords="about/after/all/also/an/and/another/any/are/as/at/be/$/because/been/before/being/between/both/but/by/came/can/come/could/did/do/each/for/from/get/got/has/had/he/have/her/here/him/himself/his/how/if/in/into/is/it/like/make/many/me/might/more/most/much/must/my/never/now/of/on/only/or/other/our/said/same/see/should/since/some/still/such/than/that/the/their/them/then/there/these/they/this/those/through/to/too/under/up/very/was/we/well/were/what/when/where/which/while/who/with/would/you/your/'/&/%/(/)/{/}/[/]/</>/?/!/;/:/=/=;/~/`/,";
strarrSearchStopWords=strarrSearchStopWords+"/" +String.fromCharCode(34)  
var arrSearchStopWords=strarrSearchStopWords.split("/");
var SearchStarted=false;
var submitDone = false;

//////////////////////////////
function Search(url, Form, textBox,IfAdv)
	 {
      
     
    var temp=new String(document.forms[Form][textBox].value);
    temp=temp.replace(/^\s+/,'')
    temp=temp.replace(/\s+$/,'')
  
    if (IfAdv==undefined)
       {
          if (temp=="") 
	     {
              SearchStarted=false;
             /// document.body.style.cursor = "auto"; 
              window.alert("Please provide search criteria");
		      
		       }
           else
            {
            DoChecking (url, Form, textBox,temp);
            }
     }
    else
    {  
    	if (temp!="")
           {
           DoChecking (url, Form, textBox,temp);
           
           }
	      
	 else
	 {      
	      ///document.body.style.cursor = "auto"; 
          SearchStarted=false;
          document.forms[Form].action=url+"?s="+ escape(temp);	 
	      document.forms[Form].submit();}
        }   
}

/////////////////////////////

function CheckFTS(strWord,n)
{
	 
       
       var ifStopWord=false;
       if (strWord=="-")
       { ifStopWord=true;}
       else
       {for (i=0;i<n;i++)
	{
         if (arrSearchStopWords[i]==strWord)
          ifStopWord=true;
          break;
	}}
       //alert(strWord + " " + ifStopWord);
       return ifStopWord;
}


/////////////////////////
function CheckStopWord(strWord,n)
{


var ifStopWord=false;
  
   for (i=0;i<n;i++)
   {
    if (arrSearchStopWords[i]==strWord)
      {
       ifStopWord=true;     break;
      }
     else   
       {
        if (strWord.length<2 )
         {
          ifStopWord=true;
          break;
         }
                 
	
     }


}
return ifStopWord;
}




/////////////////////////////
function CheckStopWords(strInput)

{
 	var strWord=new String(strInput);
	 var n = arrSearchStopWords.length;
	 var strWords=new String();
	 var StopWordCount=0;
         var FTSCount=0;
 
	 strWord=strWord.toLowerCase();
	 strWord=strWord.replace(/^\s+/,'')
	 strWord=strWord.replace(/\s+$/,'')
 

	for (k=0;k<strWord.length;k++)
	{strWord=strWord.replace("  "," ") }	

	strWords=strWord.split(" ")
	var totWords=strWords.length;

	for (k=0;k<totWords;k++)
	{
 
   	//window.alert(strWords[k])

        if (strWords[k].length==2)
           {
            
            if  (CheckFTS(strWords[k].substr(0,1),n)==true) 
               {FTSCount=FTSCount+1;            }
               
           if  (CheckFTS(strWords[k].substr(1,1),n)==true) 
               {FTSCount=FTSCount+1;   }
            
            // alert(FTSCount);
         
          }
       
  
if (FTSCount>0)
  {StopWordCount=StopWordCount+1;}  
    
  if (CheckStopWord(strWords[k],n)==true)
	{ 
         StopWordCount=StopWordCount+1;
        }
 }




if (StopWordCount>=totWords)
  {       return true;     }
    else    
   
        {return false;}    

}
////////////
function SubmitSearch(url,Form, textBox)
{
	
	if (!submitDone) 
	  {
       submitDone = true;
	   ///document.body.style.cursor = "wait";
	   SearchStarted=true;
	   WindowsStatusMessage('Searching ...');
	   var temp=new String(document.forms[Form][textBox].value);
	   temp=temp.replace(/^\s+/,'');
	   temp=temp.replace(/\s+$/,'');
	   if (temp!="")
	      {
            Search (url,Form, textBox);
          }
	  else
          {
         SearchStarted=false;
         } 
     }
    else
    {
     
     alert ("Already submitted, please wait!");
     return false;
    }     
}

/////////
function AdvSearch(url, Form, textBox)
{
		var temp=new String(document.forms[Form][textBox].value);
		temp=temp.replace(/^\s+/,'')
		temp=temp.replace(/\s+$/,'')
      
          if (temp=="") 
           	    {///document.body.style.cursor = "auto"; 
           	    window.alert("Please provide search criteria"); 
               return false;      
                     }

          else
			{	if (!submitDone) 
				{
					submitDone = true;
					Search(url, Form, textBox,"true");
				}
				else
				{
				alert ("Already submitted, please wait!");
				return false;
				}       
			}

}
//////

function ResetSearch(Form, textBox)
{
///document.body.style.cursor = "auto"; 
SearchStarted=false;
window.alert("Please check your search criteria");
document.forms[Form][textBox].value=""; 
}

/////////
function DoChecking (url, Form, textBox,temp)
{

 if (CheckStopWords(temp)==true )
    {
     ResetSearch(Form,textBox)
     //return false;
     }
else
    {
      if (temp.length<2 )
         { 
          ResetSearch(Form,textBox)
          //return false;
          }
      else
         { 
          
         document.forms[Form].action=url+"?s="+ escape(temp);
        // document.body.style.cursor = "auto";
         document.forms[Form].submit(); 
	 }
    }
}

function jumpTo(menu){
	var url = menu.options[menu.selectedIndex].value;
	if (url.indexOf('850')!=-1){	    
	    window.open(url);
	}
    else if( url != "" ) self.location.href = url;
}
///////////////////////
function WindowsStatusMessage(strMessage)
{
if (SearchStarted==false)
{window.defaultStatus=strMessage;}
else
{window.defaultStatus='Searching ...';}
}
/////////
function ResetWindowsStatus()
{
if (SearchStarted==false)
{window.defaultStatus='                             ';}
}

/** * busyProcess *  * Add a busy indicator over an element while running the function it invokes * @param {Object} element clicked on to invoke the task * @param {Function} function to invoke after adding visual indicator */       
function busyProcess(element, func) {   
var busyIndicator =new Element("div", {id: "busy"});
busyIndicator.innerHTML = '<img src="../images/wait30trans.gif" width="30px" height="30px" />Searching... ';   
busyIndicator.setStyle(busyIndicator, {zIndex: "100",                           
                        position: "absolute",                           
                        fontWeight:"bold",                           
                        height: "30px"});  
busyIndicator.clonePosition($(element), busyIndicator,{setWidth: false, setHeight: false});   

document.getElementById("search").appendChild(busyIndicator);              
// function needs to be deferred in order for the browser to render the   
// busy indicator, but we need to wrap it in order to remove the busy indicator   
// when it's done   
func = func.wrap(      
function(proceed) {         
proceed();         
      
});   
func.defer();
//busyIndicator.remove();
}