function gallery() {
	this.photos = document.getElementById('galerie_mini') ;
	// On récupère l'élément ayant pour id galerie_mini
	this.liens = this.photos.getElementsByTagName('a') ;
	// On récupère dans une variable tous les liens contenu dans galerie_mini
	this.big_photo = document.getElementById('big_pict') ;
	this.big_photo_id = 0 ;
	// Ici c'est l'élément ayant pour id big_pict qui est récupéré, c'est notre photo en taille normale
	this.titre_photo = document.getElementById('photo').getElementsByTagName('dt')[0] ;
	// le titre de la photo de taille normale
	this.prevBt = document.getElementById('prev') ;
	// l'id du bouton précédent
	this.nextBt = document.getElementById('next') ;
	//  l'id du bouton suivant


	this.init = function(){// Une boucle parcourant l'ensemble des liens contenu dans galerie_mini
		var myObj = this;
		for (var i = 0 ; i < this.liens.length ; ++i) {
			// Au clique sur ces liens 
			myObj.liens[i].setAttribute("id",i);
			myObj.id=parseInt(i);
			myObj.liens[i].onclick=function(event) {
				myObj.loadPict(this.id);
				return false;
				}
		};
		myObj.loadNextPrev();
	};


this.init();
};


gallery.prototype.loadPict = function (anId) {
			this.big_photo.src = this.liens[anId].href; // On change l'attribut src de l'image en le remplaçant par la valeur du lien
			this.big_photo.alt = this.liens[anId].ltitle; // On change son titre
			this.titre_photo.firstChild.nodeValue = this.liens[anId].title; // On change le texte de titre de la photo
			this.big_photo_id = anId ;
};
gallery.prototype.next = function () {
			var nouvId=(this.big_photo_id==this.liens.length-1)?0:parseInt(this.big_photo_id)+1;
		    this.loadPict(nouvId);
};
gallery.prototype.prev = function () {
		   var nouvId=(this.big_photo_id==0)?this.liens.length-1:parseInt(this.big_photo_id)-1;
		   this.loadPict(nouvId);
};
gallery.prototype.loadNextPrev = function () {
			var myObj = this;
			this.nextBt.onclick=function(event) { myObj.next();return false;}
			this.prevBt.onclick=function(event) {myObj.prev();return false;}
};

// Il ne reste plus qu'à appeler notre fonction au chargement de la page
window.onload = function(){new gallery();}


