var rep = []; var cur = 0; var INTERVAL = 3800; var SPEED = 50; var STEP = 2; var op = 100; var fader = null; var swapper = null; var next; var acontinue = true; window.alert = function ( str ) { acontinue = (acontinue && confirm ( str ) ); } function addToRepository ( img ) { rep.push(img); } function startFader () { if ( rep.length > 0 ) { rep[cur].style.visibility='visible'; if ( rep.length > 1 ) { swapper = setTimeout ( 'swapImg()', INTERVAL ); } } } function swapImg () { next = cur +1; if ( !(next in rep) ) { next = 0; } rep[cur].style.zIndex = 2; rep[next].style.zIndex = 1; rep[next].style.filter='alpha(opacity=100)'; rep[next].style.opacity=1; rep[next].style.MozOpacity=1; rep[next].style.visibility='visible'; fader = setInterval ( 'fadeOut()', SPEED ); } function fadeOut () { rep[cur].style.filter='alpha(opacity=' + op + ')'; rep[cur].style.opacity= (op/100); rep[cur].style.MozOpacity= (op/100); op -= STEP; if ( op == 0 ) { rep[cur].style.visibility='hidden'; clearInterval ( fader ); fader = null; cur = next; op = 100; swapper = setTimeout ( 'swapImg()', INTERVAL ); } }