// from http://www.robwalshonline.com/posts/jquery-plugin-random-image-on-page-load/

(function($){

	$.randomTroothImage = {
		defaults: {


			//you can change these defaults to your own preferences.
			path: 'uploadedimages/', //change this to the path of your images
			myImages: ['image_TTT1.jpg', 'image_TTT2.jpg', 'image_TTT3.jpg', 'image_TTT4.jpg', 'image_TTT5.jpg', 'image_TTT6.jpg', 'image_TTT7.jpg', 'image_TTT8.jpg', 'image_TTT9.jpg', 'image_TTT10.jpg'] //put image names in this bracket. ex: 'harold.jpg', 'maude.jpg', 'etc'

		}
	}

  $.fn.extend({
			randomTroothImage:function(config) {

				var config = $.extend({}, $.randomTroothImage.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 randomTroothImage
						// alt tag will be image filename.
						$(this).attr( {
										src: fullPath,
										alt: winnerImage
									});

				});
			}

	});



})(jQuery);

