var EmailAFriend = Class.create();	
EmailAFriend.prototype = {
	initialize: function() 
	{
		this.pagefunctions = $("pagefunctions");
		this.email = $("emailfriend");
		this.print = $("printpage");
		
		if( this.pagefunctions ) {
		
			this.pagefunctions.style.display = "";
		
			if( this.email ) {
				// Strip anything after and including the krypto string
				var searchString = window.location.search;
				var kryptoPattern = /(\?\S+)(&krypto=)*/;
				var results = kryptoPattern.exec(searchString);
				if (results) var search = results[1];
				else var search = "";
				
				this.email.href += "&EmailURL=" + encodeURIComponent( "http://" + window.location.hostname + window.location.pathname + search );
			}
			
			if( this.print ) {
				this.print.href = "#";
				this.print.onclick = this.printPage.bindAsEventListener( this );
			}
		
		}
	},
	
	printPage: function(e) {
		Event.stop(e);
		window.print();
	}
};

var myEmailAFriend;
Event.observe( 
	window, 
	"load", 
	function(e){ myEmailAFriend = new EmailAFriend(); } 
);