title: Set Timeout for screensaver
body: <p>I have need a set timeout that will set the timeout after a inactive time, and then        initiate a screensaver, which plays a carousel of slides, when the user clicks on the screen it will restart the process with while starting the carousel back at the start of the slideshow. below is my code, any help is much appreciated thanks!</p>
  
  <pre><code>&lt;script&gt;
      /* The redirect to autoplay page function */
      var screenSaverDelay;
      var screenSaver;
      var destroySlider;
  
      $(document).ready(function(){
  
       setInterval(function(){window.focus();},1000);
       $('.bxslider').bxSlider();
  
      //var screenSaverDelay;
  
       $('body').click(function(event) {
         killScreenSaver();
       });
  
      function startScreenSaver() {
          clearTimeout(screenSaver);
          screenSaver=setTimeout(startScreenSaver,1000);
          $('#screensaver').show();
          $('.bxslider').bxSlider();
      }//end
  
     function killScreenSaver() {
        $('#screensaver').hide();
        $('.bxslider').destroySlider();
        clearTimeout(screenSaver);
        screenSaver=setTimeout(killScreenSaver,300000);
      }//end
  
      $(document).ready(function(){
      setInterval(function(){window.focus();},1000);
      });
      startScreenSaver();
      });
  
  &lt;/script&gt;
  </code></pre>