function WindowSize() 
{
  // var myWidth = 0;
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return parseInt(myHeight);
}

function elem(id) {
    if (document.getElementById != null) {
        return document.getElementById(id);
    }
    if (document.all != null) {
        return document.all[id];
    }
    if (document.layers != null) {
        return document.layers[id];
    }
    return null;
}

function height(id) {
    var e = elem(id);
    if (e) {
        return parseInt(e.offsetHeight);
    }
    return 0;
}

var NavigationResizedForFooter = false;

function SetScrollHeight()
{
	var Content = elem('content');
	var Navigation = elem('navigation');
	var ContentHeight = height('content');

	if(NavigationResizedForFooter == false) {
		NavigationResizedForFooter = true;
		var NavigationHeight = height('navigation');
		Navigation.style.height = (NavigationHeight + 20) + "px";
	} else {
		var NavigationHeight = height('navigation') - 20;
	}

	var WindowHeight = WindowSize();		
	var AvailableHeight = WindowHeight - height('header_back') - height('footer');
	
	if(ContentHeight <= NavigationHeight) {
		if(NavigationHeight < AvailableHeight) {
			Content.style.height = (AvailableHeight - 32) + "px";
		} else {
			Content.style.height = (NavigationHeight - 32) + "px";
		}
	} else {
		if(NavigationHeight < AvailableHeight) {
			Content.style.height = (AvailableHeight - 32) + "px";
		} else {
			Content.style.height = (NavigationHeight - 32) + "px";
		}
	}
}

if (typeof window.onload == 'function') {
	var FnOnload = window.onload;
	window.onload = function() {
	  SetScrollHeight();
	  FnOnload();
	}
} else {
	window.onload = SetScrollHeight;
}

if (typeof window.onresize == 'function') {
	var FnOnResize = window.onresize;
	window.onresize = function() {
	  SetScrollHeight();
	  FnOnResize();
	}
} else {
	window.onresize = SetScrollHeight;
}
