function SlideShow(container, width, height, options)
{
	if(!document.getElementById || !document.createElement)return;
	
	if (!options){options={};}
	this.delay = (options.delay || 5000);
	this.frameDelay = (options.frameDelay || 30);
	this.step = (options.step || 5);
	this.repeatFirstImage = (options.repeatFirstImage || true);
	this.current = 0;
	this.imgs = new Array();
	this.step = this.step/50;
	
	document.getElementById(container).style.position = 'relative';
	document.getElementById(container).style.width = width+'px';
	document.getElementById(container).style.height = height+'px';

	this.imgs = document.getElementById(container).getElementsByTagName("img");
	for(i=0;i<this.imgs.length;i++) {
		if (i!=0) {this.imgs[i].xOpacity = 0;}
		this.imgs[i].style.position = 'absolute';
		this.imgs[i].style.top = 0;
		this.imgs[i].style.left = 0;
	}
	this.imgs[0].style.display = "block";
	this.imgs[0].xOpacity = .99;
	var self = this;
	setTimeout(function(){self.xfade()},this.delay);
}

SlideShow.prototype =
{
	xfade: function ()
	{
		cOpacity = this.imgs[this.current].xOpacity;
		nIndex = this.imgs[this.current+1]?this.current+1:0;
		if (!this.repeatFirstImage && nIndex == 0) { nIndex=1;	}
		nOpacity = this.imgs[nIndex].xOpacity;
		
		cOpacity-=this.step; 
		nOpacity+=this.step;
		
		this.imgs[nIndex].style.display = "block";
		this.imgs[this.current].xOpacity = cOpacity;
		this.imgs[nIndex].xOpacity = nOpacity;
		
		this.setOpacity(this.imgs[this.current]); 
		this.setOpacity(this.imgs[nIndex]);
		var self = this;
		if(cOpacity<=0) {
			this.imgs[this.current].style.display = "none";
			this.current = nIndex;
			
			setTimeout(function(){self.xfade()},this.delay);
		} else {
			
			setTimeout(function(){self.xfade()},this.frameDelay);
		}
	},

	setOpacity: function (obj)
	{
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
}