function checkDimensions() {
	var win = $(window);
	var height = win.height();
	var width = win.width();
	var wrap = $('#wrapper').outerHeight();
	var content = $('#content').height();
	var newH = (wrap < height) ? content+(height-wrap) : content;
	$('#content .body').css('height',Math.floor(newH-50)+'px');
	var newX = (width <= 930) ? 0 : (width/2)-465;
	$('#logo').css('left',newX+'px');
}

function hideMenu(M) {
	M.find('a.active ~ ul').hide();
	M.find('a.active').removeClass('active');
}

$(document).ready(function() {
	var M = $('#menu');
	$(document).click(function() {
		hideMenu(M);
	});
	$('#menu > ul > li').each(function() {
		var node = $(this);
		node.find('a:first').click(function() {
			var button = $(this);
			if (!button.hasClass('active')) {
				hideMenu(M);
				button.addClass('active');
				node.find('ul').show();
			} else 
				hideMenu(M);
			
			button.blur();
			return false;
		});
	});
	$(window).resize(function() {
		checkDimensions();
    });
	checkDimensions();
});
