/*
    Document   : ajaxInclude
    Created on : Sep 23, 2008, 12:51:55 AM
    Author     : Willie Scholtz
*/

var AjaxObject = function() {
    this.xmlHttp = null;
    this.transport = null;
    this.method = "post";
    this.url = "";
    this.div = "";

    this.create = function(url, transport, method) {
        this.xmlHttp = initialize();
        this.transport = transport;
        this.url = url;
        this.method = method;
    }

    this.request = function(params,div) {
        this.div = div;
        var string = this.url + "?" + params;
        this.xmlHttp.open(this.method,string,true);
        this.xmlHttp.onreadystatechange = this.transport;
        this.xmlHttp.send(null);
    }

    this.getData = function() {
        if (this.xmlHttp.readyState == 4) {
            if (this.xmlHttp.status && /200|304/.test(this.xmlHttp.status)){
                return this.xmlHttp.responseText;
            } else {
                return null;
            }
        } else {
            return null;
        }
    }

    this.getDiv = function() {
        return this.div;
    }

    function initialize() {
        var xmlHttp=null;
            try {
                xmlHttp=new XMLHttpRequest();
            } catch (e) {
                try {
                    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e) {
                    try {
                      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                    } catch (e) {
                      alert("Your browser does not support AJAX, please upgrade!");
                      return false;
                    }
                }
            }
        return xmlHttp;
    }
}

