function emptyQueue(q){var queue = Effect.Queues.get(q);queue.each(function(e) { e.cancel() });}
function navOver(x,p){var n=x; var i=p+n+'G.jpg'; $(n).src=i;}
function navOut(x,p){var n=x; var i=p+n+'W.jpg'; $(n).src=i;}
function pageLoad(){
		emptyQueue('pLoading');
		$('pageContainer').style.display = '';
		$('pLoading').style.display = 'none';
		$('pLoading').style.zIndex = -1000;
		$('pLoading').style.height = -0;
		$('pLoading').style.width = 0;
		$('pLoading').style.padding = 0;
		$('pLoading').style.margin = 0;
		$('pLoading').style.visibility = 'hidden';
		//new Effect.Opacity('page',{delay:0.1, duration:0.3, from:0, to:1, queue:{scope:'pLoad'}});	
		
		new Effect.Opacity('footer',{delay:0.4, duration:0.3, from:0, to:1, queue:{scope:'pLoad'}});	
		new Effect.Opacity('navT2',{delay:0.2, duration:0.4, from:0, to:1, queue:{scope:'pLoad'}});	
		new Effect.Opacity('content', {delay:0.2, duration:0.4, from:0, to:1, queue:{scope:'pLoad'}});
}
function pageUnload(loc){
		ePath=loc;
		new Effect.Opacity('content', {delay:0, duration:0.3, from:1, to:0, queue:{scope:'pUnload'}});
		new Effect.Opacity('navT2',{delay:0, duration:0.3, from:1, to:0, queue:{scope:'pUnload'}});
		new Effect.Opacity('footer',{delay:0, duration:0.3, from:1, to:0, queue:{scope:'pUnload'}});
		// new Effect.Opacity('page',{delay:0.4, duration:0.6, from:1, to:0, queue:{scope:'pUnload'}});
		setTimeout("window.location=ePath;",1000);	
}
function sendForm(loc)
	{
		ePath=loc;
		$(ePath).submit();
	}
function pageUnloadForm(loc)
	{
		ePath=loc;
		new Effect.Opacity('content', {delay:0, duration:0.3, from:1, to:0, queue:{scope:'pUnload'}});
		new Effect.Opacity('page',{delay:0.4, duration:0.6, from:1, to:0, queue:{scope:'pUnload'}});
		setTimeout("sendForm(ePath);",1000);
	}
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'}});
		$('content').setOpacity(0);
		$('navT2').setOpacity(0);
		$('footer').setOpacity(0);
		
		//$('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();
			 // alert("Onload fires!")          
	};
onload=loader;	 
function reloader(){if($('page').getStyle('opacity') == 0){pageLoad();}};
checkReload.init(reloader);