$(document).ready(function(){

  /**
   * external links
   *
   * filters href != hostname or rel="external"
   * adds .external to elements not containing img, div or mailto
   * opens external links in new window/tab
   */

  $('a, area').filter(function() {
    return this.hostname && (this.hostname).split(":")[0] !== (location.hostname).split(":")[0] || $(this).attr('rel') == 'external';
  })
  .not(':has(img, div, mailto)')
  .addClass('external')
  .end()
  .click(function(e) {
    open(this.href); 
    e.preventDefault();
  });

});
