function getWindowHeight() {
    if (window.self && self.innerHeight) {
        return self.innerHeight
    }
    if (document.documentElement && document.documentElement.clientHeight) {
        return document.documentElement.clientHeight;
    }
    return 0;
}

// Resize the UI components on load and when resized
function resizeMap() {
    var mapdiv = document.getElementById("map");
    var controldiv = document.getElementById("controls");

    var height = getWindowHeight() - controldiv.offsetHeight - 26;
	var minheight = 600 - controldiv.offsetHeight;
	if (height < minheight) {
		height = minheight;
	}
    if (height >= 0) {
        mapdiv.style.height = height + "px";
    }
    // Let the API know it has been resized
    map.checkResize();
}

GEvent.addListener(map, "load", resizeMap());

if (window.attachEvent) { 
	window.attachEvent("onresize", function() {resizeMap()});		    
} else { 
	window.addEventListener("resize", function() {resizeMap()}, false);
}
