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) {
	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 root = xmldoc.getElementsByTagName('najax')[0];
	for(var i=0;i<root.childNodes.length;i++) {
		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 'xml':
			dxml.add(root.childNodes[i].childNodes[0]);
			break
			case 'fwd':
			najax_fwd(root.childNodes[i].childNodes[0].nodeValue);
			break
		}
	}
}
function CreateHttpRequestObject(param) {
	if (!param) { param = 'text/xml'; }
	var http_request=false;
	if (window.XMLHttpRequest) {
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) { http_request.overrideMimeType(param); }
	}
	else if (window.ActiveXObject) {
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {}
		}
	}
	return http_request;
}
