/* ---------------------------------------------------------------
	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/auteurs/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/auteurs/biographie.php");

			// SURVEILLANCE DU MENU
			$('#menu_auteur a').each( function(noeud){
				gestionAncre($(this));
				$(this).click( function(){
					var idMenu = $(this).attr('id');
					switch(idMenu){
						case "biographie": demoTel("ajax/auteurs/biographie.php"); break;
						case "bibliographie": demoTel("ajax/auteurs/bibliographie.php"); break;
					}
				}); 
			});
		}
	});

}

/* ---------------------------------------------------------------
	CONTENU PLUS
 --------------------------------------------------------------- */
function listeAuteur() {
	var myAjax = $.ajax({
		url: 'ajax/auteurs/liste_auteur.php', type: 'POST',
		//data: 'recherche=' + $('#recherche').val(),
		success: function(retour){$('#liste_auteur').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=auteur_id' + '&valeur=' + $(this).attr('id'),
						type: 'POST',
						complete: function(){
							affichageSecondaire();
						}
					});
				}); 
			});

		}
	});
}

/* ---------------------------------------------------------------
	FONCTIONS A LANCER LORS DU CHARGEMENT DE LA PAGE
 --------------------------------------------------------------- */
$(document).ready(function(){
	
	// AFFICHAGE DE LA LISTE DES AUTEURS
	listeAuteur();
	
	// SURVEILLANCE DU FORMULAIRE DE RECHERCHE
	//$('#recherche').keyup(listeAuteur);

	// Verification si ouverture automatique d'un feuilleton
	var verifOuverture = $('#conteneur').attr('ouverture');
	if(verifOuverture == 1) affichageSecondaire();
});
// -------------------------------------------------------------
