var gebi = function(el){
	var t=typeof(el);
	switch(t) {
		case 'string':
			return document.getElementById(el);
		case 'object':
			return el;
		default:
			return null;
	}
}
var Dom = YAHOO.util.Dom;
var fhp = {
	err: function(txt){ alert('Error: '+txt+''); },
	_status_el: null,
	status_txt: function(el,txt) {
		Dom.getElementsBy(
			function(n){ return (n && n.id && n.id=='fhstatuscnt');}
			, 'td', el,
			function(n){ n.innerHTML=txt; }
		);
	},
	status_el: function() {
		if (!this._status_el)
			this._status_el = gebi('fhstatus');
		return this._status_el;
	},
	status: function(txt) {
		var el=this.status_el();
		if (el) {
			this.status_show();
			if (typeof(txt)!='undefined')
				this.status_txt(el,txt);
		}
	},
	status_show: function() {
		var el=this.status_el();
		if (el) Dom.addClass(el,'status');
	},
	status_hide: function() {
		var el=this.status_el();
		if (el) Dom.removeClass(el,'status');
	},
	deftxt: '',
	setup: function(o) {	
		var el=gebi(o.el),t=this.deftxt;
		if (el) {
			el.fho = o;
			el.onfocus=function(){
				var el=this;
				if (el.value==fhp.deftxt)
					el.value='';
				el.defval=el.value;
			}
			el.onblur=function(){
				if (!this.value)
					this.value=fhp.deftxt;
			}
			el.onkeyup=function(e) {
				var el=this;
				if (el.value!=el.defval) {
					if (el.value.length>2) {
						fhp.status("Searching for <b>"+el.value+'</b>');
					}
					el.defval=el.value;
				}	
			}
			if (!el.value && el.value!=fhp.deftxt)
				el.value = t;
			else
				el.focus();
		}
	}
}

