function httpPost(tag, qstring, ajax, loading) {
        var qstring = (qstring == null) ? "" : qstring;
        var loading = (loading == null) ? true : loading;

        if (loading) {
                document.getElementById(tag).innerHTML = "Loading...";
        }

        var xmlHttpReq = false;
        var self = this;
        requestAjax(qstring, self, xmlHttpReq, ajax);
        self.xmlHttpReq.onreadystatechange = function() {
                if (self.xmlHttpReq.readyState == 4) {
                                updatepage(self.xmlHttpReq.responseText, tag);
                                findJS(self.xmlHttpReq.responseText);
                }
        }
}

function retrieveXml(qstring) {
        var qstring = (qstring == null) ? "" : qstring;
        var tocurrentmodule = (tocurrentmodule == null) ? true : tocurrentmodule;

        var xmlHttpReq = false;
        var self = this;
        requestAjax(qstring, self, xmlHttpReq);
        self.xmlHttpReq.onreadystatechange = function() {
                if (self.xmlHttpReq.readyState == 4) {
                        processXml(self.xmlHttpReq.responseText);
                }
        }
}

function retrieveXmlLive(qstring, varname, ajax) {
        var qstring = (qstring == null) ? "" : qstring;

        var xmlHttpReq = false;
        var self = this;
        requestAjax(qstring, self, xmlHttpReq, ajax);
        self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
                eval(varname+".processXml(self.xmlHttpReq.responseText)");
        }
    }
}

function requestAjax(qstring, self, xmlHttpReq, ajax) {
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', ajax, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.send(qstring);
}

function makequerystring(qstring, attribute, value) {
        if (qstring != "") {
                qstring += "&";
        }
        qstring += attribute+"="+value;
        return qstring;
}

function updatepage(str, tag){
    document.getElementById(tag).innerHTML = str;
}

function findJS(ajaxreturnvalue){
        var javascriptFound = ajaxreturnvalue.match('<script>');

        if(javascriptFound){
                var ajaxreturnvalue = ajaxreturnvalue.split('<script>');
                var ajaxreturnvalue = ajaxreturnvalue[1].split('</script>');
                var ajaxreturnvalue = ajaxreturnvalue[0];

                if (window.execScript) {
                        window.execScript(ajaxreturnvalue);
                } else {
                        window.eval.call(window,ajaxreturnvalue);
                }
//alert(ajaxreturnvalue);
//              eval(ajaxreturnvalue);
        }
}

if (typeof DOMParser == "undefined") {
   DOMParser = function () {}

   DOMParser.prototype.parseFromString = function (str, contentType) {
      if (typeof ActiveXObject != "undefined") {
         var d = new ActiveXObject("MSXML.DomDocument");
         d.loadXML(str);
         return d;
      } else if (typeof XMLHttpRequest != "undefined") {
         var req = new XMLHttpRequest;
         req.open("GET", "data:" + (contentType || "application/xml") +
                         ";charset=utf-8," + encodeURIComponent(str), false);
         if (req.overrideMimeType) {
            req.overrideMimeType(contentType);
         }
         req.send(null);
         return req.responseXML;
      }
   }
}


