

var ajax = {
    script: 'this_is_required',

    initialize: function() {
        if (this.http != undefined) return;
        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.');
    },
    prepare: function(args) {
        this.params = '';
        for (var i = 0; i < args.length; i++) {
            if (i % 2 == 0) {
                this.params += (this.params ? '&' : '') + args[i];
            } else {
                this.params += '=' + args[i];
            }
        }
        this.params += '&' + new Date().getTime();
    },
    load: function() {
        this.prepare(arguments);
        this.url = config.BP + '/system/api/' + this.script + '.php?' + this.params;
        alert(this.url);
        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.prepare(arguments);
        this.url = config.BP + '/system/api/' + this.script + '.php?' + this.params;
        //alert(this.url);
        this.http.open('GET', this.url, true);
        this.http.onreadystatechange = function() {};
        this.http.send(null);
    }
}
ajax.initialize();
