
$(document).ready( 
	function() 
	{	    
	
	
	
		var ankuend_childcount = $('.ankuendigung').length;
    	var makingof_childcount = $('.ani_bild').length;
    	    	
		



		var is_hovered = false;
    	var i = 0;
		var j=0;
		var nr = 0;
    	
		$('.ankuend_preview').mouseover(function() {
			nr = $(this).index(".ankuend_preview");
			is_hovered=true;
			
			$('.ankuendigung').stop(true,true);
			$('.ankuend_preview').stop(true,true);
			var a = 0;
			a = i-1;
			if(a<0)a=ankuend_childcount-1;
			if(a!=nr){
				$('.ankuend_preview').css({"opacity": "0.3","background-color": "transparent","padding-left":"10px","margin-left": "0px","border-top": "2px solid transparent","border-bottom": "2px solid transparent",});
				$('.ankuendigung').animate(	{"opacity": "hide",} , 0, function() {} );

			
				$('.ankuendigung:eq('+nr+')').animate({"opacity": "show",} , 500,  function() {
				    pageHeight=$(document).height()-88;
	    			$('div.main-holder .content_right .short-news').height( pageHeight );
					$('div.main-holder .content_right .short-info').height( pageHeight );
	    		});
			  	$(this).animate({"opacity": "1.0",} , 500, function() {} );
				$(this).css({"background-color": "#E1E5E4","padding-left":"13px","margin-left": "-3px","border-bottom": "2px solid white","border-top": "2px solid white",});
			}
		}).mouseout(function(){
			is_hovered=false;
			
			if(nr+1>=ankuend_childcount)
				i=0;
			else
				i=nr+1;
		});

    	//var i = Math.floor(Math.random()*ankuend_childcount); // Zahl 0<=x<ankuend_childcount abgerundet ist 0<=x<=ankuend_childcount-1
    	
    	var slide = function() {
			if(!is_hovered){
				$('.ankuend_preview').css({"opacity": "0.3","background-color": "transparent","padding-left":"10px","margin-left": "0px","border-top": "2px solid transparent","border-bottom": "2px solid transparent",});
			
	    		$('.ankuendigung').animate(	{"opacity": "hide",} , 0, function() {} );
				$('.ankuendigung:eq('+i+')').animate({"opacity": "show",} , 500,  function() {
				    pageHeight=$(document).height()-88;
	    			$('div.main-holder .content_right .short-news').height( pageHeight );
					$('div.main-holder .content_right .short-info').height( pageHeight );
	    		});
				$('.ankuend_preview:eq('+i+')').animate({"opacity": "1.0",} , 500, function() {} );
				$('.ankuend_preview:eq('+i+')').css({"background-color": "#E1E5E4","margin-left": "-3px", "padding-left":"13px","border-bottom": "2px solid white","border-top": "2px solid white",});
				
				
				i++;
				if(i>=ankuend_childcount)
					i=0;

			}
			setTimeout(
				function() {
        			slide();
    				},
				8000
			);
			

/*
    		$('.ani_bild #video').html("");
    		if( $('.ani_bild:eq('+i+') #video_ogg').length || $('.ani_bild:eq('+i+') #video_mp4').length ){
					var video_ogg = $('.ani_bild:eq('+i+') #video_ogg').val();
					var video_mp4 = $('.ani_bild:eq('+i+') #video_mp4').val();
					$('.ani_bild:eq('+i+') #video').html('<video  width="582" autoplay><source src=' + video_mp4 + ' type="video/mp4" /><source src=' + video_ogg + ' type="video/ogg" /><a href="'+video_mp4+'" style="display:block;width:583px;height:289px" id="flowplayer' + i + '"></a><script>flowplayer("flowplayer' + i + '", "/media/flowplayer-3.2.5.swf",{ clip:{autoPlay: true,}, onload: function(){this.getControls().hide();}});</script></video>');

			}
*/
    		//TIME SET BY OBJECT
			// $('.ani_bild #video video').attr('muted', true);

    		

    	}
		
		var slide2 = function() {
    		$('.ani_bild').animate(	{"opacity": "hide",} , 0, function() {} );
			$('.ani_bild:eq('+j+')').animate({"opacity": "show",} , 500,  function() {
			    pageHeight=$(document).height()-88;
    			$('div.main-holder .content_right .short-news').height( pageHeight );
				$('div.main-holder .content_right .short-info').height( pageHeight );
    		});


			j++;
			if(j>=makingof_childcount)
				j=0;
			setTimeout(
				function() {
        			slide2();
    				},
				8000
			);
    	}



    	slide();
		slide2();
	}
);

