function makeSlideShow(holder,speed,width,height) {
gallery = document.getElementById(holder)
gallery.style.width = width + "px"
gallery.style.height = height + "px"
gallery.style.cssFloat = "left"
this.alphaShow = 98
this.alphaFade = 0
this.currentImg = 0
this.animationSpeed = speed
this.images = gallery.getElementsByTagName("img")
this.galleryLength = this.images.length
this.sleep = 0;// cia nekeisk!

for (x=0; x<this.galleryLength; x++) {
    this.images[x].style.width = width + "px"
    this.images[x].style.height = height + "px"
    this.images[x].style.position = "absolute"
    this.images[x].style.filter = "alpha(opacity=0)"
    if (x != 1) {
	this.images[x].style.opacity = "0"
	this.images[x].style.mozOpacity = "0"
    }
//    this.images[x].style.visibility = "";
}

var _this = this
var startShow = window.setInterval(function(){_this.engine()},this  .animationSpeed*10)
}

makeSlideShow.prototype.engine = function() {
this.nextImage = this.currentImg + 1 < this.galleryLength ? this.currentImg + 1 : 0

this.images[this.currentImg].style.filter = "alpha(opacity=" + this.alphaFade + ")";

this.images[this.currentImg].style.opacity = this.alphaFade < 10? "0.0" + this.alphaFade : this.alphaFade >= 10 && this.alphaFade < 100 ? "0." + this.alphaFade : 1.0;

this.images[this.currentImg].style.mozOpacity = this.alphaFade < 10? "0.0" + this.alphaFade : this.alphaFade >= 10 && this.alphaFade < 100 ? "0." + this.alphaFade : 1.0;



this.images[this.nextImage].style.filter = "alpha(opacity=" + this.alphaShow + ")";

this.images[this.nextImage].style.opacity = this.alphaShow < 10? "0.0" + this.alphaShow : this.alphaShow >= 10 && this.alphaShow < 100 ? "0." + this.alphaShow : 1.0;

this.images[this.nextImage].style.mozOpacity = this.alphaShow < 10? "0.0" + this.alphaShow : this.alphaShow >= 10 && this.alphaShow < 100 ? "0." + this.alphaShow : 1.0;

    if (this.sleep == 0) {

	this.alphaFade = this.alphaFade - 2

	this.alphaShow = this.alphaShow + 2
    }


    if (this.alphaFade == 100 || this.alphaShow == 100) {

	if (this.sleep < 200) { // cia reguliuojasi islaikymo laikas
	    this.sleep++;
	    return 0;
	}
	this.sleep = 0;
    
    this.alphaFade = 100

    this.alphaShow = 0

    this.currentImg = this.currentImg + 1 > this.galleryLength-1 ? 0 : this.currentImg + 1
    this.images[this.currentImg].style.visibility = "";
    if (this.currentImg+1 < this.galleryLength) this.images[this.currentImg+1].style.visibility = "";
					   else this.images[0].style.visibility = "";

    }

}

