/*
 * jQuery.easing
 * Custom easing function
 */
jQuery.easing = {
	easeinout: function(x, t, b, c, d) {
		if (t < d/2) return 2*c*t*t/(d*d) + b;
		var ts = t - d/2;
		return -2*c*ts*ts/(d*d) + 2*c*ts/d + c/2 + b;
	},
	linear: function(x, t, b, c, d) {
		return c*t/d + b; //linear
	}
};

/*
 * On document load
 */
$(document).ready(function(){
	// Set mouseover action
	$(".knop").mouseover(function(){
		if(/ actief/i.test(this.parentNode.className)) {
			this.noreplace = true;
		}
		else{
			this.noreplace = false;
			this.parentNode.className += " actief";
		}
		moveMarker(this);
	});
	// Set mouseout action
	$(".knop").mouseout(function(){
		this.parentNode.className = this.noreplace ? this.parentNode.className : this.parentNode.className.replace(" actief","");
		moveMarker(actief);
	});
	// Function to get active element
	getActiveElement = function(elm){
		var candidate = document.getElementsByTagName("div");
		for(var i=0; i<candidate.length; i++){
			if(/actief/i.test(candidate[i].className)){
				return /MSIE/i.test(navigator.userAgent) ? candidate[i].childNodes[1] : candidate[i].firstChild;
			}
		}
	};
	// Function to move the marker
	moveMarker = function(elm){
		if(typeof(elm)=="object")
		{
			var y = elm.offsetTop;
			y += Math.round(elm.offsetHeight/2 -12);
			
			$("#pijl").dequeue().animate({ 
				top: y+"px"
			}, 600, 'easeinout' );
		}
	};
	// Get active element
	var actief = getActiveElement();
	// Move marker to active position
	moveMarker(actief);
});