/* CSS should work if javascript is disabled
 * So this must be loaded inline (from within
 * the body tag) in order to work.
 */

var windowFader = {
	
	timer: 0,

 	start: function(){
		this.fadeIn();
	},
	
	fadeIn: function(){
		$S('body div').each(function(el){
			this.timer += 125;
			var fadeIn = el.effect('opacity', { duration: 500 });
			fadeIn.myCustom = function(){
				fadeIn.custom('0', '1');
			};
			fadeIn.myCustom.delay(this.timer);
		}, this);
	},

	fadeOut: function(e){
		var obj = e.target || e.srcElement;
		$S('body > div').each(function(el){
			el.effect('opacity', { duration: 900 }).custom(1, 0);
		}, this);
	}
}

window.onUnload = function(){
	setTimeout('return true', 1100);
}

Window.onDomReady(function(){

	windowFader.start();

	// Make A links fade out page
	$S('a').each(function(el){
		if (el.addEventListener)			// Use new method
		{
			el.addEventListener('click', windowFader.fadeOut, false);
		}
		else								// Support old IE
		{
			el.attachEvent('onclick',windowFader.fadeOut);
		}
		//el.setAttribute('title', el.getAttribute('href') );
	});
});

// This goes inline to take effect before the first render
$S('body div').each(function(el){
	// This handles browser dependancy for style effect
	el.effect('opacity').set(0);
});


