/**
* Got this from http://www.hunlock.com/blogs/The_Ultimate_Ajax_Object
* adapted it a bit, see //changed this
**/
function ajaxObject(url, callbackFunction)
{
    var that = this;
    this.updating = false;
    this.queue = [];
    this.queueLength = 0;
    this.update = function (passData)
    {
        if (that.updating) {
            //add to queue
            that.queue[that.queueLength] = passData;
            that.queueLength++;
            return false;
        }
        that.AJAX = null;
        if (window.XMLHttpRequest) {
            that.AJAX = new XMLHttpRequest();
        } else {
            //Internet Explorer
            try {
                //Microsofts newest version
                that.AJAX = new ActiveXObject('Msxml2.XMLHTTP');
            } catch(e) {
                try {
                    that.AJAX = new ActiveXObject('Microsoft.XMLHTTP');
                } catch (e) {
                    return false;
                }
            }
        }
        if (that.AJAX==null) {
            return false;
        } else {
            that.AJAX.onreadystatechange = function()
            {
                rs = that.AJAX.readyState;
                if (rs==4) {
                    that.updating = false;
                    if (that.callback) {
                        that.callback(that.AJAX.responseText, that.AJAX.status, that.AJAX.responseXML);
                    }
                    that.AJAX = null;
                    //check queue and execute next request
                    if (that.queueLength) {
                        data = that.queue[0];
                        for (i=0; i<that.queueLength-1; i++) {
                            that.queue[i] = that.queue[i+1];
                        }
                        that.queueLength--;
                        that.update(data);
                    }
                }
            } //function that.AJAX.onreadystatechange
            that.updating = new Date();
            var uri = urlCall;
            if (uri.search(/\?/)!=-1) {
                uri += '&';
            } else {
                uri += '?';
            }
            if (passData) {
                uri += passData+'&';
            }
            //add unique timestamp
            uri += 'timestamp='+(that.updating.getTime());
            //send the request
            that.AJAX.open('GET', uri, true);
            that.AJAX.send(null);
            return true;
        }
    } //function this.update
    var urlCall = url;
    this.callback = callbackFunction;
} //function ajaxObject
