/*********************************************
PROPRIÉTÉS
*********************************************/
var qtn_img_bkg = 5;
var img_bkg_active = 0;

/*********************************************
FONCTIONS
*********************************************/
$(function(){
	//Animations du pied de page
	animationAccueil();
});

function animationAccueil(){
	animPied(function(){
		animationElementsMenu(0, function(){
			animationAfficherImageFond(function(){
				//Toutes les 8 secondes on change l'image
				setInterval("animationAfficherImageFond()", 8000) 
			});
		});
	});
}

function animPied(callback){
	$("#pied").css('bottom', '-100px').show().animate({
		"bottom": "+=100px"
  	}, 'slow', 'swing', function(){
    	callback();
  	});
}

function animationElementsMenu(index, callback){
	try{
		index = index;
	}catch(e){
		index = 0;
	};
	
	var qtn = $("#menuAccueil li").length;
	
	if(index < qtn){
		animationElementsMenuSeul(index, callback);
	}else{
		callback();	
	}
}

function animationElementsMenuSeul(index, callback){
	var ligne = $("#menuAccueil li:eq(" + index + ")");
	ligne.animate({
		 	"width" : '+=160px',
			"opacity" : 1
		 }, 300, function(){
			index++;
			animationElementsMenu(index, callback);
		}
	);	
}

function animationAfficherImageFond(callback){
	//On cache l'image active
	$("#bkg_page" + img_bkg_active).fadeTo(1000, 0, function(){
		$(this).hide();
	});
	
	//On incrémente l'image active
	incrementation_no_image_active();
	
	$("#bkg_page" + img_bkg_active).show().fadeTo(1000, 1, function(){
		try{
			callback();
		}catch(e){};
	});	
}

function incrementation_no_image_active(){
	if(qtn_img_bkg == img_bkg_active){
		img_bkg_active = 1;	
	}else{
		img_bkg_active++;		
	}
}

