var ltop=0;
var titles=new Array;
var refs=new Array;
var ktop=0;
var keys=new Array;
var fsnet="file://h:/webpages/";
var tiscali="file://h:/tiscali/";
var fsnet2="file://h:/webpages/";
var tiscali2="file://h:/tiscali/";
var index="index.html";
var width1=90;
var height1=60;

var l2;

function setup(cols,width,height) {
   width1=width;
   var width2=width+45;
   height1=height;
   document.writeln("<table class=\"s2\" border=\"0\">");
   document.writeln("<col span=\""+cols+"\" width=\""+width2+"px\"><tr>");
   if (location.host=="localhost") {
      fsnet="http://localhost/";
      tiscali="http://localhost/tiscali/";
   } else if (location.host!="") {
      // alert("host:"+location.host); // myweb.tiscali.co.uk
      // fsnet="http://www.windsurfnow.fsnet.co.uk/";
      // tiscali="http://myweb.tiscali.co.uk/waveboy/";
      // talktalk="http://www.windsurfnow.talktalk.net/";
      fsnet="http://www.windsurfnow.co.uk/";
      tiscali="http://www.windsurfnow.co.uk/";
      fsnet2="http://www.windsurfnow.talktalk.net/";
      tiscali2="http://www.windsurfnow.talktalk.net/";
      index="";
   }
}

function endup() {
   document.writeln("<\/tr><\/table>");
}

function dorow() {
   document.writeln("<\/tr><tr>");
}

function redirect() {
   document.writeln("<p>Redirecting to <a target=\"_top\"");
   document.writeln(" href=\""+l2+"\">"+l2+"<\/a>");
   top.location=l2;
   // setTimeout("top.location=l2;",1000); // 1 secs
}

function doitem(host,frame,title,imsrc) {
   if ((frame.length==0) || (frame.charAt(frame.length-1)=="/"))
      frame=frame+index;
   var host2=fsnet2;
   if (host!=fsnet) host2=tiscali2;
   document.write('<td class=s2');
   document.write("><a target=\"_top\" href=\"");
   document.writeln(host+frame+'">');
   document.write('<img class=nobord SRC="'+host2+imsrc)
   document.writeln('" ALT="'+title+'"');
   document.writeln(" height="+height1+" width="+width1+"><\/a><h6 class=\"hh6\">"+title);
   document.writeln("<\/h6><\/td>");
   titles[ltop]=title.toLowerCase();
   refs[ltop]=host+frame;
   ltop++;
}

function match(title) {
   var i2;
   for (i2=0;i2<ktop;i2++) {
      if (title.indexOf(keys[i2])<0) return -1;
   }
   return 1;
}

function dosearch() {
   var i1;
   // e.g. ?Tenerife,2008. Test with FireFox.
   l1=l1.toLowerCase();
   for (;;) {
     i1=l1.indexOf("%20");
     if (i1<0) break;
     l1=l1.substring(0,i1)+","+l1.substring(i1+3);
   }
   // for (;;) {
   //   i1=l1.indexOf("&");
   //   if (i1<0) break;
   //   l1=l1.substring(0,i1)+","+l1.substring(i1+3);
   // }
   ktop=0;
   for (;;) {
      i1=l1.indexOf(",");
      if (i1<0) break;
      if (i1!=0) {
         keys[ktop++]=l1.substring(0,i1);
      }
      l1=l1.substring(i1+1);   
   }
   keys[ktop++]=l1;
   // for (i1=0;i1<ktop;i1++) {
   //    document.writeln("<p>Key:"+keys[i1]);
   // }
   var fnd=-1;
   for (i1=0;i1<ltop;i1++) {
      if (match(titles[i1])>0) {
         fnd=i1;
         break;
      }
   }
   if (fnd>=0) {
      l2=refs[fnd];
      redirect();
   } else {
      document.writeln("<p>Search item not found");
   }
}

