var MailtoLink = Class.create({
  initialize: function(element) {
    this.element = $(element);
    this.email = element.readAttribute('mail').replace('__at__', '@').replace('__dot__', '.')
    this.location = 'mailto:' + this.email;
    if (this.element.innerHTML.strip() == '&nbsp;' || this.element.innerHTML.strip() == '')
      this.element.update(this.email);
    this.element.setAttribute('href', 'javascript:void(0)')
    this.element.observe('mouseover', this.mouseover.bind(this));
    this.element.observe('mouseout', this.mouseout.bind(this));
    this.element.observe('click', this.click.bind(this));
    this.element.mailtoLinkObj = this;
  },
  mouseover: function() {
    window.status = this.location;
  },
  mouseout: function() {
    window.status = '';
  },
  click: function(event) {
    window.location.href = this.location;
    return event.stop();
  }
});
var setupMailtoLinks = function() {
  $$('a[mail]').each(function(element) {
    if (!element.mailtoLinkObj)
      new MailtoLink(element);
  });
}
Event.observe(window, 'load', setupMailtoLinks);
