/* XSearch version5.0 http://www.twicefun.com/just4fun */

var searchname = 'searchresults.html';

var usebannercode = false;

var ButtonCode = "<input type='submit' value='Go'>";

function templateBody()
{

	document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
	document.write('<html xmlns="http://www.w3.org/1999/xhtml">');

	document.write('<head>');
	document.write('	<title>Because I Fly Fish | Search Results</title>');
	document.write('	<meta http-equiv="X-UA-Compatible" content="IE=8" />');
	document.write('	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />');
	document.write('	<meta http-equiv="Content-Language" content="en" />');
	document.write('	<meta name="description" content="" />');
	document.write('	<meta name="keywords" content="" />');

	document.write('	<link rel="icon" href="images/favicon.ico">');
	document.write('	<link rel="shortcut icon" href="images/favicon.ico">');
	document.write('	<link rel="stylesheet" type="text/css" media="screen" href="style.css" />');
	document.write('	<link rel="stylesheet" type="text/css" media="screen" href="css/skin.css" />');
	document.write('	<link rel="stylesheet" type="text/css" media="screen" href="jscript/prettyPhoto/css/prettyPhoto.css" charset="utf-8" />');

	document.write('	<!--[if IE 6]>');
	document.write('		<link rel="stylesheet" type="text/css" media="screen" href="css/style_ie6.css" />');
	document.write('		<script type="text/javascript" src="jscript/belated_png.js"></script>');
	document.write('		<script type="text/javascript">');
	document.write('			DD_belatedPNG.fix(".logo a, #nav, #options_menu img, #search, #feed, #login, .button_search, .button_subscribe, .button_login, #intro, #pre_footer, #pre_footer .label img, #contact_form, .btn, .big_shadow, .thumb_shadow, .gallery_button_next img, .gallery_button_prev img");');
	document.write('		</script>');
	document.write('	<![endif]-->');

	document.write('	<script type="text/javascript" src="jscript/jquery.js"></script>');
	document.write('	<script type="text/javascript" src="jscript/prettyPhoto/js/jquery.prettyPhoto.js" charset="utf-8"></script>');
	document.write('	<script type="text/javascript" src="jscript/easing.js"></script>');
	document.write('	<script type="text/javascript" src="jscript/cufon-yui.js"></script>');
	document.write('	<script type="text/javascript" src="jscript/ColaborateLight_400.font.js"></script>');
	document.write('	<script type="text/javascript" src="jscript/Colaborate-Medium_400.font.js"></script>');
	document.write('	<script type="text/javascript" src="jscript/swfobject.js"></script>');
	document.write('	<script type="text/javascript" src="jscript/pk.js"></script>');
	document.write('	<script type="text/javascript" src="jscript/scripts_alabiff.js" language="JavaScript"></script>');
	document.write('	<script language="JavaScript" src="scripts/alabiff_scripts.js" type="text/javascript"></script>');

	document.write('	<script type="text/javascript" src="scripts/db.js language="Javascript""></script>');
	document.write('	<script type="text/javascript" src="scripts/xsearch-5.0.js" language="Javascript"></script>');

	document.write('	<script language="JavaScript" src="jscript/alabiff_search.js" type="text/javascript"></script>');
	document.write('</head>');

	document.write('<body id="body">');
	document.write('	<div class="wrap_fullwidth" id="top">');
	document.write('		<div class="center over_all">');
	document.write('			<div class="wrap_content" id="nav">');


	document.write('				<!--[if !IE]>start logo<![endif]-->');
	document.write('				<div id="logo">');
	document.write('					<h1 class="logo"><a href="index.html" title="">alaBIFF</a></h1>');
	document.write('				</div>');
	document.write('				<!--[if !IE]>end logo<![endif]-->');

	document.write('				<!--[if !IE]>start options menu<![endif]-->');
	document.write('				<div id="options_menu">');
	document.write('					<ul>');
	document.write('						<li class="search"><img src="images/skin/search_icon.png" alt="" /></li>');
	document.write('						<li class="feed"><img src="images/skin/twitter_icon_white.png" alt="" /></li>');
	document.write('						<li class="login"><img src="images/skin/login_icon.png" alt="" /></li>');
	document.write('					</ul>');
	document.write('				</div>');
	document.write('				<!--[if !IE]>end options menu<![endif]-->');

	document.write('				<!--[if !IE]>start menu<![endif]-->');
	document.write('				<div id="menu">');
	document.write('					<ul>');
	document.write('						<li><a href="index.html" title="">Home</a></li>');
	document.write('						<li><a href="albums.html" title="">Photo Gallery</a>');
	document.write('							<ul>');
	document.write('								<li><a href="journals_utah.html" title="">Utah Albums &raquo;</a>');
	document.write('									<ul>');
	document.write('										<li><a href="journals_duchesne.html" title="">Duchesne River</a></li>');
	document.write('										<li><a href="journals_green.html" title="">Green River</a></li>');
	document.write('										<li><a href="albums_provo.html" title="">Provo River &amp; Jordanelle</a></li>');
	document.write('										<li><a href="journals_strawberry.html" title="">Strawberry River</a></li>');
	document.write('									</ul>');
	document.write('								</li>');
	document.write('								<li><a href="journals_idaho.html" title="">Idaho Albums &raquo;</a>');
	document.write('									<ul>');
	document.write('										<li><a href="journals_henrysfork.html" title="">Henry&#39;s Fork</a></li>');
	document.write('										<li><a href="journals_southfork.html" title="">South Fork</a></li>');
	document.write('										<li><a href="albums_stjoe.html" title="">St. Joe River</a></li>');
	document.write('										<li><a href="albums_teton.html" title="">Teton River</a></li>');
	document.write('									</ul>');
	document.write('								</li>');
	document.write('								<li><a href="journals_montana.html" title="">Montana Albums &raquo;</a>');
	document.write('									<ul>');
	document.write('										<li><a href="journals_bighole.html" title="">Big Hole River</a></li>');
	document.write('										<li><a href="journals_madison.html" title="">Madison River</a></li>');
	document.write('										<li><a href="albums_missouri.html" title="">Missouri River</a></li>');
	document.write('									</ul>');
	document.write('								</li>');
	document.write('								<li><a href="journals_us.html" title="">More Albums - U.S. &raquo;</a>');
	document.write('									<ul>');
	document.write('										<li><a href="albums_casco.html" title="">Casco Bay, Maine</a></li>');
	document.write('										<li><a href="journals_salt.html" title="">Salt River, Wyoming</a></li>');
	document.write('										<li><a href="albums_snake.html" title="">Snake River, Wyoming</a></li>');
	document.write('										<li><a href="albums_spokane.html" title="">Spokane River, Washington</a></li>');
	document.write('										<li><a href="albums_friends.html" title="">Potpourri, a la BIFF</a></li>');
	document.write('										<li><a href="albums_kevin.html" title="">Kevin, in Memoriam</a></li>');
	document.write('									</ul>');
	document.write('								</li>');
	document.write('								<li><a href="journals_abroad.html" title="">More Albums - Abroad &raquo;</a>');
	document.write('									<ul>');
	document.write('										<li><a href="albums_ascension.html" title="">Ascension Bay, Mexico</a></li>');
	document.write('										<li><a href="albums_belize.html" title="">Belize, Central America</a></li>');
	document.write('										<li><a href="albums_cancun.html" title="">Cancun, Mexico</a></li>');
	document.write('										<li><a href="albums_costarica.html" title="">Costa Rica, Central America</a></li>');
	document.write('										<li><a href="albums_patagonia.html" title="">Patagonia, So. America</a></li>');
	document.write('										<li><a href="albums_newzealand.html" title="">New Zealand</a></li>');
	document.write('									</ul>');
	document.write('								</li>');
	document.write('							</ul>');
	document.write('						</li>');
	document.write('						<li><a href="quotes.html" title="">Quotes &amp; Stories</a>');
	document.write('							<ul>');
	document.write('								<li><a href="quotes_fishing.html" title="">Fishing Quotes</a></li>');
	document.write('								<li><a href="quotes_lastwords.html" title="">A Fisherman&#39;s Last Words</a></li>');
	document.write('								<li><a href="quotes_petfish.html" title="">Chuck&#39;s Pet Fish</a></li>');
	document.write('								<li><a href="quotes_drinking.html" title="">Drinking Quotes</a></li>');
	document.write('								<li><a href="quotes_general.html" title="">General Quotes</a></li>');
	document.write('							</ul>');
	document.write('						</li>');
	document.write('						<li><a href="albums_featured.html" title="">About</a></li>');
	document.write('						<li><a href="contact.html" title="">Contact</a></li>');
	document.write('					</ul>');
	document.write('				</div>');
	document.write('				<!--[if !IE]>end menu<![endif]-->');
	document.write('			</div>');

	document.write('			<!--[if !IE]>start option divs (search, feed, login)<![endif]-->');
	document.write('			<div id="options_wrapper">');
	document.write('				<div id="search">');
	document.write('					<form action="javascript:callsearch();" name="searchform" method="post">');
	document.write('						<p>');
	document.write('							<input type="text" class="input_search" name="searchwords" value="Search..." />');
	document.write('							<input type="submit" class="button_search" name="searchsubmit" id="searchsubmit" value="" />');
	document.write('						</p>');
	document.write('					</form>');
	document.write('				</div>');
	document.write('				<div id="twitter_biff">');
	document.write('					<p style="position:relative;left:85px;top:22px"><a href="http://twitter.com/#!/alabiff" target="_blank" style="color:#dddddd;font-weight:400"><i>[ Because I <strike>Fly Fish</strike> Tweet ]</i></a></p>');
	document.write('				</div>');
	document.write('				<div id="login">');
	document.write('					<form action="" method="get">');
	document.write('						<p>');
	document.write('							<input type="text" class="" name="username" value="Username" />');
	document.write('							<input type="password" class="" name="password" value="Password" />');
	document.write('							<input type="submit" class="button_login" name="btn_login" id="btn_login" value="" />');
	document.write('						</p>');
	document.write('					</form>');
	document.write('				</div>');
	document.write('			</div>');
	document.write('			<!--[if !IE]>end option divs<![endif]-->');
	document.write('		</div>');

	document.write('		<!--[if !IE]>start breadcrumb<![endif]-->');
	document.write('		<div class="center breadcrumb">');
	document.write('			<p><a href="index.html" title="">Home</a> / Search Results</p>');
	document.write('		</div>');
	document.write('		<!--[if !IE]>end breadcrumb<![endif]-->');
	document.write('	</div>');

}

function templateEnd()
{

	document.write('			</div>');

	document.write('			<!--[if !IE]>start sidebar<![endif]-->');
	document.write('			<div class="box_one_third last" id="right_sidebar">');
	document.write('			');
	document.write('				<span id="sidebar_top"></span>');
	document.write('				<span id="sidebar_bottom"></span>');

	document.write('					<div class="box">');
	document.write('						<h3 class="label">Search alaBIFF.com</h3>');
	document.write('						<form action="javascript:doSearch();" name="searchform_sub" method="post" id="searchform_sub">');
	document.write('							<div>');
	document.write('								<label for="searchwords_sub">Search for:</label>');
	document.write('								<input type="text" value="" name="searchwords_sub" id="searchwords_sub" />');
	document.write('								<input type="submit" name="searchsubmit_sub" id="searchsubmit_sub" value="Search" />');
	document.write('							</div>');
	document.write('						</form>');
	document.write('					</div>');

	document.write('					<div class="box"><h3 class="label">Photo Categories</h3>');
	document.write('						<ul class="arrows_list">');
	document.write('							<li><a href="journals_utah.html" title="">Utah Albums</a></li>');
	document.write('							<li><a href="journals_idaho.html" title="">Idaho Albums</a></li>');
	document.write('							<li><a href="journals_montana.html" title="">Montana Albums</a></li>');
	document.write('							<li><a href="journals_us.html" title="">More Albums - U.S.</a></li>');
	document.write('							<li><a href="journals_abroad.html" title="">More Albums - Abroad</a></li>');
	document.write('						</ul>');
	document.write('					</div>');

	document.write('				<!--[if !IE]>start box<![endif]-->');
	document.write('				<div class="box">');
	document.write('					<h3 class="label">Featured Fishermen:</h3>');
	document.write('					<ul class="arrows_list">');
	document.write('						<li><a href="searchresults.html?keywords=Chuck.Blattner&and=0" title="">Chuck Blattner</a></li>');
	document.write('						<li><a href="searchresults.html?keywords=Steve.Boos&and=0" title="">Steve Boos</a></li>');
	document.write('						<li><a href="searchresults.html?keywords=Jerry.Brewster&and=0" title="">Jerry Brewster</a></li>');
	document.write('						<li><a href="searchresults.html?keywords=Rease.Burk&and=0" title="">Rease Burk</a></li>');
	document.write('						<li><a href="searchresults.html?keywords=Steve.Christenson&and=0" title="">Steve Christenson</a></li>');
	document.write('						<li><a href="searchresults.html?keywords=Mike.Crosland&and=0" title="">Mike Crosland</a></li>');
	document.write('						<li><a href="searchresults.html?keywords=Bill.Harper&and=0" title="">Bill Harper</a></li>');
	document.write('						<li><a href="searchresults.html?keywords=Troy.McKinnon&and=0" title="">Troy McKinnon</a></li>');
	document.write('						<li><a href="searchresults.html?keywords=Pete.Morley&and=0" title="">Pete Morley</a></li>');
	document.write('						<li><a href="searchresults.html?keywords=Monte.Schooley&and=0" title="">Monte Schooley</a></li>');
	document.write('						<li><a href="searchresults.html?keywords=Ryan.Whittekiend&and=0" title="">Ryan Whittekiend</a></li>');
	document.write('						<li><a href="searchresults.html?keywords=Scott.Whittekiend&and=0" title="">Scott Whittekiend</a></li>');
	document.write('						<li><a href="searchresults.html?keywords=Steven.Whittekiend&and=0" title="">Steven Whittekiend</a></li>');
	document.write('					</ul>');
	document.write('				</div>');
	document.write('				<!--[if !IE]>end box<![endif]-->');

	document.write('			</div>');
	document.write('			<!--[if !IE]>end sidebar<![endif]-->');
	document.write('		</div>');

	document.write('	</div>');
	document.write('	<!--[if !IE]>end main<![endif]-->');

	document.write('	<!--[if !IE]>start footer<![endif]-->');
	document.write('	<div class="wrap_fullwidth" id="footer_back_ground">');
	document.write('		<div class="center">');
	document.write('			<div id="footer">');
	document.write('				<ul class="menu_clone">');
	document.write('					<li><a href="index.html" title="">Home</a>&nbsp;&nbsp;|&nbsp;</li>');
	document.write('					<li><a href="albums.html" title="">Photo Gallery</a>&nbsp;&nbsp;|&nbsp;</li>');
	document.write('					<li><a href="quotes.html" title="">Quotes &amp; Stories</a>&nbsp;&nbsp;|&nbsp;</li>');
	document.write('					<li><a href="albums_featured.html" title="">About</a>&nbsp;&nbsp;|&nbsp;</li>');
	document.write('					<li><a href="contact.html" title="">Contact</a>&nbsp;&nbsp;|&nbsp;</li>');
	document.write('				</ul>');
	document.write('				<ul class="networks">');
	document.write('					<li><a href="http://twitter.com/#!/alabiff" target="_blank" title="Twitter, a la BIFF"><img src="images/network_icons/twitter.png" alt="Twitter" /></a></li>');
	document.write('				</ul>');
	document.write('				<p class="copyright"> &copy; alaBIFF.com. All rights reserved.&nbsp;&nbsp;|&nbsp;&nbsp;Website implementation by <a href="http://www.techkind.com" title="Kind Web Solutions @ techkind.com" target="_blank">TechKind</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#top" title="top">top</a></p>');
	document.write('			</div>');
	document.write('		</div>');
	document.write('	</div>');
	document.write('	<!--[if !IE]>end footer<![endif]-->');

	document.write('</body>');
	document.write('</html>');

}

function bannerCode()
{
}


//-----------------------------------------------------------------------------------------------

var finds =0;
var sites =0;
var version = "v5.0"
var andresult = false;
var SortResults = true;
var display_start = 1;	
var displast = 10;

function searchAll(keyword)
{
	var timeA=new Date();
	var nw=1;
	finds=0;
	sites=0;

	var x = parseIt(keyword);
	if(x == -1)	return;
	total_keywords=x;

	document.open();
	document.clear();
	AddBody();

	if (keyword.length>50) keyword=keyword.substring(0,60)+"...";

	results=new makeArray(records_count,1);
	order=new makeArray(records_count,1);
	for (q=1; q<=results.length; q++){
		results[q]=0;
		order[q]=q;
	}

	data=new makeRecordLinks(records_count);

	while(keywords[nw].length > 1)
	{
		search(data,keywords[nw]);
		nw++;
	}

	if (andresult)
	{
		for (a=1; a<=results.length; a+=1)
		{
			if (results[a]>0)
			{
				if (results[a]<=(total_keywords-1)*2)
				{
					results[a]=0;
					sites-=1;
				}
			}
		}
	}

	var temp =0;

	if ((SortResults==true)&&(keywords!='[all]'))
	{
	 	for (a=results.length; a>=2; a-=1)
		{
			for (b=1; b<a; b+=1)
			{
				if (results[order[a]]>results[order[b]])
				{
					temp=order[b];
					order[b]=order[a];
					order[a]=temp;
				}
			}
		}
	} else {
		b=0;
	 	for (a=results.length; a>=2; a-=1)
		{
			if (results[a]>0)
			{
				order[b]=a;
				b++
			}
		}
	}

	// Now we build the output page
	displast=display_start+10;
	if (displast>sites) displast=sites+1;

	var timeB=new Date();

	document.write('			<h2 id="page_title" class="line_back_ground">Search Results</h2>');
	document.write('			<p id="slogan">Because I Fly Fish<br>Showing results <b>'+display_start+'-'+(displast-1)+'</b> of <b>'+sites+'</b> for <b>&quot;'+keyword+'&quot;</b> ...</p>');
	document.write('		</div>');
	document.write('	</div>');
	document.write('	<!--[if !IE]>end intro<![endif]-->');
	document.write('	<!--[if !IE]>strat main<![endif]-->');
	document.write('	<div class="wrap_fullwidth" id="main">');
	document.write('		<div class="center">');
	document.write('			<div class="box_two_third">');
	document.write('			<p class="clear_margin">&nbsp;</p>');
	document.write('			<h3 class="label">Passion for the Pursuit ...</h3>');

	if (finds==0)
	{
		document.write("<p class='clear_margin'>&nbsp;</p>"+
						"<h4><font color='#007ba7'>No hits on <b>''"+keyword+"''</b></font></h4>"+
						"<p class='clear_margin'>&nbsp;</p>"+
						"<p>Your search for <b>&quot;"+keyword+"&quot;</b> did not match any documents in our database.</p>"+
						"<ul class='check_list'>"+
						"<li><span>Make sure all words are spelled correctly.</span></li>"+
						"<li><span>Try using fewer words.</span></li>"+
						"<li><span>Try using more general keywords.</span></li>"+
						"<li><span>Try different keywords.</span></li>"+
						"</ul>"+
						"<p class='clear_margin'>&nbsp;</p>"+
						"<p><b>--&nbsp;or&nbsp;--</b></p>"+
						"<ul class='check_list'>"+
						"<li><span>Your fishing buddy may not be in the alaBIFF.com database.</span></li>"+
						"<li><span>We have not fished the location you are searching.</span></li>"+
						"<li><span>We have not caught the fish you are searching.</span></li>"+
						"</ul>");
			
		DisplayXSearch();
		document.close();
		return
	}

	q2=display_start;
	q3=displast;
			document.write("<ul class='thumbnail_list'>");
	for (q=display_start; q<q3;)
	{
		if (results[order[q]]>0)
		{
			document.write("<li>");
			document.write(data[order[q]].v1);
			x1=v1[order[q]].indexOf('http://')+7;
			if (x1==6) x1=v1[order[q]].indexOf('href=')+5;
			x2=v1[order[q]].indexOf('>');
			if (x1>0 && x2>0)
			{
				tmp=v1[order[q]].substring(x1,x2);
				x2=tmp.indexOf(' ');
				if (x2>0) tmp=tmp.substring(0,x2);
				if (tmp.substring(0,1)=="'") tmp=tmp.substring(1,tmp.length-1);
				if (tmp.substring(0,1)=='"') tmp=tmp.substring(1,tmp.length-1);
				document.write("<p>"+v3[order[q]]+"</p>");
				document.write("<p class='post_meta'>"+v4[order[q]]+"</p>");
				document.write("</li>");
			}
			q2++;
   		}
		q+=1;
	}
				document.write("</ul>");

	if (finds>10)
	{
		document.write("<BR>");
		pages=Math.round(finds/10);
		if (finds%10<6)	pages++;

		// Create the parameter string
		paramstring=searchname+"?keywords="+keyword+"&and="+andresult+"&sort="+SortResults;

		document.write("<div id='pagination' class='portfolio'>");
		if (display_start>1) document.write("<a href='"+paramstring+"&disp="+(display_start-10)+"'>&laquo;</a>");

		document.write("&nbsp;&nbsp;");

		for (i=1; i<=pages;){
			if ((((i-1)*10)+1)<=sites) {
				document.write("<a href='"+paramstring+"&disp="+(((i-1)*10)+1)+"' title='' id='"+i+"'>"+i+"</a>&nbsp; ");
			}
			i++;
		}

		if (displast<=sites) document.write("<a href='"+paramstring+"&disp="+(displast)+"'>&raquo;</a>");
		document.write("</div>");
	}

	DisplayXSearch();
	document.close();
}

function Cat()
{
	document.open();
	document.clear();
	AddBody();
	DisplayXSearch();
	document.close();
}


function makeArray(n,vartype) {
	this.length = n;
	for (var k = 1; k <= n; k++) {
		if (vartype==0){
			this[k] = "";
		} else {
			this[k] = 0;
		}
	}
	return this;
}

function stripInput(key)
{
	while(key.substring(0,1) == ","  || key.substring(0,1) == " " ) key = key.substring(1,key.length);
	while(key.substring(key.length-1,key.length) == "," || key.substring(key.length-1,key.length) == " ") key = key.substring(0,key.length-1);
	return key;
}

function parseIt(key) {
	key = stripInput(key)+" ";
	var y = 1;

	while(key.indexOf(" ") > 0)
	{
		if (key.substring(0,1)=='"')
		{
			var pos=key.indexOf('"',2);
			keywords[y]=key.substring(1,pos);
			keywords[y]=stripInput(keywords[y]);
			y++;
			key=key.substring(pos+1,key.length);
		} else {
			var pos=key.indexOf(' AND ');
			if ((pos>0) && (key.indexOf(' ')>=pos))
			{
				pos=key.indexOf(' ',pos+5);
				keywords[y]=key.substring(0,pos);
				keywords[y]=stripInput(keywords[y]);
				y++;
				key=key.substring(pos+1,key.length);
				if (key.substring(0,4)=='AND ')
				{
					pos=keywords[y-1].indexOf(' ')+5;
					key=keywords[y-1].substring(pos,keywords[y-1].length)+' '+key;
				}
			} else {
		  		var pos=key.indexOf(' OR ');
		  		if ((pos>0) && (key.indexOf(' ')>=pos))
				{
					pos=key.indexOf(' ');
					keywords[y]=key.substring(0,pos);
					keywords[y]=stripInput(keywords[y]);
					if (keywords[y]!=keywords[y-1])	y++;
					key=key.substring(pos+1,key.length);
					pos=key.indexOf('OR ');
					key=key.substring(pos+3,key.length);
					pos=key.indexOf(' ');
					keywords[y]=key.substring(0,pos);
					keywords[y]=stripInput(keywords[y]);
					y++;
					key=key.substring(pos+1,key.length);
					if (key.substring(0,3)=='OR ') key=keywords[y-1]+' '+key;
				} else {
					var pos = key.indexOf(" ");
					keywords[y]=key.substring(0,pos);
					keywords[y] = stripInput(keywords[y]);
					y++;
					if(y > 50) return -1
					key=key.substring(pos+1,key.length);
				}
			}
		}
	}
	return y-1;
}


var keywords = new makeArray(50,0);
var results;
var foundword;
var data;
var order;
var total_keywords;

function dataEntry ()
{
        this.v1="";
        this.v2="";
        return this;
}

function makeRecordLinks(size)
{
	this.length = size;
	for (var r=1; r<= size; r++)
	{
           this[r] = new dataEntry();
           this[r].v1 = v1[r];
           this[r].v2 = v2[r];
	}
	return this;
}

function AddBody()
{
	var keytext='"'+searchname+'?keywords="+';
	var andtext='"&and="+';

	document.write('<script>function doSearch(){'+
						'searchwords=document.searchform_sub.searchwords_sub.value; '+
						'while (searchwords.indexOf(" ")>-1){ pos=searchwords.indexOf(" ");'+
						'searchwords=searchwords.substring(0,pos)+"+"+searchwords.substring(pos+1); }'+
						'document.location='+keytext+' searchwords+'+andtext+'"0"}'+
						'<'+'/'+'script>'
						);

	templateBody();
	document.write('	<!--[if !IE]>start intro<![endif]-->');
	document.write('	<div class="wrap_fullwidth big_padding" id="intro">');
	document.write('		<div class="center">');
	if (usebannercode) bannerCode();
}

function DisplayXSearch()
{
	templateEnd();
}

function search(records, keyword)
{
	var hit=0;
	var addcomplete=0;
	
	for (q=1; q<=records.length; q++) {
	addcomplete=0;
	search_parm=records[q].v2.toLowerCase()+" "+v3[q].toLowerCase();
	
	if (keyword.indexOf(' AND ')>0)
	{
		firstword=keyword.substring(0,keyword.indexOf(' '));
		lastword=keyword.substring(keyword.indexOf(' AND ')+5,keyword.length);
		if ((search_parm.indexOf(" "+firstword+" ") != -1) && (search_parm.indexOf(" "+lastword+" ")!= -1 ))
		{
			hit++;
			finds++;
			if(hit < 2)
			{
				if (results[q]==0) sites++;
				results[q] +=2;
			}
		}
	} else {
		keyword=keyword.toLowerCase();
		if ((search_parm.indexOf(" "+keyword+" ") != -1) ||(keyword=="[all]"))
		{
			hit++;
			finds++;
			if(hit<2)
			{
				if (results[q]==0) sites++;
				results[q]+=2;
			}
		} else {
			// check for a half hit (ie. search:share find:SHAREware)
			if (search_parm.indexOf(keyword) != -1)
			{
				hit++;
				finds++;
				if(hit < 2)
				{
					if (results[q]==0) sites++;
					results[q]+=1;
					x=search_parm.indexOf(keyword)+keyword.length;
					pos=search_parm.substring(1,x-keyword.length);
					while (pos.indexOf(" ")!=-1)
					{
						y=pos.indexOf(" ");
						pos=pos.substring(y+1,pos.length);
					}
					if (pos.length<=2) addcomplete++;

					pos=search_parm.substring(x,search_parm.length);
					fullresult=search_parm.substring(x,x+pos.indexOf(" "));
					
					if (fullresult.length<=2) addcomplete++;
					if (addcomplete>1) results[q]+=1;
				}
			}
		}
	}
	hit=0;
	}
}

var searchwords = '';
var newload = true;

function countParams(text)
{
	pos=-1;
	tmp = "";
	if (text=='') return 0;
	text=text+'&';
	i=0;
	while (text.length>0)
	{
		pos=text.indexOf('&',0);
		tmp=text.substring(pos+1);
		text=tmp;
		i++;
	}
	return i;
}	

function getCommand(text,val)
{
	pos=-2;
	tmp = "";
	text=text+'&';
		
	for (i=0; i<=val;)
	{
		pos2=pos+2;
		pos=text.indexOf('&',pos2);
		tmp=text.substring(pos,pos2-1);
		i++;
	}
	text=tmp;
	pos=text.indexOf('=',0);
	if (pos!=-1) tmp=text.substring(pos,0);
	tmp=tmp.toLowerCase();
	return tmp;
}

function getValues(text,val)
{
	pos=-2;
	tmp = "";
	text=text+'&';
	for (i=0; i<=val;)
	{
		pos2=pos+2;
		pos=text.indexOf('&',pos2);
		tmp=text.substring(pos,pos2-1);
		i++;
	}
	text=tmp;
	pos2=text.indexOf('=',0)+1;
	if (pos2!=-1)
	{
		tmp=text.substring(pos2);
	} else {
		tmp=''
	}
	
	pos=-2;
	text=tmp;	
	if (text.indexOf('%20')>0)
	{
		pos=text.indexOf('%20',0);
		tmp=text.substring(0,pos2-4)+' '+text.substring(pos2-1,text.length);
		text=tmp;
	}
	return tmp;
}		

function initXsearch()
{
	if (searchwords!='')
	{
		searchAll(searchwords);
	} else {
		if (newload) Cat();
	}
}

function doParamStuff(findw)
{
	Myparams=countParams(findw);
	if (Myparams>0)
	{
		for (cnt=0; cnt<Myparams;)
		{
			tempw=getCommand(findw,cnt);
			tempv=getValues(findw,cnt);

			if (tempw=='keywords')
			{
				searchwords=getValues(findw,cnt);
				origsearchwords=searchwords;
				while (searchwords.indexOf('+')>-1)
				{
					pos=searchwords.indexOf('+');
					searchwords=searchwords.substring(0,pos)+' '+searchwords.substring(pos+1);
				}
			}
			if (tempw=='sort')
			{
				if ((tempv=='0')||(tempv=='false'))
				{
					SortResults=false;
				} else {
					SortResults=true;
				}
			}
					
			if (tempw=='and')
			{
				if ((tempv=='1')||(tempv=='true'))
				{
					andresult=true;
				} else {
					andresult=false;
				}
			}

			if (tempw=='disp') display_start=parseInt(tempv);
			cnt +=1;
		}
	}
}

findw=document.location.search;
findw="&"+findw.substring(1,findw.length);

while (findw.indexOf('%20')>0)
{
	pos2=findw.indexOf('%20',0);
	tmp=findw.substring(0,pos2)+' '+findw.substring(pos2+3,findw.length);
	findw=tmp;
}

doParamStuff(findw);

