/***********************************************************************
Copyright notice: This script/page is leased.  No use of this
script in whole or in part is authorized without the written permission of
owner.  Copyright February 10, 2004.

This copy is licenced to Valerie Boal until February 6, 2008, and subject to
renewal after that date.
************************************************************************/

var MSG_ERROR_NO_SEARCH_VALUE = "You must type at least a single character for a search value.\nClick OK to continue.";
var MSG_ERROR_NO_MATCH = "Our search did not yield any matches.\nPlease try a less specific search, like a partial name (ex. \"Ba\" instead of \"A Bay\")";

var sStdHeader = "<table cellpadding=\"2\" cellspacing=\"0\" border=\"1\" bordercolor=\"d9d9d9\" width=\"100%\">";
var sStdFooter = "</table>";
var sResults;
var oWin;
function doSearch()
{
	var sSearchStr = sTrim( document.search_form.sSearch.value );
	sResults = "";
	if( sSearchStr.length > 0 )
	{
		for( var i=0; i < aSearch.length; i++ )
		{
			if(aSearch[i].toLowerCase().indexOf( sSearchStr.toLowerCase() ) != -1)
			{
				sBuildResults( aSearch[i] );
			 }
		}
		if( sResults == "" ) alert( MSG_ERROR_NO_MATCH );
		else showResults();
	}
	else
	{
		alert(MSG_ERROR_NO_SEARCH_VALUE);
		document.search_form.sSearch.focus();
	}
}

function sTrim(sStr)
{
	while(sStr.charAt(0) == " ")
		sStr = sStr.substring(1);
	while(sStr.charAt(sStr.length-1) == " ")
		sStr = sStr.substring(0,sStr.length-2);
	return sStr;
}

function showResults()
{
	sResults += sStdFooter;
	if( oWin )
		oWin.close();
	oWin = window.open("","","toolbar=no,directories=no,status=no,menubar=no,width=300,height=200,top=40,left=50,scrollbars=yes");
	oWin.document.open("text/html");
	oWin.document.writeln("<html><body><br><center><form onsubmit='return false;'></form></center></br>");
	oWin.document.writeln(sResults + "<br><center><form onsubmit='return false;'><input type='button' onclick='window.close();' value=' CLOSE '></form></center><br></body></html>");
	oWin.document.close();
}

function sBuildResults( sStr )
{
	if( sResults == "" )
		sResults += sStdHeader;
	if( sStr.indexOf('~') != -1 )
	{
		var sDescription = sStr.substring(0, ( sStr.indexOf('~') ));
		var sImage = sStr.substring( ( sStr.indexOf('~') + 1) );
		sResults += "<tr><td width=\"100%\"><a href=\"javascript:opener.openPage('" + sImage + "')\">" + sDescription + "</a></td></tr>";
	}
} 

function openPage(sPage)
{
	if(sPage != null)
	{
		if( oWin )
			oWin.close();
		location.href = sPage;
	}
}
	
//---------------
// array to hold search descriptions and images
var aSearch = new Array(
	
	"2006 Municipal Election Enumeration Information~./htm/enumer06.html",
	"Accommodations - includes hotels, motels~./htm/accom.html",	 
	"Agenda - council agenda~./archive07/1minutes07list.html",
	"Agendas - council agenda~./archive07/1minutes07list.html",
	"Airport information~./htm/things.html#transportation",	
	"Animals~./htm/things.html#wildlife",	
	"Arena~./htm/things.html#arena",
	"Archives~./archivetransition/archivetranslist.html",
	"Art Gallery~./htm/things.html#art",
	"Accessibility Minutes~./archive07/1minutes07list.html#access",
	"Administration Contact~./htm/admin.html",
	"Agriculture~./htm/agri.html",			
	"Beach~./htm/things.html#beaches",
	"Bikes~http://www.bikersreunion.ca",
	"Bikers~http://www.bikersreunion.ca",
	"Bikers Photos~http://www.bikersreunion.ca",
	"Bikers Reunion~http://www.bikersreunion.ca",
	"Boat~./htm/things.html#boating",
	"Boats~./htm/things.html#boating",	
	"Boating information~./htm/things.html#boating",
	"Boating information~./htm/things.html#marinas",
	"Boat information~./htm/things.html#boating",			
	"Building Dept.~./htm/admin.html",
	"Bus Local rates/schedules/routes~./htm/transport.html",		
	"Bus information~./htm/things.html#transportation",
	"Business Information~./htm/industrial.html",
	"By-laws~./htm/bylawyearlist.html",
	"Bylaws~./htm/bylawyearlist.html",
	"Cemetary~./htm/things.html#cemetaries",
	"Cemetaries~./htm/things.html#cemetaries",		
	"Churches~./htm/things.html#churches",	
	"Cinema - Empire Theatre~./htm/things.html#empire",
	"City Council~./htm/council.html",	
	"Classes held~./htm/schedules.html",	
	"Comments to submit~news.html",
	"Communities in Bloom~./htm/things.html#bloom",		
	"Contact - names and phone numbers of Administration and Staff~./htm/admin.html",
	"Council minutes 2007~./archive07/1minutes07list.html",
	"Council minutes 2006~./archive06/1minutes06list.html",
	"Council minutes 2005~./archive05/cminutes05.html",	
	"Council minutes 2004~./archive04/minuteslist04.html",	
	"Councillors~./htm/council.html",		
	"Curling~./htm/things.html#curling",
	"Dining~./htm/restaurants.html",		
	"Distance to New Liskeard~./htm/streets.html",
	"DTSSAB Minutes~./archive06/1minutes06list.html",
	"Dump Hours~./htm/industrial.html#dump",
	"Dymond~./htm/streetdym.html",	
	"Earlton Zoo~./htm/things.html#museums",
	"Employment - Job Opportunities~/htm/jobs.html",		
	"Entertainment - Nightlife~./htm/things.html#nighttime",		
	"Entertainment - things to do~./htm/things.html#nighttime",
	"Enumeration~./htm/enumer06.html",
	"Events special~./htm/calendar.html",
	"Farmers Market~./htm/things.html#farmers",	
	"Fire Dept.,~/htm/fire.html",	
	"Fishing~./htm/things.html#fishing",	
	"Fitness classes~./htm/schedules.html",
	"Garbage Collection Schedule~news.html#garbage",		
	"Golf~./htm/things.html#golf",
	"Haileybury~./htm/streetshail.html",
	"Haileybury Bronze Sculpture~./htm/things.html#bronze",	
	"Haileybury Walking Tour~./htm/haileyburytour.html",
	"Haileybury Golf Club~./htm/things.html#hailgolf",		
	"Hiking~./htm/things.html#hiking",		
	"Horses~./htm/things.html#horseback",		
	"Hunting~./htm/things.html#hunting",	
	"History New Liskeard - a brief overview~./htm/historynl.html",
	"History Haileybury - a brief overview~./htm/historyhail.html",
	"History Dymond Township - a brief overview~./htm/historydym.html",
	"Hospital~./htm/things.html#hospital",
	"Hotels~./htm/accom.htm",	
	"Index - the first page of the web site~index.html",
	"Industrial Park~./htm/industrial.html",
	"Interim Emergency Response Plan~./04bylaws/2004-114.pdf",
	"Jobs - Job Opportunities~/htm/jobs.html",				
	"Kilometers - mileage to Temiskaming Shores~./htm/streets.html",
	"Landfill Operating Hours~./htm/industrial.html#dump",			
	"Lessons for swimming~./htm/schedules.html",
	"Library Hours - ~./htm/things.html#libraries",	
	"Library - our Libraries~./htm/things.html#libraries",	
	"Library Minutes~./archive07/1minutes07list.html",			
	"Location - where Temiskaming Shores is located~./htm/streets.html",
	"Marina~./htm/things.html#boating",
	"Marinas~./htm/things.html#marinas",
	"Marinas~./htm/marina.html",
	"Map~./htm/streets.html",
	"Maps~./htm/streets.html",	
	"Market~./htm/things.html#farmers",	
	"Mayor and councillors~./htm/council.html",		
	"Membership, rates for pool~./htm/schedules.html",
	"memberships~./htm/schedules.html",
	"Messages~./htm/refer.html",
	"mileage to Temiskaming Shores~./htm/streets.html",
	"Mileage to Temiskaming Shores~./htm/streets.html",
	"Minutes 2007~./archives07/1minutes07list.html",	
	"Minutes 2006~./archives06/1minutes06list.html",	
	"Minutes 2005~./archives05/cminutes05.html",
	"Minutes 2004~./archives04/minuteslist04.html",
	"Museums in our area~./htm/things.html#museums",
	"New Liskeard Golf Club~./htm/things.html#nlgolf",
	"New Liskeard~./htm/streetsnl.html",			
	"Office of the City of Temiskaming Shores~./htm/admin.html",	
	"Our Streets~./htm/streets.html",	
	"Parks - our parks and playgrounds~./htm/things.html#parks",
	"Park - our Industrial Park~./htm/industrial.html",
	"Pete's Dam~./htm/things.html#parks",
	"Photos~/htm/streets.html",
	"photos~/htm/streets.html",
	"Photos Bikers~http://www.bikersreunion.ca",	
	"Photos of streets~/htm/streets.html",	
	"Police Minutes~http://www.temiskamingshores.ca/archive07/1minutes07list.html",			
	"Planning Dept.~./htm/admin.html",
	"Pool Fitness rates~./htm/schedules.html",		
	"Pool Schedule~./htm/schedules.html",
	"Power Squadron~./htm/marina.html#power",
	"Proposal Request~news.html#proposal",
	"Proposed Notice of Sign Bylaw~./06bylaws/2006bylawlist.html#proposed",
	"Public Libraries~./htm/things.html#libraries",
	"Public Health Services~./htm/things.html#public",		
	"Real Estate~./htm/things.html#real",	
	"Recreation - pool/fitness page~./htm/schedules.html",
	"Request for Proposal~news.html#proposal",		
	"Restaurants~./htm/restaurants.html",
	"Restructuring~./archivetransition/archivetranslist.html",
	"Road Race~./roadrace06/roadrace06.htm",
	"Rockwalk Park~./htm/things.html#rockwalk",			
	"Schools~./htm/things.html#schools",			
	"Shopping~./htm/things.html#shopping",
	"Shuffleboard - Outdoor~./htm/things.html#shuffle",
	"Site Index~./htm/site.html",			
	"Skiing~./htm/things.html#skiing",
	"Smoke Free~news.html#smokefree",
	"Snowmobiling~./htm/things.html#snowmachining",			
	"Special events~./htm/calendar.html",	
	"Staff - names and how to contact them~./htm/admin.html",		
	"Streets~./htm/streets.html",		
	"Submit comments~news.html",
	"Suggestions~news.html",			
	"Swim lessons~./htm/schedules.html",	
	"Temiskaming Waterway~./htm/streets.html",
	"Temiskaming Art Gallery~./htm/things.html#art",
	"Temiskaming Wild Life Centre~./htm/things.html#wildlife",		
	"Temperatures~./htm/streets.html",	
	"Tennis~./htm/things.html#tennis",
	"Triathlon~./roadrace06/roadrace06.htm",
	"Tri-Town Power Squadron~./htm/marina.html#power",	
	"Train information~./htm/things.html#transportation",	
	"View comments~./htm/refer.html",	
	"Visitor information~./htm/visitorinfo.html",	
	"Visitors Information~./htm/visitorinfo.html",		
	"Waterway Temiskaming~./htm/streets.html",
	"Welcome~index.html",	
	"Works Dept.,~./htm/admin.html"	
	 
);