$(document).ready(setsize);

function setsize() {
	var currentHeight = 0;
	var desiredHeight = 0;
	
	$("#MapContainer").hide();
	var mapHeight = $("#MapContainer").height();
	var currentHeight = $(window).height();
	var HeaderFooter = $("#container").outerHeight();
	var desiredHeight = Math.max(currentHeight - HeaderFooter, mapHeight); // header + footer
	$("#MapContainer").show();
	
	var sidebarTop = parseInt($("#sidebar_top").css('height')) + parseInt($("#sidebar_top").css('padding-top')) + parseInt($("#sidebar_top").css('padding-bottom'));
	var sidebarBottom = parseInt($("#sidebar_bottom").css('height')) + parseInt($("#sidebar_bottom").css('padding-top')) + parseInt($("#sidebar_bottom").css('padding-bottom'));
	var desiredsidebarHeight = desiredHeight - (sidebarTop + sidebarBottom);
	
	var map = document.getElementById('map');
	if (map)
		map.style.height = desiredHeight - $("#category_filters").height() + 'px';
	
	$("#MapContainer").height( desiredHeight + 'px' );
	$("#sidebar_mid").css('height', desiredsidebarHeight);
};


