title: Avoid repeat with Random Image Array - Cycle through all images first
body: <p>I've looked here and elsewhere to locate some help with no success. What is happening: the same image will display more than once in a row.  What I would like to happen: all images will be displayed at random before it starts over to display an image that has already displayed.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <pre><code>var total_images = 4;
  var random_number = Math.floor((Math.random()*total_images));
  var random_img = new Array();
  random_img[0] = '&lt;a href="/page1"&gt;&lt;img src="/images/img1.png"&gt;&lt;/a&gt;';
  random_img[1] = '&lt;a href="/page2"&gt;&lt;img src="/images/img2.png"&gt;&lt;/a&gt;';
  random_img[2] = '&lt;a href="/page2"&gt;&lt;img src="/images/img3.png"&gt;&lt;/a&gt;';
  random_img[3] = '&lt;a href="/page3"&gt;&lt;img src="/images/img4.jpg"&gt;&lt;/a&gt;';
  document.write(random_img[random_number]);
  </code></pre>