function ajax()

{

            this.req = null;

            this.console = null;

            this.READY_STATE_UNINITIALIZED = 0;

            this.READY_STATE_LOADING = 1;

            this.READY_STATE_LOADED = 2;

            this.READY_STATE_INTERACTIVE = 3;

            this.READY_STATE_COMPLETE = 4;

            this.eventLoad = ""; // выполняемые событие

            this.console = null; // объект для выгрузки результатов

            this.url = ""; // url страницы

            this.HttpMethod = "GET";

            this.ready = -1;

            this.ArrayParam = new Array(); // передоваемые параметры

            this.data = null;

            if (window.XMLHttpRequest)

                        this.req = new XMLHttpRequest();

            else if (window.ActiveXObject) 

                        this.req = new ActiveXObject("Microsoft.XMLHTTP");

}

// метод запроса страницы

ajax.prototype.sendRequest = function()

{           
            if (this.req && this.url.length > 0)

            {

                        var loader = this;

                        var fullurl = "";

                        for (var i = 0; i < this.ArrayParam.length; i++)

                                   fullurl += ((i > 0) ? "&" : "") + this.ArrayParam[i][0] + 

                                                                                               "=" + this.ArrayParam[i][1];

                        fullurl = this.url + ((fullurl.length > 0) ? ("?" + fullurl) : "");

                        this.req.onreadystatechange = function() { loader.onReadyState(loader); }

                        this.req.open(this.HttpMethod, fullurl, true);

                        this.req.send(null);

            }

}

// метод проверки состояния загрузки страницы

ajax.prototype.onReadyState = function(loader)

{

            loader.ready = loader.req.readyState;

            if (loader.ready == loader.READY_STATE_COMPLETE)

            {

                        loader.data = loader.req.responseText;

                        if (loader.console != null)

                                   loader.console.innerHTML = loader.data;

                        if (loader.eventLoad.length > 0)

                                   eval(loader.eventLoad);

            }

}

// метод наполнения параметрами объекта

ajax.prototype.add = function(name, value)

{

            if (name.length > 0 && value.length > 0)

                                   this.ArrayParam[this.ArrayParam.length] = Array(name, escape(value));

}
