function RequestHandler() {	
    this.request_type="POST";
    this.debug_mode=false;
};

RequestHandler.prototype.getResponseXML = function(uri, func_name, args) {
    this.debug("getResponseXML called");
    var i, x, n;
    var post_data;

    if (this.request_type == "GET") {
        post_data = null;
    }
    x = this.init_object();
    x.open(this.request_type, uri, true);
    if (this.request_type == "POST") {
        x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
        x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    }

    x.onreadystatechange = function() {    	
        if (x.readyState != 4)
            return;
        if (x.status == 403 || x.status==404)        
        	failed();
        else if (x.status == 200) { // OK response
            func_name(RequestHandler,x.responseXML);
        }
    }
    this.debug("sending request...");
    x.send(post_data);
    delete x;
};

RequestHandler.prototype.getResponseText = function(uri, func_name, args) {
    var i, x, n;
    var post_data;

    if (this.request_type == "GET") {
        post_data = null;
    }
    x = this.init_object();
    x.open(this.request_type, uri, true);
    if (this.request_type == "POST") {
        x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
        x.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
    }
    x.onreadystatechange = function() {
        if (x.readyState != 4)
            return;
        if (x.status == 200) { // OK response
            func_name(RequestHandler, x.responseText);
        }
    }
    x.send(post_data);
    delete x;
};

RequestHandler.prototype.init_object = function() {
    this.debug("init_object() called");
    if (window.XMLHttpRequest) {
        A = new XMLHttpRequest();    
    } else if (window.ActiveXObject) {
        isIE = true;
        A = new ActiveXObject("Microsoft.XMLHTTP");        
    } 
    if (!A)
        this.debug("Could not create connection object.");
    return A;
};

RequestHandler.getSimpleValue = function(responseXML, tagName) {
    var xmlList = responseXML.getElementsByTagName(tagName);
    if (xmlList.length > 0)
    {
        if (xmlList[0].firstChild)
            return xmlList[0].firstChild.data;
    }
    return "";
};

RequestHandler.getRootNode = function(responseXML, tagName) {
    return responseXML.getElementsByTagName(tagName);
};

RequestHandler.getElementsByName = function(node, tagName) {
    return node[0].getElementsByTagName(tagName);
};

RequestHandler.getNodeValue = function(node, tagName) {
    return node.getElementsByTagName(tagName)[0].firstChild.data;
};

RequestHandler.prototype.debug = function(text) {
    if (this.debug_mode)
        alert("ServerRequest: " + text)
};
