/** * Jayda(R) script for header slides within a Joomla! environment. * * (C) 2013 by Jayda Solutions UG (haftungsbeschränkt). * All rights reserved. * * WWW: http://www.jayda.eu * eMail: contact@jayda.eu */ function JaydaHeaderSlides(elemImg, sBasePath, iSlideDelay, iFadeStep) { this.elemImg = elemImg; this.sBasePath = sBasePath; this.iSlideDelay = iSlideDelay; this.iFadeStep = iFadeStep; this.slideImages = new Array(); this.slidePaths = [ "images/slides//IMG_6087.jpg", "images/slides//IMG_6145.jpg", "images/slides//IMG_6318.jpg", "images/slides//IMG_6450.jpg", ]; } JaydaHeaderSlides.prototype.elemImg = null; JaydaHeaderSlides.prototype.sBasePath = null; JaydaHeaderSlides.prototype.slidePaths = null; JaydaHeaderSlides.prototype.slideImages = null; JaydaHeaderSlides.prototype.iSlideDelay = 0; JaydaHeaderSlides.prototype.iFadeStep = 0; JaydaHeaderSlides.prototype.startSlideShow = function(iIndex) { var self = this; // When the image has been loaded, fade out the old one, // switch the image source, and fade it in again. function imageLoaded(evt) { fadeOut(self.elemImg.id, function() { self.elemImg.src = img.src; fadeIn(self.elemImg.id, function() { window.setTimeout(function() { self.startSlideShow(iIndex + 1); }, self.iSlideDelay); }); }); }; // Get image from cache or lazily load it iIndex = (iIndex >= this.slidePaths.length ? 0 : iIndex); var sImgPath = this.sBasePath + "/" + this.slidePaths[iIndex]; var img = self.slideImages[sImgPath]; if (!img) { img = new Image(); img.src = sImgPath; this.slideImages[sImgPath] = img; img.onload = imageLoaded; } else { imageLoaded(null); } };