$(document).ready(function() {
	$('.Down').css('opacity', 0.5);
	$('.descript').css('opacity', 1);
	$('.homeDesc').hide();

	/* fadein del contenuto della pagina */
	$('#content').hide( 0, function() {
		goUpp();
		$(this).fadeIn(1500);
	});

	var time = 500;
	
	/* gestisce gli hover sul collage in homepage */
	$('.Down').hover(function(){
		$(this).stop().fadeTo(time, 1.0);
		$(this).parent().siblings('.descript').css({
			'z-index': 99, 
			'height': '150px',
			'bottom': '-158px'
		}).stop().animate({
			opacity: 1
		}, time);
	}, function() {
		$(this).stop().fadeTo(500, 0.5);
		$(this).parent().siblings('.descript').stop().fadeTo(50, 0, function() {
			$(this).css({
				'z-index': -1, 
				'height': '0px',
				'bottom': '0px'
			});
		});
	});
	
	/* fadeIn/out della tessera STAFF */
	$('#home').hover(function(){
		$('.homeDesc').stop().fadeTo(time, .8);
	}, function() {
		$('.homeDesc').stop().fadeTo(time, 0);
	});


	function goUpp() {	
		$('body').scrollTo('#pageTop', 1200, {
			easing: 'easeInOutQuad'
		});
	}
	
	// al click su una tessera scompare #collage e viene sostituito da #content
	$('.collage > .Down').click(function() {
		var pageName = $(this).parent().attr('id');
		var navPageName = pageName.toUpperCase();
		$('#navmenu li').removeClass('active');
		$("a:contains("+navPageName+")").parent().parent().addClass('active');
		$('#collage').fadeOut(250, function() {
			$(this).remove()
			$.post('php/getPage.php', {pageName: pageName}, function(data) {
				$('#content').hide().append(data).fadeIn();
			});
		});
	});
	

	
});

