/*!(c)2009 DStats.net*/
function xmlhttp(method,url,data,fnc) {
    var xhr = false;
    if (window.XMLHttpRequest)
        xhr = new XMLHttpRequest();
    else if (window.ActiveXObject)
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    xhr.open(method, url, true);
    if (method=='POST')
    	xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xhr.onreadystatechange = function() {
    	if (typeof(xhr)!="undefined") //prevent Undefined exception when stopped by user (ESC) or timeouted
        	if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 304)) {
            	if (xhr.getResponseHeader('Content-Type').indexOf('xml')>-1)
            		fnc(xhr.responseXML);
            	else
            		fnc(xhr.responseText);
        	}
    }
    xhr.send(data);
}