function emptyQueue(q){var queue = Effect.Queues.get(q);queue.each(function(e) { e.cancel() });}
function pageLoad(){
		emptyQueue('pLoading');
		$('pageContainer').style.display = '';
		$('pLoading').style.display = 'none';
		$('pLoading').style.zIndex = -1000;
		new Effect.Opacity('page',{delay:0.1, duration:0.3, from:0, to:1, queue:{scope:'pLoad'}});	
}
function pageUnload(loc){
		ePath=loc;
		$('pLoading').style.display = '';
		new Effect.Opacity('page',{delay:0, duration:0.1, from:1, to:0, queue:{scope:'pUnload'}});
		new Effect.Opacity('pLoading',{delay:0, duration:0.1, from:0, to:1, queue:{scope:'pUnload'}});
		setTimeout("window.location=ePath;",220);	
}
function sendForm(loc)
	{
		ePath=loc;
		$(ePath).submit();
	}
function pageUnloadForm(loc)
	{
		ePath=loc;
		$('pLoading').style.display = '';
		new Effect.Opacity('page',{delay:0, duration:0.1, from:1, to:0, queue:{scope:'pUnload'}});
		new Effect.Opacity('pLoading',{delay:0, duration:0.1, from:0, to:1, queue:{scope:'pUnload'}});
		setTimeout("sendForm(ePath);",220);
	}
Event.observe(document, 'dom:loaded', function(){
		$('pLoading').setOpacity(0);
		$('pLoading').style.display = "";
		new Effect.Opacity('pLoading', {delay:0.3, duration:0.2, from:0, to:1, queue:{scope:'loading', position:'front'}});
		$('page').setOpacity(0);
 	  // set onClick to pageExit in all links except lightbox
		var links = $$('#page a:not([rel ^= lightbox])');	
		links.each(function(i){if(i.target != "_blank") {i.onclick= function() {pageUnload(this.href); return false;};}});
		// set attribute in all submit buttons
		var links = $$('form');
		links.each(function(i){i.onsubmit = function() {pageUnloadForm(i.id); return false;};});
	});
Event.observe(window, 'load', function(){pageLoad()});

// safari reload fix
checkReload=
	{
		checker: function(x)
			{
				if (x && !this.ignorer && new Date().getTime()-x>1200){this.reloader()};
				this.ignorer=false;
				setTimeout("checkReload.checker("+new Date().getTime()+")",1000)
			},
		init: function(x){this.reloader=x;	this.checker()},
		ignore: function(){this.ignorer=true}
	};
function loader(){checkReload.ignore();
	};
onload=loader;	 
function reloader(){if($('page').getStyle('opacity') == 0){pageLoad();}};
checkReload.init(reloader);