jQuery(document).ready(function($) { 
	// fade out any flash messages we may have after 5 seconds
	setTimeout('$("div.message[id$=Message]").fadeOut();', 5000);
	$('#wrapper .container .menu ul li').hover(
		function() {
			$(this).children('ul').css('display', 'block');
		},
		function() {
			$(this).children('ul').css('display', 'none');			
		}
	);
	// Slideshow configuration
	// hide caption
	$('#slideshow .item .caption').hide();
	$('#slideshow .item:last .caption').show();
	// begin slideshow
	setInterval( "slideSwitch()", 3500);
	// init colorbox
	$("a[rel='lightbox']").colorbox();
}); 

function slideSwitch() {
	// find the visible item
	var $active = $('#slideshow .item.active');
	// check to see if the item exists, else default to last item
	if ( $active.length == 0 ) $active = $('#slideshow .item:last');
	// check to see if we have a next item, else default to first item
	var $next =  $active.next().length ? $active.next()	: $('#slideshow .item:first');
	// manipulate active (visible) image
	$active.addClass('last-active');
	$active.children('.caption').fadeOut();
	// fade in next image
	$next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 1000, function() {
		$active.removeClass('active last-active');
		// fade in new caption
		$(this).children('.caption').fadeIn();
	});
}