function parseClassSearchText() {
	var fullstring = document.searchform.searchtext.value;
	if (fullstring.indexOf("  ") != -1) {
		window.alert("Please use only one space between words.");
		document.searchform.searchtext.focus();
		return false;
	}
	if (fullstring.indexOf(" ") == 0) fullstring = fullstring.substring(1);
	var word1 = "";
	var word2 = "";
	var word3 = "";
	var spc = new Array();
	var n = 0;
	for (var i=0; i<fullstring.length; i++) {
		if (fullstring.indexOf(" ",i) == i) {
			spc[n] = i;
			n++;
		}
	}
	if (n >= 3) {
		window.alert("Note: The classified search feature supports a maximum of three words at a time.\nOnly the first three words of your search will be used.");
		word1 = fullstring.substring(0,spc[0]);
		word2 = fullstring.substring(spc[0]+1,spc[1]);
		word3 = fullstring.substring(spc[1]+1,spc[2]);
	}
	if (n == 2) {
		word1 = fullstring.substring(0,spc[0]);
		word2 = fullstring.substring(spc[0]+1,spc[1]);
		word3 = fullstring.substring(spc[1]+1);
	}
	if (n == 1) {
		word1 = fullstring.substring(0,spc[0]);
		word2 = fullstring.substring(spc[0]+1);
	}
	if (n == 0) word1 = fullstring;
	window.location.href = "http://www.pantagraphclassifieds.com/classifieds/index.inn?SEARCH=ALL&BOOLEAN=AND&FULLWORD=NO&loc=search&KEY1=" + word1 + "&KEY2=" + word2 + "&KEY3=" + word3;
}

function runSearch() {
	var searchChoice = document.searchform.searchtype[document.searchform.searchtype.selectedIndex].value;
	var searchText = document.searchform.searchtext.value;
	if (searchText == "") {
		if (searchChoice == "archive") window.location.href = "http://www.pantagraph.com/info/archive_search.html";
		if (searchChoice == "site") window.location.href = "http://www.pantagraph.com/search-pantagraph/";
		if (searchChoice == "classified") window.location.href = "http://www.pantagraphclassifieds.com/";
		if (searchChoice == "google") window.location.href = "http://www.google.com/advanced_search?hl=en";
	}
	else {
		if (searchChoice == "archive") window.location.href = "http://nl.newsbank.com/nl-search/we/Archives?p_product=BL&p_theme=bl&p_action=search&p_maxdocs=200&p_sort=YMD_date:D&p_text_search-0=" + escape(searchText);
		if (searchChoice == "site") window.location.href = "http://www.pantagraph.com/search-pantagraph/cgi-bin/search?method=and&format=builtin-long&config=search&words=" + escape(searchText);
		if (searchChoice == "classified") parseClassSearchText();
		if (searchChoice == "google") window.location.href = "http://www.google.com/search?q=" + escape(searchText);
	}
}

function tips() {
	var tipWindow = window.open('http://www.pantagraph.com/info/search_tips.html','Search','width=350,height=450,left=50,top=50,status=no,scrollbars=yes,resizable=yes,toolbar=no,menubar=no,directories=no');
}

document.write('<table width="100%" border="0" cellspacing="0" cellpadding="4">'
			+'<tr>'
				+'<td class="menuStyle" style="color:white" valign="top">'
					+'<form name="searchform" onsubmit="runSearch(); return false;">'
						+'<div align="center">'
							+'<font style="font-size:13px">Search for&nbsp;&nbsp;</font><img src="http://www.pantagraph.com/images/primary2001/search_arrow.gif" alt="" height="10" width="12" border="0"> &nbsp;<input class="menuStyle" type="text" name="searchtext" size="20" border="0"> <select class="menuStyle" name="searchtype" size="1">'
								+'<option value="archive">in the Pantagraph archive</option>'
								+'<option value="classified">in Pantagraph Classifieds</option>'
								+'<option value="site">on Pantagraph.com pages</option>'
								+'<option value="google">on the Web using Google</option>'
							+'</select> <input class="menuStyle" type="button" name="" value="Search now" onClick="runSearch();" border="0"> <input class="menuStyle" type="button" onClick="tips();" value="Tips" border="0"></div>');

if (navigator.appVersion.indexOf("Mac") != -1) document.write('&nbsp;');

document.write('</form>'
				+'</td>'
			+'</tr>'
		+'</table>');
