Simple Gallery Rotation with Mootools


I've was playing around with mootools and threw together a quick little function to do a fade in, fade out rotation of "layers" which would be just an image rotation or whatever you want to rotate. Here's the function: function startGalleryRotation(selector,delay){ var i = 0; var layers = $$(selector); delay = (delay == undefined)? 6000:delay; setInterval(function(){ layers[i].fade('out'); i = (i == layers.length-1)? 0 : i+1; layers[i].fade('in'); },delay); } To kick off this mighty beast we would then call: startGalleryRotation('#galleryRotation img',6000); Of course you will need to wait until the dom has loaded. Ok, wasn't much but thought I'd share!