var Diaporamas = new Array();

function Diaporama(title, interval, width, height) {
	this.Index=Diaporamas.length;
	this.Images=new Array();
	this.ImgIndex=0;
	this.ID=null;
	this.interval=interval==undefined ? 1000 : new Number(interval);
	this.Add=function(src){
		var Index=this.Images.length;
		this.Images[Index]=new Array();
		this.Images[Index]["image"]=new Image();
		this.Images[Index]["image"].src=src;
		this.Images[Index]["rel"]=src;        
	}
	this.Show=function(Index){
		if(Index < 0)Index=this.Images.length - 1;
		if(Index > this.Images.length - 1)Index=0;
		document.images["disc" + this.Index].src=this.Images[Index]["image"].src;
		this.ImgIndex=Index;
	}
	this.First=function(){
		this.Show(0);
	}
	this.Last=function(){
		this.Show(this.Images.length - 1);
	}
	this.Previous=function(){
		if(this.ImgIndex > 0)this.Show(this.ImgIndex - 1);
	}
	this.Next=function(){
		if(this.ImgIndex < this.Images.length - 1)this.Show(this.ImgIndex + 1);
	}
	this.Play=function(){
		this.ID=setInterval("Diaporamas[" + this.Index + "].Show(Diaporamas[" + this.Index + "].ImgIndex + 1);", this.interval);
	}
	this.Stop=function(){
		clearInterval(this.ID);
		this.ID=null;
	}
	this.Click=function(Index){
		this.Stop();
		this.Show(Index);
	}
	this.Build=function(){
		document.write('<table id="diaporama" cellspacing="0">');
		document.write('<tr><td><br/>');
        document.write('<img src="' + this.Images[0]['image'].src + '" name="disc' + this.Index + (width==undefined ? '" ' : '" width="' + width) + (height==undefined ? '" ' : ' height="' + height) + '">');
        document.write('<br/><br/></td></tr>');
		document.write('<tr><td>');
        document.write('<a href="javascript:Diaporamas[' + this.Index + '].Previous();"><img src="/chantiers/diaporamas/bouton-prec.gif" border="0" width="36" height="38" alt="Image précédente"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:Diaporamas[' + this.Index + '].Next();"><img src="/chantiers/diaporamas/bouton-suiv.gif" border="0" width="36" height="38" alt="Image suivante"></a>');
		document.write('</td></tr></table>');
	}
	Diaporamas[this.Index]=this;
}

