function Slideshow(element, duration)
{
	this.duration = duration;
	var elt = $(element);
	
	this.imgs = elt.getElements('img');
	this.idx = -1;
	
	this.srcs = [];
	
	var self = this;
	
	this.imgs.each(function(img) {self.srcs.push(img.src)});

	
	new Asset.images(self.srcs, 
	{
		onComplete:	function()
		{
			self.start();
		}
	});
	
	this.start = function()
	{
		self.timer = self.next.periodical(self.duration, self);
		self.next();
	}
		
	this.next = function()
	{
		if (self.idx >= 0)
		{
			self.imgs[self.idx].fade('out');
		}
		
		++self.idx;
		if (self.idx >= self.imgs.length) self.idx = 0;
		
		self.imgs[self.idx].setStyles({'display': 'block',
							 'opacity': 0});
		self.imgs[self.idx].fade('in');
	}
	
	this.prev = function()
	{
		if (self.idx >= 0)
		{
			self.imgs[self.idx].fade('out');
		}
		
		--self.idx;
		if (self.idx < 0) self.idx = self.imgs.length - 1;
		
		self.imgs[self.idx].setStyles({'display': 'block',
							 'opacity': 0});
		self.imgs[self.idx].fade('in');
	}
	
	this.stop = function()
	{
		if (self.timer == null) return;
		
		$clear(self.timer);
		self.timer = null;
	}
}