// **********************************************
// Build a local Find form.
//
// Adapted, Feb. 2003., Kris K
// **********************************************
function Find() {
 str = "<form name=\"searchform\" action=\"\" \
        onSubmit=\"if(this.searchtext.value!=null && this.searchtext.value!='') findString(this.searchtext.value);return false\" \
        style=\"padding:0px;margin:0px;\">"
     //+ "<p class=\"fmFine\">Find on this page<br>"
     + "<input type=\"text\" name=\"searchtext\" value=\"\" size=\"6\" class=\"fmField\">"
     + "<input type=\"submit\" name=\"searchbutton\" value=\"find\" class=\"fmButton\">"
     + "</form>"

  document.write(str);
}

/* Was:
<form name="f1" action="" 
onSubmit="if(this.t1.value!=null && this.t1.value!='')
findString(this.t1.value);return false">
<input type="text" name=t1 value="text" size=20>
<input type="submit" name=b1 value="Find">
</form>
*/


// **********************************************
// Find text on local page.
//
// cf. http://www.javascripter.net/faq/searchin.htm
// 
// **********************************************

var TRange=null

function findString (str) {
 if (parseInt(navigator.appVersion)<4) return;
 var strFound;
 if (navigator.appName=="Netscape") {

  // NAVIGATOR-SPECIFIC CODE

  strFound=self.find(str);
  if (!strFound) {
   strFound=self.find(str,0,1)
   while (self.find(str,0,1)) continue
  }
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {

  // EXPLORER-SPECIFIC CODE

  if (TRange!=null) {
   TRange.collapse(false)
   strFound=TRange.findText(str)
   if (strFound) TRange.select()
  }
  if (TRange==null || strFound==0) {
   TRange=self.document.body.createTextRange()
   strFound=TRange.findText(str)
   if (strFound) TRange.select()
  }
 }
 if (!strFound) alert ("String '"+str+"' not found.")
}

