if (!ajaxPrototype) {
    var ajaxPrototype = new Object();

    ajaxPrototype.Ajax = function() {
        this.http = null;
        this.targetElementId = null;
        this.onLoadFunction = null;
    }

    ajaxPrototype.Ajax.prototype = {
        setOnLoadFunction: function(onLoadFunction) {
            this.onLoadFunction = onLoadFunction;
        },
        load: function(url, targetElementId, method, data) {
            var requestMethod = "GET";
            if (method != null) requestMethod = method;

            this.targetElementId = targetElementId;
            this.postHTTP(url, this.delegate(this, this.onAjaxLoad), requestMethod, data);
        },
        onAjaxLoad: function() {
            if (this.http.readyState == 4) {
                if (this.http.status == 200) {
                    if (this.targetElementId != null) {
                        var element = document.getElementById(this.targetElementId);
                        if (element != null) {
                            element.innerHTML = this.http.responseText;
                        }
                    }
                    if (this.onLoadFunction != null) {
                        this.onLoadFunction();
                    }
                }
            }
        },
        postHTTP: function(url, callbackFunction, method, data) {
            this.http = this.getHTTPObject();
            this.http.open(method, url, true);
            this.http.onreadystatechange = callbackFunction;
            if (method == "POST") {
                this.http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            }
            this.http.send(data);
        },
        getHTTPObject: function() {
            var http = false;
            if (window.ActiveXObject) {
                var names = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
                for (var key in names) {
                    try {
                        return new ActiveXObject(names[key]);
                    } catch (e) {}
                }
            } else if (XMLHttpRequest) {
                try {
                    http = new XMLHttpRequest();
                } catch (e) {}
            }
            return http;
        },
        delegate: function(obj, objMethod) {
            return function() {
                return objMethod.call(obj, arguments);
            }
        }
    }
}

var Ajax = ajaxPrototype.Ajax;

function ajaxLoad(url, targetElementId, method, data, onLoadFunction) {
    var ajaxObj = new Ajax();
    if (onLoadFunction != null) ajaxObj.setOnLoadFunction(onLoadFunction);
    ajaxObj.load(url, targetElementId, method, data);
}