// JavaScript Document
(function($){
	
	$.randomImage = {
		defaults: {
			
			//you can change these defaults to your own preferences.
			path: 'images/random', //change this to the path of your images
			myImages: ['random_images (0).jpg', 'random_images (1).jpg','random_images (2).jpg','random_images (3).jpg', 'random_images (4).jpg', 'random_images (5).jpg', 'random_images (6).jpg', 'random_images (7).jpg', 'random_images (8).jpg', 'random_images (9).jpg', 'random_images (10).jpg', 'random_images (11).jpg', 'random_images (12).jpg', 'random_images (13).jpg', 'random_images (14).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() {

	$('.shuffle').randomImage({path: 'images/random/'});
	$('a:first').click(function() {
		location.reload();
		return false;
	});

});
