// To trigger a notification bar that slides down behind the navigation bar
// text : the text that will be displayed in the notification bar
// time : the time it will take for the notification bar the close
//		  if the time is 0, the notification bar will not go away
// color: must be red or green
function notification(text, time, color)
{
	//Change text of notification bar
	$('.not_text').html("<div class='text "+color+"'>"+text+"</div>");
	//Open the notification bar with the jquery SlideDown function
	$('.notification_bar').slideDown('slow', function() {});	
	//If time == 0 --> no slideup will be called
	if(time != 0)
	{
		//After some time close the notification bar with the jquery slideUp function
		setTimeout("$('.notification_bar').slideUp('slow', function() {})",time);
	}
}

var Page = {
    load: function() {
    	//Initialise Lightbox
		initLightbox();
		//Start sponsor fading
		setInterval( "slideSponsors()", 5000 );
    }
};

function slideSponsors() {
    var $active = $('.sponsors img.active');
    if ( $active.length == 0 ) $active = $('.sponsors img:last');
    var $next =  $active.next().length ? $active.next()
        : $('.sponsors img:first');
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
    	.addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
    	});
} 

function initLightbox()
{
	$("a.lightbox").fancybox({
		'overlayShow'		:	true,	
		'overlayOpacity'    :   0.7,
		'overlayColor'      :   '#000',
		'transitionIn'		:	'elastic',
		'transitionOut'		:	'elastic',
		'speedIn'			:	600, 
		'speedOut'			:	200,
		'opacity'			:   true,		// Fade in/out when opening
		'hideOnContentClick': 	false,
		'hideOnOverlayClick':   false,
		'showCloseButton'	:   true,
		'enableEscapeButton':   true,		
		'modal'				:   false		// Lock in lightbox
	});
}

