/* Faire défiler les photos de l'album photos */

var transition;

/* Définit la liste des photos de l'album */
transition = new Image(10,10);
transition.src = "images/transparent.gif";

var no_photo = 0;

function DefileAlbum(sens) {

	var photo;
	var preload;

/* Calcule le numéro de la photo à afficher */
	if (sens == "premiere") {
		no_photo = 0;
	}
	if (sens == "precedente") {
		no_photo --;
		if (no_photo < 0) {no_photo = 0;}
	}
	if (sens == "suivante") {
		no_photo ++;
		if (no_photo > nb_photo_max) {no_photo = nb_photo_max;}
	}
	if (sens == "derniere") {
		no_photo = nb_photo_max;
	}

/* Charge la photo en mémoire */
	photo = new Image(largeur[no_photo],hauteur[no_photo]);
	photo.src = racine + liste_photo[no_photo];

/* Affiche la photo */
	document.getElementById("photo").src = transition.src;
	largeur_tmp = largeur[no_photo] + 30;
	largeur_tmp = largeur_tmp + "px";
	document.getElementById("album").style.width = largeur_tmp;
	document.getElementById("photo").width = largeur[no_photo];
	document.getElementById("photo").height = hauteur[no_photo];
	document.getElementById("photo").src = photo.src;
	document.getElementById("legende").innerHTML = legende[no_photo];

/* Affiche les boutons suivant la photo en cours */
	if (no_photo == 0) {
		AfficherBoutons('debut');
	}
	else {
		if (no_photo == nb_photo_max) {AfficherBoutons('fin');}
		else {AfficherBoutons('');}
	}

/* Précharge la photo suivante */
	if (no_photo < nb_photo_max) {
		preload = new Image(largeur[no_photo+1],hauteur[no_photo+1]);
		preload.src = racine + liste_photo[no_photo+1];
	}
}

function AfficherBoutons(etat) {
/* Affiche les boutons suivant la photo en cours */

	if (etat == "debut") {
		/* Désactive les boutons Première et Précédente */
		document.getElementById("bouton0").style.visibility = "hidden";
		document.getElementById("bouton1").style.visibility = "hidden";
	}
	else {
		document.getElementById("bouton0").style.visibility = "visible";
		document.getElementById("bouton1").style.visibility = "visible";
	}
	if (etat == "fin") {
		/* Désactive les boutons Suivante et Dernière */
		document.getElementById("bouton2").style.visibility = "hidden";
		document.getElementById("bouton3").style.visibility = "hidden";
	}
	else {
		document.getElementById("bouton2").style.visibility = "visible";
		document.getElementById("bouton3").style.visibility = "visible";
	}

}