YAHOO.util.Event.onDOMReady(function (ev) { /* Assign 3 shells to the visible container. */ document.shells = YAHOO.util.Dom.getChildren('visible_shell_container'); document.shells[0].style.left = '0px'; document.shells[0].id = 'shell0'; $(document.shells[0].id).show(); document.shells[1].style.left = '282px'; document.shells[1].id = 'shell1'; $(document.shells[1].id).show(); document.shells[2].style.left = '562px'; document.shells[2].id = 'shell2'; $(document.shells[2].id).show(); setTimeout("replaceShell(0); setInterval('replaceShell(0)', 12000)", 4000); setTimeout("replaceShell(2); setInterval('replaceShell(2)', 12000)", 8000); setTimeout("replaceShell(1); setInterval('replaceShell(1)', 12000)", 12000); }); function getInvisibleShell() { var chosen_shell = null; do { var random_index = Math.floor(Math.random() * (document.shells.length)); chosen_shell = document.shells[random_index]; } while (chosen_shell.style.display != 'none'); return chosen_shell; } function replaceShell(index) { var new_shell = getInvisibleShell(); var left_val = '0px'; if (index == 1) left_val = '282px'; else if (index == 2) left_val = '562px'; var shell = YAHOO.util.Dom.get('shell' + index); shell.id = ''; Effect.Fade(shell, {duration: 2.0}); new_shell.id = 'shell' + index; new_shell.style.left = left_val; Effect.Appear(new_shell, {duration: 2.0}); }