 /* #########################################
  * ### MP_NEWS - JAVASCRIPT - TEASERVIEW ###
  * ######################################### */
 
 var newsItem_count;
 var newsItem_interval;
 var old_newsItem = 0;
 var old_newItem_sec = 1;
 var current_newsItem = 0;
 var second_newsItem = 1;
 
 var buttonUp = $("a.newsButtonUp");
 var buttonDown = $("a.newsButtonDown");
 
 var countUp = 0;
 var shownItems = 2;
 
 //$("a.newsButtonDown").css('background', 'transparent url(../img/step_newsbuttonDown_off.jpg) top left no-repeat');

 
 $(document).ready(function(){
	 	
	newsItem_count = $("div.newsItem").size();	
		
		$("a.newsButtonDown").css('background', 'url(fileadmin/templates/img/step_newsbuttonDown_off.jpg) top left no-repeat');
		$("a.newsButtonUp").click(function(){
//			buttonDown.show();
			countUp--;	
//			if ((-newsItem_count + shownItems) == countUp) {
//				$(this).hide();	
//			}
			var positionTop = (countUp*95);	
			$(this).parent('#newsTeaser').children('.news-list-container').children('.news-list-border').animate(
				{
					top: positionTop,
					
				},
				1000);
//			alert(countUp);
			return false;
			
		});
	
		$("a.newsButtonDown").click(function(){
			//buttonUp.show();
			countUp++;
			//if (countUp == 0) {
			//	$(this).hide();	
			//}
			var positionTop = (countUp*100);
			$(this).parent('#newsTeaser').children('.news-list-container').children('.news-list-border').animate(
				{
					top: positionTop,		
				},
				1000);
			return false;
			
		});
			
});
		
 
	function newsItem_rotate() {
		current_newsItem = (old_newsItem + 2) % newsItem_count; 
		second_newsItem = (old_newItem_sec + 2) % newsItem_count;
		$("div.newsItem:eq(" + old_newsItem + ")").animate({top: -320},"slow", function() {
			$(this).css('top','320px');
		});
		$("div.newsItem:eq(" + old_newItem_sec + ")").animate({top: -320},"slow", function() {
			$(this).css('top','320px');
		});
		$("div.newsItem:eq(" + current_newsItem + ")").show().animate({top: 7},"slow"); 
		$("div.newsItem:eq(" + second_newsItem + ")").show().animate({top: 140},"slow");  
		old_newsItem = current_newsItem;
		old_newItem_sec = second_newsItem;
	}
	

// Tipafriend Plugin	
 $(document).ready(function(){
 	if ('.error') {
		$('.tipafriend').not($('.error').parent('.tipafriend')).hide();
	}
	else {
		$('.tipafriend').hide();
	}
	$('.tipafriendHeader').css('cursor' , 'pointer');
	
	if ($('.tipafriend').is(':hidden')) {
		$('h1.tipafriendHeader').not($(this)).removeClass('active');
	}
	
	$('h1.tipafriendHeader').click(function(){
			$(this).next('.tipafriend').slideToggle('slow');
			$(this).toggleClass('active');
			if ($('.tipafriend').is(':visible')) {
				$('.tipafriend').not($(this).next('.tipafriend')).hide('slow');
				$('h1.tipafriendHeader').not($(this)).removeClass('active');
			}

			
		
	});
	
		
});


