$(document).ready(function()
{  
	// Pages
	var home_link = $("a[name='home']").offset().top;
	var diensten_link = $("a[name='diensten']").offset().top;
	var referenties_link = $("a[name='referenties']").offset().top;
	var contact_link = $("a[name='contact']").offset().top;
	
	// Fixed elements
	var logo = (parseInt($("body").width())-990)/2;
	var menu = (parseInt($("body").width())-990)/2+580;
	
	$("#headerCntr h1").css("left", logo);
	$(".menuBox").css("left", menu);

	function scrolling()
	{
		var y = $(this).scrollTop();
		
		switch(y)
		{
			case home_link:
			$(".menuBox li").removeClass("selected");
			$(".menuBox li a[href='#home']").parent().addClass("selected");
			break;
			case diensten_link:
			$(".menuBox li").removeClass("selected");
			$(".menuBox li a[href='#diensten']").parent().addClass("selected");
			break;
			case referenties_link:
			$(".menuBox li").removeClass("selected");
			$(".menuBox li a[href='#referenties']").parent().addClass("selected");
			break;
			case contact_link:
			$(".menuBox li").removeClass("selected");
			$(".menuBox li a[href='#contact']").parent().addClass("selected");
			break;
		}
	}    

	$(".menuBox li a").click(function(){
		var inner = $(this).attr("href").substring(1);
		var scroller = $("a[name='" + inner + "']");
		var offset = scroller.offset().top;

		$("html, body").animate({
			scrollTop: offset
		}, 1000);

		$(".menuBox li").removeClass("selected");
		$(".menuBox li a[href='#" + inner + "']").parent().addClass("selected");

		return false;
	});

	$(window).scroll(function(){
		scrolling();
	});
	
	$(".imageBox li a").hover(function(){
		$(this).children("span.text").animate({
			top: "-1px"
		}, 400);
	}, function(){
		$(this).children("span.text").animate({
			top: "208px"
		}, 800);
	});
});
