<!--


// ====================== Menu movement functionality
	//====================== Browser checks
	var IE = (document.all && document.getElementById) ? true:false;
	var Opera = window.opera ? true : false;
	var Mac = (navigator.appVersion.toLowerCase().indexOf("macintosh")>0) ? true : false;
	var Safari = (navigator.userAgent.toLowerCase().indexOf("safari")>0) ? true : false;
	var ieLow = (navigator.userAgent.toLowerCase().indexOf("msie 5")>0) ?  true : false;
	//====================== 
	var mousex;
	var mousey;
	
	function getMouseXY(e) {
		if (IE) { // grab the x-y pos.s if browser is IE
			mousex = event.clientX + document.body.scrollLeft;
			mousey = event.clientY + document.body.scrollTop;
		}
		else {  // grab the x-y pos.s if browser is not IE
			mousex = e.pageX;
			mousey = e.pageY;
		}
	}
	
	function capMouse(){
		if (!IE) document.captureEvents(Event.MOUSEMOVE)
		document.onmousemove = getMouseXY;
	}
	
	//====================== Bereken schermgrootte
	function winWidth() {
		var myWidth = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
		}
		return myWidth;
	}
	//======================
	
	// Many, many thanx to Robert Penner of course for his Flash Actionscript Easing Equations they can be very handy in javascript too...
	// exponential easing out - decelerating to zero velocity
	// t: current time, b: beginning value, c: change in position(since start), d: duration
	easeOutExpo = function (t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	} 
	
	// ====================== End Menu movement functionality
	
	var active_menu = null;
	var offset_correction  = 77;
	if(ieLow){ offset_correction  = 0; }
	
	initHomeMenu = function(){
		var menu_lists = document.getElementById("menu-home").getElementsByTagName("div");
		for(var i=0; i<menu_lists.length; i++){
			menu_lists[i].maxHeight = menu_lists[i].getElementsByTagName("ul")[0].offsetHeight-offset_correction;
			menu_lists[i].minHeight = 0;
			if(ieLow){ menu_lists[i].minHeight = 77; }
			
			menu_lists[i].getElementsByTagName("ul")[0].style.backgroundPosition = "0px 0px";
			menu_lists[i].getElementsByTagName("ul")[0].style.marginBottom = "0px";
			menu_lists[i].getElementsByTagName("ul")[0].style.borderBottom = "none";
			
			menu_lists[i].callMovement = function(){
				this.curr_time = 0; // Start time
				this.end_time = 50; // Time elapsing from start to end
				this.moveMenu();	
				this.getElementsByTagName("ul")[0].style.backgroundPosition = this.direction>0?"-300px 0px":"0px 0px";
			} 
			
			menu_lists[i].moveMenu = function(){	
				// Style rule for cursor display is disabled because it probably caused performance problems
				//this.style.cursor = "none";
				this.chg_pos = this.end_pos - this.start_pos;
				this.curr_time += 1;
				this.pos_nu = Math.floor(easeOutExpo(this.curr_time,this.start_pos,this.chg_pos,this.end_time));
				this.getElementsByTagName("ul")[0].style.height = this.pos_nu+"px";
				if(this.pos_nu>0){this.getElementsByTagName("ul")[0].style.marginBottom = Math.ceil((30/this.maxHeight)*this.pos_nu) + "px";}
				if(!(this.pos_nu >= this.end_pos) && this.direction>0){
					setTimeout("document.getElementById('" + this.id + "').moveMenu()",10);
				} 
				else if(!(this.pos_nu <= this.end_pos) && this.direction<0){
					setTimeout("document.getElementById('" + this.id + "').moveMenu()",10);
					if(this.pos_nu <= this.start_pos-1){
						this.getElementsByTagName("ul")[0].style.borderBottom = "none";
					}
				} 				
			}
			menu_lists[i].menuCheck = function(){
				this.x = 0;
				this.y = 0
				this.thisRef = this;
				while( this.thisRef.offsetParent != null ) {
					this.y +=this.thisRef.offsetTop;
					this.x += this.thisRef.offsetLeft;
					this.thisRef = this.thisRef.offsetParent;
			    }
				
				if(mousex<(this.x+this.offsetWidth) && mousex>this.x && mousey<(this.y+(this.offsetHeight)) && mousey>this.y){
					if(active_menu != null && active_menu != this.id) { 					
						var t = document.getElementById(active_menu);
						t.direction = -1;
						t.end_pos = t.minHeight;
						t.start_pos = t.getElementsByTagName("ul")[0].offsetHeight-offset_correction;
						if(ieLow){ 
							t.getElementsByTagName("ul")[0].style.height = t.end_pos + "px";
							t.getElementsByTagName("ul")[0].style.marginBottom = "0px";
							t.getElementsByTagName("ul")[0].style.borderBottom = "none";
						} else {
							t.callMovement(); 
						}
					}			
					this.direction = 1;
					this.end_pos = this.maxHeight;
					this.start_pos = this.getElementsByTagName("ul")[0].offsetHeight-offset_correction;
					if(ieLow){ 
						this.getElementsByTagName("ul")[0].style.height = this.end_pos + "px";
						this.getElementsByTagName("ul")[0].style.marginBottom = "30px";
						this.getElementsByTagName("ul")[0].style.borderBottom = "1px solid #888";
					} else {
						this.callMovement(); 
					}
					active_menu = this.id;		
					this.getElementsByTagName("ul")[0].style.borderBottom = "1px solid #888";
				} else {
					this.direction = -1;
					this.end_pos = this.minHeight;
					this.start_pos = this.getElementsByTagName("ul")[0].offsetHeight-offset_correction;
					if(ieLow){ 
						this.getElementsByTagName("ul")[0].style.height = this.end_pos + "px";
						this.getElementsByTagName("ul")[0].style.marginBottom = "0px";
						this.getElementsByTagName("ul")[0].style.borderBottom = "none";
					} else {
						this.callMovement(); 
					}
				}
			}
			
			menu_lists[i].getElementsByTagName("ul")[0].style.height = menu_lists[i].minHeight + "px";
			// Create mouse actions:
			menu_lists[i].onmouseover = function(){
				setTimeout("document.getElementById('" + this.id + "').menuCheck()",250);
				return false;
			}
			menu_lists[i].onmouseout = function(){	
				setTimeout("document.getElementById('" + this.id + "').menuCheck()",1000);
				return false;
			}
			menu_lists[i].onclick = function(){
				document.getElementById(this.id).menuCheck();
				return false;
			}
		}
	};
	
	placeMenuLayer = function(){
		var win_width = winWidth();	
		var div_ref = document.getElementById("menu-home");
		var x = 0;
		var y = 0;
		if(win_width<div_ref.offsetWidth) {
			x = 0;
		} else {
			x = ((win_width-div_ref.offsetWidth)/2);
			if((!IE && !Mac) || Opera){ x -= 8; }
		}
		div_ref.style.position="absolute";
		div_ref.style.left=x+"px";
		var link_lists = document.getElementById("sub-nav").getElementsByTagName("div");
		for(var i=0; i<link_lists.length; i++){			
			//if(link_lists[i].className.indexOf("link")){
				link_lists[i].style.marginTop="130px";	
			//}	
		}
		//document.getElementById("menu-home").style.paddingBottom = "52px";
	};
	
	//====================== Call functions at Onload-event:
	window.onload = function() {
		if(!Safari){
			capMouse();
			placeMenuLayer();
			initHomeMenu();	
		}	
	}
	//====================== 
	//====================== Call functions at Onresize-event:
	window.onresize = function() {
		if(!Safari){
			placeMenuLayer();
		}
	}
	//======================

//-->