Shadowbox.init();

$(document).ready(function()
{

	/* Home page fader */
	$('#home').innerfade({
		animationtype: 'fade',
		speed: 2000,
		timeout: 6000,
		type: 'random'
	});
	
	/* Ferrari fader */
	$('#creations_ferrari_watches').innerfade({
		animationtype: 'fade',
		speed: 2000,
		timeout: 6000,
		type: 'random'
	});
	
	/* Unique expericences fader */
	$('#motions_uniqueExperience_pictures').innerfade({
		animationtype: 'fade',
		speed: 2000,
		timeout: 6000,
		type: 'random'
	});
	
	/* Menu animation effects */
	$('.menu li').hover(
		// Mouseover, fadeIn the hidden hover class    
		function()
		{
			$(this).children('div').fadeIn('2000');
			$(this).find(".submenu").slideDown('fast').show(); // Drop down the submenu
		
			$(this).parent().hover(function() {  
			}, function()
			{  
				$(".submenu").slideUp('slow'); // When the mouse hovers out of the subnav, move it back up  
			});  
		},   
	
		// Mouseout, fadeOut the hover class  
		function() {
			$(this).children('div').fadeOut('2000');    
	});
	

	/* Rollover animation effects */
	$('.rollover').hover(
		// Mouseover, fadeIn the hidden hover class    
		function() {
			$(this).children('.rollover_on').fadeIn('2000');
		},   
	
		// Mouseout, fadeOut the hover class  
		function() {
			$(this).children('.rollover_on').fadeOut('2000');    
	});
	
	/* Artists animation effects */
	$("#artists_leftFrame li.artists_button").hover(function() {
		
		if ($(this).css("opacity") != "1")
			$(this).animate({opacity: 1}, 800 );
		
	}, function() {
	
		$(this).animate({opacity: 0.5}, 800 );
		
	}).click(function(){

		$clicked = $(this);

		// if the button is not already "transformed" AND is not animated
		if ($clicked.css("opacity") != "1" && $clicked.is(":not(animated)")) {

			$clicked.animate({opacity: 1}, 1000 );

			// each button div MUST have a "xx-button" and the target div must have an id "xx"
			var idToLoad = $clicked.attr("id").split('-');

			//we search trough the content for the visible div and we fade it out
			$("#artists_text").find("div:visible").fadeOut("def", function(){
				//once the fade out is completed, we start to fade in the right div
				$(this).parent().find("#artists-"+idToLoad[1]+"-text").fadeIn("def");
			})
			
			//we search trough the content for the visible div and we fade it out
			$("#artists_rightFrame").find("div:visible").fadeOut("def", function(){
				//once the fade out is completed, we start to fade in the right div
				$(this).parent().find("#artists-"+idToLoad[1]+"-picture").fadeIn("def");
			})
		}

		//we reset the other buttons to default style
		$clicked.siblings(".artists_button").animate({opacity: 0.5}, 1000 );

	});
	
	/* Back button animation effect */
	$(function()
	{
		// Opacity of galleries set to 50%
		$(".back_button").css("opacity","0.5");
	
		// On mouse over
		$(".back_button").hover(function ()
		{
			// Set opacity to 100%
			$(this).stop().animate({
				opacity: 1.0
			}, "slow");
		},
		// On mouse out
		function ()
		{
			// Set opacity to 50%
			$(this).stop().animate({
				opacity: 0.5
			}, "slow");
		});
	});
	
	/* Creations animation effect */
	$(function()
	{
		// Opacity of galleries set to 50%
		$(".creations_watches_descr a span").css("opacity","0.5");
	
		// On mouse over
		$(".creations_watches_descr a span").hover(function ()
		{
			// Set opacity to 100%
			$(this).stop().animate({
				opacity: 1.0
			}, "slow");
		},
		// On mouse out
		function ()
		{
			// Set opacity to 50%
			$(this).stop().animate({
				opacity: 0.5
			}, "slow");
		});
	});
	
	/* WTV animation effects */
	$("#creations_wtv_mechanic_left_movement").data("revert", false);
	$("#creations_wtv_mechanic_left_movement").click(function()
	{
		$clicked = $(this);
		//we search trough the content for the visible div and we fade it out
		$("#creations_wtv_mechanic_left_zoom").find("div:visible").fadeOut("fast", function(){
			//once the fade out is completed, we start to fade in the right div
			$("#creations_wtv_mechanic_left_def").fadeIn("fast");

			if(($clicked.data("revert") == false)) 
			{
				//we search trough the content for the visible div and we fade it out
				$("#creations_wtv_mechanic_left_movement-front").fadeOut("def", function(){
					//once the fade out is completed, we start to fade in the right div
					$("#creations_wtv_mechanic_left_movement-back").fadeIn("def");
				});
				$clicked.data("revert", true);	
			}
			else
			{
				//we search trough the content for the visible div and we fade it out
				$("#creations_wtv_mechanic_left_movement-back").fadeOut("def", function(){
					//once the fade out is completed, we start to fade in the right div
					$("#creations_wtv_mechanic_left_movement-front").fadeIn("def");
				});
				$clicked.data("revert", false);	
			}
		})
	});
	
	$(".creations_wtv_mechanic_zoom").click(function()
	{
		var idToLoad = $(this).attr("id").split('-');
		
		//we search trough the content for the visible div and we fade it out
		$("#creations_wtv_mechanic_left_zoom").find("div:visible").fadeOut("fast", function(){
			//once the fade out is completed, we start to fade in the right div
			if(($("#creations_wtv_mechanic_left_movement").data("revert") == false))
			{
				$("#creations_wtv_mechanic_left-"+idToLoad[1]+"-front").fadeIn("def");
			}
			else
			{
				$("#creations_wtv_mechanic_left-"+idToLoad[1]+"-back").fadeIn("def");
			}
		})
	});
	
	$("#creations_wtv_mechanic_left_zoom").click(function()
	{
		//we search trough the content for the visible div and we fade it out
		$("#creations_wtv_mechanic_left_zoom").find("div:visible").fadeOut("fast", function(){
			//once the fade out is completed, we start to fade in the right div
			$("#creations_wtv_mechanic_left_def").fadeIn("fast");
		})
	});
	
	/* Nostromo animation effects */
	$("[id^=creations_nostromo_off]").click(function()
	{
		if($("#creations_nostromo_night").is("div:visible"))
		{
			//we search trough the content for the visible div and we fade it out
			$("#creations_nostromo_night").fadeOut("def", function(){
				//once the fade out is completed, we start to fade in the right div
				$("#creations_nostromo_day").fadeIn("def");
			})
		}
	});
	
	/* Nostromo animation effects */
	$("[id^=creations_nostromo_on]").click(function()
	{
		if($("#creations_nostromo_day").is("div:visible"))
		{
			//we search trough the content for the visible div and we fade it out
			$("#creations_nostromo_day").fadeOut("def", function(){
				//once the fade out is completed, we start to fade in the right div
				$("#creations_nostromo_night").fadeIn("def");
			})
		}
	});
	
	/* Galleries animation effect */
	$(function()
	{
		// Opacity of galleries set to 50%
		$(".emotions_gallery_hoverEffect").css("opacity","0.5");
	
		// On mouse over
		$(".emotions_gallery_hoverEffect").hover(function ()
		{
			// Set opacity to 100%
			$(this).stop().animate({
				opacity: 1.0
			}, "slow");
		},
		// On mouse out
		function ()
		{
			// Set opacity to 50%
			$(this).stop().animate({
				opacity: 0.5
			}, "slow");
		});
	});
	
	/* Send button animation effect */
	$(function()
	{
		// Opacity of galleries set to 50%
		$(".contact_form_submit").css("opacity","0.5");
	
		// On mouse over
		$(".contact_form_submit").hover(function ()
		{
			// Set opacity to 100%
			$(this).stop().animate({
				opacity: 1.0
			}, "slow");
		},
		// On mouse out
		function ()
		{
			// Set opacity to 50%
			$(this).stop().animate({
				opacity: 0.5
			}, "slow");
		});
	});	
	
	/* Boutiques animation effect */
	$(function()
	{
		$('#boutiques_distributors').jScrollPane();
	});
});
