1
var global_timeout_id = null;
2
var global_search_request = null;
4
window.addEvent('domready', function()
6
var search_box = $('q');
11
if($('q').value == '')
13
$('search_terms').setStyle('display','none');
17
if (null != global_timeout_id)
19
clearTimeout(global_timeout_id);
21
global_timeout_id = setTimeout('$("q").fireEvent("search",$("q").value)',200);
25
search: function(query)
27
url = global_path + 'search?query=' + query;
29
if ($defined(global_search_request))
31
global_search_request.cancel();
33
global_search_request = new Request({'url':url,'method':'get','onComplete':cool_search});
34
global_search_request.send('');
35
var posicion = search_box.getPosition();
36
var size = search_box.getSize();
38
$('search_terms').setStyle('position','absolute');
39
$('search_terms').setStyle('left',posicion.x);
40
$('search_terms').setStyle('top',posicion.y + size.y);
41
$('search_terms').setStyle('display','block');
42
$('search_terms').set('html','Loading...');
44
new Request({'url':url,'method':'get','onComplete':cool_search}).send('');
51
function cool_search(response)
53
var posicion = $('q').getPosition();
54
var size = $('q').getSize();
55
$('search_terms').set('html',response);
56
$('search_terms').setStyle('display','block');
57
$('search_terms').setStyle('position','absolute');
58
$('search_terms').setStyle('left',posicion.x);
59
$('search_terms').setStyle('top',posicion.y + size.y);
62
function hide_search()
64
hide_div = setTimeout("$('search_terms').setStyle('display','none')", 300);