// Fading Image Sequence PHP JavaScript Generator // For use with Mootools Javascript Library // WrightWay Design - www.wrightwaydesign.com.au periodicalCycle = new Class({ initialize: function(dateString){ this.startTimer(); }, updateCount: function(){ nextImage(); }, stopTimer: function(){ $clear(this.periodicalTimer); }, startTimer: function(){ this.periodicalTimer = this.updateCount.periodical(5000, this); } }); function nextImage() { var oldImage = currentImage; if (currentImage == 'imgOne') { currentImage='imgTwo'; } else { currentImage='imgOne'; } $(oldImage).setStyle('zIndex','1'); $(currentImage).setStyle('zIndex','2'); this.fadeEffect = new Fx.Style($(currentImage), 'opacity', { duration: 1500 } ); this.fadeEffect.addEvent('onComplete', function() { if (headerCount == (headerPhotos.length - 1)) { headerCount = 0; } else { headerCount++; } $(oldImage).setStyle('opacity','0'); $(oldImage).setStyle('background-image', 'url('+headerPhotos[headerCount].src+')'); }); this.fadeEffect.start(0,1); } function startSequence() { imgTimer = new periodicalCycle; } var headerPhotos; var headerCount = 0; var imgTimer; var currentImage = 'imgOne'; window.addEvent('domready', function() { var count = 0; $('imgTwo').setStyle('opacity',0); $('imgTwo').setStyle('display','block'); headerPhotos = new Asset.images(['/images/panels/01-Lounge-2.jpg','/images/panels/02-Bedroom-5.jpg','/images/panels/03-Kitchen-1.jpg','/images/panels/04-Lounge-3.jpg','/images/panels/05-Bedroom-3.jpg','/images/panels/06-Logo-Timber1.jpg','/images/panels/07-Bedroom-6.jpg'], { onProgress: function() { if (count == 2) { startSequence(); } count++; } }); });