/**
 * @author guigouz
 */
$(function() {
	
	// Menu
	$('#menu > ul > li').hover(function() {
		$(this).children('ul').show();
	}, function() {
		$(this).children('ul').hide();
	});
	
	$('ul > li > img').parents('ul').addClass('galleria');
	
	$('.galleria').galleria({
			history   : false, // deactivates the history object for bookmarking, back-button etc.
			clickNext : false, // helper for making the image clickable. Let's not have that in this example.
			insert    : undefined, // the containing selector for our main image. 
								   // If not found or undefined (like here), galleria will create a container 
								   // before the ul with the class .galleria_container (see CSS)
			onImage   : function() { $('.nav').css('display','block'); } // shows the nav when the image is showing
		});

	$('.destaque').hide();
	$('.destaque:first').show();
	destaques();
});

var next = null;

function destaques() {
	
	if (next == null) {
		next = $('.destaque:first');
		if(next.size() == 0)
			return;
	}
	else {
		obj = next;
		
		next = obj.next('.destaque');
		
		if (next.size() == 0) 
			next = $('.destaque:first');
		
		obj.hide();
		
		next.show();
	}
	
	setTimeout('destaques()', 13000);
}
