function slideSwitch() {
    var $active = $('#beeld img.active');

    if ( $active.length == 0 ) $active = $('#beeld img:last');

    var $next =  $active.next().length ? $active.next() : $('#beeld img:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 2500, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
	$('#top').click(function(){
		location.href = $('base:first').attr('href');
	});
	
	if($('#beeld img').length > 1)
	{
		setInterval( "slideSwitch()", 5000 );
	}
	
	$('ul.sf-menu').supersubs({
		minWidth: 12,
		maxWidth: 27,
		extraWidth: 1
	}).superfish({
		animation: { opacity:'show',height:'show' },
		speed: 'fast',
		delay: 0,
		disableHI: false
	});
	
	$('#twitterFeed').liveTwitter('jubileeNL', {limit: 3, refresh: false, mode: 'user_timeline', showAuthor: true}, function(container, newCount){
		$('#twitterFeed a').each(function(){
			$(this).attr('target', '_blank');
		});
	});
	
	var el = $('#twitter.subpage');
	
	if(el.length > 0)
	{
		var beeldHeight = $('#beeld').height();
		var menuHeight = $('#menu').height();
		
		var newTop = menuHeight > beeldHeight ? menuHeight : beeldHeight;
		
		el.css({'position' : 'absolute', 'top' : newTop, 'display' : 'block'});
	}
});
