4 var ls_delay
= 500; // Search delay after key up
5 var ls_hidedelay
= 500; // Hide delay after lose focus (must be > 0)
7 var ls_mainDiv
= 0, // Main div
8 ls_begin_timer
= new Number(0);
10 function ls_postLoad()
12 var ls_input
= getElementsByClass('ls_search', null, 'input');
15 for (i
=0;i
<ls_input
.length
; i
++)
17 var input
= ls_input
[i
];
18 input
.setAttribute("autocomplete", "off");
19 addEvent(input
, 'keyup', liveSearch
);
20 addEvent(input
, 'focus', liveSearch
);
21 addEvent(input
, 'input', liveSearch
);
22 addEvent(input
, 'blur', ls_hide
);
27 ls_body
= document
.body
|| document
.documentElement
;
28 ls_mainDiv
= insertElement(ls_body
, 'DIV', 'ls_my_livesearch');
29 ls_mainDiv
.style
.position
= "absolute";
30 ls_mainDiv
.style
.zIndex
= 10;
31 addLoadEvent(ls_postLoad
);
33 function ls_dosearch(parent
)
35 my_AJAX
.GETupload('ajax.php?ls=' + parent
.alt
+ '&name=' + parent
.value
, function (text
){ls_show(parent
, text
);});
39 var name
= this.value
, input
= this;
46 ls_begin_timer
.Timer(function (){ls_dosearch(input
)}, ls_delay
, true);
50 function ls_show(parent
, text
)
52 ls_mainDiv
.innerHTML
= text
;
53 parseHref(ls_mainDiv
);
54 var bounds
= getBounds(parent
);
57 y
= bounds
.top
+ bounds
.height
+1,
58 max_x
= p
.width
- ls_mainDiv
.offsetWidth
,
59 max_y
= p
.height
- ls_mainDiv
.offsetHeight
,
60 x
= x
> max_x
? max_x
: x
;
61 y
= y
> max_y
? max_y
: y
;
62 var css
= ls_mainDiv
.style
;
63 css
.left
= (x
< p
.left
? p
.left
: x
) + 'px';
64 css
.top
= (y
< p
.top
? p
.top
: y
) + 'px';
65 css
.display
= "block";
69 ls_mainDiv
.style
.display
= "none";
73 ls_begin_timer
.Timer('ls_doHide()', ls_hidedelay
, true);