var xmlHttpLoad = false;
var xmlHttpSave = false;

try{
	xmlHttpLoad  = new ActiveXObject("Msxml2.XMLHTTP");
	xmlHttpSave  = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
    try{
        xmlHttpLoad  = new ActiveXObject("Microsoft.XMLHTTP");
		xmlHttpSave  = new ActiveXObject("Microsoft.XMLHTTP");
    }catch(e){
        xmlHttpLoad  = false;
		xmlHttpSave  = false;
    }
}

if (!xmlHttpLoad  && typeof XMLHttpRequest != 'undefined') {
    if(window.XMLHttpRequest){
		xmlHttpLoad = new XMLHttpRequest();
	}else if (window.ActiveXObject){
		var avers = ["Microsoft.XmlHttp", "MSXML2.XmlHttp", "MSXML2.XmlHttp.3.0",  "MSXML2.XmlHttp.4.0", "MSXML2.XmlHttp.5.0"];
		for (var i = avers.length -1; i >= 0; i--){
			xmlHttpLoad = new ActiveXObject(avers[i]);
		}
	}
}

if (!xmlHttpSave  && typeof XMLHttpRequest != 'undefined') {
    if(window.XMLHttpRequest){
		xmlHttpSave = new XMLHttpRequest();
	}else if (window.ActiveXObject){
		var avers = ["Microsoft.XmlHttp", "MSXML2.XmlHttp", "MSXML2.XmlHttp.3.0",  "MSXML2.XmlHttp.4.0", "MSXML2.XmlHttp.5.0"];
		for (var i = avers.length -1; i >= 0; i--){
			xmlHttpSave = new ActiveXObject(avers[i]);
		}
	}
}

function getData(id,file,loader){
	if(loader!=""){
		document.getElementById(id).innerHTML = "<div style='text-align:center;vertical-align:middle;display:table-cell;width:"+document.getElementById(id).offsetWidth+"px;height:"+document.getElementById(id).offsetHeight+"px;'><img src='"+loader+"' border='0'></div>";
	}
	if (xmlHttpLoad) {
		xmlHttpLoad.open('GET', file, true);
		xmlHttpLoad.onreadystatechange = function () {
			if (xmlHttpLoad.readyState == 4) {
				document.getElementById(id).innerHTML = xmlHttpLoad.responseText;
			}
		};
	xmlHttpLoad.setRequestHeader("Pragma", "no-cache");
	xmlHttpLoad.setRequestHeader("Cache-Control", "must-revalidate");
	xmlHttpLoad.setRequestHeader("If-Modified-Since", document.lastModified);
	xmlHttpLoad.send(null);
	}
}

function saveData(file,content){
	try{
		if (xmlHttpSave){
			xmlHttpSave.open('POST', file);
			xmlHttpSave.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlHttpSave.send(content);
		}
	}catch (e){
		setTimeout("saveData()", 500);
	}
	return false;
}


function setData(id,file,loader,content){
	if(loader!=""){
		if(document.getElementById(id)) document.getElementById(id).innerHTML = "<div style='text-align:center;vertical-align:middle;display:table-cell;width:"+document.getElementById(id).offsetWidth+"px;height:"+document.getElementById(id).offsetHeight+"px;'><img src='"+loader+"' border='0'></div>";
	}
	try{
		if (xmlHttpSave){
			xmlHttpSave.open('POST', file, true);
			xmlHttpSave.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlHttpSave.setRequestHeader("Pragma", "no-cache");
			xmlHttpSave.setRequestHeader("Cache-Control", "must-revalidate");
			xmlHttpSave.setRequestHeader("If-Modified-Since", document.lastModified);
			xmlHttpSave.send(content);
			xmlHttpSave.onreadystatechange = function () {
			if (xmlHttpSave.readyState == 4) {
				if(document.getElementById(id)) document.getElementById(id).innerHTML = xmlHttpSave.responseText;
				}
			};
		}
	}catch (e){
		setTimeout("saveData("+id+","+file+","+loader+","+content+")", 500);
	}
	return false;
}
