(function($) {
  return $.extend($.fn, {
    window_open_blank: function() {
      return this.each(function() {
        if (!this.href.match(document.domain)) {
          return $(this).click(function() {
            window.open(this.href, 'blank').focus();
            return false;
          });
        }
      });
    },
    active_navigation: function(class_name) {
      if (class_name == null) {
        class_name = 'active';
      }
      return this.each(function() {
        var el;
        el = $(this);
        if (location.pathname.match(el.attr('href'))) {
          return el.addClass(class_name);
        }
      });
    },
    round_image_corners: function(radius) {
      if (radius == null) {
        radius = '5px';
      }
      return this.each(function() {
        var img;
        img = $(this);
        return img.images_loaded(function() {
          var div;
          div = $('<div>').css({
            'width': img.width(),
            'height': img.height(),
            'background': "url('" + (img.attr('src')) + "') no-repeat 0 0",
            'border-radius': radius,
            '-moz-border-radius': radius,
            '-webkit-border-radius': radius
          });
          return img.replaceWith(div);
        });
      });
    },
    images_loaded: function(callback) {
      var count, elems;
      elems = this.filter('img');
      count = 0;
      elems.bind('load', function() {
        return callback.call(elems, this, ++count);
      }).each(function() {
        var src;
        if (this.complete || this.complete === void 0) {
          src = this.src;
          this.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
          return this.src = src;
        }
      });
      return this;
    }
  });
})(jQuery);
