function JsRequest () {
    this.debug        = true;
    this.req          = null;
    this.onLoad       = null;
    this.onError      = null;
    this.onProcess    = null;
    this.responseText = '';

    this.__construct = function () {
    }

    this.__init = function () {
        if (window.XMLHttpRequest)
            this.req = new XMLHttpRequest ();
        else if (window.ActiveXObject)
            this.req = new ActiveXObject ("Microsoft.XMLHTTP");
        if (this.req == null)
            return false;
        var obj = this;
        this.req.onreadystatechange = function () {
            if (obj.req.readyState == 4) {
                if (obj.req.status == 200) {
                    obj.responseText = obj.req.responseText;
                    if (obj.onLoad)
                        obj.onLoad ();
                } else if (obj.onError)
                    obj.onError ();
            }
        }
        return true;
    }

    this.getResponseObject = function () {
        var obj = null;
        try {
            if (this.responseText != '')
                eval ('obj = ' + this.responseText);
        } catch (e) {
            if (this.debug)
                alert (e + '\n\n' + this.responseText);
        }
        return obj;
    }

    this.sendPost = function (url, postData) {
        this.__init ();
        if (this.onProcess)
            this.onProcess ();
        url += (url.indexOf ('?') == -1 ? '?mr=' : '&mr=') + Math.random ();
        this.req.open ("POST", url, true);
        this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        this.req.send (postData);
    }

    this.sendGet = function (url) {
        this.__init ();
        if (this.onProcess)
            this.onProcess ();
        url += (url.indexOf ('?') == -1 ? '?mr=' : '&mr=') + Math.random ();
        this.req.open ("GET", url, true);
        this.req.send (null);
    }

    this.__construct ();
}
