﻿function GetHttpRequestObject() {
    //return a browser independent XMLHttp object
    if (window.XMLHttpRequest)
        return new XMLHttpRequest();
    else if (window.ActiveXObject)
        return new ActiveXObject("Microsoft.XMLHTTP")
    else {
        alert("This site requires a browser like Internet Explorer 6+ or FireFox to be fully functional.");
        return null;
    }
}

function SendXMLHTTP(sXML, ProcessingPage) {
    //send an XML doc to a processing page
    //can be used when we don't care about the
    //readystatechanged event

    var objRequest = GetHttpRequestObject();
    objRequest.open("post", ProcessingPage, true);
    objRequest.send(sXML);
}

function GetXMLHTTPReturnVal(sXML, ProcessingPage) {
    var objRequest = GetHttpRequestObject();
    objRequest.open("post", ProcessingPage, false);
    objRequest.send(sXML);
    return objRequest.responseText;
}

function GetDomFromXMLString(sXML) {
    //returns a dom for the browser based on xml string
    var objDom;
    if (window.ActiveXObject) {
        objDom = new ActiveXObject('Microsoft.XMLDOM');
        objDom.loadXML(sXML);
    }
    else {
        objDom = new DOMParser().parseFromString(sXML, 'text/xml');
    }
    return objDom;
}

function getResponseXML(sXML, ProcessingPage) {
    //send an xml doc, but we will do it synchonously and wait
    //for a rturn value from the processing page, then send the return data
    //to the caller.  In this case the retun value is an xml document

    var objRequest = GetHttpRequestObject();
    objRequest.open("POST", ProcessingPage, false);
    objRequest.send(sXML);
    return objRequest.responseXML;
}

function openBranchPreview(BranchNo) {
    msgWindow = window.open("/Locations/MiniMap.aspx?BranchNo=" + BranchNo, "PrintContacts",
			"toolbar=no,width=460,height=600,directories=no,scrollbars=yes,menubar=no")
}

