function SendQuery(key) { Initialize(); var url="ajax.php?search="+key; if(req!=null) { req.onreadystatechange = Process('autocomplete'); req.open("GET", url, true); req.send(null); } } function Process(div) { ShowDiv(div); if (req.readyState == 4) { if (req.status == 200) { if(req.responseText=="") HideDiv(div); else { ShowDiv(div); document.getElementById(div).innerHTML =req.responseText; } } } }