// jquery.js
// standard extensions to jquery element object
(function($) {
  
  // protects mailto elements in this form <a class="mailto" href="user(at)domain(dot)tld">Foo</a>
  $.fn.mailTo = function() {
    return this.each(function(){
      // derive the mailto: value
      var email = $(this).attr('href').replace(/\(\w+\)/g, function(s) { return { '(dot)': '.', '(at)': '@' }[s]; });
      // anchor onclick event handler
      $(this).click(function(e){
        window.location.href = 'mailto:' + email;
        return false;
      });
    });
  };
  
})(jQuery);


