//SEARCH SCRIPT

function search(){

var title = new Array(46);
var desc = new Array(46);
var links = new Array(46);
var matched = new Array(46);
var key = new Array(46);
var found = new Array(46);
var temp=0;
title[0]= 45; 
key[0]=0; 
found[0]=0;

title[1]="Hooghly Dock & Port Engineers Limited - About Us";
desc[1]="About Us";
links[1]="about.html";
matched[1]=0;

title[2]="Hooghly Dock & Port Engineers Limited - Major Activities";
desc[2]="Major Activities";
links[2]="activities.html";
matched[2]=0;

title[3]="Hooghly Dock & Port Engineers Limited - Anchor Buoy";
desc[3]="Anchor Buoy, hdpel";
links[3]="anchor.html";
matched[3]=0;

title[4]="Hooghly Dock & Port Engineers Limited - Vessels Already Build";
desc[4]="Vessels Already Build, Tug";
links[4]="build.html";
matched[4]=0;

title[5]="Hooghly Dock & Port Engineers Limited - MD's Desk";
desc[5]="MD's Desk";
links[5]="md.html";
matched[5]=0;

title[6]="Hooghly Dock & Port Engineers Limited - Contact us";
desc[6]="Contact us";
links[6]="contact.html";
matched[6]=0;

title[7]="Hooghly Dock & Port Engineers Limited - Dredger";
desc[7]="Dredger";
links[7]="dredger.html";
matched[7]=0;

title[8]="Hooghly Dock & Port Engineers Limited - Feedback Form";
desc[8]="Feedback Form";
links[8]="feedback.html";
matched[8]=0;

title[9]="Hooghly Dock & Port Engineers Limited - Fire Float";
desc[9]="Fire Float";
links[9]="fire.html";
matched[9]=0;

title[10]="Hooghly Dock & Port Engineers Limited - Fishing Vessels";
desc[10]="Fishing Vessels";
links[10]="fishing.html";
matched[10]=0;

title[11]="Hooghly Dock & Port Engineers Limited - Floating Dock";
desc[11]="Floating Dock";
links[11]="floating.html";
matched[11]=0;

title[12]="Hooghly Dock & Port Engineers Limited - Gallery";
desc[12]="Gallery";
links[12]="gallery.html";
matched[12]=0;

title[13]="Hooghly Dock & Port Engineers Limited - Gallery";
desc[13]="Gallery";
links[13]="gallery2.html";
matched[13]=0;

title[14]="Hooghly Dock & Port Engineers Limited - Gallery";
desc[14]="Gallery";
links[14]="gallery3.html";
matched[14]=0;

title[15]="Hooghly Dock & Port Engineers Limited - Gallery";
desc[15]="Gallery";
links[15]="gallery4.html";
matched[15]=0;

title[16]="Hooghly Dock & Port Engineers Limited - Gallery";
desc[16]="Gallery";
links[16]="gallery5.html";
matched[16]=0;

title[17]="Hooghly Dock & Port Engineers Limited - Gallery";
desc[17]="Gallery";
links[17]="gallery6.html";
matched[17]=0;

title[18]="Hooghly Dock & Port Engineers Limited - Gallery";
desc[18]="Gallery";
links[18]="gallery7.html";
matched[18]=0;

title[19]="Hooghly Dock & Port Engineers Limited - Gallery";
desc[19]="Gallery";
links[19]="gallery8.html";
matched[19]=0;

title[20]="Hooghly Dock & Port Engineers Limited - Gallery";
desc[20]="Gallery";
links[20]="gallery9.html";
matched[20]=0;

title[21]="Hooghly Dock & Port Engineers Limited - Gallery";
desc[21]="Gallery";
links[21]="gallery10.html";
matched[21]=0;

title[22]="Hooghly Dock & Port Engineers Limited - Gallery";
desc[22]="Gallery";
links[22]="gallery11.html";
matched[22]=0;

title[23]="Hooghly Dock & Port Engineers Limited - Grievance";
desc[23]="Grievance";
links[23]="grievance.html";
matched[23]=0;

title[24]="Hooghly Dock & Port Engineers Limited - Hooper Barge";
desc[24]="Hooper Barge";
links[24]="hooper.html";
matched[24]=0;

title[25]="Hooghly Dock & Port Engineers Limited";
desc[25]="Hooghly Dock & Port Engineers Limited";
links[25]="index.html";
matched[25]=0;

title[26]="Hooghly Dock & Port Engineers Limited - Infrastructure";
desc[26]="Infrastructure";
links[26]="infrastructure.html";
matched[26]=0;

title[27]="Hooghly Dock & Port Engineers Limited - ISO Certified";
desc[27]="ISO Certified";
links[27]="iso.html";
matched[27]=0;

title[28]="Hooghly Dock & Port Engineers Limited - Landing Ferry";
desc[28]="Landing Ferry";
links[28]="landing.html";
matched[28]=0;

title[29]="Hooghly Dock & Port Engineers Limited - Launches";
desc[29]="Launches";
links[29]="launches.html";
matched[29]=0;

title[30]="Hooghly Dock & Port Engineers Limited - Light Vessel";
desc[30]="Light Vessel";
links[30]="light.html";
matched[30]=0;

title[31]="Hooghly Dock & Port Engineers Limited - Mooring Boats";
desc[31]="Mooring Boats";
links[31]="mooring.html";
matched[31]=0;

title[32]="Hooghly Dock & Port Engineers Limited - Naval Crafts";
desc[32]="Naval Crafts";
links[32]="naval.html";
matched[32]=0;

title[33]="Hooghly Dock & Port Engineers Limited - Nazirguange Works";
desc[33]="Nazirguange Works";
links[33]="nazirguange.html";
matched[33]=0;

title[34]="Hooghly Dock & Port Engineers Limited - What's New";
desc[34]="What's New";
links[34]="new.html";
matched[34]=0;

title[35]="Hooghly Dock & Port Engineers Limited - Newsletter";
desc[35]="Newsletter";
links[35]="newsletter.html";
matched[35]=0;

title[36]="Hooghly Dock & Port Engineers Limited - Offshore Supply Vessels";
desc[36]="Offshore Supply Vessels";
links[36]="offshore.html";
matched[36]=0;

title[37]="Hooghly Dock & Port Engineers Limited - Passenger Vessel";
desc[37]="Passenger Vessel";
links[37]="passenger.html";
matched[37]=0;

title[38]="Hooghly Dock & Port Engineers Limited - Pontoons Lighters";
desc[38]="Pontoons Lighters";
links[38]="pontoons.html";
matched[38]=0;

title[39]="Hooghly Dock & Port Engineers Limited - Right to information";
desc[39]="Right to information";
links[39]="right.html";
matched[39]=0;

title[40]="Hooghly Dock & Port Engineers Limited - Salkia Works";
desc[40]="Salkia Works";
links[40]="salkia.html";
matched[40]=0;

title[41]="Hooghly Dock & Port Engineers Limited - Sitemap";
desc[41]="Sitemap";
links[41]="sitemap.html";
matched[41]=0;

title[42]="Hooghly Dock & Port Engineers Limited - Survey Craft";
desc[42]="Survey Craft";
links[42]="survey.html";
matched[42]=0;

title[43]="Hooghly Dock & Port Engineers Limited - Tender Information";
desc[43]="Tender Information";
links[43]="tender.php";
matched[43]=0;

title[44]="Hooghly Dock & Port Engineers Limited - Vessels Under Construction";
desc[44]="Vessels Under Construction";
links[44]="under.html";
matched[44]=0;

title[45]="Hooghly Dock & Port Engineers Limited - Chairman's Desk";
desc[45]="Chairman's Desk";
links[45]="chairman.html";
matched[45]=0;


var skeyword=document.searchengine.keys.value.toLowerCase(); 
var check=1;
var pos=0;
var i=0;
var j=0;
var itemp=0;
var config='';
var output='';
while (true)
{
if (skeyword.indexOf("+") == -1 )
{
key[check]=skeyword;

break;
}
pos=skeyword.indexOf("+");
if (skeyword !="+")     
{
key[check]=skeyword.substring(0,pos); check++;
}
else
{
check--;
break;
}
skeyword=skeyword.substring(pos+1, skeyword.length);  
  if (skeyword.length ==0)
{
check--;
break;
}
}
 key[0]=check;
for ( i=1; i<=key[0];i++)
{
for (j=1;j<=title[0];j++)
{
if (title[j].toLowerCase().indexOf(key[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;
}
}
}



config='toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,left=0,top=0,width=800,height=600';
output = window.open ("","outputwindow",config);
output.document.write('<html>');
output.document.write('<title> Hooghly Dock & Port Engineers Limited Search Results </title>');
output.document.write('<head>'); 
output.document.write('<script language="javascript">function ChangeMenu(file){top.opener.window.location.href = file;window.close();}</script>'); 
output.document.write('</head>');
output.document.write('<BODY  text=#000000  link=#2116C7 vlink =#2116C7 >');
output.document.write('<table width="750" border="0" cellspacing="0" cellpadding="0">');
output.document.write('<tr>');
output.document.write('<td>');
output.document.write('<font face="arial" size="5" color="blue">');
output.document.write('<b>Hooghly Dock & Port Engineers Limited</b></font>');
output.document.write('</td>');
output.document.write('</tr>');
output.document.write('</table>');
output.document.write('<table width="750" border="0" cellspacing="0" cellpadding="0">');
output.document.write('<tr>');
output.document.write('<td align="center">');
output.document.write('<font face="arial" size="3" color="red">');
output.document.write('<b>Your Matches</b></font>');
output.document.write('</td>');  
output.document.write('</tr>');
output.document.write('</table>');
output.document.write('<hr width="720">');
output.document.write('The Keyword(s) you searched :: '.big()); 
for(i=1;i<=key[0]; i++)
{
output.document.write( key[i].bold() +"   "); 
}
output.document.write('<br>');
if(found[0]==0)
{
output.document.write('<hr width="720">');
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
{
output.document.write("<hr width='720'> <b> The Results of the search are : </b>");
output.document.write( found[0] +"  Entries found  ".italics()); 
output.document.write("<table border=1 width=750>");
for(i=1;i<=found[0];i++)
{
output.document.write("<tr><td valign=top background='images/cream-bg.gif'>");
output.document.write("<h3>" +i +"</h3>" + "</td>"); 
output.document.write("<td valign=top>"); 
itemp=found[i];
output.document.write(desc[itemp].bold() +"<br>" +"<a href=javascript:ChangeMenu('" +links[itemp]+ "')>" +links[itemp]+ "</a>" +"<br>");
temp= (matched[itemp]/key[0])*100; 
output.document.write("<i> Matched  with keywords  :: "+temp+" %  </i>" );
output.document.write("</td>");
output.document.write("</tr>"); 
matched[itemp]=0;
}
found[0]=0;
output.document.write("</table>");
}
output.document.write ("<form><center>"); 
output.document.write ("<input type='button' value='Start Another Search' onClick = 'self.close()'>") ;
output.document.write ("</center></form>");
output.document.write('</body>');
output.document.write('</html>');
output.document.close();
}
