title: Javascript image loader fails in Firefox
body: <p>I am preloading images in Javascript, and it works great in Chrome, IE and Safari, but fails in Firefox with the following error:
  "NS_ERROR_NOT_AVAILABLE:"</p>
  
  <p>I'm using the following function to load images:</p>
  
  <pre><code>function loadImages(sources, callback) {
    var loadedImages = 0;
    var numImages = 0;
    // get num of sources
    for(var src in sources) {
      numImages++;
    }
    for(var src in sources) {
      images[src] = new Image();
      images[src].onload = function() {
        if(++loadedImages &gt;= numImages) {
          callback();
        }
      };
      images[src].src = sources[src];
    }}
  </code></pre>
  
  <p>And I set up the image array and call the image loader like this:</p>
  
  <pre><code>var sources = {
    blockBorder0: 'images/BlockBorder_1.jpg',
    blockBorder1: 'images/BlockBorder_2.jpg' };
  loadImages(sources, startRender);
  </code></pre>
  
  <p>Why does it fail on Firefox when it works great on all the other browsers? I put some debug statements out to the console and I see the for loop loading all of the images in Firefox.</p>