(function($){ // bonne pratique :

$.pilemaker = {};

		$.pilemaker.make = function() {
		
			// Random position
			var $imgPile = $(".pile>img").each(function make() {
				var $this = $(this); //bone pratique
				
				if($this.data('pilemaker:init')) return; // If images are known, return = exit function
				$this.removeAttr('title');
			
				var pilewidth = $('.pile').css('width').replace("px", "");
				var pileheight = $('.pile').css('height').replace("px", "");

				var picwidth = $('.pile img').css('width').replace("px", "");
				var picheight = $('.pile img').css('height').replace("px", "");

				var posx = (Math.random() * (pilewidth - picwidth)).toFixed();
				var posy = (Math.random() * (pileheight - picheight)).toFixed();
				
				$this.css({
					'left':posx+'px',
					'top':posy+'px',
				});
				
				$this.data('pilemaker:init',true);
			});
			$('.pile img').click(function(){
				$(this).hide();
			});		
		};

		// opener
		$('.open').click(function(){
			$(this).next('ul').toggle();
		});
		
		$.pilemaker.make();
		
		
	// Email hider
	$('a.email').each(function(){
		e = this.rel.replace('/','@');
		this.href = 'mailto:' + e;
		$(this).text(e);
	});		
		
})(jQuery);

