var BOX_HEIGHT_CORRECTION = -22;
if (navigator.appVersion.split('MSIE 6').length != 1)
	var BOX_HEIGHT_CORRECTION = -12;
var TEXTBOX_HEIGHT_CORRECTION = 0;
var BILDBOX_HEIGHT_CORRECTION = -10;
var SITEMAPBOX_HEIGHT_CORRECTION = 0;

var CLASSNAME_PARENTBOX = 'calcHeightContainer';

var CLASSNAME_CHILDBOXES = 'calcHeightBox';
var CLASSNAME_CHILDTEXTBOXES = 'calcHeightBoxText';
var CLASSNAME_CHILDBILDBOXES = 'calcHeightBoxBild';
var CLASSNAME_CHILDSITEMAPBOXES = 'calcHeightBoxSitemap';

if (window.attachEvent)
	window.attachEvent("onload", calcBoxHeightAll);
else
	window.addEventListener("DOMContentLoaded", calcBoxHeightAll, false);
	
var sitemapContainerList = new Array();

function calcBoxHeightAll() {
	divList = document.getElementsByTagName('div');
	containerList = new Array();
	for (i=0; i<divList.length; i++)
		if (divList[i].className.indexOf(CLASSNAME_PARENTBOX)!=-1) containerList.push(divList[i]);
	for (i=0; i<containerList.length; i++) {
		ergHeight = 0;
		ergList = new Array();
		ergTextList = new Array();
		divBoxList = containerList[i].getElementsByTagName('div');
		for (j=0; j<divBoxList.length; j++)
			if (divBoxList[j].className.indexOf(CLASSNAME_CHILDBOXES)!=-1)
				ergList.push(divBoxList[j]);

		for (j=0; j<ergList.length; j++)
			ergList[j].style.height = 'auto';

		for (j=0; j<ergList.length; j++) {
			if (ergList[j].className.indexOf(CLASSNAME_CHILDTEXTBOXES)!=-1)
				tmpHeight = ergList[j].scrollHeight + TEXTBOX_HEIGHT_CORRECTION; // TEXTBOX
			else if (ergList[j].className.indexOf(CLASSNAME_CHILDBILDBOXES)!=-1)
				tmpHeight = ergList[j].scrollHeight + BILDBOX_HEIGHT_CORRECTION; // BILDBOX
			else if (ergList[j].className.indexOf(CLASSNAME_CHILDSITEMAPBOXES)!=-1) {
				tmpHeight = ergList[j].scrollHeight + SITEMAPBOX_HEIGHT_CORRECTION; // SITEMAPBOX
				sitemapContainerList.push(ergList[j].parentNode.parentNode);
			}
			else
				tmpHeight = ergList[j].scrollHeight + BOX_HEIGHT_CORRECTION; // STANDARD
			if (tmpHeight > ergHeight) {
				ergHeight = tmpHeight;
			}
		}
		for (j=0; j<ergList.length; j++)
			ergList[j].style.height = ergHeight+'px';
	}
	setSitemapContainerWidthForIE();
}

function setSitemapContainerWidthForIE() {
	if ((navigator.appVersion.split('MSIE 6').length != 1) || (navigator.appVersion.split('MSIE 6').length != 1)) {
		if (sitemapContainerList.length != 0) {
			var aktSitemapContainer = null;
			for (i=0; i<sitemapContainerList.length; i++) {
				if (sitemapContainerList[i] != aktSitemapContainer) {
						sitemapBoxList = sitemapContainerList[i].getElementsByTagName('div');
						sitemapBoxListErg = new Array();
						for (j=0; j<sitemapBoxList.length; j++) {
							if (sitemapBoxList[j].className == 'sitemap_box calcHeightBoxSitemap')
								sitemapBoxListErg.push(sitemapBoxList[i]);
						}
						if (sitemapBoxListErg.length == 3)
							sitemapContainerList[i].style.width = '522px';
						else if (sitemapBoxListErg.length == 2)
							sitemapContainerList[i].style.width = '349px';
						else if (sitemapBoxListErg.length == 1)
							sitemapContainerList[i].style.width = '174px';
				}
				aktSitemapContainer = sitemapContainerList[i];
			}
		}
	}
}
