$(document).ready(function()
{
	setHeights();
	
	$(window).resize(function(){
		setHeights();
	});
	
	if(!$('body').hasClass('index')){
		$('#mainmenu').hide();
		
		$('#footer .center').toggle(function(){
			$('#mainmenu').show();
		},function(){
			$('#mainmenu').hide();
		});
	}
	
	$('#mainmenu li.children').click(function()
	{
		if(!$(this).find('ul').hasClass('open'))
		{
			$('.open').hide().removeClass('open');
			$(this).addClass('projectopen').find('ul').show().addClass('open');	
			
		} else {
			$('.projectopen').removeClass('projectopen');
			$('.open').hide().removeClass('open');						
		}
	});

	$('.longText .fixedLeft').hover(function(){
		$('.longText .fixedRight').fadeTo( 'slow', 0.3);
	},function(){
		$('.longText .fixedRight').fadeTo( 'slow', 1);
	});
	
	$('.longText .fixedRight').hover(function(){
		$('.longText .fixedLeft').fadeTo( 'slow', 0.3);
	},function(){
		$('.longText .fixedLeft').fadeTo( 'slow', 1);
	});


	// Hacks to fix - Anthony to advise
	$('.twoImages .fixedLeft img:eq(1)').hide();
	$('.twoImages .fixedRight img:eq(0)').hide();

});

function setHeights()
{
	var header = $('#header').height();
	var footer = $('#footer').height();
	var h = ($(window).height() - footer - header);
	
	$('#content .padding').height(h + 'px').css({'margin-top':header+'px'});
	$('#mainmenu').height(h + 'px').css({'top':header+'px'});
	$('#ui').height('64px');
}
