(function($){ 
	$.fn.rotator = function(options) {
		
		/* Standarteinstellungen festlegen */
		var defaults = {
			ms: 6000,
			animTime: 1000,
			n: 1,
			autoHeight: false
		};
		
		/* Standarteinstellung ggf. überschreiben */
		var options = $.extend(defaults, options);		
		
		return this.each(function () {
      
			/* Plugin-Code Start */
			
			var $this = $(this);
			var initialHeight = 0;
			$this.children().filter(":lt("+options.n+")").each(function(index,item){
				initialHeight += $(item).height();
			});
			$this.height(initialHeight);
			
			/* Funktionen */
			function startSrolling()
			{			
					var childHeight = $this.children().filter(":first-child").height();
					var animParams = {scrollTop: (childHeight) + "px"};
					var autoHeight = 0;
					$this.children().filter(":lt("+(options.n+1)+")").each(function(index,item){
						if(index>0)autoHeight += $(item).height();
					});
					if(options.autoHeight)animParams = $.extend({height:(autoHeight) + "px"}, animParams);			
					$this.animate(animParams, options.animTime, function(){
						$this.scrollTop(0);
						$this.append($this.children().filter(":first-child"));
						$this.css("overflow","hidden"); //Chrome hack
					});				
			}
			
			interval = setInterval(startSrolling, options.ms);
			
			/* Plugin-Code Start */
    });
  };
})(jQuery);

$(document).ready(function() {
	$("#bannerStartseite").rotator();
	$("#scrollerStartseite").rotator();
});
