var el;
var scrollstart = 154; // hoogte header
var scrollstop = 67; // hoogte footer
var starttop = 0; // startpositie

function whenscroll() {
	el = document.getElementById("menu");
		
	s = document.documentElement.scrollTop;
	c = document.documentElement.clientHeight;	
	
	if (s < scrollstart) {

		// do not scroll when the header is still visible

		y = starttop;
	} else {
		// header not visible any more

		// nieuwe positie menu
		y = s + starttop - scrollstart;

		// zorg dat nieuwe positie niet lager ligt dan de footer
		if (y > checkmax()) y = checkmax();
	}

	// move menu
	el.style.top = y + "px";	
}

function checkmax() {
	return document.documentElement.scrollHeight - el.offsetHeight - scrollstart - scrollstop;
}
