// You need these vars var paused = false; var delay = 9000; /* * The function below is a "daemon" function; it must be started from * document.onload or or equivalent. * It will call itself and execute "the contents" if not paused. **/ function slide() { if( !paused ) { // if not paused do this: $j("#image").load("slideshow.php").fadeIn('slow').animate({opacity: 1.0}, 3000).fadeOut('slow'); $j("#left_thumb").load("thumbs.php"); $j("#right_thumb").load("thumbs.php"); } // this line makes sure the slide() function is called every 9000 ms window.setTimeout(function() { slide(); }, delay); }