title: I can't get my image slideshow to work using JavaScript
body: <p>I am trying to create a simple image slideshow type thing with the Javascript code below, but what it is doing is displaying the first image in the webpage with everything else, then after 5 seconds clearing the page and displaying the <em>same</em> image, then again every 5 seconds except it doesn't clear the page anymore.</p>
  
  <p>The JavaScript:</p>
  
  <pre><code>var waiPics=new Array();
  waiPics[0]='images/path.jpg';
  waiPics[1]='images/gorse.jpg';
  waiPics[2]='images/stream.jpg';
  waiPics[3]='images/pines.jpg';
  waiPics[4]='images/stump.jpg';
  
  var time;
  
  function timeUp() {
      delete document.write();
      nextPic();
  }
  
  
  
  function nextPic() {
      var picNum=0;
  if (picNum = waiPics.length) {
      picNum=0;
  }
  else {
      picNum++;
  } 
      document.write('&lt;img src="'+waiPics[picNum]+'" title="Waipahihi" alt="Waipahihi"&gt;');
      time=setTimeout("timeUp()",5000);
  }
  </code></pre>
  
  <p>The HTML:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  &lt;!-- Begin
  nextPic();
  //  End --&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>Im not very experienced with Javascript, so thanks in advance for the help.</p>