var theTimeout;var liveSearchLast="";var isIE=false;var searchInProgress=false;function liveSearchInit(){if($("livesearch")){if(navigator.userAgent.indexOf("Safari")!=-1){$("livesearch").addEventListener("keydown",liveSearchKeyPress,false)}else{if(navigator.product=="Gecko"){$("livesearch").addEventListener("keypress",liveSearchKeyPress,false)}else{$("livesearch").attachEvent("onkeydown",liveSearchKeyPress);isIE=true}}$("livesearch").setAttribute("autocomplete","off")}}function liveSearchKeyPress(c){var d=c.keyCode;var a=$("LSHighlight");var b=$("LSRes");switch(d){case 27:if(a){a.removeAttribute("id")}closeResults();document.forms.searchform.s.value="";liveSearchLast="";return;break;case 40:if(!a){a=b.firstChild}else{a.removeAttribute("id");a=a.nextSibling}break;case 38:if(!a){a=b.lastChild}else{a.removeAttribute("id");a=a.previousSibling}break;case 9:if(theTimeout){window.clearTimeout(theTimeout)}default:return;break}if(a){a.setAttribute("id","LSHighlight")}if(!isIE){c.preventDefault()}}function liveSearchStart(){if(theTimeout){window.clearTimeout(theTimeout)}theTimeout=window.setTimeout("liveSearchDoSearch()",400)}function liveSearchDoSearch(){if(searchInProgress){return false}var c=document.forms.searchform.s.value;if(liveSearchLast!=c){if(c==""){$("LSResult").style.display="none";highlight=$("LSHighlight");if(highlight){highlight.removeAttribute("id")}return false}searchInProgress=true;var a="";var b=new Ajax.Request(liveSearchURI+c,{method:"get",parameters:a,onComplete:function(d){liveSearchProcessReqChange(d)}});liveSearchLast=c}}function liveSearchProcessReqChange(b){var a=$("LSResult");a.style.display="block";a.firstChild.innerHTML=b.responseText;searchInProgress=false;Behaviour.apply()}function liveSearchSubmit(){var a=$("LSHighlight");if(a&&a.firstChild){window.location=a.firstChild.getAttribute("href");return false}else{return true}}function closeResults(){new Effect.Fade($("LSResult"))};