var URL          = new urlBase('index', 'category', 'url');
var choiceString = getCookie('myChoices');
if (choiceString == null || choiceString.length != 9){choiceString = '00000000'}
var altavista    = 0;
var excite       = 1;
var google		 = 2;
var hotbot       = 3;
var looksmart    = 4;
var lycos        = 5;
var magellan     = 6;
var metacrawler  = 7;
var webcrawler   = 8;
var yahoo        = 9;

var webPrefix    = 0;
var roadMaps     = 1;
var yellowPages  = 2;
var whitePages   = 3;
var stocks       = 4;
var webSuffix    = 5;

URL.addRecord(altavista, roadMaps, 'http://maps.altavista.com/cgi-bin/mapcgi');
URL.addRecord(altavista, yellowPages, 'http://altavista.switchboard.com/bin/cgidir.dll?MG=&MEM=212');
URL.addRecord(altavista, whitePages, 'http://altavista.switchboard.com/bin/cgiqa.dll?MG=&MEM=212');
URL.addRecord(altavista, webPrefix, 'http://www.altavista.com/cgi-bin/query?pg=q&what=web&fmt=.&q=');
URL.addRecord(altavista, stocks, 'http://money.altavista.com/');
URL.addRecord(altavista, webSuffix, '');

URL.addRecord(excite, roadMaps, 'http://city.net/maps/address/');
URL.addRecord(excite, yellowPages, 'http://yellowpages.zip2.com/');
URL.addRecord(excite, whitePages, 'http://www.excite.com/reference/people_finder/');
URL.addRecord(excite, webPrefix, 'http://search.excite.com/search.gw?look=default&trace=b&collection=web&search=');
URL.addRecord(excite, stocks, 'http://quicken.excite.com/');
URL.addRecord(excite, webSuffix, '');

URL.addRecord(google, roadMaps, 'http://www.google.com/search?cat=gwd%2FTop%2FReference%2FMaps&hl=en&q=');
URL.addRecord(google, yellowPages, 'http://www.google.com/search?sa=Google+Search&cat=gwd%2FTop%2FReference%2FDirectories%2FAddress_and_Phone_Numbers%2FYellow_Pages&hl=en&q=');
URL.addRecord(google, whitePages, 'http://www.google.com/Top/Reference/Directories/Address_and_Phone_Numbers/White_Pages?tc=1/');
URL.addRecord(google, webPrefix, 'http://www.google.com/search?hl=en&q=');
URL.addRecord(google, stocks, 'http://www.google.com/Top/Business/Investing/Stocks_and_Bonds?tc=1/');
URL.addRecord(google, webSuffix, '');

URL.addRecord(hotbot, roadMaps, 'http://www.hotbot.com/partners/maps.asp');
URL.addRecord(hotbot, yellowPages, 'http://www.hotbot.com/partners/business.asp');
URL.addRecord(hotbot, whitePages, 'http://www.hotbot.com/partners/people.asp');
URL.addRecord(hotbot, webPrefix, 'http://www.hotbot.com/?MT=');
URL.addRecord(hotbot, stocks, 'http://stocks.hotbot.com/');
URL.addRecord(hotbot, webSuffix, '&SM=MC&DV=0&LG=any&DC=10&DE=2&submit=SEARCH&_v=2&OPs=MDRTP');

URL.addRecord(looksmart, roadMaps, 'http://www.mapblast.com/mapblast/start.hm');
URL.addRecord(looksmart, yellowPages, 'http://www.looksmart.com/r?l&tunnel=businesses.html');
URL.addRecord(looksmart, whitePages, 'http://www.looksmart.com/r?l&tunnel=people.html');
URL.addRecord(looksmart, webPrefix, 'http://www.looksmart.com/r_search?look=&key=');
URL.addRecord(looksmart, stocks, 'http://www.stockpoint.com/');
URL.addRecord(looksmart, webSuffix, '&search=0&x=9&y=4');

URL.addRecord(lycos, roadMaps, 'http://www.lycos.com/roadmap.html');
URL.addRecord(lycos, yellowPages, 'http://yp.gte.net/sform.phtml?SRC=lycos&STYPE=S');
URL.addRecord(lycos, whitePages, 'http://www.whowhere.lycos.com/Phone');
URL.addRecord(lycos, webPrefix, 'http://www.lycos.com/cgi-bin/pursuit?matchmode=and&cat=lycos&query=');
URL.addRecord(lycos, stocks, 'http://investing.lycos.com/');
URL.addRecord(lycos, webSuffix, '&x=50&y=11');

URL.addRecord(magellan, roadMaps, 'http://city.net/maps/');
URL.addRecord(magellan, yellowPages, 'http://yellowpages.zip2.com/');
URL.addRecord(magellan, whitePages, 'http://www.excite.com/reference/people_finder/');
URL.addRecord(magellan, webPrefix, 'http://www.mckinley.com/search.gw?search=');
URL.addRecord(magellan, stocks, 'http://quicken.excite.com/investments/quotes/');
URL.addRecord(magellan, webSuffix, '&c=web&look=magellan');

URL.addRecord(metacrawler, roadMaps, 'http://www.infospace.com/info.go2net/fillc?nf=mapdir.html');
URL.addRecord(metacrawler, yellowPages, 'http://www.athand.com/');
URL.addRecord(metacrawler, whitePages, 'http://www.infospace.com/info.go2net/index_ppl.html');
URL.addRecord(metacrawler, webPrefix, 'http://search.go2net.com/crawler?general=');
URL.addRecord(metacrawler, stocks, 'http://www.stocksite.com/research/');
URL.addRecord(metacrawler, webSuffix, '&method=0&target=&region=0&rpp=20&timeout=5&hpe=10');

URL.addRecord(webcrawler, roadMaps, 'http://webcrawler.city.net/maps/');
URL.addRecord(webcrawler, yellowPages, 'http://yellowpages.zip2.com/webc');
URL.addRecord(webcrawler, whitePages, 'http://webcrawler.com/reference/people_finder');
URL.addRecord(webcrawler, webPrefix, 'http://www.webcrawler.com/cgi-bin/WebQuery?searchText=');
URL.addRecord(webcrawler, stocks, 'http://quicken.webcrawler.com/investments/quotes/');
URL.addRecord(webcrawler, webSuffix, '');

URL.addRecord(yahoo, roadMaps, 'http://maps.yahoo.com/py/maps.py');
URL.addRecord(yahoo, yellowPages, 'http://yp.yahoo.com/');
URL.addRecord(yahoo, whitePages, 'http://people.yahoo.com/');
URL.addRecord(yahoo, webPrefix, 'http://search.yahoo.com/bin/search?p=');
URL.addRecord(yahoo, stocks, 'http://finance.yahoo.com/');
URL.addRecord(yahoo, webSuffix, '');

function urlBase(arg1, arg2, arg3){
  var count;
  this.fields = 3;
  this.field = new Array(3);
  this.field[0] = arg1;
  this.field[1] =arg2;
  this.field[2] = arg3;
  this.records = 0;
  this.record =new Array(11);
  for (count=0; count<11; count++){
    this.record[count] = new Array(9)}
  this.addRecord = addRecord;
  this.getRecord = getRecord}

function addRecord(arg1, arg2, arg3){
  this.record[arg1][arg2] = arg3;
  this.records++}

function getRecord(arg1, arg2){
  return(this.record[arg1][arg2])}

function displaySite(oURL){
  var oWindow =  'toolbar=yes,location=yes,';
      oWindow += 'resizable=yes,scrollbars=yes,';
      oWindow += 'status=yes,width=600,height=400';
  myWindow = open(oURL, 'URL', oWindow)}

function displayURL(){
  var thisURL
  var oCategory = document.myForm.myCategory.selectedIndex;
  var oIndex = document.myForm.myIndex.selectedIndex;
  var oString = document.myForm.myText.value;
  var oWindow =  'toolbar=yes,location=yes,';
      oWindow += 'resizable=yes,scrollbars=yes,';
      oWindow += 'status=yes,width=600,height=400';
  var newChoiceString = '';
  if (oCategory == 0){
    thisURL =  URL.getRecord(oIndex, webPrefix);
    thisURL += formatString(oString);
    thisURL += URL.getRecord(oIndex, webSuffix);
    myWindow = open(thisURL, 'URL', oWindow)}
  else {
    myWindow = open(URL.getRecord(oIndex, oCategory), 'URL', oWindow)}
  for (count=0; count<8; count++){
    if (count == oCategory){
      newChoiceString += (oIndex == 10) ? 'A' : oIndex}
    else {newChoiceString += choiceString.charAt(count)}}
  choiceString = newChoiceString;
  setCookie('myChoices',choiceString,365)}

function formatString(theString){
  if (isNotBlank(theString)){
    theString = spaceTrim(theString);
    theString = replaceChar(theString,'"',"'");
    theString = replaceChar(theString,"'",'%22');
    theString = replaceChar(theString, '+', '%2B');
    theString = replaceChar(theString, ' ', '+');
    return(theString)}
  else {return('')}}

function replaceChar(InString, oldChar, newStr) {
   var NewString='';
   var count;
   for (count=0; count < InString.length; count++){
      if   (InString.charAt(count)==oldChar) {NewString += newStr}
      else {NewString += InString.charAt(count)}}
   return(NewString)}

function isNotBlank(InString) {
   if (InString == null) {
      return(false)}
   if (InString.length != 0) {
      return(true)}
   else {return(false)}}

function spaceTrim(InString) {
   var LoopCtrl=true;
   while (LoopCtrl) {
      if (InString.indexOf('  ') != -1) {
         Temp = InString.substring(0, InString.indexOf('  '));
         InString = Temp + InString.substring(InString.indexOf('  ')+1,InString.length)}       else
         LoopCtrl = false}
   if (InString.substring(0, 1) == ' ')
      InString = InString.substring(1, InString.length)
   if (InString.substring (InString.length-1) == ' ')
      InString = InString.substring(0, InString.length - 1)
   return (InString)}

function setCookie(name, value, days) {
   var today = new Date();
   var expires = new Date();
   expires.setTime(today.getTime() + 1000*60*60*24*days);
   document.cookie = name + '=' + escape(value) + '; expires=' + expires.toGMTString()}

function getCookie(name){
   var search = name + '=';
   if (document.cookie.length > 0){
      offset = document.cookie.indexOf(search);
      if (offset != -1){
         offset += search.length ;
         end = document.cookie.indexOf(';', offset);
         if (end == -1){
            end = document.cookie.length}
         return unescape(document.cookie.substring(offset, end))}
       else {return('')}}
   else {return('')}}

function updateIndex(){
  var oCategory = document.myForm.myCategory.selectedIndex;
  var oIndex = choiceString.charAt(oCategory);
  if (oIndex == 'A'){oIndex = 10}
  document.myForm.myIndex.selectedIndex = oIndex}

