
<!-- Original:  Dion (biab@iinet.net.au) -->
<!-- Web Site:  http://www.iinet.net.au/~biab -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var item = new Array();
getSearchArr();

/* Here is where all the magic happens.  
    Just enter as many additional pages that
    that you want to search, then fill in the
    additional listings for each page.
*/

// "Page Name","path","Page Title","Many,Key,Words","Descriptive Comments"
/*
c=0; item[c]=new Array("index.html","","DemoSite","index,main,start,home,front","Demonstration search engine data about an imagined but probable internet site.");
c++; item[c]=new Array("about.htm","","About Me","about,author,contact,email,who","Contact details and general information about the creator of the site and what the site is about.");
c++; item[c]=new Array("links.htm","","Links page","links,more,where,similar,friends","Links to my favourite sites which I find interesting. Other friends sites which have similar interests to my own.");
c++; item[c]=new Array("main.htm","main/","Main Page","content,main,focus","The main part of my site which contains what you have come to see. Lots of stuff like that and more great things. All in a sub directory.");
c++; item[c]=new Array("logo.jpg","main/images/","Link Logo","link,image,logo,graphic","The logo.jpg is just a small image which you can place on your site as a link to me. It's in a second level subdirectory.");
*/
page="<html><head><title>Search Results</title><link href=\"/css/global.css\" rel=\"stylesheet\" type=\"text/css\" /></head><body bgcolor='white'><table width='100%' height='100%' style=\"background-color:#FFFFFF\"><tr><td align='center'><span class='header1'>Search Results</span><center><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"475\"><tr><td width=\"10\" height=\"10\"><img src=\"/global/hotPane1/topLeftCorner.gif\" width=\"10\" height=\"10\" /></td><td background=\"/global/hotPane1/topBorder.gif\"></td>"
page+="<td width=\"11\"><img src=\"/global/hotPane1/topRightCorner.gif\" width=\"11\" height=\"10\" /></td></tr><tr><td valign=\"top\" background=\"/global/hotPane1/leftBorder.gif\"><img src=\"/global/hotPane1/leftBorderGradient.gif\" width=\"10\" height=\"147\" /></td><td valign=\"top\" bgcolor=\"#EFEFEF\" class=\"hotPanel1ContentCell\" style=\"background-image:url(/global/hotPane1/bodyBGGradient.gif); background-repeat:repeat-x\"><p>";



function getSearchArr(){
	
	
	var indexXML = getAjaxXML("/xml/siteIndex.xml");
	c=0;
	
	var pageNodesArr = getNode(indexXML, "page");
	
	for(var i = 0; i < pageNodesArr.length; i++){
		
		var fileNameStr = getNode(pageNodesArr[i], "fileName")[0].firstChild.nodeValue;
		var fileDirStr = getNode(pageNodesArr[i], "fileDir")[0].firstChild.nodeValue;
		var descStr = getNode(pageNodesArr[i], "description")[0].firstChild.nodeValue;
		
		var wordsNode = getNode(pageNodesArr[i], "keywords")[0];
		var wordNodeArr = getNode(wordsNode, "word");
		
		var wordsStr = "";
		for(var j = 0; j < wordNodeArr.length; j++){
			wordsStr += wordNodeArr[j].firstChild.nodeValue + " ";
		}
		item[c] = new Array(fileNameStr, fileDirStr, wordsStr, descStr);
		c++;
	}
	
	

}

function search(frm) {
//var item = new Array();


	
	
win = window.open("","","scrollbars,height=250,width=515");
win.document.write(page);
txt = frm.srchval.value.split(" ");
fnd = new Array(); total=0;
for (i = 0; i < item.length; i++) {
fnd[i] = 0; order = new Array(0, 3, 1, 2);
for (j = 0; j < order.length; j++)
for (k = 0; k < txt.length; k++)
if (item[i][order[j]].toLowerCase().indexOf(txt[k]) > -1 && txt[k] != "")
fnd[i] += (j+1);
}
for (i = 0; i < fnd.length; i++) {
n = 0; w = -1;
for (j = 0;j < fnd.length; j++)
if (fnd[j] > n) { n = fnd[j]; w = j; };
if (w > -1) total += show(w, win, n);
fnd[w] = 0;
}
win.document.write("</p><p>&nbsp;</p></td><td valign=\"top\" background=\"/global/hotPane1/rightBorder.gif\"><img src=\"/global/hotPane1/rightBorderGradient.gif\" width=\"11\" height=\"147\" /></td></tr><tr><td width=\"10\" height=\"5\"><img src=\"/global/hotPane1/leftBottomCorner.gif\" width=\"10\" height=\"5\" /></td><td background=\"/global/hotPane1/bottomBorder.gif\"></td><td><img src=\"/global/hotPane1/rightBottomCorner.gif\" width=\"11\" height=\"5\" /></td></tr></table><span class='header1'><br>Total found: "+total+"<br></span></td></tr></table></body></html>");
win.document.close();
}
function show(which,wind,num) {
link = item[which][1] + item[which][0]; 
line = "<br><br><a href='javascript:opener.location.href=\""+link+"\";window.close();'>"+link+"</a><br>";
line += item[which][3];
wind.document.write(line);
return 1;
}
