var xhReq = null;
var targetModule = '';
var targetAction = '';
var installDir = '';

function createXMLHttpRequest() {
	try { return new ActiveXObject("Msxm12.XMLHTTP"); } catch (e) {}
	try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
	try { return new XMLHttpRequest(); } catch (e) {}
	
	alert("XMLHttpRequest not supported!");
	return null;	
}


function sendRequest(basedir, data, ajaxhandler, mod, action) {
	targetModule = mod;
	targetAction = action;
	installDir = basedir;
	xhReq = createXMLHttpRequest();
	xhReq.open('POST', basedir+'ajax/'+ajaxhandler+'/', true);
	xhReq.onreadystatechange = onResponse;
	xhReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xhReq.send(data);
}

function onResponse() {
	if (xhReq.readyState == 4) {
		if (xhReq.status == 200) {
			if (targetModule != '') {
				document.location=installDir+targetModule+'/'+targetAction
			}
		}
	}
}
