/*	Called from Search/Products Index page ...
	Generates a Search Results list
*/
var path = document.location.href;
var htmPos = path.lastIndexOf("html");
var lastSlashPos = path.lastIndexOf("/");
var page = path.substr(lastSlashPos+1,htmPos-lastSlashPos+3);
var artDir=path.indexOf("articles")>0?1:0;
var prodDir=path.indexOf("products")>0?1:0;
var galDir=path.indexOf("gallery")>0?1:0;
var imgDir=path.indexOf("images")>0?1:0;
var topDir=!artDir&&!prodDir&&!galDir&&!imgDir?1:0;

/* Set up header text/colour and generate array for Search item links 
	jsi is the multi array generated in keys.js; keyword is the string in the form search box*/
function show_s_items(links, keyword)
{
	docs.length = 0;
	oTxt.length = 0;
	nLnks.length = 0;
	document.getElementById("PRLH").className = "newp";	//red!
	document.getElementById("PRLI").innerHTML = "";		//Clear contents
	
	var findCount = 0;
	var repStr = "";
	if ((keyword != null) && (keyword != ""))
		{
		var newkey=keyword.toLowerCase();
		}

		for (var q=1; q<=links.length; q++) 
			{
				var lcName=links[q].dName.toLowerCase();
				var lcKeys=links[q].Keys.toLowerCase();

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

		document.getElementById("PRLH").innerHTML = "Search Results (" + findCount + ")";

		if (findCount == 0)
			{
			document.getElementById("PRLI").innerHTML = "There were no matching entries";
			}
			else
			{
			nextI = 0;
			prevI = 0;
			write_lnks(0,findCount-1,"PRLI",ctc);
			}
}

/*********************************/
/* Functions called from keys.js */
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];
		var hPos = dP[r].indexOf("htm");
		var lSPos = dP[r].lastIndexOf("/");
		this[r].Doc = dP[r].substr(lSPos+1,hPos-lSPos+3);
		
	}
	return this;
}

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

/* Go straight to search string entry - called from keys.js (the final script loaded) */
function go()
{
document.searchForm.searchStr.focus();
}

