/* START customsearch object */
		
if (!customsearch)	var customsearch = {};

customsearch.init = function ()
{
	// add customsearch 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 = "wp-content/themes/nachix/search.css";
	}
}

// called when on user input - toggles clear fld btn
customsearch.onChange = function (fldID, btnID)
{
	// check whether to show delete button
	var fld = document.getElementById( fldID );
	var btn = document.getElementById( btnID );
	if (fld.value.length > 0 && !this.clearBtn)
	{
		btn.style.background = "transparent url('wp-content/themes/nachix/images/srch_r.gif') no-repeat -19px 0";
		btn.style.width = "19px";
		btn.style.height = "19px";
		btn.style.cursor = "pointer";
		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 = "transparent url('wp-content/themes/nachix/images/srch_r.gif') no-repeat 0 0";
		btn.style.width = "19px";
		btn.style.height = "19px";
		btn.onclick = null;
		this.clearBtn = false;
	}
}

//clears field onfocus
customsearch.clear = function (fldID)
{
  var fld = document.getElementById( fldID );
	fld.value = "";
}

// clears field
customsearch.clearFld = function (fldID,btnID)
{
	var fld = document.getElementById( fldID );
	fld.value = "";
	this.onChange(fldID,btnID);
}

// called by btn.onclick event handler - calls clearFld for this button
customsearch.clearBtnClick = function ()
{
	customsearch.clearFld(this.fldID, this.id);
}

/* END customsearch object */