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) || (interval=='')) ? 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);
    else
      this.Show(0);
    
	}
	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(){
		w=Number(width)+14;
		document.write("<table width='"+w+"' border=1 cellpadding=5 cellspacing=0>");

		if ((title != undefined) && (title != '')) {
			document.write("<tr><th align='center'>" + title + "</th></tr>");
			}
			
		document.write("<tr bgcolor='silver'><td align=center" +
(width==undefined ? " " : " width=" + width) + 
(height==undefined ? " " : " height=" + height) +
"><img onclick='Diapo.Stop();Diapo.Next();Diapo.Play()' src=" + this.Images[0]["image"].src + 
" name=disc" + 
this.Index +
"></td></tr>");

		document.write("</td></tr></table>");
	}
	Diaporamas[this.Index]=this;
}
