Ape.Element.Lists_rotation = function(){
	var that = this;
	var target = '.rotation_teaser';
	var stepper = 1;
	var timeoutId = 0;
	var rotationspeed = 500;
	var rotationswitchEverySeconds = 5;
	
	this.start = function(){
		
		$(target+' ul.top_themen li').unbind('click.switchdirect').bind('click.switchdirect', openStep);
		
		timeoutId = setInterval(showNextItem, (rotationswitchEverySeconds*1000));
		
	};
	function showNextItem(type){
		jQuery.easing.def = 'linear';
		var Beitrag = that.beitraege[stepper];
		
		var aktuell = $(target+' ul.top_themen li ul:visible').parent().attr('id').split('_').pop();
		
		if(aktuell != stepper){
		
			$(target+' ul.top_themen li').removeClass('aktiv');
			$(target+' ul.top_themen li ul:visible').slideUp(rotationswitchEverySeconds*100);
			$(target+' ul.top_themen li#rotation_teaser_item_'+stepper).addClass('aktiv');
			$(target+' ul.top_themen li#rotation_teaser_item_'+stepper+' ul').slideDown(rotationswitchEverySeconds*100);
			
			if(stepper === 0 && type !== 'click'){
				$(target+' .preview .scroller').animate({top: -(333*that.stepcount)+"px"}, (rotationswitchEverySeconds*100), 'linear', resetPositionCallback);
			}else{
				$(target+' .preview .scroller').animate({top: -(333*stepper)+"px"}, (rotationswitchEverySeconds*100));
			}
			
			
			$(target+' .preview .headline strong').fadeOut(rotationswitchEverySeconds*50,function(){
				$(target+' .preview .headline strong').removeClass('rating_0')
													.removeClass('rating_1')
													.removeClass('rating_2')
													.removeClass('rating_3')
													.removeClass('rating_4')
													.removeClass('rating_5')
													.removeClass('automobil')
													.removeClass('motorrad')
													.removeClass('panorama')
													.addClass(Beitrag['Beitragsart_Name'])
													.addClass('rating_'+Beitrag['BewertungDurchschnitt'])
													.html(''+Beitrag['Dachzeile_kurz'])
													.fadeIn(rotationswitchEverySeconds*50);
				
			});
			
			$(target+' .preview .headline h2 a').fadeOut((rotationswitchEverySeconds*50), function(){
				$(target+' .preview .headline h2 a').html(''+Beitrag['Ueberschrift_lang'])
													.attr('href', ''+Beitrag['URL'])
													.fadeIn(rotationswitchEverySeconds*50);
			});
			$(target+' .preview .headline p a').fadeOut((rotationswitchEverySeconds*50), function(){
				$(target+' .preview .headline p a').html(''+Beitrag['Teasertext_kurz'])
												   .attr('href', ''+Beitrag['URL'])
												   .fadeIn(rotationswitchEverySeconds*50);
			});
			
			
			stepper++;
			
			if(stepper >= that.stepcount){
				stepper = 0;
			}
		}
	}
	function openStep(){
		
		clearInterval(timeoutId);
		
		stepper = $(this).attr('id').split('_').pop();
		
		showNextItem('click');
		
		timeoutId = setInterval(showNextItem, (rotationswitchEverySeconds*1000));
		
	}
	function resetPositionCallback(){
		$(target+' .scroller').css('top', "0px");
	}
};
