(function($) {
  $.fn.carousel = function(options) {
	
	var e=this;
	
	var config = {
		speed: 350,
		pause: 3000
	};
	
	var opts=$.extend(config,options);
	
	$(e).children("img:not(:first)").hide();
	$(e).children("img:last").addClass($(e).attr("id") + "_last");
	
	function rotate() {
		if($(e).children("img:visible").hasClass($(e).attr("id") + "_last")) {
			$(e).children("img:first").show();
			$(e).children("img:visible:last").fadeOut(opts.speed,function() {
				setTimeout(function() { rotate(); },opts.pause);
			});
		} else {
			$(e).children("img:visible").next("img").fadeIn(opts.speed,function() {
				$(this).prev("img").hide();
				setTimeout(function() { rotate(); },opts.pause);
			});
		}
	}
	
	setTimeout(function() { rotate(); },opts.pause);
  }
})(jQuery);

(function($) {
  $.fn.carousel2 = function(options) {
	
	var e=this;
	
	var config = {
		speed: 350,
		pause: 3000
	};
	
	var opts=$.extend(config,options);
	
	$(e).children("#sentences:not(:first)").hide();
	$(e).children("#sentences:last").addClass($(e).attr("id") + "_last");
	
	function rotate() {
		if($(e).children("#sentences:visible").hasClass($(e).attr("id") + "_last")) {
			$(e).children("#sentences:first").show();
			$(e).children("#sentences:visible:last").fadeOut(opts.speed,function() {
				setTimeout(function() { rotate(); },opts.pause);
			});
		} else {
			$(e).children("#sentences:visible").next("#sentences").fadeIn(opts.speed,function() {
				$(this).prev("#sentences").hide();
				setTimeout(function() { rotate(); },opts.pause);
			});
		}
	}
	
	setTimeout(function() { rotate(); },opts.pause);
  }
})(jQuery);
