title: Random Image refreshed after set time
body: <p>so earlier I asked about creating a javascript which automatically picks an image out of the a directory randomly. </p>
  
  <p>The script works perfectly, however. I would like to modify the script so that it picks an image at random to load (which it already does) then, after a set time like 10 seconds, will fade out and a new randomly picked image will fade in. </p>
  
  <p>Here is the existing code:</p>
  
  <pre><code>function randomImage() {
  
  var fileNames = [
      "1.jpg",
      "2.jpg",
      "3.jpg"
  ];
  
  var randomIndex = Math.floor(Math.random() * fileNames.length);
  
  document.getElementById("background").background = "backgrounds/" + fileNames[randomIndex];
  }
  </code></pre>
  
  <p>Thank you!</p>