// Functie voor het aanmaken van het ajax object
function ajaxinit()
{
	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}

  	return xmlhttp;
}

function getHttphost()
{
	url = window.location.href;

	// Url is hier bijvoorbeeld - http://www.wesensit.nl/
	// Hieruit moeten we de request uri en domein halen
	// Even controleren of de http:// er wel in zit
	if(url.substr(0, 7)=="http://")
	{
		// We gaan de http:// verwijderen
		url = url.substr(7);

		// Ook gaan we de / tekens verwijderen
		tmp_http_host = url.split('/');
		http_host = tmp_http_host[0];
	}

	return http_host;
}

// Functie voor ophalen van de project afbeeldingen
function getVestiging(id)
{
    // We gaan de box openen
    document.getElementById('addressData').innerHTML = '<div style="text-align:center;"><img src="/images/ajax-loader.gif" alt="Loading..." title="Loading..." border="0" /></div>';
    document.getElementById('vestigingId').value = id;

    // We gaan de request string maken
	var http = ajaxinit();
    var str = "getVestiging=true&id=" + id;
	if(http)
	{
		http.open('POST','http://' + getHttphost() + '/index.php?ajax=1',true);
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded;');
		http.onreadystatechange = function() {
			if (http.readyState == 4)
			{
				if (http.status == 200)
				{
					document.getElementById('addressData').innerHTML = http.responseText; // responseXML
				} else {
					alert("There was a problem retrieving the XML data:\n" + http.statusText);
					return false;
				}
			}
		}
		http.send(str);
	}
}
