function moveToNextRight(fromsrcright,tosrcright) { new Effect.Move('imageBoxInsideRight', { x: 0, y: -245, transition: Effect.Transitions.sinoidal, duration:0.8 , beforeStart: function() { $('fromimgright').src = fromsrcright; $('toimgright').src = tosrcright; }, afterFinish: function() { new Effect.Move('imageBoxInsideRight', { x: 0, y: 245, duration:0 }); $('fromimgright').src = tosrcright; $('toimgright').src = tosrcright; } }); } function faderright(indexright){ nextindexright = (indexright+1) % RIGHT_ITEMS.length; moveToNextRight(RIGHT_ITEMS[indexright],RIGHT_ITEMS[nextindexright]); window.setTimeout("faderright(nextindexright)",3000); } if(RIGHT_ITEMS.length>1){ window.setTimeout("faderright(0)",3000); }