/* Layout-Script fuer TUEVRheinland */
/* Autor: MKue|AZ 23.11.2006        */

var WindowHeight = 0;
var WindowWidth = 0;

var ContentHeight = 0;
var ContextHeight = 0;
var NavigationHeight = 0;

var bGettingBigger = false;

function getWindowHeightandWidth() {
	if (typeof(window.innerHeight) == 'number') {
		WindowHeight = window.innerHeight;
		WindowWidth = window.innerWidth;
	} else if (document.documentElement && document.documentElement.clientHeight) {
			WindowHeight = document.documentElement.clientHeight;
			WindowWidth = document.documentElement.clientWidth;
	} else if (document.body && document.body.clientHeight) {
			WindowHeight = document.body.clientHeight;
			WindowWidth = document.body.clientWidth;
	}
}

function getScreenRes() {
	if (WindowWidth < 981) {
		document.getElementById('tuevbody').style.width = '757px';
		document.getElementById('tuevbody').style.marginLeft = '0px';
		bGettingBigger = true;
	}

	if ((WindowWidth >= 981) && (bGettingBigger)) {
		document.getElementById('tuevbody').style.width = '935px';
		document.getElementById('tuevbody').style.marginLeft = '20px';
		bGettingBigger = false;
	}
}

function getAllContent() {
	if (document.getElementById) {

		ContentHeight = document.getElementById('inhalt').offsetHeight;
		ContextHeight = document.getElementById('kontext').offsetHeight;

		if (document.getElementById('seitennavigation')) {
			NavigationHeight = document.getElementById('seitennavigation').offsetHeight;
		}
		if (document.getElementById('produktnavi')) {
			NavigationHeight = document.getElementById('produktnavi').offsetHeight;
		}
		if (document.getElementById('branchennavi')) {
			NavigationHeight = document.getElementById('branchennavi').offsetHeight;
		}
		if (document.getElementById('tuvdotcomnavi')) {
			NavigationHeight = document.getElementById('tuvdotcomnavi').offsetHeight;
		}
	}
}

function setAllContent() {

	var iNewHeight = 0;

	if (NavigationHeight == 0) {

		if (ContextHeight >= ContentHeight)
			iNewHeight = ContextHeight;
	} else {

		if ((NavigationHeight > ContentHeight) && (NavigationHeight > ContextHeight))
			iNewHeight = NavigationHeight;

		if ((ContextHeight > NavigationHeight) && (ContextHeight > ContentHeight))
			iNewHeight = ContextHeight;
	} // if (NavigationHeight == 0)

	if (iNewHeight > 0)
		document.getElementById('inhalt').style.height = iNewHeight + 'px';
}

window.onload = function() {
	getWindowHeightandWidth();
	getScreenRes();
	getAllContent();
	setAllContent();
}

window.onresize = function() {
	getWindowHeightandWidth();
	getScreenRes();
	getAllContent();
	setAllContent();
}
