var http_request = false;
var naseptavac_value;
function createAjax(){
if (window.XMLHttpRequest) {
http_request = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (eror) {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
}
}
function ajax_go(site,request,onok) {
if(http_request==false){
createAjax();
http_request.onreadystatechange = onok;
http_request.open('POST', site, true);
http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
http_request.send(request);
}
}
function naseptavac_zpracuj() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
if(http_request.responseText!=''){
document.getElementById('naseptavac').style.display='';
document.getElementById('naseptavac').innerHTML=http_request.responseText;
} else {
document.getElementById('naseptavac').style.display='none';
}
http_request = false;
}
}
}
function naseptavac(obj){
document.getElementById('searchinput').setAttribute("autocomplete", "off");
naseptavac_value = obj.value;
setTimeout(
function(){
if (naseptavac_value != obj.value) {
return false;
}
ajax_go('/naseptavac.php','q='+obj.value+'&sub=krizenci-psu',function(){naseptavac_zpracuj();});
}
,250);
}