
var _diaManager = null;

function Image(parent,src,alt)
{
	this.img = null;
	this.parent = parent;
	this.src = src;
	this.alt = alt;
	
	this.CreateElement = function()
	{
		this.img = document.createElement('img');
		this.img.src=this.src;
		this.img.alt=this.alt;
		this.img.style.display = "none";
		this.img.style.position = "absolute";
		this.img.style.className = "DiaporamaImage";
		
		this.parent.appendChild(this.img);
	};
	
	this.GetImage = function()
	{
		if(this.img==null)
			this.CreateElement();
		
		return this.img;
	};
}

function Image2(parent,imgAtt)
{
	this.img = null;
	this.parent = parent;
	this.att = imgAtt;
	
	this.CreateElement = function()
	{
		this.img = document.createElement('img');
		this.img.src=this.att["src"];
		this.img.alt=this.att["alt"];
		this.img.style.display = "none";
		this.img.style.position = "absolute";
		this.img.className = this.att["class"];
		
		this.parent.appendChild(this.img);
	};
	
	this.GetImage = function()
	{
		if(this.img==null)
			this.CreateElement();
		
		return this.img;
	};
}


function Diaporama(containerId,time)
{
	this.position = -1;
	this.images = new Array();
	this.container = document.getElementById(containerId);
	src = document.getElementsByClassName("DiaporamaImg");
	for(i=0; i<src.length; i++)
	{
		if(src[i].nodeName=="INPUT" && src[i].type=="hidden")
			this.images.push(new Image(this.container,src[i].value,src[i].alt));
	}
	_diaManager.Add(this);
	
	this.images[0].GetImage().style.display = "inline";
	
	
	this.NextImage = function()
	{
		if(0<=this.position && this.position<this.images.length)
			new Effect.Fade(this.images[this.position].GetImage());
		if(++this.position==this.images.length)
			this.position = 0;
		new Effect.Appear(this.images[this.position].GetImage());
		
		self.setTimeout("_diaManager.GetDiaporama('"+this.GetId()+"').NextImage()",time);
	}
	
	this.GetId = function()
	{
		return this.container.id;
	}
	
	this.NextImage();
}

function Diaporama2(containerId,time)
{
	this.position = -1;
	this.images = new Array();
	this.container = document.getElementById(containerId);
	src = document.getElementsByClassName("DiaporamaImg");
	for(i=0; i<src.length; i++)
	{
		src[i].style.display="none";
		src[i].style.position="absolute";
		this.images.push(src[i]);
	}
	_diaManager.Add(this);
	
	this.images[0].style.display = "inline";
	
	
	this.NextImage = function()
	{
		if(0<=this.position && this.position<this.images.length)
			new Effect.Fade(this.images[this.position]);
		if(++this.position==this.images.length)
			this.position = 0;
		new Effect.Appear(this.images[this.position]);
		
		self.setTimeout("_diaManager.GetDiaporama('"+this.GetId()+"').NextImage()",time);
	}
	
	this.GetId = function()
	{
		return this.container.id;
	}
	
	this.NextImage();
}


function Diaporama3(containerId,time,imgList)
{
	this.position = -1;
	this.images = new Array();
	this.container = document.getElementById(containerId);
	
	for(i=0; i<imgList.length; i++)
	{
		this.images.push(new Image2(this.container,imgList[i]));
	}
	_diaManager.Add(this);
	
	this.images[0].GetImage().style.display = "inline";
	
	
	this.NextImage = function()
	{
		if(0<=this.position && this.position<this.images.length)
			new Effect.Fade(this.images[this.position].GetImage());
		if(++this.position==this.images.length)
			this.position = 0;
		new Effect.Appear(this.images[this.position].GetImage());
		
		self.setTimeout("_diaManager.GetDiaporama('"+this.GetId()+"').NextImage()",time);
	}
	
	this.GetId = function()
	{
		return this.container.id;
	}
	
	this.NextImage();
}


function DiaporamaManager()
{
	this.diaporamas = new Array();
	
	this.Add = function(diaporama)
	{
		this.diaporamas.push(diaporama);
	}
	
	this.GetDiaporama = function(diaporamaId)
	{
		i=0;
		for(; i<this.diaporamas.length && this.diaporamas[i].GetId!=diaporamaId; i++)
			pos=i;
		if(this.diaporamas[pos].GetId()==diaporamaId)
			return this.diaporamas[pos];
		else
			return null;
	}
}

if(_diaManager==null)
	_diaManager = new DiaporamaManager();