$(document).ready(function() {
    fitToHeight();
});

$(window).resize(function() {
    fitToHeight();
});

function fitToHeight() {
    var current_height = getWindowHeight();
    if (current_height > 700) {
        var offset = 250;
    }
    else {
        var offset = 190;
    }
    var new_height = current_height - offset;
    //if (current_height > new_height) new_height = max_height - offset - 60;
    $('#mapcontainer').add('#mapcontainer2').add('#subcontent').css("height", new_height+"px");
}


// get the current window height
function getWindowHeight() {
    var window_height = 0;
    if (typeof(window.innerWidth) == 'number') {
        // Non-IE
        window_height = window.innerHeight;
    }
    else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        // IE 6+ in 'standards compliant mode'
        window_height = document.documentElement.clientHeight;
    }
    else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        // IE 4 compatible
        window_height = document.body.clientHeight;
    }
    return parseInt(window_height);
}