<!--
//Prepare for variable page loading
var local  = "../bollington/";
var remote = "http://www.macclesfieldcanal.org.uk/";
//Get source and set prefix
var source = parent.location.href.substring(0,4);
if (source == "file") {prefix = local; }
else {prefix = remote; } 
			//window.alert("Extract source: " + source + prefix);
//Disable right mouse click
var temp="";
function clickStop1() {
	if (document.all) {	(temp);return false; } }
function clickStop2(a) {
	if (document.layers||(document.getElementById&&!document.all)) {
		if (a.which==2||a.which==3) { (temp);return false; } } }
if (document.layers){document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickStop2;}
else{document.onmouseup=clickStop2;document.oncontextmenu=clickStop1;}
document.oncontextmenu=new Function("return false")

function loadPage(URL,winName) {
	pageName = prefix + URL;
			//window.alert("Extract URL address: " + pageName);
	aWindow = window.open(pageName,winName);
	aWindow.focus();
	}

window.defaultStatus = "  Welcome to the Macclesfield Canal!"
/*
	 Window name is set when each page is loaded in order to set the name to 'bollington'.
	 This is necessary so that further pages are loaded into the same window when selected
	 from the pub map (Firefox, Chrome and Opera browsers only), or the business windows.
*/
window.name = "macclesfield";
//
// Now determine whether we are running on the PC, a laptop or on the live server
var prefix = "";  // for the live server add nothing (default)
var local  = "file:///E:/WWW/Macclesfieldcanal";  // the PC running with the data in E:
var laptop = "/Documents%20and%20Settings/All%20Users/Documents/WWW/Macclesfieldcanal";  // the old laptop
var laptop1545 = "/Users/WW1SAM/Web%20sites/Macclesfieldcanal";  // the laptop Inspiron 1545
//
var source = parent.location.href.substring(0,4);
//window.alert("1a. Source: " + source);
if (source == "file") {prefix = local;
//			window.alert("1b. Source: " + source);
			};
var source = parent.location.href.substring(39,43);
//window.alert("2a. Source: " + source);
if (source == "Users") {prefix = laptop; 
//			window.alert("2b. Source: " + source);
			};
var source = parent.location.href.substring(11,18);
//window.alert("3a. Source: " + source);
if (source == "Users/W") {prefix = laptop1545; 
//			window.alert("3b. Source: " + source);
			};
//
// Now the email crypt fix
/*
   Default email addresses. On any page having more than webmaster (and town hall) there 
  	will be a full set of coded addreses. Any page having only webmaster (and town hall) 
  	will rely on this default set of addresses.
  
   In navigation1.js the data setting is conditional. The special needs are provided for 
  	in the pages themselves prior to the call to navigation1.js (which is template driven). 
  	In these cases the data from navigation1.js will be ignored and not loaded. The test is 
  	to see if adrdata already exists
*/
if(!adrdata) {
	var adrdata = new Array(); // for email addresses
	adrdata.push("29591 29587 5323 17953 10250 12173 23284 18129 17452 24507 17275 8296 5323 17953 1584 23284 17275 7414 7255 5323 17953 814 814 12173 17275 1584 12878 10250 17275 12173 14008 814 17953 7703 17953 12173 6362 18129 7414 28420 6362 3744 25126 15986 1584 3744 8296 25620 17275 814 23284 22855 26443 17953 814 814 12173 17275 1584 12878 10250 17275 12173 14008 27307 7480 17953 7703 17953 12173"); // [0] web master subject Macc C
} // Must follow all adrdata entries
//
// 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!
//
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])	
		return decryption_cache[cache_index];	
	if(adrdata[crypted_string])	
		var crypted_string = adrdata[crypted_string];	
	if(!crypted_string.length)	
		return "Error, not a valid index.";
	if(n == 0 || decryption_key == 0) {	
		var numbers = crypted_string.split(' ');	
		n = numbers[0];	decryption_key = numbers[1];	
		numbers[0] = ""; numbers[1] = "";	
		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) 
			continue;
		if(just_email_address && decrypted_character == 63) 
			break;
		decrypted_string += String.fromCharCode(decrypted_character);
		}
	decryption_cache[cache_index] = decrypted_string; 
	return decrypted_string;
}
function sendmsg(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;
}
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;
}
//-->

