$(document).ready(function(){
	
	$(function () {
		
//////////Print me me me...
		$("#print").click(function(){
			window.print();
		});
			
//////////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 spaceStation = $(this).text();
			var  spaceShip = $(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;
		  });
		
//////////open fade les menu 1 a 1à
		function fadeLI(elem) { 
		  elem.fadeIn(100, function() { fadeLI($(this).next()); }); 
		}
		$('#content, #seo_footer').fadeIn(1000, function() {fadeLI($("#main_menu li:first"));});
		
		
/////////// wrap chaque 24 element dans un div
		jQuery.fn.wrapInChunks = function(html, chunkSize) {

		    chunkSize = chunkSize || 1;
		
		    var items = this.get(),
		        rows = [],
		        cur = rows[0] = $(html);
		
		    while (items[0]) {
		
		        if (rows[rows.length - 1].children().length === chunkSize) {
		            cur = rows[rows.length] = $(html);
		        }
		
		        cur.append( items.shift() );
		
		    }
		
		    return this.pushStack(rows);
		
		};
		
		//$('.boxgrid').wrapInChunks('<div />', 24).appendTo('.items');
		


		
///////////remove last/

		$('.theService').find('.itemWrap:last').css("border-bottom","none")

//////////// le portfolio

		$('.hiddendesc').prependTo('.boxgriddesc');
		$('.hiddendesc').css("display","none");
		$('#hiddendesc1 .hiddendesc').css("display","block");
		
		function getActive(){
			var listItem = $('.active');
			var indexNumber = $('.boxgrid').index(listItem) + 1;	
			var gaaa = "#hiddendesc"
			$('.hiddendesc').css("display","none");
			$(gaaa+indexNumber).css("display","block");
		};
		function getActive2(){
			var listItem = $('.active');
			var indexNumber = $('.webPfolio').index(listItem) + 1;	
			var gaaa = "#hiddendesc"
			$('.hiddendesc').css("display","none");
			$(gaaa+indexNumber).css("display","block");
		};

		$('.boxgrid').click(function(){
			 getActive();
		});
		$('.webPfolio').click(function(){
			 getActive2();
		});
		
////////// Les scenario

		$('#scena').click(function(){
			$('#serviceContentB').fadeOut();
			$('#serviceContentA').fadeIn();
			return false;
		});
		$('#scenb').click(function(){
			$('#serviceContentA').fadeOut();
			$('#serviceContentB').fadeIn();
			return false;
		});
		
	});	
});



//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"));
		 	
});
