var http_request = false;
var http_request2 = false;
function makePOSTRequest(url, parameters) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
// set type accordingly to anticipated content type
//http_request.overrideMimeType('text/xml');
http_request.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}
http_request.onreadystatechange = alertContents;
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(parameters);
return true;
}
function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
//alert(http_request.responseText);
result = http_request.responseText;
var string = result.split("split")
//window.alert(string[1]);
if(typeof(string[0]) !== 'undefined' && string[0] != null) {
document.getElementById('captain_left').innerHTML = string[0];
} else {
document.getElementById('captain_left').innerHTML = '';
}
if(typeof(string[1]) !== 'undefined' && string[1] != null) {
document.getElementById('ship_left').innerHTML = string[1];
} else {
document.getElementById('ship_left').innerHTML = '';
}
if(typeof(string[2]) !== 'undefined' && string[2] != null) {
document.getElementById('game_body_handler').innerHTML = string[2];
} else {
document.getElementById('game_body_handler').innerHTML = 'You must be logged in to access this page!
Click Here to go to the login page !';
}
if(typeof(string[3]) !== 'undefined' && string[3] != null) {
document.getElementById('game_sub_body_handler').innerHTML = string[3];
} else {
document.getElementById('game_sub_body_handler').innerHTML = '';
}
if(typeof(string[4]) !== 'undefined' && string[4] != null) {
document.getElementById('target_right').innerHTML = string[4];
} else {
document.getElementById('target_right').innerHTML = '';
}
if(typeof(string[5]) !== 'undefined' && string[5] != null) {
document.getElementById('actions_right').innerHTML = string[5];
} else {
document.getElementById('actions_right').innerHTML = '';
}
if(typeof(string[6]) !== 'undefined' && string[6] != null) {
document.getElementById('compass_right').innerHTML = string[6];
} else {
document.getElementById('compass_right').innerHTML = '';
}
} else {
alert('There was a problem with the request.');
}
}
}
function get(locatie,dir,auth) {
var poststr = "locatie=" +escape(encodeURI( locatie )) +"&directie=" +escape(encodeURI( dir )) +"&auth=" +escape(encodeURI( auth )) ;
setTimeout('makePOSTRequest("game_send.php",\''+poststr+'\')',200);
//makePOSTRequest('game_send.php',poststr);
}