Event.observe(window, 'load', function(){
	
	var opacity = {from:1, to:0.85};

	var header 			= $('header');
	var headerBackground= $('header-bg');
	var headerPosition	= header.cumulativeOffset();
	var headerSize		= header.getDimensions();
	
	header.setStyle( {background:'none'} );
	headerBackground.setStyle( {
		position:'absolute',
		width:headerSize.width + 'px', 
		height:headerSize.height + 'px',
		left:headerPosition.left + 'px',
		top:headerPosition.top + 'px',
		background:'white',
		zIndex: '-1'
	} );
	
	new Effect.Opacity(headerBackground, {from:opacity.from, to:opacity.to, duration:1});
	
	var menu 			= $('menu');
	var menuBackground	= $('menu-bg');
	
	if (menu && menuBackground) {
		var menuPosition	= menu.cumulativeOffset();
		var menuSize		= menu.getDimensions();
		
		menu.setStyle( {background:'none'} );
		menuBackground.setStyle( {
			position:'absolute',
			width:menuSize.width + 'px', 
			height:menuSize.height + 'px',
			left:menuPosition.left + 'px',
			top:menuPosition.top + 'px',
			background:'white',
			zIndex: '-1'
		} );
		
		new Effect.Opacity(menuBackground, {from:opacity.from, to:opacity.to, duration:1});
	}
	
	var submenu 			= $('submenu');
	var submenuBackground	= $('submenu-bg');
	
	if (submenu && submenuBackground) {
		var submenuPosition		= submenu.cumulativeOffset();
		var submenuSize			= submenu.getDimensions();
		
		submenu.setStyle( {background:'none'} );
		submenuBackground.setStyle( {
			position:'absolute',
			width:submenuSize.width + 'px', 
			height:submenuSize.height + 'px',
			left:submenuPosition.left + 'px',
			top:submenuPosition.top + 'px',
			background:'white',
			zIndex: '-1'
		} );
		
		new Effect.Opacity(submenuBackground, {from:opacity.from, to:opacity.to, duration:1});
	}
	
	var content 			= $('content');
	var contentBackground	= $('content-bg');
	
	if (content && contentBackground) {
			
		var contentPosition	= content.cumulativeOffset();
		var contentSize		= content.getDimensions();
		
		content.setStyle( {background:'none'} );
		contentBackground.setStyle( {
			position:'absolute',
			width:contentSize.width + 'px', 
			height:contentSize.height + 'px',
			left:contentPosition.left + 'px',
			top:contentPosition.top + 'px',
			background:'white',
			zIndex: '-1'
		} );
		
		new Effect.Opacity(contentBackground, {from:opacity.from, to:opacity.to, duration:1});
	}
	
	var book 			= $('book-right');
	var bookBackground	= $('book-bg');
	
	if (book && bookBackground) {
			
		var bookPosition	= book.cumulativeOffset();
		var bookSize		= book.getDimensions();
		
		bookBackground.setStyle( {
			position:'absolute',
			width:bookSize.width + 'px', 
			height:bookSize.height + 'px',
			left:bookPosition.left + 'px',
			top:bookPosition.top + 'px',
			background:'white',
			zIndex: '-1'
		} );
		
		new Effect.Opacity(bookBackground, {from:opacity.from, to:opacity.to, duration:1});
	}
	
	$$("a").each( function(element){
		if( !element.href.match(/beate-b.nl/i) ){
			element.target = "_blank";
		}
	});
});

