	if (document.getElementById && document.getElementsByTagName) {
		if (window.addEventListener) window.addEventListener('load', init, false);
		else if (window.attachEvent) window.attachEvent('onload', init);
	}
	function init() {
		slide = new Slideshow();
		timer = setTimeout("slide.start()", slide.timer);
	}
	
	function Slideshow() {
		this.images = new Array();
		if(typeof(document.getElementById('slideshow')) !== "undefined" || document.getElementById('slideshow') !== null) {
			this.slideshowdiv = document.getElementById('slideshow');
			if(this.slideshowdiv !== null) {
				this.slideshowimages = this.slideshowdiv.childNodes;
				this.timer = 5000;
				cnt = 0;
				for(var i=0; i<this.slideshowimages.length; i++) {
					if(this.slideshowimages[i].className == "ssimg") {
						this.images[cnt] = this.slideshowimages[i];
						this.images[cnt].style.zIndex = (cnt-i)+100;
						cnt++;
					}
				}
			}
		}
	}
	
	Slideshow.prototype.start = function(){
		if (this.images.length > 1) {
			for(var i=0; i<this.images.length; i++) {
				this.fader=setTimeout("slide.fadeout("+i+")",this.timer*i);
			}
		}
	}

	Slideshow.prototype.fadeout = function(index){
		if (this.images[index].fadeout)
		{
			window.clearInterval(this.images[index].fadeout);
		}
		this.images[index].fadeout = window.setInterval('this.slide.startfadeout('+index+')', 1);		
	}
		
	Slideshow.prototype.startfadeout = function(index){
		if(index == this.images.length-1) { //processing last image
			//move this one to top of stack
			this.images[index].style.zIndex = this.images[0].style.zIndex;
			for(var i=0; i<this.images.length-1; i++) {
				this.images[i].style.opacity = 1;
				this.images[i].style.filter = "alpha(opacity=100)";
				this.images[i].style.zIndex = 100-(i+1);
			}
		}
	
		if(this.images[index].style.opacity == "" || this.images[index].style.opacity == undefined) {
			opacity = 1;
		} else {
			opacity = this.images[index].style.opacity-0.05;
		}
		this.images[index].style.opacity = opacity;
		this.images[index].style.filter = "alpha(opacity="+opacity*100+")";
		if(opacity <= 0) {
			this.images[index].style.opacity = 0;
			this.images[index].style.filter = "alpha(opacity=0)";
			window.clearInterval(this.images[index].fadeout);
			if(index == this.images.length-1) {
				for(var i=0; i<this.images.length; i++) {
					this.images[i].style.opacity = 1;
					this.images[i].style.filter = "alpha(opacity=100)";
					this.images[i].style.zIndex = (this.images.length-i)+100;
				}
				timer = setTimeout("this.slide.start('out')", this.timer);
			}
		}
	}
