function getStyle(elem, name){
	if (elem.style[name])
		return elem.style[name];
	else if (elem.currentStyle)
		return elem.currentStyle[name];
	else if (document.defaultView && document.defaultView.getComputedStyle) {
		name = name.replace(/([A-Z])/g,"-$1");
		name = name.toLowerCase();
		var s = document.defaultView.getComputedStyle(elem,"");
		return s && s.getPropertyValue(name);
	}
	else
		return null; 
}
var sf = document.getElementById("ctl00_SearchTextBox");
sf.onblur = function(){
	sf.value = sf.value.replace(/\s*$/, ""); // trim
	if (sf.value.length == 0){
		// Add watermark.
		var el = document.getElementById("search");
		el.style.backgroundImage = getStyle(el,"backgroundImage").replace("search.png", "search-watermark.png");
	}
}
sf.onfocus = function(){
	// Remove watermark.
	var el = document.getElementById("search");
	el.style.backgroundImage = getStyle(el,"backgroundImage").replace("-watermark", "");
}
// Hide the watermark if there's text in the box on load
if (sf.value.length > 0)
	sf.focus();
