﻿if (!window.XMLHttpRequest) {
    window.XMLHttpRequest = function() {
        var progIDs = ['MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP.2.6', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'MSXML.XMLHTTP'];
        for (var i = 0; i < progIDs.length; i++) {
            try {
                return new ActiveXObject(progIDs[i]);
            }
            catch (ex) { }
        }
        return null;
    }
}
Function.createDelegate = function(instance, method) {
    return function() { return method.apply(instance, arguments); }
}
Request = function(_url, _body) {
    this._xmlHttpRequest;

    this.url = _url;
    this.body = _body;
    this.onCompleted = function() { return false; }

    this.send = function() {
        this._xmlHttpRequest = new XMLHttpRequest();
        this._xmlHttpRequest.open("POST", this.url, true);
        this._xmlHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        this._xmlHttpRequest.onreadystatechange = Function.createDelegate(this, this._completed);
        this._xmlHttpRequest.send(this.body);
    }
    this._completed = function() {
        if (this._xmlHttpRequest == null) return;
        if (this._xmlHttpRequest.readyState == 4) {
            this.onCompleted(this._xmlHttpRequest);
        }
    }
}
Comment = function(posturl,para) {
    this.load = function() {
    var r = new Request(posturl, para);
        r.onCompleted = Function.createDelegate(this, this._load);
        r.send();
    }
    this._load = function(request) {
        return request.responseText;
    }
}
