// *********************
// DXMLHttpRequest Class
// *********************
function DXMLHttpRequestShell() {
    this.XMLHttp = null;
    
    this.init();
}
DXMLHttpRequestShell.prototype.init = function() {
    if (window.ActiveXObject) {
        try {
            this.XMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch(ex) {
            throw new MicrosoftXMLHTTPInitErrorException();
        }
    } else if (window.XMLHttpRequest){
        this.XMLHttp = new XMLHttpRequest();
    } else {
        throw new XMLHttpNotImplementedException();
    }
    
    var obj = this;
    this.XMLHttp.onreadystatechange = function() {
        obj._onLoadHandler();
    };
}
DXMLHttpRequestShell.prototype.getReadyState = function() {
    return this.XMLHttp.readyState;
}
DXMLHttpRequestShell.prototype.getServerStatusId = function() {
    return this.XMLHttp.status;
}
DXMLHttpRequestShell.prototype.getServerStatusText = function() {
    return this.XMLHttp.statusText;
}
DXMLHttpRequestShell.prototype.getResponseXML = function() {
    if (this.getReadyState() == 4) {
        return this.XMLHttp.responseXML;
    }
}
DXMLHttpRequestShell.prototype.getResponseText = function() {
    if (this.getReadyState() == 4) {
        return this.XMLHttp.responseText;
    }
}
DXMLHttpRequestShell.prototype._onLoadHandler = function() {
    if (this.getReadyState() == 4) {
        if (this.getServerStatusId() == 200 || this.getServerStatusId() == 304) {
            try {
                this.onLoad();
            } catch (ex) {
                alert(ex);
            }
        }
    }
}
DXMLHttpRequestShell.prototype.fastGetUrl = function(url) {
    try {
        this.XMLHttp.open("GET", url, true);
        this.XMLHttp.send(null);
    } catch(ex) {
        throw ex;
    }
}
DXMLHttpRequestShell.prototype.fastPostUrl = function(url, parameters) {
    try {
        this.XMLHttp.open("POST", url, true);
        this.XMLHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      	this.XMLHttp.setRequestHeader("Content-length", parameters.length);
      	this.XMLHttp.setRequestHeader("Connection", "close");
        this.XMLHttp.send(parameters);
    } catch(ex) {
        throw ex;
    }
}
DXMLHttpRequestShell.prototype.onLoad = function() {
    throw new MethodNotImplementedException();
}
DXMLHttpRequestShell.prototype.getAttributeValue = function(attributeName, XMLNodeObject) {
    for (var i = 0; i < XMLNodeObject.attributes.length; i++) {
        with (XMLNodeObject.attributes.item(i)) {
            if (nodeName == attributeName) {
                return nodeValue;
            }
        }
    }
    
    return null;
}
DXMLHttpRequestShell.prototype.getAllData = function(XMLNodeObject) {
    var collection = {
        name : "",
        attributes : {},
        value : "",
        childNodes : []
    };

    with (XMLNodeObject) {
        collection.name = nodeName;
        if (hasChildNodes()) {
            collection.value = firstChild.nodeValue;
        }
    }
    
    if (XMLNodeObject.attributes.length > 0) {
        for (var i = 0; i < XMLNodeObject.attributes.length; i++) {
            with (XMLNodeObject.attributes.item(i)) {
                collection.attributes[nodeName] = nodeValue;
            }
        }
    }
    
    if (XMLNodeObject.childNodes.length > 0) {
        for (var i = 0; i < XMLNodeObject.childNodes.length; i++) {
            var currentNode = XMLNodeObject.childNodes.item(i);
            if (currentNode.nodeName.indexOf("#") != 0) {
                collection.childNodes.push(
                    this.getAllData(currentNode
                ));
            }
        }
    }
    
    return collection;
}
// *************************
// DXMLHttpRequest Class end
// *************************