var _xmlHttp;
var _xmlHttpQueue = Array();
var _xmlSending = 0;

function getXMLHTTP() {
	var A = null;
	try {
		A = new ActiveXObject("Msxml2.XMLHTTP")
	} catch(e) {
	try {
		A = new ActiveXObject("Microsoft.XMLHTTP")
		} catch(oc) {
			A = null;
		}
	}
	if(!A && typeof XMLHttpRequest != "undefined") {
		A = new XMLHttpRequest();
	}

	return A;
}

function addToXMLqueue(path, mode, flags) {
	var newObj = new Object();
	newObj.path = path;
	newObj.mode = mode;
	newObj.flags = flags;

	_xmlHttpQueue.push(newObj);
}

function runXMLqueue() {
	if (_xmlSending == 0) {
		if (_xmlHttpQueue.length > 0) {
			var queueObj = _xmlHttpQueue.shift();
			getData(queueObj.path, queueObj.mode, queueObj.flags);
		}
	}
}

function getData(path, mode, flags) {
	_xmlHttp = getXMLHTTP();
	if(_xmlHttp){
		_xmlSending = 1;
		//_xmlHttp.open("GET", path + '?mode=' + mode + '&' + flags, true);
		_xmlHttp.open("POST", path, true);
		_xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		_xmlHttp.onreadystatechange=function() {
			if (_xmlHttp.readyState==4&&_xmlHttp.responseText) {
				eval(_xmlHttp.responseText);
				runXMLqueue();
			}
			_xmlSending = 0;
		}
	}

	_xmlHttp.send('mode=' + mode + '&' + flags)
}

function generalHTTPSend(path) {
	_xmlHttp = getXMLHTTP();
	if(_xmlHttp){
		_xmlSending = 1;
		_xmlHttp.open("GET", path, true);
		_xmlHttp.onreadystatechange=function() {
			if (_xmlHttp.readyState==4&&_xmlHttp.responseText) {
				eval(_xmlHttp.responseText);
			}
			_xmlSending = 0;
		}
	}

	_xmlHttp.send(null)
}
