var ua = navigator.userAgent.toLowerCase();
var isOpera = (ua.indexOf('opera')  > -1);
var isIE = (!isOpera && ua.indexOf('msie') > -1);

function getDocumentHeight() {
  return Math.max(document.compatMode != 'CSS1Compat' ? document.body.scrollHeight : document.documentElement.scrollHeight, getViewportHeight());
}

function getViewportHeight() {
  return ((document.compatMode || isIE) && !isOpera) ? (document.compatMode == 'CSS1Compat') ? document.documentElement.clientHeight : document.body.clientHeight : (document.parentWindow || document.defaultView).innerHeight;
}
function setTrueHeight() {
 	var	trueheight = getDocumentHeight() ; // здесь можно вставить любую функцию рассчитывающую высоту блока
 	//alert(trueheight);
	document.getElementById("main-bg1").style.height = (trueheight) + "px";
	document.getElementById("main-bg2").style.height = (trueheight) + "px";
	document.getElementById("main").style.height     = (trueheight) + "px";
	document.getElementById("footer").style.top      = (trueheight-84) + "px";
	if(trueheight > 600) {
		document.getElementById("main").className        = "main-show-bg";
	}
	document.getElementById("footer").style.display  = "block";
}
window.onload = setTrueHeight;
window.onresize = setTrueHeight;
