/* ---------------------------------------------------------------
	CONTENU PLUS
 --------------------------------------------------------------- */
function listeRoman() {
	var myAjax = $.ajax({
		url: 'ajax/libraire/liste_roman.php', type: 'POST',
		data: 'recherche=' + $('#recherche_titre').val(),
		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=livre_id' + '&valeur=' + $(this).attr('id'),
						type: 'POST',
						complete: function(){
							affichageSecondaire();
						}
					});
				}); 
			});

		}
	});
}
/* ---------------------------------------------------------------
	ZONE SECONDAIRE
 --------------------------------------------------------------- */
function affichageSecondaire(){ 
	// MASQUE DE LA ZONE PRINCIPALE
	$("div.contenu_centre").css("visibility","hidden");
	// AFFICHAGE DE LA ZONE SECONDAIRE
	$("#zone_secondaire").show();
	
	var myAjax = $.ajax({
		url: 'ajax/libraire/zone_secondaire.php', type: 'POST',
		success: function(retour){$('#zone_secondaire').html(retour);},
		complete: function(){
			// BOUTON FERMER
			gestionAncre("#fermer");
			$("#fermer").click(function(){
				$("#zone_secondaire").hide();					
				$("div.contenu_centre").css("visibility","visible");
			});
			
			// AFFICHAGE PAR DEFAUT
			demoTel("ajax/libraire/premier_chapitre.php");
			
			// SURVEILLANCE DU MENU
			$('#menu_roman a').each( function(noeud){
				gestionAncre($(this));
				$(this).click( function(){
					var idMenu = $(this).attr('id');
					switch(idMenu){
						case "chapitre": demoTel("ajax/libraire/premier_chapitre.php"); break;
						case "biographie": 
							var myAjax = $.ajax({
								url: 'ajax/session_id.php',
								data: 'clef=auteur_id' + '&valeur=' + $(this).attr('auteur'),
								type: 'POST',
								complete: function(){
									demoTel("ajax/libraire/biographie.php");
								}
							});
						break;
					}
				}); 
			});
		}
	});

}

/* ---------------------------------------------------------------
	FONCTIONS A LANCER LORS DU CHARGEMENT DE LA PAGE
 --------------------------------------------------------------- */
$(document).ready(function(){
	// MENU PRINCIPAL - AFFICHAGE DES BOUTONS
	boutonMenu('decouverte');
	// AFFICHAGE DE LA LISTE DES ROMANS
	listeRoman();
});
// -------------------------------------------------------------