var xmlHttp

function showResult(str) {
	
	// Reset if no input
	if( 0 == str.length ) {
		document.getElementById("livesearch").innerHTML="";
  	document.getElementById("livesearch").style.border="0px";
  	return;
	}
	xmlHttp = GetXmlHttpObject();
	
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
			document.getElementById("livesearch").innerHTML=xmlHttp.responseText;
    	document.getElementById("livesearch").style.border="1px solid #A5ACB2";
		}
	}
	xmlHttp.open("GET","scripts/livesearch.php?q="+str,true);
	xmlHttp.send();
}

function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
      {
          // Firefox, Chrome, 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;
}
