(function($){
  Drupal.behaviors.incubatorMapping = {
    attach: function() {
      $('img.leaflet-marker-icon.tweak').each(function() {
        var el = $(this).closest('div');
        var num = Math.floor(Math.random() * 24) - 12;
        var tf = el.css('transform')+' rotate('+num+'deg)';
        if ($(this).hasClass('ne')) { el.css({'transform-origin':'left bottom'}); }
        if ($(this).hasClass('nw')) { el.css({'transform-origin':'left bottom'}); }
        if ($(this).hasClass('se')) { el.css({'transform-origin':'left top'}); }
        if ($(this).hasClass('sw')) { el.css({'transform-origin':'left top'}); }
        el.once('tweak', function() {
          $(this).css({'transform':tf});
        });
      });
    }
  }
})(jQuery);
