function SlideShow(slideel, faddingSpeed, stopTime, stopOnMouseOver) { var slideshow = this; slideel.mouseover = false; if (stopOnMouseOver) { slideel.addEvent('mouseover', function() { this.mouseover = true; }); slideel.addEvent('mouseout', function() { this.mouseover = false; slideshow.next(true); }); } var sttoped = false; this.next = function(triggeredByEvent) { if (!sttoped && triggeredByEvent) return; sttoped = true; if (slideel.mouseover) return; sttoped = false; this.current.fadeOut(); this.current = this.current.nextSlide; this.current.fadeIn(); } function createSlides() { var imgs = slideel.getElementsByTagName('img'); var slides = []; for (var i = 0; i < imgs.length; i++) { slides[i] = new SlideShowImage(imgs[i]); } for (var i = 0; i < slides.length; i++) { if (i == slides.length - 1) slides[i].nextSlide = slides[0]; else slides[i].nextSlide = slides[i + 1]; } slideshow.current = slides[0]; slides[0].fadeIn(); function SlideShowImage(img) { var currOpacity = 0; applyCurrOpacity(); this.fadeIn = function() { var i = 0; while (++i <= 50) { window.setTimeout(function() { addFade(0.02); }, i * faddingSpeed); } window.setTimeout(function() { slideshow.next(); }, 50 * faddingSpeed + stopTime); } this.fadeOut = function() { var i = 0; while (++i <= 50) { window.setTimeout(function() { addFade(-0.02); }, i * faddingSpeed); } } function applyCurrOpacity() { if ((navigator.appVersion.indexOf("MSIE")!= -1) && !window.opera) img.style.filter = 'alpha(opacity=' + (currOpacity * 100) + ')'; else img.style.opacity = currOpacity; } function addFade(value) { currOpacity += value; applyCurrOpacity(); } } } createSlides(slideel); }