var xmlHttp; var showLiveSearch = true; document.onkeydown = checkKeycode function checkKeycode(e) { var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; //alert("keycode: " + keycode); if(keycode == 27){ //Sys.UI.Key.esc document.getElementById("livesearch").style.display = "none"; showLiveSearch = false; } } function closeLiveSearch(){ document.getElementById("livesearch").innerHTML=""; document.getElementById("livesearch").style.border="0px"; return } function showLiveSearchResult(str, appPath) { if (str.length==0) { document.getElementById("livesearch").innerHTML=""; document.getElementById("livesearch").style.border="0px"; return } catIndex = document.getElementById('searchCat').selectedIndex; // if live searching in specific category cat = document.getElementById('searchCat').options[catIndex].value; xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } if(showLiveSearch == true){ var url= appPath + 'inc/live_search.php' url=url+"?cat="+cat+"&q="+encodeURIComponent(str) url=url+"&sid="+Math.random() xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) } } function stateChanged() { document.getElementById("search-bar-field").className = "on"; if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("search-bar-field").className = ""; document.getElementById("livesearch").style.display="block"; document.getElementById("livesearch").innerHTML=xmlHttp.responseText; document.getElementById("livesearch").style.border="1px solid #A5ACB2"; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }