var xmldoc;
var param;
function najax_ejs(data) {
	eval(data);
}
function najax_art(data) {
	if (typeof(syswins) == 'object') { syswins.alertWin('syswins.noexit',eval(data)); }
	else { alert(eval(data)); }
}
function najax_fwd(data) {
	document.location.href=data;
}
function makeRequest(url,method,data,async) {
	if (url) {
		if (url.indexOf('connection=ajax') == -1) {
			if (url.indexOf('?') != -1) { url += '&connection=ajax'; }
			else { url += '?connection=ajax'; }
		}
		if (tplf.getUrlParam('reqFile') && url.indexOf('reqFile=') && -1) {
			if (url.indexOf('?') != -1) { url += '&reqFile='+tplf.getUrlParam('reqFile'); }
			else { url += '?reqFile='+tplf.getUrlParam('reqFile'); }
		}
	}
	var httpRequest=CreateHttpRequestObject();
	httpRequest.onreadystatechange = function() {
		if (httpRequest.readyState == 4) {
			if (httpRequest.status == 200) {
				var xmltmp = httpRequest.responseXML;
				if(xmltmp) {
					if(httpRequest.responseText=='') {
						return;
					}
					try {
						if(xmltmp.documentElement.tagName!='najax') {
							return 0;
						}
					}
					catch (e) {
						return 0;
					}
					ajaxResponse(xmltmp);
				}
			}
			else {
				if(httpRequest.status!=404) {
					setTimeout("makeRequest('"+url+"','"+method+"','"+data+"','"+async+"')",5000);
				}
			}
		}
	};
        httpRequest.open(method, url, async);
	if(method=='POST') {
		httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	}
	httpRequest.send(data);
}
function ajaxResponse(xmldoc) {
	var updatelastreq = true;
	var root = xmldoc.getElementsByTagName('najax')[0];
	for(var i=0;i<root.childNodes.length;i++) {
		if (root.childNodes[i].getAttribute('act') == 'nosess') { updatelastreq = false; }
		switch(root.childNodes[i].getAttribute("act")) {
			case 'ejs':
			najax_ejs(root.childNodes[i].childNodes[0].nodeValue);
			break
			case 'art':
			najax_art(root.childNodes[i].childNodes[0].nodeValue);
			break
			case 'fsxml':
			fsxml.newxml(root.childNodes[i].childNodes[0]);
			break
			case 'fwd':
			najax_fwd(root.childNodes[i].childNodes[0].nodeValue);
			break
		}
	}
	if (updatelastreq) { tplf.updatelastreq(); }
}