if (window.XMLDocument && window.XMLSerializer && XMLDocument.prototype && XMLDocument.prototype.getElementsByTagNameNS) {

    XMLDocument.prototype.serialize = function() {
        return new XMLSerializer().serializeToString(this);
    };

    function loadXMLFile(uri, load_callback, error_callback, status_callback) {
        if (typeof load_callback !== "function") {
            throw new Error("load_callback argument must be a function");
        }
        if (typeof error_callback !== "function") {
            error_callback = function(message) {
                throw new Error(message);
            };
        }
        if (typeof status_callback !== "function") {
            status_callback = function(status) {

            };
        }
        var req = new XMLHttpRequest();
        req.onreadystatechange = function() {
            if (this.readyState === 4 && (this.status === 200 || document.location.protocol === "file:")) {
                if (this.responseXML && this.responseXML.documentElement && this.responseXML.getElementsByTagNameNS("http://www.mozilla.org/newlayout/xml/parsererror.xml", "parsererror").length === 0) {
                    load_callback(this.responseXML);
                } else {
                    error_callback("Parse Error");
                }
            } else if (this.readyState === 4 && (this.status !== 200 && document.location.protocol !== "file:")) {
                error_callback(this.status);
            } else {
                status_callback(this.readyState)
            }
        };
        try {
            req.open("GET", uri);
            req.send();
        } catch (err) {
            error_callback(err.message);
        }
    }
}