Containerhöhe minus 150px minus 40px = <div>-Höhe
Noch ein kleines Schaubild:
<div id="mainDiv"> - - - - - (Container, height: 100%)
<div id="topDiv"> - - - (height: 150px)
<div id="middleDiv"> - - - (height: automatisch der Rest von der Containerhöhe)
<div id="bottomDiv"> - - - (height: 40px)
</div>
[...]
<body onLoad="init();">
function init()
{
var winHeight = document.body.clientHeight;
var differenz = winHeight - ((document.getElementById("topDiv").style.height) + (document.getElementById("bottomDiv").style.height));
document.getElementById("middleDiv").style.height = differenz;
}
Nur mal so aus dem Kopf schnell geschrieben, aber das müsste dir die "richtige" Höhe deines Divs immer initialisieren, bei Laden der Seite,