var xmlhttp = false;
var XMLHTTP_SUCCEED_CODE = 200;
var XMLHTTP_READY = 4;
function createXmlhttp() {
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		//if not, try older IE versions for even dumber people
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function loadPage (serverPage, contentDiv) {
	xmlhttp = createXmlhttp();
	obj = document.getElementById(contentDiv);
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() {
	if (xmlhttp.readyState == XMLHTTP_READY && xmlhttp.status == XMLHTTP_SUCCEED_CODE) {
			obj.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}

function openDiv(divName) {
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
		calculateLeft = ((document.body.clientWidth/2) - 270);
		calculateTop = (((document.body.clientHeight/2) - 317)-128);
	} else {
		calculateLeft = ((window.innerWidth/2) - 270);
		calculateTop = ((window.innerHeight/2) - 317);
	}
	var oDiv = document.getElementById(divName);
	oDiv.style.visibility = 'visible';
	oDiv.style.width = '700px';
	oDiv.style.height = '650px';
	oDiv.style.position = 'absolute';
	oDiv.style.top = calculateTop+"px";
	oDiv.style.left = calculateLeft+"px";
		
}
function closeDiv(divName) {
	var oDiv = document.getElementById(divName);
	oDiv.style.visibility = 'hidden';
	oDiv.style.width = '0px';
	oDiv.style.height = '0px';	
} 

function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"),
            { size: new GSize(700,600) } );
        map.removeMapType(G_HYBRID_MAP);
        map.setCenter(new GLatLng(53.2949, 6.5934), 15);
        map.addControl(new GLargeMapControl());
        map.openInfoWindow(map.getCenter(),
                            document.createTextNode
                           ("Groenvoorziening A.J. van der Werf b.v."));
    
        var mapControl = new GMapTypeControl();
        map.addControl(mapControl);
        
      }
}
function insertContent(divId){
	document.getElementById(divId).innerHTML = "&nbsp;&nbsp;<a href='#' onClick=\"closeDiv('"+divId+"'); GUnload()\">Venster sluiten</a><br/><div id='map_canvas' style='width: 500px; height: 300px'></div>";
}
//set the height of the side, this is needed for the sides
function setSideHeight () {
	var screenWidth,screenHeight;
	if (self.innerHeight) // all except Explorer
	{
		screenWidth = self.innerWidth;
		screenHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		screenWidth = document.documentElement.clientWidth;
		screenHeight = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		screenWidth = document.body.clientWidth;
		screenHeight = document.body.clientHeight;
	}

	var headerHeight = document.getElementById('header').offsetHeight;
	var mainHeight = document.getElementById('main').offsetHeight;
	var totalHeight = headerHeight + mainHeight;
	var theDiv = document.getElementById('bottom');
	theDiv.style.height = ((screenHeight - totalHeight)-14)+'px';
	theDiv.style.width  = (screenWidth-16)+'px';
}
