

var ajax = {
    version: 0.1,
    path:    '/system/server/ajax.php',

    init: function(args) {
        if (window.XMLHttpRequest) {
            this.http = new XMLHttpRequest();
            if (this.http.overrideMimeType) this.http.overrideMimeType('text/xml');
        } else if (window.ActiveXObject) {
            this.http = new ActiveXObject('Msxml2.XMLHTTP');
        }
        if (!this.http) alert('Cannot create an XmlHttp instance.');
        this.query = '';
        for (var i = 0; i < args.length; i++) {
            if (i % 2 == 0) {
                this.query += (this.query ? '&' : '?') + args[i];
            } else {
                this.query += '=' + args[i];
            }
        }
        this.url = this.path + this.query + '&' + new Date().getTime();
    },
    load: function() {
        this.init(arguments);
        this.http.open('GET', this.url, false);
        this.http.send(null);
        if (this.http.status == 200) return this.http.responseText;
        return 'Error ' + this.http.status + ': ' + this.http.responseText;
    },
    exec: function() {
        var self = this;
        this.init(arguments);
        this.http.open('GET', this.url, true);
        this.http.onreadystatechange = function() {
            if ((self.http.readyState == 4) && (self.http.status == 200) && (self.http.responseText)) {
                alert(self.http.responseText);
            }
        }
        this.http.send(null);
    }
}
