var actual = 1; var total = 9; var timeout = 8000; function cycle() { actual++; var old = actual - 1; if (actual == total + 1) { actual = 1; old = total; } $("#b" + old + "_t").animate({ width: 0, opacity: 0 }, 600, function() { $("#b" + old + "_n").animate({ opacity: 0 }, 250, function() { $("#b" + old).fadeOut(1000, function() { }); $("#b" + actual + "_t").css('width', 0); $("#b" + actual + "_t").css('opacity', 0); $("#b" + actual + "_n").css('opacity', 0); $("#b" + actual).fadeIn(1000, function() { $("#b" + actual + "_n").animate({ opacity: 0.85 }, 250, function() { $("#b" + actual + "_t").animate({ width: 500, opacity: 0.7 }, 600, function() { }); }); }); }); }); setTimeout('cycle();', timeout); } $(document).ready(function() { $("#b1_n").css('opacity', 0.85); $("#b1_t").css('opacity', 0.7); setTimeout('cycle();', timeout); $('a.showimage').zoomimage({ border: 1, centered: true, hideSource: false, shadow: 5, controlsTrigger: 'mouseover', controls: false }); });