/* ---------------------------------------------------------------
	CONTENU PLUS
 --------------------------------------------------------------- */
function listeRoman() {
	var myAjax = $.ajax({
		url: 'ajax/audio/liste_roman.php', type: 'POST',
		success: function(retour){$('#liste_roman').html(retour);},
		complete: function(){
			// Gestion du Flow
			$("#myController").jFlow({
				slides: "#mySlides",
				controller: ".jFlowControl", 
				slideWrapper : "#jFlowSlide", 
				selectedWrapper: "jFlowSelected",  
				width: "100%",
				height: "100%",
				duration: 400, // Temps en milisecondes 
				prev: ".jFlowPrev",
				next: ".jFlowNext"
			});

			//
			$('div[@class=vignette]').each( function(noeud){
				gestionAncre($(this));
				$(this).click( function(){
					var myAjax = $.ajax({
						url: 'ajax/session_id.php',
						data: 'clef=roman_id' + '&valeur=' + $(this).attr('id'),
						type: 'POST',
						complete: function(){
							affichageSecondaire();
						}
					});
				}); 
			});		
		
		}
	});
}
/* ---------------------------------------------------------------
	ZONE SECONDAIRE
 --------------------------------------------------------------- */
function affichageSecondaire(){
	// MASQUE DE LA ZONE PRINCIPALE
	$("#zone_principale").hide();
	// AFFICHAGE DE LA ZONE SECONDAIRE
	$("#zone_secondaire").show();
	
	var myAjax = $.ajax({
		url: 'ajax/audio/zone_secondaire.php', type: 'POST',
		success: function(retour){$('#zone_secondaire').html(retour);},
		complete: function(){
			// BOUTON FERMER
			gestionAncre("#fermer");
			$("#fermer").click(function(){
				$("#zone_secondaire").hide();					
				$("#zone_principale").show();
			});

			$("#jquery_jplayer").jPlayer({
				ready: function () {
					$("#jquery_jplayer").setFile('http://www.miaowmusic.com/mp3/Miaow-07-Bubble.mp3').play();
				},
				cssPrefix: "different_prefix_example"
			});




// ECOUTE EPISODE 1
//			ecouteEpisode(1);
			// SURVEILLANCE DU MENU
//			$('#menu_roman a').each( function(noeud){
//				gestionAncre($(this));
//				$(this).click( function(){
//					var idEpisode = $(this).attr('id');
//					ecouteEpisode(idEpisode);
//				}); 
//			});
		}
	});

}
/* ---------------------------------------------------------------
	ECOUTE EPISODE
 --------------------------------------------------------------- */
function ecouteEpisode(idEpisode){	
	var myAjax = $.ajax({
		url: 'ajax/audio/ecoute.php', type: 'POST',
		success: function(retour){$('#detail_roman').html(retour);},
		complete: function(){
		}
	});
}
/* ---------------------------------------------------------------
	FONCTIONS A LANCER LORS DU CHARGEMENT DE LA PAGE
 --------------------------------------------------------------- */
$(document).ready(function(){
	// MENU PRINCIPAL - AFFICHAGE DES BOUTONS
	boutonMenu('audio');
	// AFFICHAGE DE LA LISTE DES ROMANS
	listeRoman();

});
// -------------------------------------------------------------