// JavaScript Document

// preload images first (can run before page is fully loaded)
/*function preloade(){
  $.preloadImages("img/bg_page.gif", "img/auteurs/jerome.jpg", "img/auteurs/znarf.jpg", "img/auteurs/alex.jpg", "img/auteurs/adrian.jpg", "img/auteurs/maxime.jpg");
	$(
		function()
		{
			// do something when page is ready
			alert('loadé');
		}
	)
}*/

/**/

/**/
//init
tem1 = 1;
tem2 = 1;

/**/
//function rotation des citationss
function qotd_rotate(){
	
	if( tem1 == (quotd.length) ){
		tem1 = 1;
	}
	
	$("#effect1").hide();
	$("#qotd_cit").html(quotd[tem1]);
	$("#qotd_auteur").html(quotd_auteur[tem1]);
	$("#bulle1").html(bulle1[tem1]);
	$("#bulle2").html(bulle2[tem1]);
	//$("#effect1").animate({   height: 'toggle', opacity: 'toggle'}, "slow");
	$("#effect1").animate({   opacity: 'toggle'}, 900);
	tem1++;
	
}

/**/

$(document).ready(function() {
	
	//init aux premieres valeurs 
	$("#qotd_cit").html(quotd[tem1]);
	$("#qotd_auteur").html(quotd_auteur[tem1]);
	$("#bulle1").html(bulle1[tem1]);
	$("#bulle2").html(bulle2[tem1]);
	$("#decouvre_auteur").attr({ src: decouvre_auteur[tem2] });	
	//on appelle regulierement la rotaion des citations
	//qotd_interval = setInterval(qotd_rotate,5000);
	
	
	//bouton nous decouvrir next
	$("#next").click(function() {
		
		//effet + fonction de callback kan effet terminé pour changement d'image
		$("#effect2").animate({   opacity: 'toggle'}, 2000, "easeinout", function(){
			
			tem2++;				  
			if( tem2 == (decouvre_auteur.length) ){
			  tem2 = 1;
			}				  
			
			$("#decouvre_auteur").attr({ src: decouvre_auteur[tem2] });	
			$("#citation_txt").html(decouvre_txt[tem2]);
			$("#auteur_txt").html(decouvre_auteur_txt[tem2]);
			$("#effect2").animate({   opacity: 'toggle'}, 400, "easeinout");
			
		});
		//$("#decouvre_auteur").show();
		
		return false;
		
    });
	
	//bouton nous decouvrir prev
	$("#prev").click(function() {
			  
		/*tem2--;
		if( tem2 == 0 ){
		  tem2 = (decouvre_auteur.length-1);
		}
		
		$("#decouvre_auteur").attr({ src: decouvre_auteur[tem2] });	
		$("#citation_txt").html(decouvre_txt[tem2]);
		$("#auteur_txt").html(decouvre_auteur_txt[tem2]);
		
		//effet
		$("#decouvre_auteur").hide();
		$("#decouvre_auteur").animate({   opacity: 'toggle'}, 400, "easeinout");*/
		
		//effet
		$("#effect2").animate({   opacity: 'toggle'}, 2000, "easeinout", function(){
			tem2--;																		 
			if( tem2 == 0 ){
			  tem2 = (decouvre_auteur.length-1);
			}
			
			$("#decouvre_auteur").attr({ src: decouvre_auteur[tem2] });	
			$("#citation_txt").html(decouvre_txt[tem2]);
			$("#auteur_txt").html(decouvre_auteur_txt[tem2]);
			$("#effect2").animate({   opacity: 'toggle'}, 400, "easeinout");
		});
		//$("#decouvre_auteur").show();
		
		
		return false;
		
    });
	
});// end doc ready
