﻿// class to cope with SpamSafeEmail - converts passed spam safe email address to clickable mailto
SpamSafeEmail = new Class({
	Implements:[Options],
	options: {
		unobs: [
		{re:/\(at\)/ig , txt:'@'},
		{re:/\(dot\)/ig, txt:'.'},
		{re:/\[at\]/ig , txt:'@'},
		{re:/\[dot\]/ig, txt:'.'},
		{re:/[\.]?invalid$/i, txt:''},
		{re:/\s+/g, txt:''},
		{re:/\s+info+/g, txt:''}
		]
	},

	initialize:function(el) {
		this.container = $(el);
		this.addr = this.container.get('html');
		this.options.unobs.each(function(r) {
			this.addr = this.addr.replace(r.re, r.txt);
		}, this);
		// setup the mail link
		this.container.set('href','mailto:'+this.addr);
		this.container.set('html',this.addr);
	}
});
