function wjDirectSearch(form, el, baseurl){
	var _self = this;
	this.form = form;
	this.el = el;
	
	//this.el.focus();
	this.baseurl = baseurl;
	this._timer = null;
	this.eventhandler = new olEvent();
	this._global_name = '_wjDirectSearch_instance';
	
	eval(this._global_name + ' = this;');
	
	/*this._select = function(txt){
		_self.el.value = txt;
		_self.popup.style.display = 'none';
		_self.form.submit();
	};*/
	
	this._init = function(){
		this.popup = $$('div');
		this.popup.className = 'wjDirectSearch';
		this.popup.style.width = this.el.offsetWidth + 'px';
		this.popup.style.top = this.el.offsetTop + this.el.offsetHeight + 'px';
		this.popup.style.display = 'none';
		this.el.parentNode.appendChild(this.popup);
		
		this.eventhandler.observe(this.el, 'keydown',  this.key_handler_del);
		this.eventhandler.observe(this.el, 'keypress', this.key_handler_char);
		/*this.eventhandler.observe(this.popup, 'click', function(e){
			var el = e.originalTarget;
			_self._select(el.innerHTML);
		});*/
		return this;
	};
	
	this._timer_start = function(txt){
		this._timer_value = txt;
		
		if (typeof(this._timer)!='undefined')
			window.clearTimeout(this._timer);

		this._timer = window.setTimeout(this._global_name + '._timer_func()', 750);
	};
	
	this._timer_func = function(){
		var a = new olAjax(this.baseurl);
		a.onComplete = function (txt){
			this.el.innerHTML = txt;
			this.el.style.display = 'block';
		}
		a.send('?search=1&ds=1&q='+encodeURI(_self.el.value), _self.popup, 'GET');
	};
	
	this._update = function(txt){
		if (txt.length>=3)
			this._timer_start(txt);
//		__(txt);
	};
	
	this.key_handler_del = function(e){
		var v = _self.el.value;
		var c = e.keyCode ? e.keyCode : e.charCode;

		if (c == 8){
			v = v.substr(0, v.length - 1);
			_self._update(v);
		}
	};
	
	this.key_handler_char = function(e){
		var v = _self.el.value;
		var c = e.keyCode ? e.keyCode : e.charCode;

		if (c==8)
			return;

		if ((c >= 32) && (c<127))
			v += String.fromCharCode(c);
			
		_self._update(v);
	};

	return this._init();
}

