function Slideshow(ul)  
{  
	var that = this;
	var target;
	var pictures; //array of li
	var currentLi;
	var e;
	var duration;
	
	this.slideshow = function(target)
	{
		that.target = target;	
		$(that.target).css("position","relative");
		that.pictures = $(that.target).children();
		for (var i = 0;i< that.pictures.length ; i++)
		{
			var li = that.pictures[i];
			$(li).css("display","none");
			$(li).css("position","absolute");
		}
		var li = that.pictures[0];
		$(li).css("display","inline");
	}
	
	
	this.init = function()  
	{  
		//console.log("initialized");
	}  
	
	this.start = function()
	{
		//console.log("je start le diapo");
		that.e = setTimeout(that.changePicture,that.duration);
	}
	
	this.changePicture = function()
	{
		//console.log("je vais sur l'image : "+(that.currentLi))
		clearTimeout(that.e)
		var picture = that.pictures[that.currentLi];
		$(picture).css("z-index","1");
		$(picture).fadeOut(800);
		
		if(that.currentLi < (that.pictures.length-1))
		{
			that.currentLi++;
		}
		else
		{
			that.currentLi = 0;
		}
		var picture = that.pictures[that.currentLi];
		$(picture).css("z-index","2");
		$(picture).fadeIn(800);
		that.e = setTimeout(that.changePicture,that.duration);
	}
	
	this.stop = function ()
	{
		//je remet à 0 mon slideshow
		var picture = that.pictures[that.currentLi];
		$(picture).css("z-index","1");
		$(picture).css("display","none");
		$(picture).stop(true,true);
		clearTimeout(that.e);
		that.currentLi = 0;
		var picture = that.pictures[that.currentLi];
		$(picture).css("z-index","2");
		$(picture).css("display","inline");
	}
	//si on veut initialisé un truc, on le met la
	this.currentLi = 0;
	this.duration = 3000;
	this.slideshow(ul);
} 
