var currentMediaIndex = null;

$(document).ready(function(){

	//hide player at popin display
	$.nyroModalSettings({
	  processHandler: function(settings){ 
		$('#blocker').css({'zIndex':'9000'});
		$('#smartPlayer object').css({'visibility' : 'hidden'});
		$('#smartPlayer #fakePlayer').css({'visibility' : 'visible'});
	  },
	  endRemove: function(elts, settings){ 
		  $('#blocker').css({'zIndex':'0'});
		  $('#smartPlayer object').css({'visibility':'visible'});
		  $('#smartPlayer #fakePlayer').css({'visibility' : 'hidden'});
	  },
	  blocker: '#blocker'
	});
	
	
	$('#directsNavigation').show();
	
	$('#nextLive').paginate({
		buttonLeft: $('#prevDirect'),
		buttonRight: $('#nextDirect'),
		onChange: function(from, to, pager){
			$(from).fadeOut(function(){
				$(to).fadeIn(pager.changeEnded());
			});
		}
	});
	
	// display or not coverflow previous/next button
	// needed because css change at button hover done with jQuery force display: block 
	var coverflowButtonCallback = function(carousel, button, status)
	{
		var display = status ? 'block' : 'none';
		$(button).css({'display' : display});
	};
	
	var coverflowOptions = {
		scroll: 4,
		visible: 5,
		buttonNextCallback: coverflowButtonCallback,
		buttonPrevCallback: coverflowButtonCallback
	};
	
	if(currentMediaIndex != null)
	{
		coverflowOptions = $.extend(coverflowOptions, {start: currentMediaIndex });
	}
	
	//Initialize coverflow
	$('#carousel').jcarousel(coverflowOptions);
	
	//arrow rollover for coverflow (needed for ie, :hover work only on a tag)
	$('.jcarousel-prev').add('.jcarousel-next').hover(
			function(){
				$(this).css({
					'backgroundPosition' : '0 -40px'
				});
			},
			function(){
				$(this).css({
					'backgroundPosition' : '0 0'
				});
			}
	);
	
	
	//Initialize popin
	$('.popin').nyroModal({
		minHeight: 150,
		resize: null
	});
	
	//call player method
	$('#linkLastEditions').click(function(){
		players.getPlayer().showArchives();
	});
});

