    function pageLoaded() {
   		
   		var px = 'px';
		var windowWidth = $(window).width();
		var windowHeight = $(window).height();
		var wWnopx = (4000 - windowWidth ) / 2;
   		var hHnopx = (2800 - windowHeight ) / 2;
		var wWidth = (4000 - windowWidth ) / 2 + px;
		var hHeight = (2800 - windowHeight) / 2 + px;
		var wW = wWidth.toString();
		var hH = hHeight.toString();
		var fromPage = document.referrer;
		
//     	if (fromPage == 'http://permanentpress.ca/north/') { 		
//     		$.scrollTo( {top:'0', left:wW}, 1);
//     		$.scrollTo( {top:hH, left:'+=0'}, {duration:2000} );
//     	} else if (fromPage == 'http://permanentpress.ca/east/') {
//     		$.scrollTo( {top:hH, left:3000}, 1 );
//     		$.scrollTo( {top:'+=0', left:wW}, {duration:1500} );
//     	} else if (fromPage == 'http://permanentpress.ca/south/') {
//     		$.scrollTo( {top:3000, left:wW}, 1 );
//     		$.scrollTo( {top:hH, left:'+=0'}, {duration:2000} );
//     	} else if (fromPage == 'http://permanentpress.ca/west/') {
//     		$.scrollTo( {top:hH, left:0}, 1 );
//     		$.scrollTo( {top:'+=0', left:wW}, {duration:1500} );
//     	} else {
//     		
//     	}

		$.scrollTo( {top:hHnopx, left:wWnopx}, 0);
    	
		$('#compass-north a').click(function(event) {
			event.preventDefault();
			var time = 500; // time for slideup effect
			var url = $(this).attr("href"); // pick url for redirecting via javascript
			$.scrollTo( {top:'0', left:'+=0'}, 2000 );
			window.setTimeout(function(){window.location.href=url;}, time); // timeout and waiting until effect is complete
			return -1;
		});
		
		$('#compass-east a').click(function(event) {
			event.preventDefault();
			var time = 1000; // time for slideup effect
			var url = $(this).attr("href"); // pick url for redirecting via javascript
			$.scrollTo( {top:'+=0', left:'+=1000'}, 2000 );
			window.setTimeout(function(){window.location.href=url;}, time); // timeout and waiting until effect is complete
			return -1;
		});
		
		$('#compass-south a').click(function(event) {
			event.preventDefault();
			var time = 500; // time for slideup effect
			var url = $(this).attr("href"); // pick url for redirecting via javascript
			$.scrollTo( {top:'3000', left:'+=0'}, 2000 );
			window.setTimeout(function(){window.location.href=url;}, time); // timeout and waiting until effect is complete
			return -1;
		});
		
		$('#compass-west a').click(function(event) {
			event.preventDefault();
			var time = 1000; // time for slideup effect
			var url = $(this).attr("href"); // pick url for redirecting via javascript
			$.scrollTo( {top:'+=0', left:'-=1000px'}, 2000 );
			window.setTimeout(function(){window.location.href=url;}, time); // timeout and waiting until effect is complete
			return -1;
		});
    }
    
    window.setTimeout(pageLoaded,0);
    
    $("#compass-north [title]").tooltip({offset: [44, 65], effect: 'fade', predelay: 600, fadeOutSpeed: 400, fadeInSpeed: 400});
    $("#compass-east [title]").tooltip({offset: [43, 78], effect: 'fade', predelay: 600, fadeOutSpeed: 400, fadeInSpeed: 400});
    $("#compass-south [title]").tooltip({offset: [43, 74], effect: 'fade', predelay: 600, fadeOutSpeed: 400, fadeInSpeed: 400});
    $("#compass-west [title]").tooltip({offset: [43, -70], effect: 'fade', predelay: 600, fadeOutSpeed: 400, fadeInSpeed: 400});
    $("#compass-middle p img[title]").tooltip({offset: [170, 0], effect: 'fade', predelay: 600, fadeOutSpeed: 400, fadeInSpeed: 400});
    
    $(window).bind('resize',function(){
		 window.location.href = window.location.href;
	});

	function pageUnloaded(){}

	window.addEventListener("load", pageLoaded, false);
	window.addEventListener("unload", pageUnloaded, false);

// $( pageLoaded ); 
// $(window).load( );
