
function el(id){
	return document.getElementById(id);
}

var Diapo = {
	"init" : function(id_content, width, height, nbre){
		Diapo = this;
		this.index = 1;
		this.ObjContent = el(id_content);
		this.ObjContent.style.position="relative";
		this.ObjContent.style.width=width+'px';
		this.ObjContent.style.height=(height+20)+'px';
		this.nbre = nbre;
		if(this.nbre>0){
			var anchors = this.ObjContent.getElementsByTagName("img");
			for (var i=0; i<anchors.length; i++){
				anchors[i].style.display="none";
				anchors[i].style.position="absolute";
			}
		}
		el('img_'+this.index).style.display="block";
		var ObjNav = document.createElement("div");
		this.ObjContent.appendChild(ObjNav);
		ObjNav.style.position="absolute";
		ObjNav.style.bottom=0;
		ObjNav.innerHTML = '<span id="prev"><< Précedent</span>&nbsp;&nbsp;&nbsp;<span id="next">Suivant>></span>';
		el('prev').style.cursor="pointer";
		el('next').style.cursor="pointer";
		el('prev').onclick = function(){
			Diapo.move(-1);
		}
			el('next').onclick = function(){
			Diapo.move(1);
		}
		this.ObjContent.style.display="block";
	},
	"move" : function(i){
		var oldIndex = this.index;
		if(i==-1 && this.index==1)this.index=this.nbre;
		else if(i==1 && this.index==this.nbre)this.index=1;
		else this.index+=i;
		el('img_'+oldIndex).style.display="none";
		el('img_'+this.index).style.display="block";
	}
}