(function($) {
	
	$.fn.extend({
				
		evinaura_slideshow: function() {
			
			return this.each(function() {
				
				var obj = $(this);
				var numImages = $("img", obj).length;
				
				for (var i=0; i<numImages; i++) {
					if($("img:eq(" + i + ")", obj).hasClass('current') == true)
					{
						$("img:eq(" + i + ")", obj).removeClass('current');
					}	
				}
				
				var ranPic = Math.round(Math.random() * (numImages - 1));
				
				$("img:eq(" + ranPic + ")", obj).addClass('current');
				
				for (var i=0; i<numImages; i++)
				{
					if($("img:eq(" + i + ")", obj).hasClass('current') == false)
					{
						$("img:eq(" + i + ")", obj).css({opacity:0.0});
					}
				}
				
				setInterval(function rotateImages() {
					
					var currentPhoto = $("img.current", obj);
					
					var nextPhoto = currentPhoto.next();
					
					if (nextPhoto.length == 0)
					{
						nextPhoto = $("img:first", obj);	
					}
					
					currentPhoto.removeClass('current').addClass('previous');
					nextPhoto.css({opacity:0.0}).addClass('current').animate({opacity:1.0}, 1500,
						function() {
							currentPhoto.removeClass('previous');
							currentPhoto.css({opacity:0.0});
						}
					);
				}, 10000);   
			});
		}
	});
	
})(jQuery);
