I've used the following to get the dimensions when working with similar requirements:
// You can just copy and paste this function:
function getViewportDimensions() {
var viewport = {};
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined') {
viewport.Width = window.innerWidth;
viewport.Height = window.innerHeight;
}
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
viewport.Width = document.documentElement.clientWidth;
viewport.Height = document.documentElement.clientHeight;
}
// older versions of IE
else {
viewport.Width = document.getElementsByTagName('body')[0].clientWidth;
viewport.Height = document.getElementsByTagName('body')[0].clientHeight;
}
return viewport;
}
Then you can use it like this:
// Obviously, you'll need to include jQuery...
function resizeViewportItems() {
var viewport = getViewportDimensions();
$('#some-element').css('height', viewport.Height);
$('#another-element').css('width', viewport.Width);
}