$(document).ready(function(){
	
	$(function () {
		
//////////Print me me me...
		$("#print").click(function(){
			window.print();
		});
		
////////Hover des boutons
		$('.cta').find('a').each(function () {
			var $img = $('img.hover', this).css("opacity", "0");
			var $img = $('img.hover', this).css("display", "block");
			$(this).hover(function () {
				$img.stop().fadeTo(150, 1);
			}, function () {
				$img.stop().fadeTo(450, 0);
			});
		});
			
//////////Put some decoration on my links
		$("a[href$=pdf]").addClass("pdf").attr("target","_blank");
		$("a[href$=xls]").addClass("xls").attr("target","_blank");
		
//////////Tell me where i'm going
		$("a[rel='3m4il']").each(function(){
			var spaceShip = $(this).text();
			var spaceStation = $(this).attr('title');
			
			$(this).attr({
				href: 'mailto:'+ spaceShip +'@'+ spaceStation +'',
				rel: 'nofollow'
			});
			$(this).text(''+ spaceShip +'@'+ spaceStation +'');
		});
		
//////////open links in external window
		$('a[rel="external"]').click( function() {
		window.open( $(this).attr('href') );
		return false;
		});
			
/////////page protfolio
		
	$('ul#filter a').click(function() {
		$(this).css('outline','none');
		$('ul#filter .current').removeClass('current');
		$(this).parent().addClass('current');
		
		var filterVal = $(this).text().toLowerCase().replace(' ','-');
				
		if(filterVal == 'portfolio-complet') {
			$('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden');
		} else {
			
			$('ul#portfolio li').each(function() {
				if(!$(this).hasClass(filterVal)) {
					$(this).fadeOut('normal').addClass('hidden');
				} else {
					$(this).fadeIn('slow').removeClass('hidden');
				}
			});
		}
		
		return false;
	});			
		
/////////load my facebox           
	 $("#facebox").html('<iframe src="//www.facebook.com/plugins/likebox.php?href=https%3A%2F%2Fwww.facebook.com%2Fpages%2FEsteban-Productions-Friends%2F272980112761650&amp;width=260&amp;height=558&amp;colorscheme=light&amp;show_faces=true&amp;border_color&amp;stream=true&amp;header=false&amp;appId=298808550150169" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:260px; height:558px;" allowTransparency="true"></iframe>')
            
            
    $("#primary").fadeIn();
    
            	
	});	
});

//apres que les images soient loadé :)
$(window).load(function(){
	
////////////////////////// equal height
		function equalHeight(group) {
			var tallest = 0;
			group.each(function() {
				var thisHeight = $(this).height();
				if(thisHeight > tallest) {
					tallest = thisHeight;
				}
			});
			group.height(tallest);
		}
		
		 	equalHeight($(".equalCol"));
		 	equalHeight($(".weAreEquals"));
		 	
//////////////////// Supprimer les liens e certains menus
		//$(".page-item-18 a:first, .page-item-2 a:first, .page-item-44 a:first, .page-item-50 a:first").removeAttr('href');
		 	
});
