var newsboxOpen = false;
var activePage = 1; 
var maxPages = 1;

$(function () {
	
	$('#expandButton').bind("click",toggleNewsbox);
	
	$('#galleryStripe a').lightBox(); 
	
	$('#playerStatisticsTabs').tabs();
	
	$('#teamviewTabs').tabs();
	
	initAjaxTeaser();
	
	
});


function toggleNewsbox() {
	
	if(!newsboxOpen) {
		
		$("#newsboxContentWrap").animate( {
			height:"408px"
			//top:"100px"
		},1000
		);
	
		$("#newsbox").animate( {
			top:"60px"
		},1000
		);
		
		newsboxOpen = true;

		$("#newsboxExpand img").attr("src","fileadmin/templates/images/newsboxExpandClose.gif");
		
	}else{
		$("#newsboxContentWrap").animate( {
			height:"29px"
			//top:"100px"
		},1000
		);
	
		$("#newsbox").animate( {
			top:"448px"
		},1000
		);
		

		newsboxOpen = false;
		
		$("#newsboxExpand img").attr("src","fileadmin/templates/images/newsboxExpand.gif");
		
	}

}



function nextPage() {
	
	if(activePage < maxPages) {
		$('#galleryStripe').animate({
			left: (activePage*625)*-1
		},1000);
		activePage++;
	}
	
}

function prevPage() {
	
	var newPos = parseInt($('#galleryStripe').css('left').substr(0,$('#galleryStripe').css('left').length-2))+625

	if(activePage > 1) {		
		$('#galleryStripe').animate({
			left: newPos
		},1000);
		activePage--;
	}
	
}

function initAjaxTeaser() {
	$('#ajaxTeaser').css('display','none');
}

function loadNewsContent(newsId) {
	
	$('#ajaxTeaser').fadeOut("slow");
	
	$.ajax({
		url:'index.php?id=6&ajax=true&no_cache=1&newsid='+newsId,
		cache:false,
		success: function(html) {
			$("#ajaxTeaserContent").html(html);
			$('#ajaxTeaser').fadeIn("slow");
		}
	});
	
}


function loadTeamContent(memberId) {
	
	$('#ajaxTeaser').fadeOut("slow");
	$.ajax({
		url:'index.php?id=24&ajax=true&no_cache=1&member='+memberId,
		cache:false,
		success: function(html){
			$('#ajaxTeaserContent').html(html);
			$('#ajaxTeaser').fadeIn('slow');
		}
	});
	
}


function initWithNews(newsid) {
	
	if(newsid > 0) {
		loadNewsContent(newsid);		
	}
	
}


function swapLayers(layer1,layer2) {
	$(layer1).fadeOut("slow");
	$(layer2).fadeIn("slow");
}

