function spotlightSearchTool() {
	this.searchUrl 		= '/ajax.php?module=search&';
	this.form 			= $("spotlightSearchForm");
	this.results		= $("spotlightSearchResults");
	this.searchTerm		= $('spotlightSearchTerm');
}

spotlightSearchTool.prototype.execute = function() {
	p = Form.serialize(this.form);
	
	load_doc('spotlightSearchResults', this.searchUrl+p);
	
	this.results.show();

}

spotlightSearchTool.prototype.hide = function() {

	if(! this.form)
		return false;
		
	this.form.hide();
	this.results.hide();
	this.searchTerm.value = "";

}

spotlightSearchTool.prototype.show = function() {

	this.form.show();
	this.searchTerm.focus();
}

spotlightSearchTool.prototype.keyEvent = function(e) {
	if(e.keyCode == 27) { this.hide();    return false; }
	if(e.keyCode == 13) { this.execute(); return false; }

	if(this.searchTerm.value.length > 2)
		this.execute();
		
	return true;
}

spotlightSearchTool.prototype.toggle = function() {
	if(this.form.getStyle('display') == 'block')
	{
		this.hide();
	} else {
		this.show();
	}
}

/*
document.observe("dom:loaded", function() {
	spotlightSearch= new spotlightSearchTool;
});
*/
