$(document).ready(function(){
	
	$('#menu ul li').hover(function () {
	
		$(this).attr('class','active');
	
		$(this).find('.submenu').fadeIn();
		
	},function () {
		
		$(this).attr('class','');
		
		$(this).find('.submenu').hide();
	});
	
	// Sponsors
	
	$(".photo-album .album .photo a,.big-photos div.photo a").colorbox({close:'Sluiten',next: '<img src="/static/img/colorbox/next-photo.png" />',previous: 'Vorige'});	
});


// Slider functie
function slideImage(slideSelector) {
	
	var $active = $(slideSelector + ' img.active');

    if ( $active.length == 0 ) $active = $(slideSelector + ' img:last');

    var $next =  $active.next().length ? $active.next()
        : $(slideSelector + ' img:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 3000, function() {
            $active.removeClass('active last-active');
        });
	
}

// Slider functie
function slideImage2(slideSelector) {
	
var 	$slider = $(slideSelector),
	$active = $slider.find('.active'),
	$next = ( $active.length == 1 && $active.next().length == 1 ) ? $active.next() : $slider.children().first();

	
    $active	.css({'z-index':80}).removeClass('active').addClass('last-active')

    $next	.css({opacity: 0.0, 'z-index':100,'display':'block'})
        	.addClass('active')
        	.animate({opacity: 1.0}, 3000, function(){ $('> .last-active', slideSelector).css({'z-index':50,'display':'none'}).removeClass('last-active'); });
	
}


$(function() {
	
	$('.sponsor-slideshow').cycle({
		fx:     'fade', 
		speed: 1400
	});
	
	/*if( $('.sponsor-slideshow').length )
{ 
    $(".sponsor-slideshow > *:not(:first-child)").hide();
    $(".sponsor-slideshow > *:first-child").addClass('active');
    setInterval( "slideImage2('.sponsor-slideshow')", 6000 );
	
}*/

if( $('.slideshow-top').length )
	
	setInterval( "slideImage('.slideshow-top')", 6000 );
});
