var lecture = false;

function bt_lecteur_play(){
 		/*$('#btn_lecteur').css({
 			'background-position' : '-94px'
 		});*/
 		$('#btn_lecteur').removeClass('jp-play');
 		$('#btn_lecteur').addClass('jp-stop');
 		//alert("play");
 	}
 	
 	function bt_lecteur_pause(){
 		/*$('#btn_lecteur').css({
 			'background-position' : '0px'
 		});*/
 		//class="jp-pause"
 		$('#btn_lecteur').removeClass('jp-stop');
 		$('#btn_lecteur').addClass('jp-play');
 		//alert("pause");
 	}
 	
$(document).ready(function(){
 
 	

 // Local copy of jQuery selectors, for performance.
	var	my_jPlayer = $("#jquery_jplayer"),
		my_trackName = $("#jp_container .track-name"),
		my_playState = $("#jp_container .play-state"),
		my_extraPlayInfo = $("#jp_container .extra-play-info");

	// Some options
	var	opt_play_first = false, // If true, will attempt to auto-play the default track on page loads. No effect on mobile devices, like iOS.
		opt_auto_play = true, // If true, when a track is selected, it will auto-play.
		opt_text_playing = "Now playing", // Text when playing
		opt_text_selected = "Track selected"; // Text when not playing

	// A flag to capture the first track
	var first_track = true;

	// Change the time format
	$.jPlayer.timeFormat.padMin = false;
	$.jPlayer.timeFormat.padSec = false;
	$.jPlayer.timeFormat.sepMin = " min ";
	$.jPlayer.timeFormat.sepSec = " sec";

	// Initialize the play state text
	my_playState.text(opt_text_selected);

	// Instance jPlayer
	my_jPlayer.jPlayer({
		ready: function () {
			$("#jp_container .track-default").click();
		},
		timeupdate: function(event) {
			my_extraPlayInfo.text(parseInt(event.jPlayer.status.currentPercentAbsolute, 10) + "%");
		},
		play: function(event) {
			my_playState.text(opt_text_playing);
			bt_lecteur_play();
		},
		pause: function(event) {
			my_playState.text(opt_text_selected);
			bt_lecteur_pause();
		},
		ended: function(event) {
			my_playState.text(opt_text_selected);
			bt_lecteur_pause();
		},
		swfPath: "js",
		cssSelectorAncestor: "#jp_container",
		supplied: "mp3",
		wmode: "window"
	});

	// Create click handlers for the different tracks
	$("#jp_container .track").click(function(e) {
		my_trackName.text($(this).text());
		my_jPlayer.jPlayer("setMedia", {
			mp3: $(this).attr("href")
		});
		if((opt_play_first && first_track) || (opt_auto_play && !first_track)) {
			my_jPlayer.jPlayer("play");
			lecture = true;
		}
		first_track = false;
		$(this).blur();
		return false;
	});
	
	$("#btn_lecteur").click(function(e) {
		if (lecture == false){
			my_jPlayer.jPlayer("play");
			lecture = true;
		} else {
			my_jPlayer.jPlayer("stop");
			lecture = false;
		}
			
		
	});
	
	//Zone defileur pour l'actualité
	$('.defileur').vTicker({
	   speed: 500,
	   pause: 8000,
	   showItems: 1,
	   animation: 'fade',
	   mousePause: false,
	   height: 0,
	   direction: 'up'
	});


});
