	function cmsSlideShow( instance, cellid, images, delay_display, delay_fade, delay_init, antialias, ratio, width, display_name, display_legend, type ) {
		this.instance = instance;
		this.cellid = cellid;
		this.images = images;
		this.pos = this.images.length; // set to end to start at beginning...
		this.delay_init = delay_init;
		this.delay_display = delay_display;
		this.delay_fade = delay_fade;
		this.antialias = antialias;
		this.ratio = ratio;
		this.width = width;
		this.display_name = display_name;
		this.display_legend = display_legend;
		this.is_fading = false;
		this.type = (type > 0) ? type : 32;
		this.Initialize();
		this.slide_count = 0;
		this.max_slide_counts = 100;
	}

	cmsSlideShow.prototype.Initialize = function() {
		window.setTimeout(this.instance + ".Forward()", this.delay_init + this.delay_display);
	}

	cmsSlideShow.prototype.Forward = function() {
		if ((this.is_fading) || (this.slide_count >= this.max_slide_counts)) return false;
		this.is_fading = true;
		this.pos = ((this.pos + 1) % this.images.length);
		// need to wait a litte for ff to render the image - animation would be broken if we didn't
		this.SetVisibility( 'hidden', this.cellid );
		window.setTimeout(this.instance + ".DoForward()", 10);
		window.setTimeout(this.instance + ".Forward()", this.delay_display);
    }

	cmsSlideShow.prototype.DoForward = function() {
		// thickbox extension: if front image parent is an A node, we change its href
		var frontimg = document.getElementById('slideshow' + this.cellid + 'front');
		var frontimgparent = frontimg ? frontimg.parentNode : false;
		if (frontimgparent && frontimgparent.nodeName == 'A') {
			var href=frontimgparent.getAttribute("href");
			frontimgparent.setAttribute("href",href.replace(/frontend\/handler\/image.php\?id=[0-9]+/, "frontend/handler/image.php?id="+this.images[this.pos].pointer_id));
		}

		this.slide_count++;
		this.FadeIn(this.delay_fade, this.cellid);

		if (this.display_name == 1) {
			var imagename = this.images[this.pos].imagename;
			var imageNameDiv = document.getElementById('imagename' + this.cellid);
			imageNameDiv.innerHTML = imagename;
		}

		if (this.display_legend == 1) {
			var imagecomment = this.images[this.pos].imagecomment;
			var imageCommentDiv = document.getElementById('imagecomment' + this.cellid);
			imageCommentDiv.innerHTML = imagecomment;
		}
	}

	cmsSlideShow.prototype.SetImageSource = function( img, id ) {
		img.src = "/__/frontend/handler/image.php?id=" + id + "&type=" + this.type + "&antialias=" + this.antialias + "&ratio=" + this.ratio + "&fill=1&width=" + this.width;
	}

	cmsSlideShow.prototype.FadeIn = function( millisec, id ) {
		var frames = 50;
		this.SetFrontImage();
	    var speed = Math.round(millisec / frames);
		// again - make sure the image is really hidden before starting to fade in...
	    var delay = Math.round(Math.random() * 20);
		this.SetOpacity( 0, id );
		window.setTimeout(this.instance + ".SetVisibility('','" + id + "')", delay);

        if ( speed > 0 ) for (i = 1; i <= frames; i++) {
            window.setTimeout(this.instance + ".SetOpacity(" + Math.round(i / frames * 100) + ",'" + id + "')", ((i * speed) + delay));
        }
        window.setTimeout(this.instance + ".SetBackImage()", (millisec + delay + 10) ); 
	}

	cmsSlideShow.prototype.SetBackImage = function() {
		this.SetImageSource( document.getElementById('slideshow' + this.cellid + 'back'), this.images[this.pos].pointer_id );
		this.is_fading = false;
	}

	cmsSlideShow.prototype.SetFrontImage = function() {
		this.SetImageSource( document.getElementById('slideshow' + this.cellid + 'front'), this.images[this.pos].pointer_id );
	}

	cmsSlideShow.prototype.SetOpacity = function( opacity, id ) {
		obj = document.getElementById('slideshow' + id + 'front');
		opacity = (opacity == 100) ? 99.999 : opacity;
		// IE/Win
		obj.style.filter = "alpha(opacity:"+opacity+")";
		// Safari<1.2, Konqueror
		obj.style.KHTMLOpacity = opacity/100;
		// Older Mozilla and Firefox
		obj.style.MozOpacity = opacity/100;
		// Safari 1.2, newer Firefox and Mozilla, CSS3
		obj.style.opacity = opacity/100;
	}

	cmsSlideShow.prototype.SetVisibility = function( visibility, id ) {
		obj = document.getElementById('slideshow' + id + 'front');
		obj.style.visibility = visibility;
	}