title: Javascript, change css background image when colour changes
body: <p>i made this script for my forum and i was wondering if someone could help me out, when the color changes to red, i want the background image to be:    </p>
  
  <p><code>/images/redshield.png</code> </p>
  
  <p>and on green </p>
  
  <p><code>/images/greenshield.png</code></p>
  
  <p>here is the script</p>
  
  <pre><code>function flashy(index) {
      setTimeout(function() {
          if (index &gt; 1) {
              index = 0;
              for (x = 0; x &lt; document.getElementsByClassName('style113').length; x++) {
                  document.getElementsByClassName('style113')[x].style.color = 'Lime';
              }
          } else {
              for (x = 0; x &lt; document.getElementsByClassName('style113').length; x++) {
                  document.getElementsByClassName('style113')[x].style.color = 'Red';
              }
          }
          index++;
          flashy(index);
      }, 100);
  }
  </code></pre>