var req;
var obj;
var error;

var loadType='';

function ajLoadObj(objName, url, loadingHTML) {
	loadType = 'loadscr';
    obj = document.getElementById(objName);
    obj.innerHTML = loadingHTML;
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    req.open("GET", url, true);
    req.onreadystatechange = callback;
    req.send(null);
}

function ajLoadObjs(objName, url, loadingHTML) {
	loadType = 'loadobjs';
    obj = document.getElementById(objName);
    obj.innerHTML = loadingHTML;
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    req.open("GET", url, true);
    req.onreadystatechange = callback;
    req.send(null);
}

function ajLoadSilent(objName, url, loadingHTML) {
	loadType = 'silent';
    obj = document.getElementById(objName);
    obj.innerHTML = loadingHTML;
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    req.open("GET", url, true);
    req.onreadystatechange = callback;
    req.send(null);
}

function ajSynchroCall(url) {
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    req.open("GET", url, false);
    req.send(null);
}

function callback() {
    if (req.readyState == 4) {
        if (req.status == 200) {
			if (loadType=='silent') {
				obj.innerHTML = "";
			} else if (loadType=='loadobjs') {
				obj.innerHTML = "";
				loadMultipleObjects(req.responseText);
			} else {
				obj.innerHTML = req.responseText;
            }
        }
    }
}

function loadMultipleObjects(loadData) {
	var dataArray = loadData.split('¤');
	if (dataArray.length>0) {
		for (var i=0;i<(dataArray.length/2);i++)
		{
			var o = document.getElementById(dataArray[i*2]);
			if (o!=null && typeof(o)!="undefined")
				o.innerHTML = dataArray[i*2+1];
		}
	}
}
