$(document).ready(function(){
	
	jQuery.easing.def = "easeOutQuad";
	
	/*** Animazione iniziale ***/
	/*
	$('#information_slogan').animate( { color: "#F7279C" }, 1000, function(){
		$(this).animate( { color: "#808080" }, 1000, function(){
			$('#management_slogan').animate( { color: "#F7279C" }, 1000, function(){
				$(this).animate( { color: "#808080" }, 1000, function(){
					$('#design_slogan').animate( { color: "#F7279C" }, 1000, function(){
						$(this).animate( { color: "#808080" }, 1000 );
					});
				});
			});
		});
	});
	*/
	/*** Menu di navigazione ***/
	
	var display = false;
	var runningAnimation = false;
	
	$('.home_link').click(function(){
		$( 'html, body' ).animate( { scrollTop: 0 }, 'slow', function(){
			if(!runningAnimation) {
				runningAnimation = true;
				display = true;
				$('.content-block:visible').animate({opacity: 0.0}, function(){
					stopTicker = true;
					$(this).slideToggle(300);
					$('#home_partial').css({opacity: 0.0});
					$('#home_partial').slideToggle(500);
					$('#home_partial').animate({opacity: 1.0}, 500);
					setTimeout("restartTicker()", 30);
					runningAnimation = false;
				});
			}
		});
	});
	
	$('.chi_link').click(function(){
		$( 'html, body' ).animate( { scrollTop: 0 }, 'slow', function(){
			if(!runningAnimation) {
				runningAnimation = true;
				display = true;
				$('.content-block:visible').animate({opacity: 0.0}, function(){
					stopTicker = true;
					$(this).slideToggle(300);
					$('#chi_partial').css({opacity: 0.0});
					$('#chi_partial').slideToggle(500);
					$('#chi_partial').animate({opacity: 1.0}, 500);
					runningAnimation = false;
				});
			}
		});
	});
	
	$('.dove_link').click(function(){
		$( 'html, body' ).animate( { scrollTop: 0 }, 'slow', function(){
			if(!runningAnimation) {
				runningAnimation = true;
				display = true;				
				$('.content-block:visible').animate({opacity: 0.0}, function(){
					stopTicker = true;
					$(this).slideToggle(300);
					$('#dove_partial').css({opacity: 0.0})
					$('#dove_partial').slideToggle(500);
					$('#dove_partial').animate({opacity: 1.0}, 500);
					runningAnimation = false;
				});
			}
		});
	});
	
	$('.information_link').click(function(){
		$( 'html, body' ).animate( { scrollTop: 0 }, 'slow', function(){
			if(!runningAnimation) {
				runningAnimation = true;
				display = true;
				$('.content-block:visible').animate({opacity: 0.0}, function(){
					stopTicker = true;
					$(this).slideToggle(300);
					$('#information_partial').css({opacity: 0.0})
					$('#information_partial').slideToggle(500);
					$('#information_partial').animate({opacity: 1.0}, 500);
					runningAnimation = false;
				
				});
			}
		});
	});
	
	$('.management_link').click(function(){
		$( 'html, body' ).animate( { scrollTop: 0 }, 'slow', function(){
			if(!runningAnimation) {
				runningAnimation = true;
				display = true;
				$('.content-block:visible').animate({opacity: 0.0}, function(){
					stopTicker = true;
					$(this).slideToggle(300);
					$('#management_partial').css({opacity: 0.0})
					$('#management_partial').slideToggle(500);
					$('#management_partial').animate({opacity: 1.0}, 500);
					runningAnimation = false;
				});
			}
		});
	});
	
	$('.design_link').click(function(){
		$( 'html, body' ).animate( { scrollTop: 0 }, 'slow', function(){
			if(!runningAnimation) {
				runningAnimation = true;
				display = true;
				$('.content-block:visible').animate({opacity: 0.0}, function(){
					stopTicker = true;
					$(this).slideToggle(300);
					$('#design_partial').css({opacity: 0.0})
					$('#design_partial').slideToggle(500);
					$('#design_partial').animate({opacity: 1.0}, 500);
					runningAnimation = false;
				});
			}
		});
	});
	
	if (!display) {
		$('#home_partial').fadeIn("slow");
		rotateTicker();
	}
	
	/*** Submenu pagina `management` ***/
	/*
	$('.management_submenu_trigger_open').click(function() {
		$(this).parent("li").children("ul").slideDown("slow");
		$(this).children("img").fadeOut("slow");
	});
	
	$('.management_submenu_trigger_close').click(function() {
		$(this).parent("li").parent("ul").slideUp("slow");
		$(this).parent("li").parent("ul").parent("li").children(".management_submenu_trigger_open").children("img").fadeIn("slow");
	});
	*/
	/*** Submenu pagina `design` ***/
	/*
	$('.design_submenu_trigger_open').click(function() {
		$(this).parent("li").children("ul").slideDown("slow");
		$(this).children("img").fadeOut("slow");
	});
	
	$('.design_submenu_trigger_close').click(function() {
		$(this).parent("li").parent("ul").slideUp("slow");
		$(this).parent("li").parent("ul").parent("li").children(".design_submenu_trigger_open").children("img").fadeIn("slow");
	});
	*/
});
