function set_div_height() {

    var bottom_padder = document.getElementById('footer');
    var header_footer_height = 140; //gedeelte wat niet hoeft te worden opgevuld  
    var body_height = getCurPageSize();
    var content_div = document.getElementById('wrap_content');
    var content_height = content_div.offsetHeight;
    var total_content_h = content_height + header_footer_height;
    window_height=body_height[3];
    page_height=body_height[1];
    //resthoogte    
    if(total_content_h<window_height) {
        var div_height = window_height - header_footer_height - 20;
        var footer_top_margin = window_height - total_content_h -  20;
    } else {
        var div_height = content_height;
        var footer_top_margin = 0;
    }

    bottom_padder.style.paddingTop = footer_top_margin+'px';
}

function getCurPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, window_height;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		window_height = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		window_height = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		window_height = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < window_height){
		page_height = window_height;
	} else { 
		page_height = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,page_height,windowWidth,window_height) 
	return arrayPageSize;
}
// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
//
function addLoadEvent(func) {	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}
}
addLoadEvent(set_div_height);
window.onresize= set_div_height;