/* EMAIL ENCRYPTION SCRIPT */

// This script is (c) copyright 2008 by Dan Appleman under the
// GNU General Public License (http://www.gnu.org/licenses/gpl.html)
// This script is modified from an original script by Jim Tucek
// For more information, visit www.danappleman.com 
// Leave the above comments alone!
// see encryption_instructions.txt for explanation of usage

var decryption_cache = new Array();

function decrypt_string(crypted_string,n,decryption_key,just_email_address) {
	var cache_index = "'"+crypted_string+","+just_email_address+"'";

	if(decryption_cache[cache_index])					// If this string has already been decrypted, just
		return decryption_cache[cache_index];				// return the cached version.

	if(addresses[crypted_string])						// Is crypted_string an index into the addresses array
		var crypted_string = addresses[crypted_string];			// or an actual string of numbers?

	if(!crypted_string.length)						// Make sure the string is actually a string
		return "Error, not a valid index.";

	if(n == 0 || decryption_key == 0) {					// If the decryption key and n are not passed to the
		var numbers = crypted_string.split(' ');			// function, assume they are stored as the first two
		n = numbers[0];	decryption_key = numbers[1];			// numbers in crypted string.
		numbers[0] = ""; numbers[1] = "";				// Remove them from the crypted string and continue
		crypted_string = numbers.join(" ").substr(2);
	}

	var decrypted_string = '';
	var crypted_characters = crypted_string.split(' ');

	for(var i in crypted_characters) {
		var current_character = crypted_characters[i];
		var decrypted_character = exponentialModulo(current_character,n,decryption_key);
		if(just_email_address && i < 7)				// Skip 'mailto:' part
			continue;
		if(just_email_address && decrypted_character == 63)	// Stop at '?subject=....'
			break;
		decrypted_string += String.fromCharCode(decrypted_character);
	}
		decryption_cache[cache_index] = decrypted_string;			// Cache this string for any future calls

	return decrypted_string;
}

function decrypt_and_email(crypted_string,n,decryption_key) {
	if(!n || !decryption_key) { n = 0; decryption_key = 0; }
	if(!crypted_string) crypted_string = 0;

	var decrypted_string = decrypt_string(crypted_string,n,decryption_key,false);
	parent.location = decrypted_string;
}

function decrypt_and_echo(crypted_string,n,decryption_key) {
	if(!n || !decryption_key) { n = 0; decryption_key = 0; }
	if(!crypted_string) crypted_string = 0;

	var decrypted_string = decrypt_string(crypted_string,n,decryption_key,true);
	document.write(decrypted_string);
	return true;
}

// Finds base^exponent % y for large values of (base^exponent)
function exponentialModulo(base,exponent,y) {
	if (y % 2 == 0) {
		answer = 1;
		for(var i = 1; i <= y/2; i++) {
			temp = (base*base) % exponent;
			answer = (temp*answer) % exponent;
		}
	} else {
		answer = base;
		for(var i = 1; i <= y/2; i++) {
			temp = (base*base) % exponent;
			answer = (temp*answer) % exponent;
		}
	}
	return answer;
}

// Remove the comments below to improve spam resistance! 
// email addresses: 

 if(!addresses) var addresses = new Array();
addresses.push("22927 22921 16448 12277 1661 17532 237 4757 8278 17566 12277 22840 237 4757 22302 237 1661 16448 22840 9476 12277 14767 4248 22840 10830 12288 16448 12277 1661 17532 1376 3771 4757 16448");  // [0] pastortim
addresses.push("22927 22921 16448 12277 1661 17532 237 4757 8278 12277 22302 16448 3771 7978 12277 14767 1661 6565 17532 10830 16448 22840 14767 1376 3771 4757 16448");  // [1] armcdaniel
addresses.push("22927 22921 16448 12277 1661 17532 237 4757 8278 18562 12880 6335 1376 6335 6335 3771 17532 12277 22840 22840 10830 12288 16448 12277 1661 17532 1376 3771 4757 16448");  // [2] GBC.CCclass
addresses.push("22927 22921 16448 12277 1661 17532 237 4757 8278 3437 3169 4872 6612 10830 12288 16448 12277 1661 17532 1376 3771 4757 16448");  // [3] 2781
addresses.push("22927 22921 16448 12277 1661 17532 237 4757 8278 7978 12277 4033 14767 10467 12277 12288 4757 4757 7978 6565 10830 12288 16448 12277 1661 17532 1376 3771 4757 16448");  // [4] dawnyagoode
addresses.push("22927 22921 16448 12277 1661 17532 237 4757 8278 3771 12277 22302 12277 17566 12277 7479 17532 9476 12277 22302 237 16448 12277 14767 10830 12277 237 237 1376 14767 6565 237");  // [5] carapaulhartman
addresses.push("22927 22921 16448 12277 1661 17532 237 4757 8278 3771 9476 12277 22302 17289 10467 4757 10830 12288 16448 12277 1661 17532 1376 3771 4757 16448");  // [6] charbyo
addresses.push("22927 22921 16448 12277 1661 17532 237 4757 8278 237 4033 4757 17289 6565 3771 12277 16448 6565 4757 14767 6565 2721 3437 1973 4515 7479 17532 10467 3437 7384 7384 1973 10830 9476 4757 237 16448 12277 1661 17532 1376 3771 4757 16448");  // [7] twobecameone_24july2004
addresses.push("22927 22921 16448 12277 1661 17532 237 4757 8278 12288 17289 3771 3437 3169 4872 6612 10830 12288 16448 12277 1661 17532 1376 3771 4757 16448");  // [8] gbc2781
addresses.push("22927 22921 16448 12277 1661 17532 237 4757 8278 22302 12277 10467 237 6565 22302 6565 22840 12277 4872 6612 4872 4872 1973 10830 10467 12277 9476 4757 4757 1376 3771 4757 16448");  // [9] rayteresa81884
addresses.push("22927 22921 16448 12277 1661 17532 237 4757 8278 12288 17289 3771 3437 3169 4872 6612 10830 12288 16448 12277 1661 17532 1376 3771 4757 16448");  // [10] gbc2781
addresses.push("21509 21503 19991 5 18260 893 9304 14398 843 5951 18260 893 893 18260 5 19991 4361 19346 14398 4991 2294 20631 2980 5 2294 14398 14398 2558 15328 14398 19991");  // [11] william3josh
addresses.push("21509 21503 19991 5 18260 893 9304 14398 843 19991 5 5093 19991 5 5093 4991 4361 20631 4991 8066 15328 3351 893 14398 8066 5 893 2558 16625 729 9304");  // [12] marmars3
addresses.push("21509 21503 19991 5 18260 893 9304 14398 843 5473 5093 2980 4991 9304 5 16625 20631 10166 729 5093 18260 9157 14398 16625 2558 16625 729 9304");  // [13] krystan
if(!addresses) var addresses = new Array();
addresses.push("5989 5987 482 1247 1324 2452 1319 1794 522 5548 1247 1616 1324 5548 5325 4490 1682 2963 3877 3877 3877 1363 1682 1794 1319 482 1247 1324 2452 1056 844 1794 482");  // [14] davidsuh2000

