// JavaScript Document

document.onclick=check;

function check(e){
var target = (e && e.target) || (event && event.srcElement);
var obj = document.getElementById('livesearch');
var obj2 = document.getElementById('sho');
checkParent(target)?obj.style.display='none':null;
target==obj2?obj.style.display='block':null;
}
function checkParent(t){
while(t.parentNode){
if(t==document.getElementById('livesearch')){
return false
}
t=t.parentNode
}
return true
}

var xmlHttp

function showResult(str)
{

if (str.length==0)
 { 
// document.getElementById('Loading').style.visibility='hidden';
 document.getElementById('livesearch').style.display='none';
 document.getElementById("livesearch").
 innerHTML="";
 document.getElementById("livesearch").
 style.border="1px solid #999999";
return
 }

xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 

var url="livesearch_db.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)

} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("livesearch").innerHTML=xmlHttp.responseText;
 document.getElementById("livesearch").style.border="1px solid #999999";
document.getElementById("livesearch").style.padding="4px";
document.getElementById("livesearch").style.align="left"; 
 //document.getElementById('Loading').style.visibility='hidden';
 }
}

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;
}
