
window.addEvent('domready', function()
{
	if (Browser.Engine.name=='trident' && Browser.Engine.version==4)
	{
		mtop = $('header').getSize().y;
		$w = $$('div.wrap')[0].addClass('nobg');
		ht = $w.getSize().y;
		mleft = $w.getCoordinates().left;
		$(document.body).adopt(new Element('div', {'id':"wrapbg"}));
		$('wrapbg').setStyles({
			height : ht,
			marginTop : mtop,
			marginLeft : mleft
		});
	
		window.addEvent('resize', function()
		{
			mleft = $w.attr('offsetLeft');
			$('wrapbg').setStyle('margin-left', mleft);
		});

		// Navigation
		$$('#nav ul > li').addEvent('mouseover', function(event){
			this.getChildren('ul').addClass('show');
		});
		$$('#nav ul > li').addEvent('mouseout', function(event){
			this.getChildren('ul').removeClass('show');
		});
		// Subnavigation
		$$('#nav li li a').addEvent('mouseover', function(event){
			this.addClass('on');
		});
		$$('#nav li li a').addEvent('mouseout', function(event){
			this.removeClass('on');
		});

		// Header
		$('header').adopt(new Element('span', {'class':'bg'}));

		// Gallery boxes
		$$('#gallery div.int p a').addEvent('mouseover', function(event){
			this.addClass('on');
		});
		$$('#gallery div.int p a').addEvent('mouseout', function(event){
			this.removeClass('on');
		});
	}

	// Columns height
	ht = 0;
	$div = $$('#content > div');
	for(i=0; i<$div.length; i++)
	{
		$obj = $div[i];
		cs = $obj.getComputedSize();
		if (ht < cs.totalHeight)
		{
			ht = cs.totalHeight;
		}
		$obj.store('pad', (cs['padding-top'] + cs['padding-bottom']));
	}
	for (i=0; i<$div.length; i++)
	{
		$obj = $div[i];
		newht = ht - $obj.retrieve('pad');
		$obj.setStyle('height', newht);
	}
	
	// Menu width
	menu_width = 121;
	$ul = $$('#nav ul ul').setStyle('width', 'auto');
	for (i=0; i<$ul.length; i++)
	{
		$menu = $ul[i];
		$links = $menu.getElements('a');	
		padding = $links[0].getComputedSize()['padding-left'];
		$links.setStyles({
			'white-space' : 'nowrap',
			'display' : 'inline-block'
		});
		for (j=0; j<$links.length; j++)
		{
			width = $links[j].getSize().x;
			if (menu_width < width) {
				menu_width = width;
			}
		}
		$links.removeProperty('style');
		$menu.setStyle('width', (menu_width + 2 * padding));
		menu_width = 121;
	}
});
