var xhttp;

function loadAjax() {

	if (window.ActiveXObject) { 
		try { 
			// IE 6 and higher
			xhttp = new ActiveXObject("MSXML2.XMLHTTP");
		} catch (e) {
			try {
				// IE 5
				xhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				xhttp=false;
			}
		}
	}
	else if (window.XMLHttpRequest) {
		try {
			// Mozilla, Opera, Safari ...
			xhttp = new XMLHttpRequest();
		} catch (e) {
			xhttp=false;
		}
	}
}

function showLoadingImage(show) {
	
	if (show == 1) { 
		document.getElementById("loading").style.display = "block";
	} else {
		document.getElementById("loading").style.display = "none";
	}
}

function sendRequest_joinLandmark(id) {
	
	loadAjax();

	if(xhttp) {
		
		xhttp.open("GET", DOMAIN+"/core/ajax/joinLandmark.php?id="+id, true);
        xhttp.onreadystatechange = handleResponseMessage;
        xhttp.send(null); 
		
	} else {
		alert("Objekt konnte nicht instanziert werden.");
	}
	
}

/*
function sendRequest_cancelJLAndmark(id) {
	
	loadAjax();

	if(xhttp) {
		
		showLoadingImage(1);
		
		if(window.confirm("Möchtest du dich wirklich von dieser Reise abmelden?")) {
		
			xhttp.open("GET", DOMAIN+"/core/ajax/joinJourney.php?modul=abmelden&rid="+id, true);
			xhttp.onreadystatechange = handleResponseMessage;
			xhttp.send(null); 
		}else {
			showLoadingImage(2);
		}
	} else {
		alert("Objekt konnte nicht instanziert werden.");
	}
	
}
*/
function handleResponseMessage() {
	
	if (xhttp.readyState == 4) {
		
		showLoadingImage(2);
		alert(xhttp.responseText);
		return true;
		
	}
}