  function tAjaxLoader() {
    function tQueue(document, type, target, vars, callback) {
      this.type = type;
      this.document = document;
      this.target = target;
      this.vars= vars;
      this.callback = callback;
    }
    this.callback = false;
    this.xmlhttp = false;
    this.queue = new Array();
    this.currentDocumentContainer = false;
    document.ajaxLoader = this;

    this.init = function() {
      if (window.XMLHttpRequest) {
        this.xmlhttp = new XMLHttpRequest();
      }
      else if (window.ActiveXObject) {
        var msxmls = new Array('Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0',
                               'Msxml2.XMLHTTP.3.0','Msxml2.XMLHTTP','Microsoft.XMLHTTP');
        for (var i = 0; i < msxmls.length; i++) {
          try {
            this.xmlhttp=  new ActiveXObject(msxmls[i]);
          } catch (e) {
          }
        }
      }
    }

    this.refreshComponents = function(obj) {
    if(obj.id=="checkbox_bypass") {
    }

      if(obj.onshow) obj.onshow();
      for(var i=0; i<obj.childNodes.length; i++) {
        document.ajaxLoader.refreshComponents(obj.childNodes[i]);

      }
    }

    this.getContent = function(srcfile, target, callback) {
      if(this.status == "busy") {
        var item = new tQueue(srcfile, "get", target, '', callback);
        this.queue.push(item);
      } else {
        this.status="busy";
        this.init();
        this.currentDocumentContainer = target;
        this.callback = callback;
        this.xmlhttp.open('GET',srcfile,true);
        this.xmlhttp.setRequestHeader('Accept-Charset','utf-8');
        this.xmlhttp.setRequestHeader('Content-Type','text/xml; charset=utf-8');
        this.xmlhttp.onreadystatechange = function() {
          switch(document.ajaxLoader.xmlhttp.readyState) {
            case 1: window.status="Ajax loading.";
            case 2: window.status="Ajax loading..";
            case 3: window.status="Ajax loading...";
          }
          if(document.ajaxLoader.xmlhttp.readyState == 4 ) {
            if(document.ajaxLoader.xmlhttp.status == 200) {
              var data = document.ajaxLoader.xmlhttp.responseText;
              if(document.ajaxLoader.currentDocumentContainer) {
                document.ajaxLoader.currentDocumentContainer.innerHTML = data;
                document.ajaxLoader.refreshComponents(document.ajaxLoader.currentDocumentContainer);
              }
              document.ajaxLoader.status="ready";
              window.status = "Done";
              if(document.ajaxLoader.callback) document.ajaxLoader.callback(data);
              if(document.ajaxLoader.queue.length>0) {
                var item=document.ajaxLoader.queue.shift();
                if(item.type=="get")
                  document.ajaxLoader.getContent(item.document, item.target, item.callback);
                else
                  document.ajaxLoader.postContent(item.document, item.target, item.vars, item.callback);
              }
            } else {
              window.status = "Ajax error "+document.ajaxLoader.xmlhttp.status + " - "+document.ajaxLoader.xmlhttp.statusText;
            }
          }
        }
        window.status="Ajax loading";
        this.xmlhttp.send(null);
      }
    }

    this.postContent = function(srcfile, target, data, callback) {
      if(this.status == "busy") {
        // push request to queue
        var item = new tQueue(srcfile, "post", target, data, callback);
        this.queue.push(item);
      } else {
        this.status="busy";
        this.init();
        this.currentDocumentContainer = target;
        this.callback=callback;
        this.xmlhttp.open('POST',srcfile,true);
        this.xmlhttp.setRequestHeader('Accept-Charset','utf-8');
        this.xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        this.xmlhttp.onreadystatechange = function() {
          switch(document.ajaxLoader.xmlhttp.readyState) {
            case 1: window.status="Ajax sending.";
            case 2: window.status="Ajax sending..";
            case 3: window.status="Ajax sending...";
          }
          if(document.ajaxLoader.xmlhttp.readyState == 4 ) {
            if(document.ajaxLoader.xmlhttp.status == 200) {
              var data = document.ajaxLoader.xmlhttp.responseText;
              if(document.ajaxLoader.currentDocumentContainer) {
                document.ajaxLoader.currentDocumentContainer.innerHTML = data;
                document.ajaxLoader.refreshComponents(document.ajaxLoader.currentDocumentContainer);
              }
              document.ajaxLoader.status="ready";
              window.status = "Done";
              if(document.ajaxLoader.callback) document.ajaxLoader.callback(data);
              if(document.ajaxLoader.queue.length>0) {
                var item=document.ajaxLoader.queue.shift();
                if(item.type=="get")
                  document.ajaxLoader.getContent(item.document, item.target, item.callback);
                else
                  document.ajaxLoader.postContent(item.document, item.target, item.vars, item.callback);
              }
            } else {
              window.status = "Ajax error "+document.ajaxLoader.xmlhttp.status + " - "+document.ajaxLoader.xmlhttp.statusText;
            }
          }
        }
        window.status="Ajax sending";
        this.xmlhttp.send(data);
      }
    }
  }

