window.addEvent('domready', function(){
	
	//footer afronden
	roundFooter();
	
	$$('#header ul li a').each(function(el){

		//parent van menu-item ophalen
		var parentItem = el.getParent();		
		
		//item ronde corners geven op mouseover
		el.addEvent('mouseover', function() {
			roundCorners(el);
		}).addEvent('mouseout', function() {
			if (parentItem.className != 'active')
				undoRoundCorners(el);
		});
		
		//actieve item ronde corners geven
		if (parentItem.className.contains('active'))
			roundCorners(el);
		
	});
	
	function roundCorners(el)
	{	
		if (Browser.Engine.gecko || Browser.Engine.webkit)
			return;

		//grootte van item bepalen
		var elSize = el.getSize();
		var elWidth = elSize.x;
		var elHeight = elSize.y;

		//parent element krijgt position relative zodat de corders er absoluut ingeplaatst kunnen worden
		el.setStyle('position', 'relative');
		
		//links boven
		new Element('div').setStyles({
			'background-image': 'url(' + basepath +'images/menu_rounded_corners.gif)',
			'background-repeat': 'no-repeat',
			'background-position': 'top left',
			'width': '3px',
			'height': '3px',
			'position': 'absolute',
			'z-index': '2',
			'overflow': 'hidden'
		}).inject(el, 'inside').setPosition({x: 0, y: 0});	

		//rechts boven							
		new Element('div').setStyles({
			'background-image': 'url(' + basepath +'images/menu_rounded_corners.gif)',
			'background-repeat': 'no-repeat',
			'background-position': 'top right',
			'width': '3px',
			'height': '3px',
			'position': 'absolute',
			'z-index': '2',
			'overflow': 'hidden'
		}).inject(el, 'inside').setPosition({x: elWidth - 3, y: 0});
		
		//rechts onder													
		new Element('div').setStyles({
			'background-image': 'url(' + basepath +'images/menu_rounded_corners.gif)',
			'background-repeat': 'no-repeat',
			'background-position': '-3px -3px',
			'width': '3px',
			'height': '3px',
			'position': 'absolute',
			'z-index': '99',
			'overflow': 'hidden'
		}).inject(el, 'inside').setPosition({x: elWidth - 3, y: elHeight - 3});
		
		//links onder			
		new Element('div').setStyles({
			'background-image': 'url(' + basepath +'images/menu_rounded_corners.gif)',
			'background-repeat': 'no-repeat',
			'background-position': '0 -3px',
			'width': '3px',
			'height': '3px',
			'position': 'absolute',
			'z-index': '2',
			'overflow': 'hidden'
		}).inject(el, 'inside').setPosition({x: 0, y: elHeight - 3});

	}
	
	function undoRoundCorners(el)
	{
		if (Browser.Engine.gecko || Browser.Engine.webkit)
			return;
					
		if (el.className == 'active')
			return;
		
		var elChildren = el.getChildren();
		elChildren.each(function(subEl){
			subEl.dispose();
		});
	}
	
	function roundFooter()
	{	
		//grootte van item bepalen
		var elSize = $('footer').getSize();
		var elWidth = elSize.x;
		var elHeight = elSize.y;		

		var yOffset = 26;
		
		//links boven
		new Element('div').setStyles({
			'background-image': 'url(' + basepath +'images/footer_rounded_corners.gif)',
			'background-repeat': 'no-repeat',
			'background-position': 'top left',
			'width': '3px',
			'height': '3px',
			'position': 'absolute',
			'z-index': '2',
			'overflow': 'hidden'
		}).inject($('footer'), 'inside').setPosition({x: 0, y: 0 + yOffset});	

		//rechts boven							
		new Element('div').setStyles({
			'background-image': 'url(' + basepath +'images/footer_rounded_corners.gif)',
			'background-repeat': 'no-repeat',
			'background-position': 'top right',
			'width': '3px',
			'height': '3px',
			'position': 'absolute',
			'z-index': '2',
			'overflow': 'hidden'
		}).inject($('footer'), 'inside').setPosition({x: elWidth - 3, y: 0 + yOffset});
			
	}
	
	//footer afbeelding in content plaatsen
	if ($('plain'))
		new Element('div', {id: 'content_footer'}).inject($('plain'), 'inside');		
				
});
