(function($){
	
	$.randomImage = {
		defaults: {
			
			//you can change these defaults to your own preferences.
			path: 'images/', //change this to the path of your images
			myImages: ['image1.jpg','image2.jpg','image3.jpg','image4.jpg','image5.jpg'] //put image names in this bracket. ex: 'harold.jpg', 'maude.jpg', 'etc'
			
		}			
	}
	
	$.fn.extend({
			randomImage:function(config) {
				
				var config = $.extend({}, $.randomImage.defaults, config); 
				
				 return this.each(function() {
						
						var imageNames = config.myImages;
						
						//get size of array, randomize a number from this
						// use this number as the array index

						var imageNamesSize = imageNames.length;

						var lotteryNumber = Math.floor(Math.random()*imageNamesSize);

						var winnerImage = imageNames[lotteryNumber];

						var fullPath = config.path + winnerImage;
						
						
						//put this image into DOM at class of randomImage
						// alt tag will be image filename.
						$(this).attr( {
										src: fullPath,
										alt: winnerImage
									});
				
				});	
			}
			
	});
	
	
	
})(jQuery);
$(document).ready(function(){

	$(window).keydown(function(e){

		switch (e.keyCode) {

			case 37: // fl¸che gauche
				$('#back a').click();
				//alert('toto');
				break;    
			case 39: // fl¸che droite
				$('#next a').click();
				break;    
		}
	});

});
$(document).ready(function() {
	$('.shuffle').randomImage({path: 'http://alicedechelette.com/alice-dechelette/wp-content/themes/alice-dechelette/images/'});
});
