function getRefer(){
	searched=location.search;
	if (document.referrer){
		ref=document.referrer.replace(/\w*:\/\//,"");
		domain=ref.match(/[\w_\-\.]*/);
		dom=domain[0];
		srch=ref.match(/\?.+/);
		if (srch&&srch.length) searched=srch[0];
	}
}

function hilightSearch(){
	tooCommon=" the of and a to in is you that it he for was on are as with his they at be this from I have or by had not but what were we can an your their said if do will how up out them then she so would into has her him no been its who my over did down ";
	getRefer();
	somethingHilighted=false;
	s="";
	m=new Array();
	var query=unescape(searched);
	if (query){
		query=query.slice(1);
	}
	q=query.split("&");
	for (i=0;i<q.length;i++){
		r=q[i].split("=");
		if ((r[0]=="q")||(r[0]=="p")||(r[0]=="va")||(r[0]=="query")) s=r[1];
	}
	s=unescape(s).replace(/\+/g," ");
	m=s.match(/["][^"]+["]/g);
	s=s.replace(/["][^"]+["]/g,"");
	t=s.split(" ");
	t=t.concat(m);
	for (i=0;i<t.length;i++){
		if (eval("tooCommon.match(/ "+t[i]+"\ /i)")) {
			t[i]="";
		}
		if (t[i]){
			hilight(t[i].replace(/"/g,""));
		}
	}
	if (somethingHilighted) {
		searchNotice="<div align=center style='padding:13px;'>";
		searchNotice=searchNotice+"<DIV style='text-align:left;font-family:arial,helvetica,sans-serif;font-size:12px;width:400px;margin:5px;padding:5px;background-color:black;color:skyblue;center;border:3px solid skyblue;'>The following search terms you were looking for on <B>"+dom+"</B> have been <SPAN style='background-color:white;color:red'><B>highlighted</B></SPAN> below:<UL>";
		for (i=0;i<t.length;i++){
			if (t[i]){
				searchNotice=searchNotice+"<LI style='margin:3px;margin-left:10px;'>"+t[i];
			}
		}
		searchNotice=searchNotice+"</UL>[<a href="+location.href+" target=_self>Click here</a> to get rid of highlighting.]</DIV></DIV>";
		document.body.insertAdjacentHTML("AfterBegin",searchNotice);
		tr=document.body.createTextRange();
		tr.collapse(true);
		tr.select();
		tr.scrollIntoView();
	}
}
function hilight(keyword){
	tr=document.body.createTextRange();
	for (var i=0;tr.findText(keyword) != false;i++){
		tr.select();
		document.execCommand("ForeColor","false","red");
		document.execCommand("Bold","false");
		document.execCommand("BackColor","false","white");
		tr.collapse(false);
		tr.select();
		somethingHilighted=true;
	}
}
hilightSearch();

