var xhr = new Array(); 
var xi = new Array(0);
xi[0] = 1;
window.onload = windowLoad;

function windowLoad() {	
	if (document.all&&document.getElementById) {		
		menunavParent = document.getElementById("nav");	
		for (x=0; x < menunavParent.childNodes.length; x++) {		
			menunode = menunavParent.childNodes[x];
			if (menunode.nodeName=="LI") {			
				menunode.onmouseover=function() {				
					this.className+="over";			
				}			
                menunode.onmouseout=function() {				
					this.className=this.className.replace("over", "");
				}
			}
		}
	}
	loadInitial();
}
 
function loadInitial() {
	if (window.location.href.indexOf("url=") > 0) {
		var url = window.location.href.substring(window.location.href.indexOf("url=") + 4)
		processAjax(url,"contentDiv");
	} else {
		processAjax("home/home_home.htm","contentDiv");
	}
	processAjax("nieuwsbanner.htm","sidebarDiv");
}
function xhrRequest(type) {
	if (!type) {
		type = 'html';
	}

	var xhrsend = xi.length;

	for (var i=0; i<xi.length; i++) {
		if (xi[i] == 1) {
			xi[i] = 0;
			xhrsend = i;
			break;
		}
	}

	xi[xhrsend] = 0;

	if (window.ActiveXObject) {
		try {
			xhr[xhrsend] = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xhr[xhrsend] = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	} else if (window.XMLHttpRequest) {
		xhr[xhrsend] = new XMLHttpRequest();
		if (xhr[xhrsend].overrideMimeType) {
			xhr[xhrsend].overrideMimeType('text/' + type);
		}
	}
	return (xhrsend);
}

function processAjax(url, div) {
	var xhri = xhrRequest('html');
	// +"?ref="+new Date().valueOf() = a fix for caching problems 
	if (url.indexOf("#")>0) {
		xhr[xhri].open('GET', url.slice(0,url.indexOf("#"))+"?ref="+new Date().valueOf(), true);
	} else {
		xhr[xhri].open('GET', url+"?ref="+new Date().valueOf(), true);
	}
	xhr[xhri].onreadystatechange = function() {
		if (xhr[xhri].readyState == 4 && xhr[xhri].status == 200) {
			document.getElementById(div).innerHTML = xhr[xhri].responseText;
			document.getElementById(div).scrollTop=0;
			if (url.indexOf("#")>0) {
				if (document.getElementsByName(url.slice(url.indexOf("#")+1)).length>0) {
					document.getElementsByName(url.slice(url.indexOf("#")+1))[0].scrollIntoView(true);
				}
			}
			xi[xhri] = 1;
			xhr[xhri] = null;
		}
	};
	xhr[xhri].send(null);
	return false;
}

