text: ;(function (window, document) {
  
      'use strict';
  
      var defaultWidths, getKeys, nextTick, addEvent, getNaturalWidth;
  
      nextTick = window.requestAnimationFrame ||
                 window.mozRequestAnimationFrame ||
                 window.webkitRequestAnimationFrame ||
                 function (callback) {
                     window.setTimeout(callback, 1000 / 60);
                 };
  
      function applyEach (collection, callbackEach) {
          var i = 0,
              length = collection.length,
              new_collection = [];
  
          for (; i < length; i++) {
              new_collection[i] = callbackEach(collection[i], i);
          }
  
          return new_collection;
      }
  
      function returnDirectValue (value) {
        return value;
      }
  
      getNaturalWidth = (function(){
          if (Object.prototype.hasOwnProperty.call(document.createElement('img'), 'naturalWidth')) {
              return function (image){ return image.naturalWidth;};
          }
          // IE8 and below lacks the naturalWidth property
          return function (source){
              var img = document.createElement('img');
              img.src = source.src;
              return img.width;
          };
      })();
  
      addEvent = (function(){
          if (document.addEventListener){
              return function addStandardEventListener(el, eventName, fn){
                  return el.addEventListener(eventName, fn, false);
              };
          }
          else {
              return function addIEEventListener(el, eventName, fn){
                  return el.attachEvent('on'+eventName, fn);
              };
          }
      })();
  
      defaultWidths = [96, 130, 165, 200, 235, 270, 304, 340, 375, 410, 445, 485, 520, 555, 590, 625, 660, 695, 736];
  
      getKeys = typeof Object.keys === 'function' ? Object.keys : function (object) {
          var keys = [],
              key;
  
          for (key in object) {
              keys.push(key);
          }
  
          return keys;
      };
  
  
      /*
          Construct a new Imager instance, passing an optional configuration object.
  
          Example usage:
  
              {
                  // Available widths for your images
                  availableWidths: [Number],
  
                  // Selector to be used to locate your div placeholders
                  selector: '',
  
                  // Class name to give your resizable images
                  className: '',
  
                  // If set to true, Imager will update the src attribute of the relevant images
                  onResize: Boolean,
  
                  // Toggle the lazy load functionality on or off
                  lazyload: Boolean,
  
                  // Used alongside the lazyload feature (helps performance by setting a higher delay)
                  scrollDelay: Number
              }
  
          @param {object} configuration settings
          @return {object} instance of Imager
       */
      function Imager (elements, opts) {
          var self = this,
              doc  = document;
  
          opts = opts || {};
  
          if (elements !== undefined) {
              // first argument is selector string
              if (typeof elements === 'string') {
                  opts.selector = elements;
                  elements = undefined;
              }
  
              // first argument is the `opts` object, `elements` is implicitly the `opts.selector` string
              else if (typeof elements.length === 'undefined') {
                  opts = elements;
                  elements = undefined;
              }
          }
  
          this.imagesOffScreen  = [];
          this.viewportHeight   = doc.documentElement.clientHeight;
          this.selector         = opts.selector || '.delayed-image-load';
          this.className        = opts.className || 'image-replace';
          this.gif              = doc.createElement('img');
          this.gif.src          = 'data:image/gif;base64,R0lGODlhEAAJAIAAAP///wAAACH5BAEAAAAALAAAAAAQAAkAAAIKhI+py+0Po5yUFQA7';
          this.gif.className    = this.className;
          this.gif.alt          = '';
          this.scrollDelay      = opts.scrollDelay || 250;
          this.onResize         = opts.hasOwnProperty('onResize') ? opts.onResize : true;
          this.lazyload         = opts.hasOwnProperty('lazyload') ? opts.lazyload : false;
          this.scrolled         = false;
          this.availablePixelRatios = opts.availablePixelRatios || [1, 2];
          this.availableWidths  = opts.availableWidths || defaultWidths;
          this.onImagesReplaced = opts.onImagesReplaced || function () {};
          this.widthsMap        = {};
          this.refreshPixelRatio();
          this.widthInterpolator = opts.widthInterpolator || returnDirectValue;
  
          // Needed as IE8 adds a default `width`/`height` attribute…
          this.gif.removeAttribute('height');
          this.gif.removeAttribute('width');
  
          if (typeof this.availableWidths !== 'function'){
            if (typeof this.availableWidths.length === 'number') {
              this.widthsMap = Imager.createWidthsMap(this.availableWidths, this.widthInterpolator);
            }
            else {
              this.widthsMap = this.availableWidths;
              this.availableWidths = getKeys(this.availableWidths);
            }
  
            this.availableWidths = this.availableWidths.sort(function (a, b) {
              return a - b;
            });
          }
  
  
  
          if (elements) {
              this.divs = applyEach(elements, returnDirectValue);
              this.selector = null;
          }
          else {
              this.divs = applyEach(doc.querySelectorAll(this.selector), returnDirectValue);
          }
  
          this.changeDivsToEmptyImages();
  
          nextTick(function(){
              self.init();
          });
      }
  
      Imager.prototype.scrollCheck = function(){
          if (this.scrolled) {
              if (!this.imagesOffScreen.length) {
                  window.clearInterval(this.interval);
              }
  
              this.divs = this.imagesOffScreen.slice(0); // copy by value, don't copy by reference
              this.imagesOffScreen.length = 0;
              this.changeDivsToEmptyImages();
              this.scrolled = false;
          }
      };
  
      Imager.prototype.init = function(){
          this.initialized = true;
          this.checkImagesNeedReplacing(this.divs);
  
          if (this.onResize) {
              this.registerResizeEvent();
          }
  
          if (this.lazyload) {
              this.registerScrollEvent();
          }
      };
  
      Imager.prototype.createGif = function (element) {
          // if the element is already a responsive image then we don't replace it again
          if (element.className.match(new RegExp('(^| )' + this.className + '( |$)'))) {
              return element;
          }
  
          var elementClassName = element.getAttribute('data-class');
          var elementWidth = element.getAttribute('data-width');
          var gif = this.gif.cloneNode(false);
  
          if (elementWidth) {
            gif.width = elementWidth;
            gif.setAttribute('data-width', elementWidth);
          }
  
          gif.className = (elementClassName ? elementClassName + ' ' : '') + this.className;
          gif.setAttribute('data-src', element.getAttribute('data-src'));
          gif.setAttribute('alt', element.getAttribute('data-alt') || this.gif.alt);
  
          element.parentNode.replaceChild(gif, element);
  
          return gif;
      };
  
      Imager.prototype.changeDivsToEmptyImages = function(){
          var self = this;
  
          applyEach(this.divs, function(element, i){
              if (self.lazyload) {
                  if (self.isThisElementOnScreen(element)) {
                      self.divs[i] = self.createGif(element);
                  } else {
                      self.imagesOffScreen.push(element);
                  }
              } else {
                  self.divs[i] = self.createGif(element);
              }
          });
  
          if (this.initialized) {
              this.checkImagesNeedReplacing(this.divs);
          }
      };
  
      Imager.prototype.isThisElementOnScreen = function (element) {
          // document.body.scrollTop was working in Chrome but didn't work on Firefox, so had to resort to window.pageYOffset
          // but can't fallback to document.body.scrollTop as that doesn't work in IE with a doctype (?) so have to use document.documentElement.scrollTop
          var offset = Imager.getPageOffset();
          var elementOffsetTop = 0;
  
          if (element.offsetParent) {
              do {
                  elementOffsetTop += element.offsetTop;
              }
              while (element = element.offsetParent);
          }
  
          return (elementOffsetTop < (this.viewportHeight + offset)) ? true : false;
      };
  
      Imager.prototype.checkImagesNeedReplacing = function (images) {
          var self = this;
  
          if (!this.isResizing) {
              this.isResizing = true;
              this.refreshPixelRatio();
  
              applyEach(images, function(image){
                  self.replaceImagesBasedOnScreenDimensions(image);
              });
  
              this.isResizing = false;
              this.onImagesReplaced(images);
          }
      };
  
      Imager.prototype.replaceImagesBasedOnScreenDimensions = function (image) {
          var computedWidth, src, naturalWidth;
  
          naturalWidth = getNaturalWidth(image);
          computedWidth = typeof this.availableWidths === 'function' ? this.availableWidths(image)
                                                                     : this.determineAppropriateResolution(image);
  
          image.width = computedWidth;
  
          if (image.src !== this.gif.src && computedWidth <= naturalWidth) {
              return;
          }
  
          src = this.changeImageSrcToUseNewImageDimensions(image.getAttribute('data-src'), computedWidth);
  
          image.src = src;
      };
  
      Imager.prototype.determineAppropriateResolution = function (image) {
        return Imager.getClosestValue(image.getAttribute('data-width') || image.parentNode.clientWidth, this.availableWidths);
      };
  
      /**
       * Updates the device pixel ratio value used by Imager
       *
       * It is performed before each replacement loop, in case a user zoomed in/out
       * and thus updated the `window.devicePixelRatio` value.
       *
       * @api
       * @since 1.0.1
       */
      Imager.prototype.refreshPixelRatio = function refreshPixelRatio(){
          this.devicePixelRatio = Imager.getClosestValue(Imager.getPixelRatio(), this.availablePixelRatios);
      };
  
      Imager.prototype.changeImageSrcToUseNewImageDimensions = function (src, selectedWidth) {
          return src
              .replace(/{width}/g, Imager.transforms.width(selectedWidth, this.widthsMap))
              .replace(/{pixel_ratio}/g, Imager.transforms.pixelRatio(this.devicePixelRatio));
      };
  
      Imager.getPixelRatio = function getPixelRatio(context){
          return (context || window)['devicePixelRatio'] || 1;
      };
  
      Imager.createWidthsMap = function createWidthsMap (widths, interpolator) {
          var map = {},
              i   = widths.length;
  
          while (i--) {
              map[widths[i]] = interpolator(widths[i]);
          }
  
          return map;
      };
  
      Imager.transforms = {
          pixelRatio: function (value) {
              return value === 1 ? '' : '-' + value + 'x';
          },
          width: function (width, map) {
              return map[width] || width;
          }
      };
  
      /**
       * Returns the closest upper value.
       *
       * ```js
       * var candidates = [1, 1.5, 2];
       *
       * Imager.getClosestValue(0.8, candidates); // -> 1
       * Imager.getClosestValue(1, candidates); // -> 1
       * Imager.getClosestValue(1.3, candidates); // -> 1.5
       * Imager.getClosestValue(3, candidates); // -> 2
       * ```
       *
       * @api
       * @since 1.0.1
       * @param {Number} baseValue
       * @param {Array.<Number>} candidates
       * @returns {Number}
       */
      Imager.getClosestValue = function getClosestValue(baseValue, candidates){
          var i             = candidates.length,
              selectedWidth = candidates[i - 1];
  
          baseValue = parseFloat(baseValue, 10);
  
          while (i--) {
              if (baseValue <= candidates[i]) {
                  selectedWidth = candidates[i];
              }
          }
  
          return selectedWidth;
      };
  
      Imager.prototype.registerResizeEvent = function(){
          var self = this;
  
          addEvent(window, 'resize', function(){
              self.checkImagesNeedReplacing(self.divs);
          });
      };
  
      Imager.prototype.registerScrollEvent = function (){
          var self = this;
  
          this.scrolled = false;
  
          this.interval = window.setInterval(function(){
              self.scrollCheck();
          }, self.scrollDelay);
  
          addEvent(window, 'scroll', function(){
              self.scrolled = true;
          });
      };
  
      Imager.getPageOffsetGenerator = function getPageVerticalOffset(testCase){
          if(testCase){
              return function(){ return window.pageYOffset; };
          }
          else {
              return function(){ return document.documentElement.scrollTop; };
          }
      };
  
      // This form is used because it seems impossible to stub `window.pageYOffset`
      Imager.getPageOffset = Imager.getPageOffsetGenerator(Object.prototype.hasOwnProperty.call(window, 'pageYOffset'));
  
      // Exporting for testing purpose
      Imager.applyEach = applyEach;
  
      /* global module, exports: true, define */
      if (typeof module === 'object' && typeof module.exports === 'object') {
          // CommonJS, just export
          module.exports = exports = Imager;
      } else if (typeof define === 'function' && define.amd) {
          // AMD support
          define(function () { return Imager; });
      } else if (typeof window === 'object') {
          // If no AMD and we are in the browser, attach to window
          window.Imager = Imager;
      }
      /* global -module, -exports, -define */
  
  }(window, document));
  