temp_hash='';
if (!applesearch)	var applesearch = {};

applesearch.init = function ()
{
	// add applesearch css for non-safari, dom-capable browsers
	if ( navigator.userAgent.toLowerCase().indexOf('safari') < 0  && document.getElementById )
	{
		this.clearBtn = false;
		// add style sheet if not safari
		var dummy = document.getElementById("dummy_css");
		if (dummy)	dummy.href = "_version2/_css/_search/applesearch.css";
	}
}

// called when on user input - toggles clear fld btn
applesearch.onChange = function (fldID, btnID)
{
	// adjust the #has
	//alert (window.location.hash.substring(2,7));
	
	
	//
	// check whether to show delete button
	//var fld = document.getElementById( fldID );
	// fix by Akiem > because the ID of this input field changes dynamically
	var fld = document.getElementsByName( fldID );
	var fld =fld[0];
	var btn = document.getElementById( btnID );
	if (fld.value.length > 0 && !this.clearBtn)
	{
		btn.style.background = " url('_version2/_css/_search/srch_r_f2.png') no-repeat top left";
		btn.fldID = fldID; // btn remembers it's field
		btn.onclick = this.clearBtnClick;
		this.clearBtn = true;
	} else if (fld.value.length == 0 && this.clearBtn)
	{
		btn.style.background = " url('_version2/_css/_search/srch_r.png') no-repeat top left";
		btn.onclick = null;
		this.clearBtn = false;
	}

	//alert (">" + document.getElementById('srch_fld').value)
	if (window.location.hash.substring(2,7) !="find/") 						temp_hash = window.location.hash;
	if (document.getElementById('srch_fld').value=='' && temp_hash =='') 	window.location.hash = '';
	if (document.getElementById('srch_fld').value=='' && temp_hash !='') 	window.location.hash = temp_hash;
	if (document.getElementById('srch_fld').value!='')  					window.location.hash = '/find/' + document.getElementById('srch_fld').value;
}


// clears field
applesearch.clearFld = function (fldID,btnID)
{
	var fld = document.getElementByName( fldID );
	fld.value = "";
	this.onChange(fldID,btnID);
}

// called by btn.onclick event handler - calls clearFld for this button
applesearch.clearBtnClick = function ()
{
	applesearch.clearFld(this.fldID, this.id);
}

/* END applesearch object */

