



SlideShow = function (target,elements, options) {
	var current= 0;
	var nbItems = elements.length;
	var on = options.on;
	var off = options.off;
	var wait = options.wait;
	var bImg = elements.eq(0).is('img');
	this.init = function(){
		if (bImg)	{ 
			$(elements).each(function() { 
				$(this).css({opacity:0});
			}); 			
			elements.eq(0).animate({opacity:1},0,"swing",waiter); 
		}
		else {
			$(elements).each(function() { 
				$(this).hide();
			}); 
			elements.eq(0).fadeIn('slow',waiter); 

		}
	}
	
	var disappear = function() {
		if (bImg) 	elements.eq(current).animate({opacity:0},off);
		else elements.eq(current).fadeOut('slow');
		appear();
		
	}
	// temps d'apparition d'une image (pas la premiere)
	var appear = function() {
		current++;
		if (current >= nbItems) { current=0; }
		//disparraitre le premier
		if (bImg) elements.eq(current).animate({opacity:1},on,waiter);
		else elements.eq(current).fadeIn('slow',waiter);
		// apparaitre le second
	}
	// Temps d'affichage d'une image
	var waiter = function() {
		setTimeout( function(ms){disappear();}, wait);
	}
	
}
