// Distribution Rights Granted to: http://www.web-search.com/
// All code in this script is Copyright(C) 1996, Justin Boyan
// For documentation and more info, see: http://www.cs.cmu.edu/~jab/snark/
// This is SNARK Version 1.0, 18 May 1996 

var MAX_ENGINES = 75;
var SNARK_STRING = "hunting+the+snark";
cansrch = true;

function MakeArray(n)
{
  for (var i = 1; i <= n; i++)
  {
    this[i] = 0;
  }
  this.maxlen = n;
  this.len = 0;
  return this;
}


var engs = new MakeArray(MAX_ENGINES);


function find_substring(needle, haystack)
{
  var i, needlen = needle.length, haylen = haystack.length;
  for (i=0; i<=haylen-needlen; i++)
  {
    if (needle == haystack.substring(i,i+needlen))
      return i;
  }
  return false;
}


function Engine(name, opts, home, search)
{
  var snark = find_substring(SNARK_STRING, search);
  this.name = name;
  this.opts = opts;
  this.home = home;
  this.pre_snark = search.substring(0,snark);
  this.post_snark= search.substring(snark+SNARK_STRING.length, search.length);
}


function Add(name, opts, home, search)
{
  engs.len++;
  if (engs.len <= engs.maxlen)
  {
    engs[engs.len] = new Engine(name, opts, home, search)
  }
  else
  {
    alert("Better increase MAX_ENGINES: " + engs.len + ">" + engs.maxlen)
  }
}


// ADD YOUR OWN SEARCH ENGINES BELOW. (See http://www.cs.cmu.edu/~jab/snark/ )


Add("Google", "SELECTED",
"http://www.google.com",
"http://www.google.com/search?q=hunting+the+snark&num=10&sa=Google+Search" );

Add("AltaVista", "",
   "http://altavista.digital.com/",
   "http://altavista.digital.com/cgi-bin/query?pg=q&what=web&fmt=d&q=hunting+the+snark" );

Add("Lycos UK sites", "",
   "http://www.lycos.co.uk/",
   "http://www.lycos.co.uk/cgi-bin/pursuit?matchmode=and&mtemp=main.sites&etemp=error&query=hunting+the+snark&cat=brit" );

Add("Lycos", "",
   "http://www.lycos.co.uk/",
   "http://www.lycos.co.uk/cgi-bin/pursuit?matchmode=and&mtemp=main.sites&etemp=error&query=hunting+the+snark&cat=lycos" );

Add("Netscape", "",
   "http://search.netscape.com/",
   "http://search.netscape.com/cgi-bin/search?cp=srpwidsrc&search=hunting+the+snark" );

Add("HotBot", "",
"http://www.hotbot.com",
"http://hotbot.lycos.com/?MT=hunting+the+snark&SM=MC&DV=0&LG=any&DC=10&DE=2&BT=H&x=26&y=8"); 

Add("Yahoo", "",
"http://www.yahoo.com",
"http://search.yahoo.com/search?o=1&p=hunting+the+snark&d=y&za=default&h=s&g=0&n=10"); 

Add("Open Directory", "",
"http://www.web-search.com/open.html",
"http://www.web-search.com/Open/anacondaodpp.cgi?search=hunting+the+snark" ); 

Add("Search A Lot", "",
"http://search.searchalot.com",
"http://search.searchalot.com/Searchalot?lang=1&qtype=0&query=hunting+the+snark&phrases=on" ); 

Add("All The Web", "",
"http://www.alltheweb.com",
"http://www.alltheweb.com/cgi-bin/asearch?type=all&query=hunting+the+snark" ); 

Add("Ask Jeeves", "",
"http://www.askjeeves.com",
"http://www.askjeeves.com/main/askjeeves.asp?ask=hunting+the+snark&origin=&site_name=Jeeves&metasearch=yes" ); 

Add("InfoSeek", "",
"http://infoseek.go.com",
"http://infoseek.go.com/Titles?col=WW&qt=hunting+the+snark&svx=home_searchbox&sv=IS&lk=noframes" ); 

Add("WebCrawler", "",
"http://www.webcrawler.com",
"http://www.webcrawler.com/cgi-bin/WebQuery?search=hunting+the+snark&src=wc_results&showSummary=true" ); 

Add("GoTo.Com", "",
"http://www.goto.com",
"http://www.web-search.com/cgi-bin/texis/webinator/goto/main.html?q=hunting+the+snark&searchhost=GoTo.com"); 

Add("Web-Search.Com", "",
"http://www.web-search.com",
"http://www.web-search.com/cgi-bin/texis/webinator/meta/main.html?q=hunting+the+snark&searchhost=WebSearch&searchhost=OpenDirectory&searchhost=Excite&searchhost=Thunderstone"); 

Add("Jayde.Com", "",
"http://www.jayde.com",
"http://www.jayde.com/cgi-bin/search.cgi?category_num=none&query=hunting+the+snark&x=13&y=14" ); 

Add("QuestFinder.Com", "",
"http://www.questfinder.com/",
"http://www.questfinder.com/search/search.cgi?s=hunting+the+snark&category=catx3dx%3DALL&match=and&ul=either" ); 

Add("NoImages.Com", "",
"http://www.noimages.com",
"http://www.web-search.com/cgi-bin/texis/webinator/image/main.html?q=hunting+the+snark&searchhost=GoTo.com&searchhost=WebSearch&searchhost=OpenDirectory&searchhost=Excite&searchhost=Thunderstone"); 

Add("Thunderstone", "",
"http://www.thunderstone.com/",
"http://search.thunderstone.com/texis/websearch/?q=hunting+the+snark&max=10&w3meta=1" ); 

Add("SavvySearch", "",
"http://www.savvysearch.com/",
"http://www9.savvysearch.com/search?q=hunting+the+snark&op=a&cat=11" ); 

//new to add - 

// ADD YOUR OWN SEARCH ENGINES ABOVE. (See http://www.cs.cmu.edu/~jab/snark/ )


function HandleForm(form)
{
  form.submit(); // This fixes a mysterious Netscape bug. Without this line,
  // you can't use <enter> to start the search the first time.
  var i, oldq=form.query.value, newq="";
  for (i=0; i<oldq.length; i++)
  { // compress [ ]+ into \+
    var thischar = oldq.charAt(i);
    if (thischar != ' ')
      newq += thischar;
    else if (lastchar != ' ')
      newq += '+';
    lastchar = thischar;
  }
  var eng = engs[1+form.service.selectedIndex];
  location.href = newq ? eng.pre_snark + newq + eng.post_snark : eng.home;
}


function DisplayForm()
{
 document.writeln('<tr>');
 document.writeln('<td>');

  //original bit
  document.writeln('<FORM OnSubmit="HandleForm(this); return false">');
  document.writeln('<SELECT name="service">');
  for (i=1; i <= engs.len; i++)
  {
    document.writeln("<OPTION " + engs[i].opts + "> " + engs[i].name);
  }
  document.writeln('</SELECT> <BR> <INPUT size=20 name="query" value="Ecclesfield"> <BR>');
  document.writeln('<input type=submit value=" Search">');
  document.writeln('<input type=reset value=" Reset">');
  document.writeln('</FORM>');
  //end original

  document.writeln('</td>');
  document.writeln('</tr>');

  //Display How to Use
  document.writeln('<tr>');
  document.writeln('<td align="center">Simply type your');
  document.writeln('search string, select the search engine,');
  document.writeln('and press &quot;Search&quot;.</td>');
  document.writeln('</tr>');
}

//http://www.monkeysweat.com/cgi-bin/search.cgi?keywords=hunting+the+snark

//<table border=1 width="300" cellpadding="2"><tr>
//<td bgcolor="#336699">
//<form method="POST" action="http://www.england-online.co.uk/cgi-bin/search/search.pl"> 
//<strong><font face="Arial" color="#FFcc22">
//<IMG BORDER=0 ALT="England Online" SRC="http://www.england-online.co.uk/images/searchbox.gif"><BR> 
//</strong><input type="text" name="search" size="30">
//<input type="submit" value="Search" name="action"></form></td></tr></table>