var MailtoLink = Class.create({
  initialize: function(element) {
    this.element = $(element);
    this.location = 'mailto:' + element.readAttribute('mail').replace('__at__', '@').replace('__dot__', '.');
    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) {
    if (!window.PageEditor || !window.PageEditor.active)
      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);