// AjaxSearch 0.1
// Adding Ajax-like search into your blog easily
// By blewtooth, 2005
// http://www.start.com.my <--- there is a .my!! I'm no Microsoft!
//
// This is a free software that comes with absolutely no warranty. So please use at your own risk.

var req;

function Initialize()
{
    try
    {
        req=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            req=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(oc)
        {
            req=null;
        }
    }

    if(!req&&typeof XMLHttpRequest!="undefined")
    {
        req = new XMLHttpRequest();
	}

}
function SendQuery(key,user)
{
    Initialize();
    document.getElementById('loading').innerHTML="<img src='http://www.omnisitebuilder.com/administrator/common/image/spinner_moz.gif'>";
	document.getElementById('autocomplete').innerHTML = '';
    var url="shared/administrator/doba/ajax.search.php?s="+key+"&id="+user;
    if(req!=null)
    {
        req.onreadystatechange = Process;
        req.open("GET", url, true);
        req.send(null);
    }
}

function Process()
{
    if (req.readyState == 4)
    {
        if (req.status == 200)
        {
            if(req.responseText=="")
                HideDiv("autocomplete");
            else
            {
                ShowDiv("autocomplete");
                document.getElementById("autocomplete").innerHTML =req.responseText;
				document.getElementById('loading').innerHTML="";
            }
        }
        else
        {
            document.getElementById("autocomplete").innerHTML=
				"There was a problem retrieving data:<br>"+req.statusText;
        }
    }
}

function ShowDiv(divid)
{
   if (document.layers) document.layers[divid].visibility="show";
   else document.getElementById(divid).style.display="inline";
}

function HideDiv(divid)
{
   if (document.layers) document.layers[divid].visibility="hide";
   else document.getElementById(divid).style.display="block";
}

function BodyLoad()
{
    HideDiv("autocomplete");
    document.form1.keyword.focus();
}
