title = new Object();
desc = new Object();
links= new Object();
matched= new Object();
keywords= new Object();
found= new Object();
var temp=0;
title[0]=22
keywords[0]=0
found[0]=0

title[1]="welcome home linwood intermediate"
desc[1]="Welcome to the Linwood Intermediate School Website "
links[1]="http://www.linwood.school.nz/index.html"
matched[1]=0

title[2]="school facilities rooms room"
desc[2]="Linwood intermediate school facilities"
links[2]="http://www.linwood.school.nz/School_Facilities.html"
matched[2]=0

title[3]="map school"
desc[3]="Map of linwood school"
links[3]="http://www.linwood.school.nz/School_Map.html"
matched[3]=0

title[4]="curriculum maths subjects english taught"
desc[4]="School Curriculum"
links[4]="http://www.linwood.school.nz/School_Curriculum.html"
matched[4]=0

title[5]="culture kapahaka samoan group"
desc[5]="Culture at Linwood Intermediate"
links[5]="http://www.linwood.school.nz/Culture.html"
matched[5]=0

title[6]="sport sports"
desc[6]="Sport at Linwood Intermediate..."
links[6]="http://www.linwood.school.nz/Sport.html"
matched[6]=0

title[7]="date object write html setTimeout function"
desc[7]="Art at Linwood Intermediate..."
links[7]="http://www.linwood.school.nz/Arts.html"
matched[7]=0

title[8]="inquiry students"
desc[8]="Student Inquiries (Part 2 of 2)"
links[8]="http://www.linwood.school.nz/Enquiry_Learning.html"
matched[8]=0

title[9]="bulletin news current events"
desc[9]="Important Dates in 2007..."
links[9]="http://www.linwood.school.nz/Bulletin.html"
matched[9]=0

title[10]="newsletter update school newsletter"
desc[10]="Linwood Intermediate School Newsletters..."
links[10]="http://www.linwood.school.nz/Newsletter.html"
matched[10]=0

title[11]="BOT board of trustees"
desc[11]="Linwood Intermediate Board of Trustees information..."
links[11]="http://www.linwood.school.nz/BOT.html"
matched[11]=0

title[12]="enrolling enrolment linwood intermediate"
desc[12]="Enrolment Procedure...."
links[12]="http://www.linwood.school.nz/Enrolment_Procedure.html"
matched[12]=0

title[13]="information parents"
desc[13]="Information for parents..."
links[13]="http://www.linwood.school.nz/Info_For_Parents.html"
matched[13]=0

title[14]="attendance school hours"
desc[14]="Attendance..."
links[14]="http://www.linwood.school.nz/Attendance.html"
matched[14]=0


title[15]="school uniform policy"
desc[15]="School Uniform..."
links[15]="http://www.linwood.school.nz/Uniform.html"
matched[15]=0

title[16]="education review office ero report ERO "
desc[16]="ERO Report 2006..."
links[16]="http://www.linwood.school.nz/ERO_Report.html"
matched[16]=0

title[17]="site map navigation "
desc[17]="Linwood Intermediate website site map..."
links[17]="http://www.linwood.school.nz/Site_Map.html"
matched[17]=0

title[18]="contact email phone number address"
desc[18]="Linwood Intermediate Contact information"
links[18]="http://www.linwood.school.nz/Contact_Us.html"
matched[18]=0

title[19]="student section corner main "
desc[19]="Student Corner "
links[19]="http://www.linwood.school.nz/StudentSectionMain.html"
matched[19]=0

title[20]="literacy games student quizzes fun things "
desc[20]="Literacy Games for Students..."
links[20]="http://www.linwood.school.nz/Student_Section/LiteracySection.html"
matched[20]=0

title[21]="Maths games student quizzes fun things "
desc[21]="Maths Games for Students..."
links[21]="http://www.linwood.school.nz/Student_Section/MathsMania.html"
matched[21]=0

title[22]="links other websites "
desc[22]="Useful Links..."
links[22]="http://www.linwood.school.nz/Student_Section/UsefulLinks.html"
matched[22]=0



function search(){
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;
		}
			 
	}

keywords[0]=check;

for ( i=1; i<=keywords[0];i++)
	{
	for (j=1;j<=title[0];j++)
		{
		if (title[j].toLowerCase().indexOf(keywords[i]) > -1 )
			{
			  matched[j]++;
			}
		}	
	}

for (i=1;i<=title[0];i++)
{
	if (matched[i] > 0 )
		{
		  found[0]++;
		  found[found[0]]=i;
			
		}	
}



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;
			}
		}
	}


output = self;
output.document.write('<html>');
output.document.write('<head>');
output.document.write('<script>');
output.document.write('window.onerror=new Function("return true")');
output.document.write('<\/script>');
output.document.write('<title> Search Results </title>');
output.document.write('</head>');
output.document.write('<BODY background="images/background.gif" text=#000000  link=#990099 vlink =#339966>');
output.document.write('<div align="center">');
output.document.write('<font face="arial">');
output.document.write('<center> <h1> Search Results </h1></center>');    
output.document.write(' The Keyword(s) you searched :: '.big() )
for (i=1;  i<=keywords[0]; i++)
	{
	output.document.write( keywords[i].bold() +"   ");
	}
output.document.write('<br>');

if (found[0]==0)
	{
	//alert(found[0]);
	output.document.write("<b>No matches resulted in this search </b> <br>");
	output.document.write("You may close the results and reduce the length/number  of the keywords  <br>");
	}
else
	{
	// data has been found
	output.document.write("<b> The Results of the search are  : </b>  ");
	output.document.write( found[0] +"  Entries found  ".italics());
	output.document.write("<table border=1 cellpadding=0 cellspacing=0 width=60%>");
	for (i=1; i<=found[0];i++)
		{
		output.document.write("<tr><td valign=top bgcolor=#9999ff>");
		output.document.write("<h3>" +i +"</h3>");
		output.document.write("<td valign=top bgcolor=#ffffff>");
		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("<i> Matched  with keywords  :: " +temp+" %  </i>" );
		matched[itemp]=0
		} 
	found[0]=0;
	output.document.write("</table>");

	}
output.document.write ("<form><center>"); 
output.document.write ("<input type='button' value='Click to go back' onClick = 'history.back()'"); 
output.document.write ("<center></form>");
output.document.write ("</div></font></body></html>"); 
output.document.close();
}
