/*
 * jQuery SPEmail plug-in 1.0
 * (c) 2008 Richard Chiriboga
 * Inspired by David Walsh's blog on spam proofing emails using moo tools.
 *
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
*/
$.fn.spemail = function(opt,type){
	var opt_in = opt.split(",");
	var type;
	
	if (type == "linkbase")
	{
		this.each(function() {
			el = $(this);
			el.each(function(){
			el.attr('href','mailto:' + el.attr('href').replace(opt_in[0],'@').replace(opt_in[1],'.'));
			el.attr('title',el.attr('href').replace(opt_in[0],'@').replace(opt_in[1],'.').replace('mailto.','Email: '));
			el.html(el.attr('href').replace(opt_in[0],'@').replace(opt_in[1],'.').replace('mailto.','').replace('mailto:',''));
			});
		});
	}
	else if(type == "mailbase") {
		this.each(function() {
			el = $(this);
			el.each(function(){
			el.html('<a href="mailto:'+el.html().replace(opt_in[0],'@').replace(opt_in[1],'.')+'" title="Email: '+el.html().replace(opt_in[0],'@').replace(opt_in[1],'.')+'">'+el.html().replace(opt_in[0],'@').replace(opt_in[1],'.')+'</a>');
			});
		});
	}
	else if(type == "plainbase") {
		this.each(function() {
			el = $(this);
			el.each(function(){
			el.html(el.html().replace(opt_in[0],'@').replace(opt_in[1],'.'));
			});
		});
	}
};

(function($) {
	$('.ema').spemail('///,///','mailbase');
})(jQuery);
