//<!--
// This script is (c) copyright 2006 Jim Tucek under the
// GNU General Public License (http://www.gnu.org/licenses/gpl.html)
// For more information, visit www.jracademy.com/~jtucek/email/ 
// Leave the above comments alone!

var decryption_cache = new Array();
// these strings were generated by the javascript in components EmailEncryptor.html
// webmaster(leydon),rakic,ang,ayoub,bartley,breunig,adi-begovic,anita-begovic,hashimoto-torii,letinic,liu,morozov,pappy,sarkisian,torii, arellano
if(!addresses) var addresses = new Array();
addresses.push("6169 4243 194 6123 1543 1263 1889 3698 5750 5910 6123 5436 2649 3278 1263 3753 2649 2601 3698 1314 2329 2649 6123 1263 3753 3278 3753 2601 2731");
addresses.push("6169 4243 194 6123 1543 1263 1889 3698 5750 1402 6123 145 5878 3698 3278 5436 6123 5878 1543 4563 2329 2649 6123 1263 3753 3278 3753 2601 2731");
addresses.push("2533 1579 666 793 44 811 568 2344 71 1903 757 1004 1903 1175 44 757 1075 1082 793 1175 1004 1245 994 793 811 1903 1082 1903 1998 757");
addresses.push("2533 1579 666 793 44 811 568 2344 71 793 811 1449 1903 2272 568 1082 793 994 2344 757 1449 1245 994 793 811 1903 1082 1903 1998 757");
addresses.push("2533 1579 666 793 44 811 568 2344 71 160 212 2272 44 1075 568 2344 1646 212 1903 2272 1082 1449 793 2272 568 811 1903 994 1245 994 793 811 1903 1082 1903 1998 757");
addresses.push("2533 1579 666 793 44 811 568 2344 71 506 2344 1075 212 757 793 1082 1449 2272 1903 757 1175 44 1004 1245 994 793 811 1903 1082 1903 1998 757");
addresses.push("2533 1579 666 793 44 811 568 2344 71 793 1998 44 1082 1449 1903 1004 2344 1648 44 160 1245 994 793 811 1903 1082 1903 1998 757");
addresses.push("2533 1579 666 793 44 811 568 2344 71 793 1175 44 568 793 1082 1449 1903 1004 2344 1648 44 160 1245 994 793 811 1903 1082 1903 1998 757");
addresses.push("2533 1579 666 793 44 811 568 2344 71 1604 793 2220 757 1903 1082 212 793 1075 212 44 666 2344 568 2344 2470 568 2344 2272 44 44 1245 994 793 811 1903 1082 1903 1998 757");
addresses.push("2533 1579 666 793 44 811 568 2344 71 1604 2272 1903 1075 44 666 44 2272 1082 811 1903 568 44 1175 44 160 1245 994 793 811 1903 1082 1903 1998 757");
addresses.push("2533 1579 666 793 44 811 568 2344 71 494 44 757 494 44 1175 1082 811 44 757 1245 994 793 811 1903 1082 1903 1998 757");
addresses.push("2533 1579 666 793 44 811 568 2344 71 994 757 2272 994 1082 666 2344 2272 2344 2220 2344 1648 1245 994 793 811 1903 1082 1903 1998 757");
addresses.push("2533 1579 666 793 44 811 568 2344 71 666 793 2272 44 793 666 666 793 1082 1646 793 1646 1646 994 1245 994 793 811 1903 1082 1903 1998 757");
addresses.push("2533 1579 666 793 44 811 568 2344 71 666 793 568 568 212 1903 714 1082 1075 793 2272 1604 44 1075 44 793 1175 1245 994 793 811 1903 1082 1903 1998 757");
addresses.push("2533 1579 666 793 44 811 568 2344 71 666 793 1075 793 793 1604 44 1082 568 2344 2272 44 44 1245 994 793 811 1903 1082 1903 1998 757");
addresses.push("4439 845 4138 1538 2580 4330 3980 4381 1789 2476 4381 4051 2254 1538 1080 54 4330 4330 1538 4051 4381 992 1359 1538 4330 54 2254 54 2799 1895");
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;
}
// -->