function animateText()
{
	 // Slide up the text.
	 $("#nouvatan").animate({top : "-428px"}, 1800,
	 	function(){$("#leaves").animate({top : "-856px"}, 1600,
	 	function(){$("#all").animate({top : "-1284px"}, 1400,
	 	function(){$("#others").animate({top : "-1712px"}, 1200,
	 	function(){$("#in").animate({top : "-2140px"}, 1000,
	 	function(){$("#the").animate({top : "-2568px"}, 800,
	 	function(){$("#shade").animate({top : "-2996px"}, 600,
	 	function(){
	 		$("#nouvatan").fadeOut(2000);
	 		$("#leaves").fadeOut(2000);
	 		$("#all").fadeOut(2000);
	 		$("#others").fadeOut(2000);
	 		$("#in").fadeOut(2000);
	 		$("#the").fadeOut(2000);
	 		$("#shade").fadeOut(2000,
			 	function(){
			 		$("#nouvatan").css("top", "0px");
			 		$("#leaves").css("top", "-488px");
			 		$("#all").css("top", "-976px");
			 		$("#others").css("top", "-1464px");
			 		$("#in").css("top", "-1952px");
			 		$("#the").css("top", "-2440px");
			 		$("#shade").css("top", "-2928px");
		
			 		$("#nouvatan").css("display", "block");
			 		$("#leaves").css("display", "block");
			 		$("#all").css("display", "block");
			 		$("#others").css("display", "block");
			 		$("#in").css("display", "block");
			 		$("#the").css("display", "block");
			 		$("#shade").css("display", "block");
			 		
			 		animateText();
	 	});});});});});});});});
}

function getHeight(element)
{
	var height = 0;
	if (element.offsetHeight)
	{
		height = element.offsetHeight;
	}
	else if (element.style.pixelHeight)
	{
		height = element.style.pixelHeight;
	}
	return height;
}

$(document).ready(function(){

	// Online Shop navigation items.
    $("ul.sf-menu").supersubs({ 
        minWidth:    2,    // minimum width of sub-menus in em units 
        maxWidth:    15,   // maximum width of sub-menus in em units 
        extraWidth:  2     // extra width can ensure lines don't sometimes turn over 
                           // due to slight rounding differences and font-family 
    }).superfish({
    	hoverClass    : "sfHover", 
    	delay        : 400, 
    	animation    : {opacity:"show"}, 
    	speed        : 200 
	});
 
 	// Defuscate email addresses.
 	$('a').defuscate();

    // Make the minimum height of the content div the same as the navigation div.
    var contentMinHeight = getHeight($("#navigation").get(0)) + 269;
	$("#content").css("display", "none");
	$("#content").css("min-height", contentMinHeight);
     	 
	// Fade the page in.
	$('#logo').css("display", "none");
	$('#navigation').css("display", "none");
	$('#logo').fadeIn(2500);
	$('#navigation').fadeIn(2500);
	$('#content').fadeIn(2500);

	 // When an entry is hovered over, show the link as hovered.
	 $("p.navigation-button").hover(
	 	function() {
	 		$(this).addClass("prettyHover");
	 		$(this).css("background-image", "url('/salonalchemyapp/nouvatan/content/nouvatan/images/nav-background-hover.png.action')");
	 	},
	 	function() {
	 		$(this).removeClass("prettyHover");
	 		$(this).css("background-image", "url('/salonalchemyapp/nouvatan/content/nouvatan/images/nav-background.png.action')");
	 	}
	 );

	 $(".navigation-menu").children("li").hover(
	 	function() {
	 		$(this).addClass("prettyHover");
	 		$(this).css("background-image", "url('/salonalchemyapp/nouvatan/content/nouvatan/images/nav-background-hover.png.action')");
	 	},
	 	function() {
	 		$(this).removeClass("prettyHover");
	 		$(this).css("background-image", "url('/salonalchemyapp/nouvatan/content/nouvatan/images/nav-background.png.action')");
	 	}
	 );

	 // When an entry is clicked on, activate the link.
	 $("p.navigation-button").click(
	 	function() {
	 		window.location = $(this).children("a").attr("href");
	 	}
	 );

	 $(".navigation-menu").children("li").click(
	 	function() {
	 		window.location = $(this).children("a").attr("href");
	 	}
	 );

	 // Open external links in a new window.
	 $("a").filter(".link").click(function(){
	   return !window.open(this.href);
	 });
	 
	 // Animate the text.
	 animateText();
});
