// JavaScript Document
 (function ($) {
   $.extend($, {
     cacheImage: function (src, options) {
       if (typeof src === 'object') {
         $.each(src, function () {
           $.cacheImage(String(this), options);
         });
       }

       var image = new Image();

       options = options || {};

       $.each(['load', 'error', 'abort'], function () { // Callbacks
         var e = String(this);
         if (typeof options[e] === 'function') { $(image)[e](options[e]); }
       });

       image.src = src;

       return image;
     }
   });

   $.extend($.fn, {
     cacheImage: function (options) {
       return this.each(function () {
         $.cacheImage(this.src, options);
       });
     }
   });
 })(jQuery);