/*version 1.0.0
by 2hoch11*/

$(document).ready(function() {
	
	function zeigeReiter(obj, ziel){
		$(obj).find(".reiterinhalte > div").each(function(index, element) {
           	if (ziel==index) {
				$(this).show(0);   
			}else{
				$(this).hide(0)
			}
        });	
	}
	
	$(".reiter > a").click(function(){
		zeigeReiter( $(this).parent().parent(), $(this).index() );
	});
	
	$(".reiter").parent().hover(
		function() { $.data(this, 'hover', true); },
		function() { $.data(this, 'hover', false); }
	).data('hover', false);
	
	var autoplay_reiter = setInterval(nextReiter, 5000);
	
	function nextReiter(){
		$(".reiterinhalte").each(function(index, element) {
			if ( !$(this).parent().data('hover')){
				var max_index = $(this).find("> div").length - 1;
				var cur_index=0;
				$(this).find("> div").each(function(index2, element2) {
					if( $(this).css("display")!="none" ){
						cur_index = index2;
					}
				});
				var ziel_index = cur_index + 1;
				if (ziel_index > max_index) ziel_index = 0;
				zeigeReiter( $(this).parent(), ziel_index );
			} 
		});
	}

});
