var Wii = window.Wii || {};

Wii.html = window.Wii.html || {};

Wii.html.preloader = (function(){
  var f = function(){
    $(window).load(function(){
      Wii.html.imagePreloader.flush();
    });
    var imageStack = [];
    this.add = function(src, classHash){
      imageStack.push({src: src, hash: classHash});
    }
    this.flush = function(){
      for(var i in imageStack){
        var imageObj = imageStack[i]; //img = new Image;
        $('img.'+imageObj.hash).attr('src', imageObj.src);
      }
    }
  }
  return f;
}());

Wii.html.imagePreloader = new Wii.html.preloader;
