// search.js 02-21-2003

	// search variables
	var strOpen = "";
	strOpen += "<!doctype html public '-//w3c//dtd html 4.0 transitional//en'>";
	strOpen += "<html><head><title>Stone Dragon Press - Search Results</title>";
	strOpen += "<meta name='file_name' content='search_results.html'>";
	strOpen += "<meta name='author' content='BigTime Interactive'>";
	strOpen += "<meta name='copyright' content='©2002 BigTime Interactive'>";
	strOpen += "<meta scheme='month-day-year' name='date' content='01-06-2003'>";
	strOpen += "<script type='text/javascript'>";
	strOpen += "var strID1 = 'volkhvy';var strURL = 'stonedragonpress' + '.' + 'com';</script>";
	strOpen += "<script src='scripts/search.js' type ='text/javascript'></script>";
	strOpen += "<script src='scripts/index.js' type='text/javascript'></script>";
	strOpen += "<link rel='stylesheet' type='text/css' href='stylesheets/wicca_201.css'></head>";
	strOpen += "<body bgcolor='#ffffff' topmargin='0' leftmargin='0' marginwidth='0' marginheight='0'>";
	strOpen += "<table  border='0' cellpadding='0' cellspacing='0' width='600'>";
	strOpen += "<tr><td align='left' valign='top'><img src='images/sp.gif' height='1' width='20'></td>";
	strOpen += "<td align='left' valign='top'><img src='images/sp.gif' height='1' width='560'></td>";
	strOpen += "<td align='left' valign='top'><img src='images/sp.gif' height='1' width='20'></td></tr>";
	strOpen += "<tr><td align='left' colspan='3' valign='top'>";
	strOpen += "<table border='0' cellpadding='0' cellspacing='0' width='600'><tr>";
	strOpen += "<td align='center' rowspan='3' valign='middle' width='80'>";
	strOpen += "<img src='images/dragonhead.gif' alt='Stone Dragon Press' border='0' height='100' width='74'> </td>";
	strOpen += "<td align='left' valign='top' width='320'><font class='logo'>Stone Dragon Press</font><br>";
	strOpen += "<font class='logosub'>&nbsp;&nbsp;speculative fiction &#8212; science fiction &#8212; horror &#8212; fantasy</font> </td>";
	strOpen += "<td align='left' valign='top' width='200'><img src='images/wicca_201.gif' border='0' height='48' width='200'></td></tr>";
	strOpen += "<tr><td align='left' colspan='2' height='35' valign='bottom'>";
	strOpen += "<a href='../index.html'><img src='images/back_to_sdp.gif' alt='Stone Dragon Press' border='0' height='25' width='92'></a>";
	strOpen += "<img src='images/spacer_10.gif' height='25' width='10'>";
	strOpen += "<a href='table_of_contents.html'><img src='images/table_of_contents.gif' alt='Table of Contents' border='0' height='25' width='119'></a>";
	strOpen += "<img src='images/spacer_10.gif' height='25' width='10'>";
	strOpen += "<a href='bibliography.html'><img src='images/bibliography.gif' alt='Bibliography' border='0' height='25' width='87'></a>";
	strOpen += "<img src='images/spacer_10.gif' height='25' width='10'>";
	strOpen += "<a href='search.html'><img src='images/back.gif' alt='Back' border='0' height='25' width='47'></a>";
	strOpen += "<img src='images/spacer_10.gif' height='25' width='10'>";
	strOpen += "<img src='images/forward_inactive.gif' alt='Forward' border='0' height='25' width='63'></a></td></tr>";
	strOpen += "<tr><td align='left' height='30' valign='middle'>";
	strOpen += "<a href='table_of_contents.html'><font class='navloc'>Table of Contents</font></a>";
	strOpen += "<img src='images/point_new.gif' border='0' height='12' width='24'>";
	strOpen += "<a href='search.html'><font class='navloc'>Search</font></a>";
	strOpen += "<img src='images/point_new.gif' border='0' height='12' width='24'>";
	strOpen += "<font class='navlocdis'>Search Results</font> </td>";
	strOpen += "<td align='center' valign='bottom'><a href='search.html'><img src='images/search.gif' alt='Search' border='0' height='25' width='58'></a>";
	strOpen += "<img src='assets/sp.gif' height='1' width='2'></td>";
	strOpen += "</tr></table></td></tr>";
	strOpen += "<tr><td align='center' colspan='3' valign='top'><hr align='center' size='1' width='90%'></td></tr>";
	strOpen += "<tr><td align='left'  colspan='3' valign='top'><img src='images/sp.gif' height='10' width='1'></td></tr>";
	strOpen += "<tr><td align='left' valign='top'><img src='images/sp.gif' height='1' width='20'></td>";
	strOpen += "<td align='left' class='txt' valign='top' width='560'>";

	var strClose = "";
	strClose += "<br></td><td align='left' valign='top'><img src='images/sp.gif' height='1' width='20'></td>";
	strClose += "</tr><tr><!-- horizontal rule -->";
	strClose += "<td align='center' colspan='3' height='20' valign='top'><hr align='center' size='1' width='90%'></td>";
	strClose += "</tr><tr><td align='center' colspan='3' valign='top'>";
	strClose += "<a href='search.html'><img src='images/back.gif' alt='Back' border='0' height='25' width='47'></a>";
	strClose += "<img src='images/spacer_52.gif' height='25' width='52'>";
	strClose += "<a href='#top'><img src='images/top_of_page.gif' alt='Top of Page' border='0' height='25' width='88'></a>";
	strClose += "<img src='images/spacer_52.gif' height='25' width='52'>";
	strClose += "<img src='images/forward_inactive.gif' alt='Forward' border='0' height='25' width='63'><br>";
	strClose += "<a href='http://www.stonedragonpress.com'>";
	strClose += "<img src='images/copyright_sdp.gif' alt='copyright 2002, Stone Dragon Press' border='0' height='25' width='177'></a>";
	strClose += "<img src='images/spacer_10.gif' height='25' width='10'>";
	strClose += "<script type='text/javascript'>document.write('<a href=\"mailto:' + strID1 + '&#064;' + strURL + '\">";
	strClose += "<img src=\"images/email_author.gif\" alt=\"E-Mail the Author\" border=\"0\" height=\"25\" width=\"115\"></a>')</script>";
	strClose += "<noscript><img src='images/email_author_inactive.gif' height='25' width='115'></noscript><br><br>";
	strClose += "</td></tr></table><br></body></html>";

	var strResults = "";

// search functions

	function searchLocal() { // match words & sort on frequency of matches
		var cnt1 = 0;
		var flgChange = true;
		var inc1 = 1;
		var rayRank = new Array();
		var rayOrder = new Array();
		var rayNdx = new Array();
		var rayPhrase = new Array();
		var strSearch = document.idForm1.idText1.value.toLowerCase();
		for (cnt1 = 0; cnt1 < dbKey.length; cnt1++) { // get each key phrase
			var ray1 = dbKey[cnt1].split(","); // place key phrase & URL index into an array
			var str1 = ray1[0].toLowerCase(); // set str1 to lower case
			if (str1.indexOf(strSearch) != -1) { // if there's a match
				if (str1 == strSearch) { // perfect match
					rayRank[cnt1] = 2
				} else { // partial match
					rayRank[cnt1] = 1;
				}
				rayOrder[cnt1] = cnt1;
				rayPhrase[cnt1] = ray1[0];
				rayNdx[cnt1] = ray1[1];
			} else { // no match found
				rayRank[cnt1] = 0;
			}
		}
		while (flgChange == true) { // bubble sort in orser of precentage match
			flgChange = false
			for (cnt1 = 0; cnt1 < rayRank.length - 1; cnt1++) {
				if (rayRank[cnt1] < rayRank[cnt1 + 1]) {
					int1 = rayRank[cnt1];
					rayRank[cnt1] = rayRank[cnt1 + 1];
					rayRank[cnt1 + 1] = int1;
					int1 = rayOrder[cnt1];
					rayOrder[cnt1] = rayOrder[cnt1 + 1];
					rayOrder[cnt1 + 1] = int1;
					flgChange = true;
				}
			}
		}
		for (cnt1 = 0; cnt1 < rayRank.length; cnt1++) { // build search results display
			if (rayRank[cnt1] > 0) {
				strResults += inc1 +")&nbsp;&nbsp;<a href='" + dbURL[rayNdx[rayOrder[cnt1]]] + ".html'>";
				strResults += "<font class='linkblu'>"+ dbTitle[rayNdx[rayOrder[cnt1]]] + "</font></a>";
				if (rayRank[cnt1] == 2) {
					strResults += "&nbsp;&nbsp;<font class='bgld'>&nbsp;&#149;&nbsp;match&nbsp;&#149;&nbsp;</font> ";
				} else {
					strResults += "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;partial match &#151; <font class='bgry'>";
					strResults += rayPhrase[rayOrder[cnt1]] + "</font>";
				}
				strResults += "<font class='lf'><br><br></font>";
				inc1++;
			}
		}
		if (strResults == "") { // no matches found
			strResults += "Results of search for: <font class='bgry'>" + strSearch + "</font><font class='lf'><br><br></font>";
			strResults += "No matches found<font class='lf'><br><br></font>";
		} else { // matches found
			strResults = "Results of search for: <font class='bgry'>" + strSearch + "</font><font class='lf'><br><br></font>" + strResults;
		}
		// var strHTML = strOpen + strResults + strClose;
		// document.open("search_results.html");
		document.write(strOpen + strResults + strClose); // display search results
		document.write("");
		document.close();
	} // end function
