// THIS IS BY ROB WALSH

(function($){
	
	$.randomImage = {
		defaults: {
			
			//you can change these defaults to your own preferences.
			path: 'images/random_home/', //change this to the path of your images
			myImages: ['atlanta050.jpg', 'degenerate-orchestra-18x27-flat.jpg', 'finland-1652.jpg', 'harbor-island-pano2.jpg', 'Istanbul-0318-2.jpg', 'Istanbul-0634-2.jpg', 'ny-09-171.jpg', 'oysterville_0194.jpg', 'shirtless-in-ipanema12x12.jpg', 'sonic-tales-2-print.jpg', 'trina-trinity-228-final.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);
