title = new Object();
desc = new Object();
links= new Object();
matched= new Object();
keywords= new Object();
found= new Object();
var temp=0;
title[0]=8
keywords[0]=0
found[0]=0




title[1]="northumberland county durham cumbria co yorkshire lancashire westmorland isle of man tyne and wear cleveland"
desc[1]="Northern England<br><br><a href='nengland.html'>CLICK HERE</a>"
links[1]=""
matched[1]=0

title[2]="cleveland nottinghamshire cheshire derbyshire lincolnshire shropshire staffordshire"
desc[2]="North Midlands<br><br><a href='nmidlands.html'>CLICK HERE</a>"
links[2]=""
matched[2]=0

title[3]="herefordshire worcestershire warwickshire leicestershire northamptonshire buckinghamshire oxfordshire gloucestershire"
desc[3]="South Midlands<br><br><a href='smidlands.html'>CLICK HERE</a>"
links[3]=""
matched[3]=0

title[4]="cambridgeshire bedfordshire hertfordshire norfolk suffolk essex"
desc[4]="Anglia<br><br><a href='anglia.html'>CLICK HERE</a>"
links[4]=""
matched[4]=0

title[5]="kent greater london surrey sussex east west north south"
desc[5]="South East<br><br><a href='southeast.html'>CLICK HERE</a>"
links[5]=""
matched[5]=0

title[6]="dorset berkshire wiltshire hampshire isle of wight"
desc[6]="Mid-South England<br><br><a href='southmid.html'>CLICK HERE</a>"
links[6]=""
matched[6]=0

title[7]="avon cornwall devon somerset"
desc[7]="South West England<br><br><a href='southwest.html'>CLICK HERE</a>"
links[7]=""
matched[7]=0

title[8]="clwyd gwent dyfed gwynedd glamorgan powys "
desc[8]="Wales<br><br><a href='wales.html'>CLICK HERE</a>"
links[8]=""
matched[8]=0

function search(){
// get the input from the input by the user and strip it into keywords
//+
var skeyword=document.searchengine.keywords.value.toLowerCase();
var check=1;
var pos=0;
var i=0;
var j=0;
var  itemp=0;
var config='';

while (true)
	{
	if (skeyword.indexOf("+") == -1 )
		{
		keywords[check]=skeyword;
		break;
		}
	pos=skeyword.indexOf("+");
	if (skeyword !="+")	
	{
	keywords[check]=skeyword.substring(0,pos);
	check++;
	}
	else
	{
	check--;
	break;
	}
	skeyword=skeyword.substring(pos+1, skeyword.length);	
	if (skeyword.length ==0)
		{
		check--;
		break;
		}
			 
	}
// the keywords have been put in keywords object.
keywords[0]=check;
//alert(check);
// matching and storing the matches in matched
for ( i=1; i<=keywords[0];i++)
	{
	for (j=1;j<=title[0];j++)
		{
		if (title[j].toLowerCase().indexOf(keywords[i]) > -1 )
			{
			  matched[j]++;
			}
		}	
	}
// putting all the indexes of the matched records  in found

for (i=1;i<=title[0];i++)
{
	if (matched[i] > 0 )
		{
		  found[0]++;
		// increment the found 	
		  found[found[0]]=i;
			
		}	
}
//alert("found 0 " +  found[0]);
// sort the list as per max percentage of matches


for (i=1;i<=found[0]-1;i++)
	{
	for(j=i+1;j<=found[0];j++)
		{
		if ( matched[found[i]]< matched[found[j]] )
			{
			temp= found[j];
			found[j]=found[i];
			found[i]=temp;
			}
		}
	}



// end of sort

// prepare for document write.
config='toolbar=no,location=no,directories=no,status=no,menubar=no,' 
config += 'scrollbars=yes,resizable=yes' 
output = parent.window 
output.document.write('<title> Search Results </title>');
output.document.write('<font class=black>');
output.document.write('<STYLE>a:hover{color: red}</STYLE>');
output.document.write('<BODY bgcolor=#C0E8C0 text=000000 link=blue vlink =blue alink=blue>');
output.document.write('<center><a href="home.html"><img src="logofront.jpg" width=240 height=110 border=0></a><BR><BR><h1><font class=black> Search Results </h1>');    
output.document.write(' Results For ' )
for (i=1;  i<=keywords[0]; i++)
	{
	output.document.write( keywords[i].bold() +"   ");
	}
output.document.write(' Search:');

if (found[0]==0)
	{
	//alert(found[0]);
	 output.document.write('');
	 output.document.write('');
	output.document.write("No Records Found</B>");
	output.document.write("<br>");
	}
else
	{
	// data has been found
	output.document.write("<b></b>  ");
	output.document.write( found[0] +"  entries found - Please Wait  ");
	output.document.write("<table border=0 width=600><font class=black>");
	for (i=1; i<=found[0];i++)
		{
		output.document.write("<tr><td valign=top bgcolor=#c0e8co>");
		output.document.write("<h3>" +i +"</h3>");
		output.document.write("<td valign=top>");
		output.document.write("<font class=black>");
		itemp=found[i];
		output.document.write(desc[itemp].bold() +"<br>" +
links[itemp].link(links[itemp])+"<br>");
		temp= (matched[itemp]/keywords[0])*100
		output.document.write(" <font class=black>Matched  with keywords: " +temp+" %  " );
		matched[itemp]=0
		} 
	found[0]=0;
	output.document.write("</table>");
	}
output.document.write ('');
output.document.write ("<br>");
output.document.write ("<form><center>") 
output.document.write ("<FONT CLASS=black>Can't find what you're looking for? <input type=submit value='Return To The Search' class=black onClick='history.go(-1)'>") 
output.document.write ("</center></form>") 
output.document.write ("</select>")
}

<!-- 

//Make reference to the selected link

function makeLinkTo(s) { window.top.location.href =
s.options[s.selectedIndex].value; }

//-->

