jQuery(document).ready(function(){

// start: News flash
	var newsItems = jQuery('.brr .news-latest-container .news-latest-item');
	var newsContainer = jQuery('.brr .news-latest-container');
	var heightNewsBox = 0;
	var currentItemIndex = -1;

	// if there is only one news item we need no animation
	if(newsItems.length > 1) {
		// first get the height of the biggest news item ...
		newsItems.each(function(i) {
			var itemHeight = jQuery(this).height();
			jQuery(this).hide();
			heightNewsBox = itemHeight > heightNewsBox? itemHeight : heightNewsBox;
		});
		// ... and assign it to the container element
		newsContainer.css({ height: heightNewsBox+'px', position:'relative' });

		// change the positioning of the news items so that they are stacked upon each other
		newsItems.css({ position:'absolute', top:'0px'});

		// to emulate a recursive function we append a helper SPAN element ...
		newsContainer.append('<span class="next-teaser" style="display:none; position:absolute; left:-2000px;"></span>');
		// .. and assign a click handler to it which will do the animation by repetitive "virtual clicks" on our SPAN element
		newsContainer.children('span').click( function() {
			currentItemIndex++;
			currentItemIndex = currentItemIndex >= newsItems.length? 0 : currentItemIndex;
			newsItems.eq(currentItemIndex).fadeIn('slow', function() {
				jQuery(this).animate({top: '0'}, 5000, function(){
					jQuery(this).fadeOut('slow', function() {
						newsContainer.children('span.next-teaser').click();
					});
				});
			});
		});

		// start the animation
		newsContainer.children('span.next-teaser').click();
	}
// end: News flash

});
