/*	Called from Search page ...
	Generates a Search Results page
*/

function searchLinks(links, keyword)
{
	/*document.writeln("<!--HEADER-->");*/
	document.writeln("<HTML>");
	document.writeln("<HEAD>");
	//document.writeln("<LINK HREF=\"http://www.rkburt.co.uk/rkb.css\" REL=\"STYLESHEET\" TYPE=\"text/css\">");
	//document.writeln("<LINK HREF=\"/rkb.css\" REL=\"STYLESHEET\" TYPE=\"text/css\">");
	/* Generate an internal version of part of rkb.css so dynamic document is "self-sufficient"!*/
	/*Main colours/attributes...*/
	var CFG = "#000000";
	var CBG = "#FFFFFF";
	var CH1 = "#305B2D";
	var CActi = "#ADADAD";
	var CLink = CH1;
	document.writeln("<STYLE TYPE=\"text/css\"><!--");
	document.writeln("BODY {font-family:Tahoma,Arial,Verdana,Helvetica,sans-serif;color:"+CFG+";background-color:"+CBG+";}");
	document.writeln("TABLE {font-size:13px;} TR {text-align:left;} H1 {color:"+CH1+";font-size:19px;font-weight:bold;}");
	document.writeln(".NAV {font-size:9px;}");
	document.writeln("A:link {text-decoration:underline;font-weight:bold;color:"+CLink+";}");
	document.writeln("A:visited {text-decoration:underline;font-weight:bold;color:"+CLink+";}");
	document.writeln("A:active {text-decoration:underline;font-weight:bold;color:"+CActi+";}");
	document.writeln("A:hover {text-decoration:underline;font-weight:bold;color:"+CActi+";}");
	document.writeln("--></STYLE>");			
	document.writeln("<TITLE>Search Results</TITLE>");
	document.writeln("</HEAD>");
	document.writeln("<BODY><CENTER>");
	document.writeln("<A NAME=\"search_begin\"></A>");
	/* Main page table start */
		document.writeln("<TABLE WIDTH=\"85%\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">"); 
		/* R1 */
		document.writeln("<TR><TD ALIGN=\"LEFT\"><P>&nbsp\;</P><H1>Search Results</H1></TD></TR>");
		/* R2 */
		document.writeln("<TR><TD ALIGN=\"CENTER\">");
		/* Start inner T1*/
			document.writeln("<TABLE WIDTH=\"40%\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\"><TR><TD ALIGN=\"CENTER\">");
			if ((keyword != null) && (keyword != "")) 
			{	
			document.writeln("Click the link below to go to the document you require, or click the <A HREF=\"javascript:history.back()\">Back</A> link for a new search.");
			document.writeln("</TD><TR><TD ALIGN=\"CENTER\">&nbsp\;</TD></TR><TR><TD ALIGN=\"CENTER\">");
			document.writeln("Search results for keyword: <B>" +keyword.toUpperCase()+ "</B>");
			}
			else
			{
			document.writeln("No search keyword has been entered. Click the <A HREF=\"javascript:history.back()\">Back</A> link for a new search.");
			document.writeln("</TD><TR><TD ALIGN=\"CENTER\">&nbsp\;</TD></TR><TR><TD ALIGN=\"CENTER\">");
			document.writeln("&nbsp\;");
			}		
			document.writeln("<BR><BR></TD></TR></TABLE>");
			<!--WORDSFORSRCH--> <!--DO NOT ERASE THIS LINE-->
			/*document.writeln("<!--HEADER end-->");*/
		/* End inner T1*/

		/* Start inner T2 - hit results*/
			document.write("<TABLE BORDER=\"1\" CELLSPACING=\"3\" CELLPADDING=\"2\">");
		
			var findCount = 0;
		
			for (var q=1; q<=links.length; q++) 
			{
			if ((keyword != null) && (keyword != ""))
				{
				var newkey=keyword.toLowerCase();
				}
				var lcName=links[q].dName.toLowerCase();
				var lcKeys=links[q].Keys.toLowerCase();

			if (lcName.indexOf(newkey) != -1)
				{
				document.write("<tr><td><a href=\"" + links[q].URL + "\">" + links[q].dName + "</a></td></tr>");
				findCount = findCount + 1;
				continue;
				}
			
			if (lcKeys.indexOf(newkey) != -1) 
				{
				document.write("<tr><td><a href=\"" + links[q].URL + "\">" + links[q].dName + "</a></td></tr>");
				findCount = findCount + 1;
				continue;
				}
			}

			if (findCount == 0)
			{
			document.write("<tr><td>There were no matching entries</td></tr>");
			}
			else
			{
			document.write("<tr><td>&nbsp\;</td></tr>");
			if (findCount > 1)
				{
				document.write("<tr><td>There were " + findCount + " matching entries</td></tr>");
				}
				else
				{
				document.write("<tr><td>There was " + findCount + " matching entry</td></tr>");
				}
			}

			/*document.writeln("<!--FOOTER-->");*/
			<!--WORDSFORSRCH end--> <!--DO NOT ERASE THIS LINE-->
			document.writeln("</TABLE></TR>");
		/* End table T2 - hit results */
		/* R3 */
		document.writeln("<TR><TD ALIGN=\"CENTER\">");
		document.writeln("<P>&nbsp\;</P></TD></TR>");
		/* R4 */
		document.writeln("<TR><TD ALIGN=\"LEFT\" CLASS=\"NAV\">"); 
		document.writeln("<A HREF=\"javascript:history.back()\">Back</A>");
		if (findCount > 15)
		{
			document.writeln(" | <A HREF=\"#search_begin\">Back To Top</A>");
		}
		document.writeln(" | <A HREF=\"index.html\" TARGET=\"_top\">Home</A></TD>");
		document.writeln("</TR></TABLE>");
	/* Main page table end */
	document.writeln("<P>&nbsp\;</P><P>&nbsp\;</P></CENTER></BODY>");
	document.writeln("</HTML>");
	/*document.writeln("<!--FOOTER end-->");*/
	document.close();
}

/*********************************/
/* Functions called from keys.js */
function makeArray(n)
{
	this.length = n;
	for (var k = 1; k <= n; k++)
	{
		this[k] = "";
	}
	return this;
}

function makeLinks(size)
{
	this.length = size;
	for (var r=1; r<= size; r++) {
		this[r] = new makeEntry();
		this[r].Keys = kW[r];
		this[r].URL = dP[r];
		this[r].dName = dN[r];
	}
	return this;
}

function makeEntry ()
{
	this.Keys="";
	this.URL = "";
	this.dName = "";
	this.Category = "";
	return this;
}

/* Go straight to search string entry */
function go()
{
document.searchForm.searchStr.focus();
}
/*********************************/
function showAll(linkobj)
{
	for (var s=1; s<= linkobj.length; s++)
	{
		showLink(linkobj,s);
	}
}

function showLink (links, index)
{
	document.write("<tr><td>" + links[index].Keys + "</td>");
	document.write("<td><a href=" + links[index].URL + ">" + links[index].dName + "</a></td></tr>");
}
