title: how to make a slideshow repeat using javascript
body: <p>ok my slideshow is my body background and the imgs are in img tags like this </p>
  
  <pre><code> &lt;img name="pic" src="../../Content/images/bg.jpg" style="  width: 100%; position: absolute; top: 0; left: 0; z-index: -1;width: expression(document.body.clientWidth + 'px');   " alt=""/&gt;
  </code></pre>
  
  <p>my problem is it plays but then stops on the last image instead of being continuous </p>
  
  <p>also how would i implement a stop play prev next button a the top of the page that also controls the background 
  i dont want to download no plugins if possible
  thanks</p>
  
  <p>here is my code so far </p>
  
  <pre><code>  var pause = 3000;
  
  var n = 0;
  
  var imgs = new Array("bg.jpg", "bg2.jpg", "bg3.jpg", "bg4.jpg", "bg5.jpg", "bg6.jpg", "bg7.jpg", "bg8.jpg", "bg9.jpg", "bg10.jpg", "bg11.jpg");
  
  
  var preload = new Array();
  for (var i = 1; i &lt; imgs.length; i++ ) {
      preload[i] = new Image();
      preload[i].src = imgs[i];
  }
  
  var inc = -1
  
  function rotate() {
  
      document.images.pic.src = imgs[n];
      (n == (imgs.length - 1)) ? n = 0 : n++;
      setTimeout("rotate(0)", pause);
  }
  </code></pre>