// JavaScript Document
var xmlHttp;
function getDelegates(q)
{
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } var url = "../FunctionFiles/Delegate/delegateSearch.php";
    url=url+"?q="+q;
    xmlHttp.onreadystatechange=stateChangedGetDelegates;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function checkDelegates(q)
{
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } var url = "../FunctionFiles/Admin/Delegates/delegateSearch.php";
    url=url+"?q="+q;
    xmlHttp.onreadystatechange=stateChangedGetDelegates;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function stateChangedGetDelegates()
{
    if (xmlHttp.readyState==4)
    {
        document.getElementById("possibilities").innerHTML=xmlHttp.responseText;
    }
}

function setDelegateID(dID)
{
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } var url = "../FunctionFiles/Delegate/setDelegateID.php";
    url=url+"?dID="+dID;
    xmlHttp.onreadystatechange=stateChangedSetDelegateID;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function stateChangedSetDelegateID()
{ 
    if (xmlHttp.readyState==4)
    {
        window.location = "StepTwo.php";
    }
}

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