(function() {
  var HoverImage;
  HoverImage = (function() {
    function HoverImage(img) {
      this.element = $(img);
      this.path = this.element.getAttribute('src');
      this.chop = this.element.getAttribute('data-chop') || '';
      this.suffix = this.element.getAttribute('data-suffix') || '-hover';
      this.hover_path = this.path.replace(new RegExp("" + this.chop + "(\.[^\.]+)$"), "" + this.suffix + "$1");
      this.element.observe('mouseover', this.hover.bind(this));
      this.element.observe('mouseout', this.unhover.bind(this));
      this.preload = new Image();
      this.preload.setAttribute('src', this.hover_path);
    }
    HoverImage.prototype.hover = function() {
      if (!this.hovering()) {
        return this.element.setAttribute('src', this.hover_path);
      }
    };
    HoverImage.prototype.unhover = function() {
      if (this.hovering()) {
        return this.element.setAttribute('src', this.path);
      }
    };
    HoverImage.prototype.hovering = function() {
      return this.element.getAttribute('src').endsWith(this.hover_path);
    };
    return HoverImage;
  })();
  $(document).observe('dom:loaded', function() {
    return $$('.hover').each(function(e) {
      return new HoverImage(e);
    });
  });
}).call(this);

