
var http = new Array();

function xmlHttp(thread, script, callback) {
    http[thread] = false;
    if (window.XMLHttpRequest) {
        try {
            http[thread] = new XMLHttpRequest();
            if (http[thread].overrideMimeType) {
                http[thread].overrideMimeType('text/xml');
            }
        } catch (e) {
            xmlHttpError(thread, 1);
        }
    } else if (window.ActiveXObject) {
        try {
            http[thread] = new ActiveXObject('Msxml2.XMLHTTP');
        } catch (e) {
            try {
                http[thread] = new ActiveXObject('Microsoft.XMLHTTP');
            } catch (e) {
                xmlHttpError(thread, 2);
            }
        }
    } else {
        xmlHttpError(thread, 3);
        return false;
    }
    if(callback != '') {
        http[thread].onreadystatechange = eval(callback);
    }
    http[thread].open('POST', script, true);
    http[thread].send(null);
}

function xmlHttpStatus(thread) {
    if (http[thread].readyState == 4) {
        if (http[thread].status == 200) {
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}

function xmlHttpSource(thread) {
    var xml;
    var root;
    var src;
    xml = http[thread].responseXML;
    root = xml.childNodes;
    if(root.item(0).nodeName == 'xml') {
        src = root.item(1);
    } else {
        src = root.item(0);
    }
    return src;
}

function xmlHttpError(thread, code) {
    var xmlHttpErrorMsg = new Array();
    xmlHttpErrorMsg[1] = 'Error at thread '+thread+': XMLHttpRequest on Mozilla compatible failed\n\n' + navigator.userAgent + '';
    xmlHttpErrorMsg[2] = 'Error at thread '+thread+': ActiveXObject on MSIE (or compatible) failed\n\n' + navigator.userAgent + '';
    xmlHttpErrorMsg[3] = 'Error at thread '+thread+': Initializing XMLHttpRequest or ActiveXObject failed\n\n' + navigator.userAgent + '';
    //alert(xmlHttpErrorMsg[code]);
}