
var addthis_config = {
	services_compact: 'facebook, studivz, twitter,  meinvz, myspace',
        services_exclude: 'print',
        ui_click: 'true'
}


var aktPos = 0;
var anzPos = 0;
$(document).ready(function(){
	
	hideSliders();
	
	$('#nextBtn').click(function(event){
		stopPlayers();
		hideButtons();
		showNext();
	});
	$('#prevBtn').click(function(event){
		stopPlayers();
		hideButtons();
		showPrev();
	});
	
	$('#prevBtn').hide();
	
});

	function hideButtons()
	{
		$('#nextBtn').hide();
		$('#prevBtn').hide();
	}
	
	function checkButtons()
	{
		if(aktPos+1 == anzPos)
		{
			$('#nextBtn').hide();
		}
		else
		{
			$('#nextBtn').show();
		}
		if(aktPos == 0)
		{
			$('#prevBtn').hide();
		}
		else
		{
			$('#prevBtn').show();
		}
	}
	
	function hideSliders()
	{
		anzPos = 0;
		$('#slider ul li').each(function(i,obj){
			if(i!=aktPos) $(this).hide();
			
			$(this).attr('id', 'slide-' + i);
			//$(this).attr('style', 'position: absolute; ');
			anzPos++;
		});
	}
	
	function showNext()
	{
		if( (aktPos+1) < anzPos)
		{
			$('#slide-' + aktPos).fadeOut('slow', function() {
				$('#slide-' + (aktPos+1)).fadeIn('slow', function() {
					aktPos++;
					checkButtons();
					$('.slider_title').focus();
				});
			});
		}
	}
	
	function showPrev()
	{	
		if( aktPos>0 )
		{
			$('#slide-' + aktPos).fadeOut('slow', function() {
				$('#slide-' + (aktPos-1)).fadeIn('slow', function() {
					aktPos--;
					checkButtons();
					return false;
				});
			});
		}
	}
	
	function stopPlayers()
	{
		var id;
		var player;
		$('#slider object').each(function(){
			id=$(this).attr('id');
			
			if(id.substr(0,13) == 'media-center-')
			{
				try
			        {
					player = document.getElementById(id);
					player.sendEvent("PLAY","false");
				}
			        catch(e)
			        {}
			}
		});
	}
