function prepareSearch(inForm, blnNew)
{ // all the logic to prepare the search
	// needed every time
	inForm.D.value = inForm.Ntt.value;

	if(blnNew)
	{ // called by new search
		// get the the right text term
		return adjustTheNewSearchForm(inForm);
	}
	else
	{ // refine search
		// check for boolean search
		if(hasBooleanSearchTerm(inForm.Ntt.value))
		{ // have a boolean, so swap things
			inForm.Ntx.value = "mode+matchboolean";
		}
	}
}

function hasBooleanSearchTerm(strInput)
{
	var myPat = / (OR|AND|NOT) /gi;
	return (strInput.search(myPat) > 0);
}

function adjustTheNewSearchForm(inForm)
{ // for new searches
	var myUrl = '';
	var myAuctionList = '';
	if(inForm.AuctionList)
		myAuctionList = inForm.AuctionList.options[inForm.AuctionList.options.selectedIndex].value; // need to do this for the sorry macs			
	var myNVals = inForm.NVals.options[inForm.NVals.options.selectedIndex].value; // need to do this for the sorry macs	
	if(parseInt(myAuctionList) > 0)
		myNVals += '+' + myAuctionList; // add the auction dropdown value to the N	
		
	if (inForm.Ntt.value == inForm.Ntt.defaultValue ) inForm.Ntt.value = '';
	if(inForm.Ntt.value == '') // no text specified
		myUrl = inForm.action + "?" + myNVals;
	else
		myUrl = inForm.action + "?Ntk=" + encodeURIComponent(inForm.Ntk.value) + "&Ntt=" + encodeURIComponent(inForm.Ntt.value) + "&" + myNVals;

	// check for boolean search
	if(hasBooleanSearchTerm(inForm.Ntt.value))
	{ // have a boolean, so swap things
		myUrl += "&D=" + encodeURIComponent(inForm.Ntt.value) + "&Ntx=mode+matchboolean";
	}

	location.href = myUrl + "&Ns=" + inForm.Ns.value;
	return false;
}

function adjustTheHomeForm(inForm)
{ // called on endeca homepages
	var myUrl = '';
	var myNVals = inForm.NVals.options[inForm.NVals.options.selectedIndex].value; // need to do this for the sorry macs
	if (inForm.Ntt.value == inForm.Ntt.defaultValue ) inForm.Ntt.value = '';
	if(inForm.Ntt.value == '') // no text specified
		myUrl = inForm.action + "?" + myNVals;
	else
		myUrl = inForm.action + "?Ntk=SI_Titles&Ntt=" + encodeURIComponent(inForm.Ntt.value) + "&" + myNVals;

	// check for boolean search
	if(hasBooleanSearchTerm(inForm.Ntt.value))
	{ // have a boolean, so swap things
		myUrl += "&D=" + encodeURIComponent(inForm.Ntt.value) + "&Ntx=mode+matchboolean";
	}

	location.href = myUrl + '&ic=homepage_search';

	return false;
}