window.addEvent('domready', function() {
	var body = $$('body')[0];
	body.setStyle('position', 'relative');
	var div_overlay = $('overlay_div');
	
	if(Browser.Engine.trident)
		div_overlay.setStyle("width", "100%");
	
	div_overlay.setStyle("height", body.offsetHeight);
	
	var init_links = function(item) {
		item.set('onclick', 'return false;');
		item.addEvent('click', function(event) {
			div_overlay.setStyles({'opacity' : '0.0', 'display' : 'block'});
			
			var fx = new Fx.Tween(div_overlay, { 'onComplete' : function() {
					document.location = item.get('href');
				}.bindWithEvent(item)
			});
			fx.start('opacity', ['0.0', '1.0']);
		}.bindWithEvent(item));
	}
	
	$$('div#menu ul li a').each(init_links);
	$$('ul#externalLinks li a').each(init_links);
	$$('ul#subMenu li a').each(init_links);
	
	var fx = new Fx.Tween(div_overlay, { 'duration' : '500', 'fps' : 70, 'onComplete' : function() {
			this.setStyle('display', 'none');
		}.bindWithEvent(div_overlay)
	});
	fx.start('opacity', ['1.0', '0.0']);
});