sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);



function LoadPage ( e ) {
	$$('#nav UL').each(function(element) {
		element.hide();
	});
	if ( e.href == "javascript://" ) {
		return false;
	}
	else if ( e.target == "_new" ) {
		return true;
	}	
	else {
		url = e.href
		if ( url.indexOf('?') == -1 ) {
			url = url +"?ajax=1&dummy=" + new Date().getTime();
		}
		else {		
			url = url +"&ajax=1&dummy=" + new Date().getTime();
		}
		
		new Ajax.Request(url, { 
			method: 'GET', 
			onComplete: function(transport) { 			
				$$('#nav UL').each(function(element) {
					element.show();
				});
				$('Content').innerHTML = transport.responseText;
				document.title = e.innerHTML + " - Leys BV";
				launchJavascriptFromXML($('Content'));
			} 
		}); 
		return;
	}
}

function launchJavascriptFromXML(responseXML) {

if (responseXML == null) return;

if (responseXML.getElementsByTagName('script') == null) return;
  var jsCode = responseXML.getElementsByTagName('script');
	
	for (var i = 0; i < jsCode.length; i++) { 

	if(!jsCode[i].innerHTML == ''){
	if(window.execScript) {
		window.execScript(jsCode[i].innerHTML); // eval in global scope for IE
	} else {
		//eval(scripts.innerHTML);
		var dj_global = this; // global scope object
		if (dj_global.eval)
		{
			dj_global.eval(jsCode[i].innerHTML) //This works in Firefox but not in IE (eval is not an object method in IE).
		}
		else
		{
			eval(jsCode[i].innerHTML);	      // doesn’t work in FF or IE
		}
	}
}
}
}

function CheckAjax () {
	if(!LoadPage(this)) { return false; }
}