function slideSwitch() {
	
	$('#beeld img, #beeldHome img').css('visibility', 'visible');
    var $active = $('#beeld img.active, #beeldHome img.active');

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

    var $next =  $active.next().length ? $active.next() : $('#beeld img:first, #beeldHome 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() {
	if($('#beeld img, #beeldHome img').length > 1)
	{
		setInterval( "slideSwitch()", 5000 );
	}
	
	$('a.imagePopup[rel=afbeeldingen]').fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Afbeelding ' + (currentIndex + 1) + ' van ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});

});
