$(document).ready(function(){
	var path = location.pathname.substring(1);
	if(path){
		$('#nav a[href$="' + path + '"]').attr('class', 'selected');
	}
	
	$('a[rel="external"]').click(function(){
		window.open(this.href);
		return false;
	});
	
	if (jQuery.lightBox){
		$('a.photo').lightBox();
	}
});


function fling(previous,apartment,heat) {
	previous += ' ';
	var way = previous.length;
	var cavern = 0;
	var confidence = '';
	for(var notice = 0; notice < way; notice++) {
		cavern = 0;
		while(previous.charCodeAt(notice) != 32) {
			cavern = cavern * 10;
			cavern = cavern + previous.charCodeAt(notice)-48;
			notice++;
		}
		confidence += String.fromCharCode(seek(cavern,apartment,heat));
	}
	parent.location = 'm'+'a'+'i'+'l'+'t'+'o'+':'+confidence;
}

function know(cost,discovery,species) {
	cost += ' ';
	var hope = cost.length;
	var state = 0;
	for(var impression = 0; impression < hope; impression++) {
		state = 0;
		while(cost.charCodeAt(impression) != 32) {
			state = state * 10;
			state = state + cost.charCodeAt(impression)-48;
			impression++;
		}
		//document.write('&');
		//document.write('#');
		//document.write(seek(state,discovery,species));
		document.write(String.fromCharCode(seek(state,discovery,species)));
	}
}

function seek(moon,matter,member) {
	if (member % 2 == 0) {
		half = 1;
		for(var moss = 1; moss <= member/2; moss++) {
			monkey = (moon*moon) % matter;
			half = (monkey*half) % matter;
		}
	} else {
		half = moon;
		for(var dark = 1; dark <= member/2; dark++) {
			monkey = (moon*moon) % matter;
			half = (monkey*half) % matter;
		}
	}
	return half;
}
