// Ready state: 0 -- uninitialized, 1 -- loading, 2 -- loaded, 3 -- interactive, 4 -- complete
// Status: 200 -- OK, 404 -- Not Found, and so on...
//var xmlHttpRequest;

function createXMLHTTPRequest() {
	var xmlHttp = null;
	if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		var activeNames = ['Microsoft.XMLHTTP','Msxml2.XMLHTTP','Msxml2.XMLHTTP.3.0',
			'Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.6.0'];
		var i = activeNames.length;
		while (i -- > 0) {
			try {
				xmlHttp = new ActiveXObject(activeNames[i]);
				break;
			} catch(ex) {
				xmlHttp = null;
			}
		}
	}
	if (xmlHttp == null && window.createRequest) {
		try {
			xmlHttp = window.createRequest();
		} catch (ex) {
			xmlHttp = null;
		}
	}
	return xmlHttp;
}


function callbackXML() {
//	alert('default-callback: empty');
//	if (xmlHttp != null && xmlHttp.readyState == 4) {
//		if (xmlHttp.status == 200) {
//			// return xml-response
//			alert('default-callback function!!!');
//			return xmlHttp.responseXML;
//		}
//	}
//	return null;
}

function requestPOST(url, content) {
	if (content == null) return requestGET(url);
	return requestPOST(url, content, callbackXML);
}

function requestPOST(url, content, fncCallBack) {
	if (content == null) return requestGET(url, asynch);
	return requestPOST(url, content, fncCallBack, null);
}

function requestPOST(url, content, fncCallBack, asynch) {
	if (content == null) return requestGET(url, asynch, fncCallBack);
	var xmlHttp = createXMLHTTPRequest();
	if (xmlHttp != null) {
		if (asynch == null) xmlHttp.open("POST", url, true);
		else xmlHttp.open("POST", url, asynch);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.onreadystatechange = fncCallBack;
		xmlHttp.send(content);
	}
	return xmlHttp;
}

function requestGET(url) {
	return requestGET(request, url, callbackXML);
}

function requestGET(url, fncCallBack) {
	return requestGET(url, fncCallBack, true);
}

function requestGET(url, fncCallBack, asynch) {
	var xmlHttp = createXMLHTTPRequest();
	if (xmlHttp != null) {
		if (asynch == null) asynch = true;
		xmlHttp.open("GET", url, asynch);
		xmlHttp.onreadystatechange = fncCallBack;
		xmlHttp.send(null);
	}
	return xmlHttp;
}