(function($) {
	$.fn.bottleAnimation = function(callerSettings) {
		var settings = $.extend(true, {}, $.fn.bottleAnimation.settings, callerSettings);
		return this.each(function() {
			var n = $(this);
			var slides = n.children(settings.slides);
			var current = 0;
			var animating = false;
			var intial = true;
			var setup = function() {
				slides.each(function(i){
					var count = i++;
					$(this).addClass('slide-'+count);
					$(this).css({display:'none'});
				});
				viewSlide(0);
			};
			var viewSlide = function(i) {
				var nextSlide = slides.eq(i);
				var currentSlide = slides.eq(current);
				current = i;
				next = (current == slides.length-1) ? 0 : current+1;
				if (intial == false) {
					currentSlide.delay(settings.pause).fadeOut(settings.speed, function(){
						nextSlide.delay(settings.delay).fadeIn(settings.speed,function(){							
							viewSlide(next);
						});
					});
				}else{
					intial = false;
					nextSlide.fadeIn(settings.speed,function(){
						viewSlide(next);
					});
				}
			};
			setup();
		});
	};
	$.fn.bottleAnimation.settings = {
		slides: 'img',
		speed: 500,
		delay: 0,
		pause: 4000
	};
})(jQuery);
