﻿jQuery.fn.nospam = function(settings) {
	settings = jQuery.extend({}, settings);

	return this.each(function() {
		var e = null;
		var bReplaceText = false;

		if ($(this).is('a[rel]')) {
			e = $(this).attr('rel').split('').reverse().join('').replace('//', '@').replace(/\//g, '.');
		} else {
			e = $(this).text().split('').reverse().join('').replace('//', '@').replace(/\//g, '.');
		}

		if ($(this).hasClass('smlReplaceText')) {
			bReplaceText = true;
		}

		if (e) {
			if ($(this).is('a[rel]')) {
				$(this).attr('href', 'mailto:' + e);
				if (bReplaceText) {
					$(this).text(e);
				}
			} else {
				$(this).text(e);
			}
		}
	});
};

$(document).ready(function() {
	$('a.smlApplied').nospam();
});