$(function(){
	var $menu_items = $("#menu li a");
	$menu_items.click(function(){
		$menu_items.removeClass('active').filter(this).addClass('active');
	});

	$(".youtube").colorbox({iframe:true, innerWidth:640, innerHeight:360});
	$(".colorphoto").bind('click', function(event){
		event.stopPropagation();
		event.preventDefault();
		var $link = $(this);
		$.colorbox({href: $link.attr('href'), rel: $link.attr('rel')});
	});

	$('.hidden', '#pictures').colorbox();

	$(".oneallbum").click(function(event)
	{
		var $link = $(this).find('a').trigger('click');
	});

	$prev = $('#vidcar_prev');
	$next = $('#vidcar_next');

	$("#videocaroussel").cycle({
		fx: 'scrollHorz',
		prev: $prev,
		next: $next,
		after: onAfterClick,
		speed: 500,
		timeout: 0
	});

	function onAfterClick(curr, next, opts)
	{
		var index = opts.currSlide;
		$prev[index == 0 ? 'hide' : 'show']();
		$next[index == opts.slideCount - 1 ? 'hide' : 'show']();
	}

	window.onscroll = function() {
		var pos = $(window).scrollTop();

		if(pos+50 < $('#video').offset().top)
		{
			$menu_items.removeClass('active').filter('#menuhome').addClass('active');
			if(window.location.hash !== '#home')
			{
				window.location.hash = 'home';
			}
		}
		else if(pos+50 < $('#tourlijst').offset().top)
		{
			$menu_items.removeClass('active').filter('#menuinfo').addClass('active');
			if(window.location.hash !== '#info')
			{
				window.location.hash = 'info';
			}
		}
		else
		{
			$menu_items.removeClass('active').filter('#menutour').addClass('active');
			if(window.location.hash !== '#tourlijst')
			{
				window.location.hash = 'tourlijst';
			}
		}
	}
});

