title: Sequence of Image Changes on Refresh
body: <p><strong>EDIT</strong>: Found the error and fixed it, rather than colors.length it should be theImages.length. Thanks to those who helped.</p>
  
  <p>I got a problem with an array I've been using for a while to change certain images on my blog in a sequence every time you refresh the page. For instance, when you refresh my page, images 1A, 1B, and 1C change to 2A, 2B, and 2C, so on and so forth. After making around 4 different themes for my blog using this array with little to no problems, I'm making a theme which involves 6 different images, which is more than I've usually used. The images only have one alternate set, so when you refresh it goes back and forth between the sets. However, the images have stopped changing on refresh, and I'm stuck with <a href="http://trickorterratest.tumblr.com" rel="nofollow">this</a> for my theme when it's supposed to change on refresh. Does anyone have any idea on how to fix it? I've attached the code I've used, if anyone can help I'd be so grateful.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
              function refreshSequence() {
  
              //get current cookie value
              var currentIndex = parseInt(getCookie());
  
              //get image object
              var myImg = document.getElementById('SidebarIcon');
  
              //declare image directory path and image array
              var thePath = "https://";
              var theImages = ["31.media.tumblr.com/99731e8e83fb073cf39c9384137d9c1f/tumblr_inline_nesxwvNhwO1ql0f75.png", "31.media.tumblr.com/eb31394be711bc9acaae672d81dc979d/tumblr_inline_nesxx2Ay3R1ql0f75.png"]
  
              var imgPath = thePath + theImages[currentIndex];
              myImg.src = imgPath;
  
              //get image object
              var myImg = document.getElementById('SidebarPixel');
  
              //declare image directory path and image array
              var thePath = "https://";
              var theImages = ["31.media.tumblr.com/3c74b0cddf6eea3b464d2d1a7f34e597/tumblr_inline_nesxwgSnSv1ql0f75.png", "31.media.tumblr.com/de88145e72ccb2987d323f4ff8a607d8/tumblr_inline_nesxl0LzRO1ql0f75.png"]
  
              var imgPath = thePath + theImages[currentIndex];
              myImg.src = imgPath;
  
               //get image object
              var myImg = document.getElementById('SidebarGIF');
  
              //declare image directory path and image array
              var thePath = "http://";
              var theImages = ["static.tumblr.com/v2omgmu/bNEnejyu1/terrabg.gif", "static.tumblr.com/v2omgmu/SoXner1tt/terrabg2.gif"]
  
              var imgPath = thePath + theImages[currentIndex];
              myImg.src = imgPath;
  
              //get image object
              var myImg = document.getElementById('SidebarBG');
  
              //declare image directory path and image array
              var thePath = "http://";
              var theImages = ["static.tumblr.com/v2omgmu/LKZnelu4o/background.png", "http://static.tumblr.com/v2omgmu/1DTnesy9e/backgroundthang.png"]
  
              var imgPath = thePath + theImages[currentIndex];
              myImg.src = imgPath;
  
              //get image object
              var myImg = document.getElementById('NavIcon');
  
              //declare image directory path and image array
              var thePath = "https://";
              var theImages = ["31.media.tumblr.com/7b5bc574d9d829df1091687ed4fda3af/tumblr_inline_nesxxnEn5S1ql0f75.png", "31.media.tumblr.com/c083dc983293f5f37d5f827c636ca93f/tumblr_inline_nesxxyNUWz1ql0f75.png"]
  
              var imgPath = thePath + theImages[currentIndex];
              myImg.src = imgPath;
  
              //get image object
              var myImg = document.getElementById('SideThing');
  
              //declare image directory path and image array
              var thePath = "http://";
              var theImages = ["static.tumblr.com/v2omgmu/bgOnesvtn/terrasidething1.png", "static.tumblr.com/v2omgmu/y9nnesvuq/terrasidething2.png"]
  
              var imgPath = thePath + theImages[currentIndex];
              myImg.src = imgPath;
  
              //set next cookie index
              currentIndex += 1;
              currentIndex %= colors.length;
              setCookie(currentIndex);
          }
  
          function setCookie(someint) {
              var now = new Date();
              var addDays = now.getDate() + 7
              now.setDate(addDays); // cookie expires in 7 days
              var theString = 'imgID=' + escape(someint) + ';expires=' + now.toUTCString();
              document.cookie = theString;
          }
  
          function getCookie() {
              var output = "0";
              if(document.cookie.length &gt; 0) {
                  var temp = unescape(document.cookie);
                  temp = temp.split(';');
                  for(var i = 0; i &lt; temp.length; i++) {
                      if(temp[i].indexOf('imgID') != -1) {
                          temp = temp[i].split('=');
                          output = temp.pop();
                          break;
                      }
                  }
              }
              return output;
          }
  
  &lt;/script&gt;
  
  &lt;body onload="refreshSequence();"&gt;
  
  &lt;img id="SidebarIcon"&gt;
  &lt;img id="SidebarGIF"&gt; etc etc
  </code></pre>