
function HttpRequest(url, method, headerArray, eventHandler) {
    httpreq = false;
    if (window.XMLHttpRequest) {
        try {
            httpreq = new XMLHttpRequest();
        } catch (e) {
            httpreq = false;
        }
    } else if (window.ActiveXObject) {
        try {
            httpreq = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            httpreq = false;
            try {
                httpreq = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {

            }
        }
    }
    if (httpreq) {
        try {
            if (eventHandler != null) {
                httpreq.onreadystatechange = eventHandler;
            }
            httpreq.open(method, url, true);
            if (headerArray != null) {
                for (var key in headerArray) {
                    httpreq.setRequestHeader(key, headerArray[key]);
                }
            }
        } catch (e) {
            // A "Permission Denied" error will be thrown
            // if the current domain doesn't match the 
            // url's domain. Don't alert the user, b/c
            // this is annoying when on the dev site..

            // alert("Error: " + e.message);
        }
    }
    else {
        alert("Could not create HttpRequest");
    }
    return httpreq;
}
