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.documentElement.clientHeight/2) - 317));
	} else {
		calculateLeft = ((window.innerWidth/2) - 270);
		calculateTop = ((window.innerHeight/2) - 317);
	} 
	var oDiv = document.getElementById(divName);
	oDiv.style.visibility = 'visible';
	oDiv.style.width = '640px';
	oDiv.style.height = '480px';
	oDiv.style.position = 'absolute';
	oDiv.style.top = calculateTop+"px";
	oDiv.style.left = calculateLeft+"px";
		
}
function openOverlayDiv(width, height) {
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
		calculateLeft = (Math.round(document.body.clientWidth/2) - (width/2));
		calculateTop = (Math.round(document.body.clientHeight/2)-(height/2));
	} else {
		calculateLeft = (Math.round(window.innerWidth/2) - (width/2));
		calculateTop = (Math.round(window.innerHeight/2)-(height/2));
	}
	var scrolled  = GetScrollTop();
	var oGreyDiv = document.getElementById('grey');
	//gray overlay first
	oGreyDiv.style.position = 'absolute';
	oGreyDiv.style.left = '0px';
	oGreyDiv.style.top = scrolled+'px';
	oGreyDiv.style.visibility = 'visible';
	oGreyDiv.style.width = '100%';
	oGreyDiv.style.height = '100%';
	//open the bigdiv
	var oDiv = document.getElementById('bigFoto');
	oDiv.style.visibility = 'visible';
	oDiv.style.width = width+'px';
	oDiv.style.height = height+'px';
	oDiv.style.backgroundColor = '#FFFFFF';
	oDiv.style.position = 'absolute';
	oDiv.style.top = (calculateTop+scrolled)+"px";
	oDiv.style.left = calculateLeft+"px";
		
}
function closeDiv(divId) {
	var oDiv = document.getElementById(divId);
	oDiv.style.visibility = 'hidden';
	oDiv.style.width = '0px';
	oDiv.style.height = '0px';	
	oDiv.innerHTML = '';
} 
function closeTd(tdId) {
	var oTd = document.getElementById(tdId);
	oTd.innerHTML = '';
} 
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.3378, 6.9113), 15);
        map.addControl(new GLargeMapControl());
        map.openInfoWindow(map.getCenter(),
                            document.createTextNode
                           ("BS noorderbreedte"));
    
        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>";
}
function GetScrollTop() {
  return window.pageYOffset||
    document.documentElement&&document.documentElement.scrollTop||
    document.body.scrollTop||0;
}

function setSideHeight () {
	var mainHeight = document.getElementById('sidebar').offsetHeight;
	var theDiv = document.getElementById('content');
	var theDiv2 = document.getElementById('menu');
	theDiv.style.minHeight = mainHeight+"px";
	//link the menu on the content
	theDiv2.style.height = theDiv.offsetHeight+"px";
	if (mainHeight < theDiv.offsetHeight) {
		document.getElementById('sidebar').style.height = theDiv.offsetHeight+"px";
	}
}
