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.getElementById('win_content').innerHTML+="<table border='0' cellpadding='5' cellspacing='0'><tr height='1'><td width='250'><img src='img/spacer.gif' height='1' width='250'></td><td width='300'></td></tr>";
		document.getElementById('win_content').innerHTML+="<tr><td align='center'><img src='img/spacer.gif' height='1' width='250'><img src='" + this.Images[0]["image"].src + "' name='disc" + this.Index + "'" + (width==undefined ? " " : " width='" + width+"'") + (height==undefined ? " " : " height='" + height+"'") + "></td></tr>";
		document.getElementById('win_content').innerHTML+="<tr><td align='center'><img src='img/spacer.gif' height='1' width='250'><a href='javascript:Diaporamas[" + this.Index + "].Play();'><img src='img/5.gif' alt='Lecture' border='0'></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:Diaporamas[" + this.Index + "].Stop();'><img src='img/6.gif' alt='Stop' border='0'></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:Diaporamas[" + this.Index + "].First();'><img src='img/1.gif' border='0' alt='Première image'></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:Diaporamas[" + this.Index + "].Previous();'><img src='img/2.gif' border='0' alt='Image précedente'></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:Diaporamas[" + this.Index + "].Next();'><img src='img/3.gif' border='0' alt='Image suivante'></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:Diaporamas[" + this.Index + "].Last();'><img src='img/4.gif' border='0' alt='Dernière image'></a></td></tr>";
		document.getElementById('win_content').innerHTML+="</table>";
	}
	Diaporamas[this.Index]=this;
}

function purgeDiapo()
{
	for(k=0;k<Diaporamas.length;k++)
	{
		Diaporamas[k].Stop();
	}
}