// LOGO -----------------------------------------------------------------------

$(document).ready(function() {
	// find the div.fade elements and hook the hover event
	$('.logo').hover(function() {
		// on hovering over find the element we want to fade *up*
		var fade = $('> .logo-hover', this);

		// if the element is currently being animated (to fadeOut)...
		if (fade.is(':animated')) {
			// ...stop the current animation, and fade it to 1 from current position
			fade.stop().fadeTo(300, 1);
		} else {
			fade.fadeIn(300);
		}
	}, function () {
		var fade = $('> .logo-hover', this);
		if (fade.is(':animated')) {
			fade.stop().fadeTo(300, 0);
		} else {
			fade.fadeOut(300);
		}
	});

	// get rid of the text
	$('.logo > .logo-hover').empty();
});


// WEB -----------------------------------------------------------------------

$(document).ready(function() {
	// find the div.fade elements and hook the hover event
	$('.web').hover(function() {
		// on hovering over find the element we want to fade *up*
		var fade = $('> .web-hover', this);

		// if the element is currently being animated (to fadeOut)...
		if (fade.is(':animated')) {
			// ...stop the current animation, and fade it to 1 from current position
			fade.stop().fadeTo(300, 1);
		} else {
			fade.fadeIn(300);
		}
	}, function () {
		var fade = $('> .web-hover', this);
		if (fade.is(':animated')) {
			fade.stop().fadeTo(300, 0);
		} else {
			fade.fadeOut(300);
		}
	});

	// get rid of the text
	$('.web > .web-hover').empty();
});

// MICRODOCS -----------------------------------------------------------------------

$(document).ready(function() {
	// find the div.fade elements and hook the hover event
	$('.microdocs').hover(function() {
		// on hovering over find the element we want to fade *up*
		var fade = $('> .microdocs-hover', this);

		// if the element is currently being animated (to fadeOut)...
		if (fade.is(':animated')) {
			// ...stop the current animation, and fade it to 1 from current position
			fade.stop().fadeTo(300, 1);
		} else {
			fade.fadeIn(300);
		}
	}, function () {
		var fade = $('> .microdocs-hover', this);
		if (fade.is(':animated')) {
			fade.stop().fadeTo(300, 0);
		} else {
			fade.fadeOut(300);
		}
	});

	// get rid of the text
	$('.microdocs > .microdocs-hover').empty();
});

// COMMERCIALS -----------------------------------------------------------------------

$(document).ready(function() {
	// find the div.fade elements and hook the hover event
	$('.commercials').hover(function() {
		// on hovering over find the element we want to fade *up*
		var fade = $('> .commercials-hover', this);

		// if the element is currently being animated (to fadeOut)...
		if (fade.is(':animated')) {
			// ...stop the current animation, and fade it to 1 from current position
			fade.stop().fadeTo(300, 1);
		} else {
			fade.fadeIn(300);
		}
	}, function () {
		var fade = $('> .commercials-hover', this);
		if (fade.is(':animated')) {
			fade.stop().fadeTo(300, 0);
		} else {
			fade.fadeOut(300);
		}
	});

	// get rid of the text
	$('.commercials > .commercials-hover').empty();
});

// MUSIC VIDEOS -----------------------------------------------------------------------

$(document).ready(function() {
	// find the div.fade elements and hook the hover event
	$('.musicvideos').hover(function() {
		// on hovering over find the element we want to fade *up*
		var fade = $('> .musicvideos-hover', this);

		// if the element is currently being animated (to fadeOut)...
		if (fade.is(':animated')) {
			// ...stop the current animation, and fade it to 1 from current position
			fade.stop().fadeTo(300, 1);
		} else {
			fade.fadeIn(300);
		}
	}, function () {
		var fade = $('> .musicvideos-hover', this);
		if (fade.is(':animated')) {
			fade.stop().fadeTo(300, 0);
		} else {
			fade.fadeOut(300);
		}
	});

	// get rid of the text
	$('.musicvideos > .musicvideos-hover').empty();
});


// YOUTUBE -----------------------------------------------------------------------

$(document).ready(function() {
	// find the div.fade elements and hook the hover event
	$('.youtube').hover(function() {
		// on hovering over find the element we want to fade *up*
		var fade = $('> .youtube-hover', this);

		// if the element is currently being animated (to fadeOut)...
		if (fade.is(':animated')) {
			// ...stop the current animation, and fade it to 1 from current position
			fade.stop().fadeTo(300, 1);
		} else {
			fade.fadeIn(300);
		}
	}, function () {
		var fade = $('> .youtube-hover', this);
		if (fade.is(':animated')) {
			fade.stop().fadeTo(300, 0);
		} else {
			fade.fadeOut(300);
		}
	});

	// get rid of the text
	$('.youtube > .youtube-hover').empty();
});

// TWITTER -----------------------------------------------------------------------

$(document).ready(function() {
	// find the div.fade elements and hook the hover event
	$('.twitter').hover(function() {
		// on hovering over find the element we want to fade *up*
		var fade = $('> .twitter-hover', this);

		// if the element is currently being animated (to fadeOut)...
		if (fade.is(':animated')) {
			// ...stop the current animation, and fade it to 1 from current position
			fade.stop().fadeTo(300, 1);
		} else {
			fade.fadeIn(300);
		}
	}, function () {
		var fade = $('> .twitter-hover', this);
		if (fade.is(':animated')) {
			fade.stop().fadeTo(300, 0);
		} else {
			fade.fadeOut(300);
		}
	});

	// get rid of the text
	$('.twitter > .twitter-hover').empty();
});

// VIMEO -----------------------------------------------------------------------

$(document).ready(function() {
	// find the div.fade elements and hook the hover event
	$('.vimeo').hover(function() {
		// on hovering over find the element we want to fade *up*
		var fade = $('> .vimeo-hover', this);

		// if the element is currently being animated (to fadeOut)...
		if (fade.is(':animated')) {
			// ...stop the current animation, and fade it to 1 from current position
			fade.stop().fadeTo(300, 1);
		} else {
			fade.fadeIn(300);
		}
	}, function () {
		var fade = $('> .vimeo-hover', this);
		if (fade.is(':animated')) {
			fade.stop().fadeTo(300, 0);
		} else {
			fade.fadeOut(300);
		}
	});

	// get rid of the text
	$('.vimeo > .vimeo-hover').empty();
});

// FACEBOOK -----------------------------------------------------------------------

$(document).ready(function() {
	// find the div.fade elements and hook the hover event
	$('.facebook').hover(function() {
		// on hovering over find the element we want to fade *up*
		var fade = $('> .facebook-hover', this);

		// if the element is currently being animated (to fadeOut)...
		if (fade.is(':animated')) {
			// ...stop the current animation, and fade it to 1 from current position
			fade.stop().fadeTo(300, 1);
		} else {
			fade.fadeIn(300);
		}
	}, function () {
		var fade = $('> .facebook-hover', this);
		if (fade.is(':animated')) {
			fade.stop().fadeTo(300, 0);
		} else {
			fade.fadeOut(300);
		}
	});

	// get rid of the text
	$('.facebook > .facebook-hover').empty();
});

// MAIL -----------------------------------------------------------------------

$(document).ready(function() {
	// find the div.fade elements and hook the hover event
	$('.mail').hover(function() {
		// on hovering over find the element we want to fade *up*
		var fade = $('> .mail-hover', this);

		// if the element is currently being animated (to fadeOut)...
		if (fade.is(':animated')) {
			// ...stop the current animation, and fade it to 1 from current position
			fade.stop().fadeTo(300, 1);
		} else {
			fade.fadeIn(300);
		}
	}, function () {
		var fade = $('> .mail-hover', this);
		if (fade.is(':animated')) {
			fade.stop().fadeTo(300, 0);
		} else {
			fade.fadeOut(300);
		}
	});

	// get rid of the text
	$('.mail > .mail-hover').empty();
});

// TABS -----------------------------------------------------------------------

$(document).ready(function() {

	//Default Action
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});

});

// SLIDE -----------------------------------------------------------------------

 $(document).ready(function()
    {
		
		$("#connected p.connected").click(function()
        {
        $(this).next("div.menu_body_connected").slideToggle(300).siblings("div.menu_body_connected").slideUp("slow");
        });
        
    });
 
// HOVER -----------------------------------------------------------------------
 
 $(document).ready(function() {
	
	$("ul.gallery li, ul.nav li, .works, .about, .connected, .blog, .films, .info").hover(function() { //On hover...
		
		var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'
		
		//Set a background image(thumbOver) on the &lt;a&gt; tag 
		$(this).find("a.thumb, a.thumbcommercial, a.logo, a.films, a.thumbfilm, a.nav, a.works, a.about, a.connected, a.blog, a.films, a.info").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});
		//Fade the image to 0 
		$(this).find("span").stop().fadeTo('normal', 0 , function() {
			$(this).hide() //Hide the image after fade
		}); 
	} , function() { //on hover out...
		//Fade the image to 1 
		$(this).find("span").stop().fadeTo('normal', 1).show();
	});

});
 
// BACKGROUND -----------------------------------------------------------------------

$(document).ready(function(){ 

			$("li.one").click( function(){ $
				("body").removeClass('bg2 , bg3').addClass("bg1"); 
			});

			$("li.two").click( function(){ $
				("body").removeClass("bg1 , bg3").addClass("bg2"); 
			});

			$("li.three").click( function(){ $
				("body").removeClass("bg1 , bg2").addClass("bg3"); 
			}); 
			$(this).addClass("active");
			$(addClass).fadeIn(); //Fade in the active content
		return false;
				
});
