
title = new Object();
description = new Object();
links= new Object();
matched= new Object();
keywords= new Object();
found= new Object();
var temp=0;

title[0]=5
//no of keywords after parsing
keywords[0]=0
//no of  matches found.
found[0]=0

<!-- Begin List of Search Items -->

<!--put the list of the links and descriptions here!!-->

title[1]="Introduction 101 Law"
description[1]="Introduction To The Law"
links[1]="pdf/sample.pdf"
matched[1]=0

title[2]="white collar crime"
description[2]="The White Collar Criminal Mind"
links[2]="pdf/sample.pdf"
matched[2]=0

title[3]="what is embezzling"
description[3]="What is Embezzling?"
links[3]="pdf/sample.pdf"
matched[3]=0

title[4]="addicted to embezzling?, reasons people do it"
description[4]="Addicted To Embezzling?, Reasons People Do It"
links[4]="pdf/sample.pdf"
matched[4]=0


title[5]="detaining destroying embezzling  "
description[5]="A Treatise on Federal Criminal Law Procedure"
links[5]="pdf/sample.pdf"
matched[5]=0
<!-- End list of Searchable items -->

function searchf(){
var skeyword=document.search_form.search.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;

// 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;
			
		}	
}



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

div_content = "";
div_content = div_content + '<center><h1>Search Results</h1></center>';    
div_content = div_content + ' Keywords: "' ; 
for (i=1;  i<=keywords[0]; i++)
	{
	div_content = div_content +  keywords[i].bold() +"   ";
	}
div_content = div_content + '"' 
div_content = div_content + '<br>';

if (found[0]==0)
	{
	//alert(found[0]);
	div_content = div_content + '<hr>';
	div_content = div_content + "<b>Sorry, no matches resulted in this search </b> <br>";
	div_content = div_content + "Please try again by refining your keywords. Make sure you seperate your keywords with a &#034;+&#034;.<br>";
	}
else
	{
	// data has been found
	div_content = div_content +  found[0] +"  Entries found  ".italics();
	div_content = div_content + "<table border=0 width=100%>";
	for (i=1; i<=found[0];i++)
		{
		div_content = div_content + "<tr><td valign=top>";
		div_content = div_content + "<b>" +i +"</b>";
		div_content = div_content + "<td valign=top>";
		itemp=found[i];
	div_content = div_content + description[itemp].bold() +"<br>" + "<a href=" + links[itemp] + " target=_blank>"  + links[itemp] + "</a>" + "<p>";
			//div_content = div_content + description[itemp].bold() +"<br>" + links[itemp].link(links[itemp])+"<p>";
		matched[itemp]=0
		} 
	found[0]=0;
	div_content = div_content + "</table>";
	}
document.all.content_div.innerHTML = div_content 
//alert(div_content);
}

