/*
	author		Jeroen Butenaerts (formfab.nl)
	copyright	Jeroen Butenaerts (formfab.nl)
				Bobby van der Sluis (refunk.com)
*/
setOnloadEvent(setDivOffsets);

window.onresize = function(){ setDivOffsets(); }

function setDivOffsets(){
	if(document.getElementById){
		var combinedHeight = document.getElementById('header').offsetHeight + 10 + document.getElementById('sidebar').offsetHeight + 10 + document.getElementById('footer').offsetHeight;
		var windowHeight = getWindowHeight();
		if(windowHeight > 0){
			if(combinedHeight < windowHeight){
				document.getElementById('sidebarwrap').style.height = document.getElementById('sidebar').offsetHeight + (windowHeight - combinedHeight) + 'px';
				document.getElementById('bodywrap').style.height = windowHeight + 'px';
				document.getElementById('formfabpromo').style.bottom = 1 + 'px';
			}
			else{
				document.getElementById('sidebarwrap').style.height = document.getElementById('sidebar').offsetHeight + 'px';
				document.getElementById('bodywrap').style.height = combinedHeight + 'px';
				document.getElementById('formfabpromo').style.bottom = 1 - (combinedHeight-windowHeight) + 'px';
			}
		}
	}
}
function getWindowHeight(){
	var windowHeight = 0;
	if((typeof(window.innerHeight) == 'number')){
		windowHeight = window.innerHeight;
	}
	else if(document.documentElement && document.documentElement.clientHeight){
		windowHeight = document.documentElement.clientHeight;
	}
	else if(document.body && document.body.clientHeight){
		windowHeight = document.body.clientHeight;
	}
	return windowHeight;
}


