/*
Plugin Name: Email Encryption
Plugin URI: http://www.fel.li/2006/10/18/email-encryption-in-wordpress/
Description: This plugin add an easy encryption to email addresses, so that spam bots do not recognize them anymore. The encryption is done by translating each character of the email address into a corresponding ASCII number, add 3 to that number and convert them back into a character. By doing so, the email address looses its typical format.
Author: Alexander Fell
Version: 0.1 alpha
Author URI: http://www.fel.li/
*/ 

/*  Copyright 2006  Alexander Fell  (email: alexanderfell@gmx.de)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

function UnCryptMailto(s) {
	var code   = 0;
	var result = "";
	for(var i=0; i<s.length; i++) {
		code=s.charCodeAt(i);
		if (code>=8364) {
			code = 128;
		}
		result += String.fromCharCode(code-3);
	}
	return result;
}

// JS function for uncrypting spam-protected emails:
function linkToUnCryptMailto(s) {
	var result = UnCryptMailto(s);
	location.href = result;
}

