var xmlHttp; 

function SendXmlHttpRequest(xmlhttp, url) { 
    xmlhttp.open('GET', url + "&randomId=" + Math.random(), true); 
    xmlhttp.send(null); 
}
 
function SendXmlHttpPost(xmlhttp, url, sData) { 
    xmlhttp.open('POST', url, false); 
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlhttp.send(sData); 
}

function GetMSXmlHttp() {
    var xmlHttp = null;
    var clsids = ["Msxml2.XMLHTTP.6.0",
                  "Msxml2.XMLHTTP.4.0",
                  "Msxml2.XMLHTTP.3.0"];
    for(var i=0; i<clsids.length && xmlHttp == null; i++) {
        xmlHttp = CreateXmlHttp(clsids[i]);
    }
    return xmlHttp;
}

function CreateXmlHttp(clsid) {
    var xmlHttp = null;
    try {
        xmlHttp = new ActiveXObject(clsid);
        lastclsid = clsid;
        return xmlHttp;
    }
    catch(e) {}
}

function GetXmlHttpObject(handler)
{ 
    var objXmlHttp = null;
    if (window.XMLHttpRequest && !(window.ActiveXObject))
    {
        // Mozilla | Netscape | Safari
        objXmlHttp = new XMLHttpRequest();
        if (objXmlHttp != null)
        {
            objXmlHttp.onload = handler;
            objXmlHttp.onerror = handler;
        }	
    } 
    else if(window.ActiveXObject)
    {
        // Microsoft
        objXmlHttp = GetMSXmlHttp();
        if (objXmlHttp != null)
        {
            objXmlHttp.onreadystatechange = handler;
        }
    } 
    return objXmlHttp; 
} 

function ExecuteAjax(url, CallBackMethod)
{ 
    try 
    { 
        xmlHttp = GetXmlHttpObject(CallBackMethod); 
        SendXmlHttpRequest(xmlHttp, url); 
    }
    catch(e)
	{
		alert("An Ajax error has occurred.  Please try again.  If this problem persists, please contact Rogerjob support.");
	} 
}

function ExecuteAjaxPost(url, sData, CallBackMethod)
{ 
    try 
    { 
        xmlHttp = GetXmlHttpObject(CallBackMethod); 
        SendXmlHttpPost(xmlHttp, url, sData); 
    }
    catch(e)
	{
		alert("An Ajax error has occurred.  Please try again.  If this problem persists, please contact Rogerjob support.");
	} 
} 
