function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

	function setHeight()
	{
		if(typeof(document.getElementById('main').offsetHeight) != undefined)
			var h_main = document.getElementById('main').offsetHeight;
		else
			var h_main = document.getElementById('main').clientHeight;

		if(h_main >= document.body.clientHeight - 257) // 257 = height of header + space to top edge
			document.getElementById('main').style.height = h_main;
		else
			document.getElementById('main').style.height = document.body.clientHeight - 257;
	}


addLoadEvent(function() {
		setHeight()
	});
