function centerTopNav(containerID) {	
	var elems = $(containerID + ' .topnavi_item, ' + containerID + ' .topnavi_divider');
	var elemWidth = 0;
	
	for (var i = 0, j = elems.length; i < j; i++) {
		elemWidth += elems[i].offsetWidth;
	}
	
	var container = $(containerID);
	var containerWidth = container[0].offsetWidth;
	
	var newLeft = containerWidth - elemWidth - 35;
	
	$(containerID).css("left", newLeft);
}

function initMenu(containerID) {
	//Alle ULs innerhalb des Containers auf display none setzen
	$(containerID + " ul").css("display", "none");
	
	//Auf alle Div-Elemente innerhalb des Containers einen Hover-Effekt setzen
	$(containerID + " div .topnavi_item, " + containerID + " li").hover(function() {
									$(this).find('ul:first:hidden').css({visibility: "visible",display: "none"}).show(0);
									}, function() {
									$(this).find('ul:first').css({display: "none"});
									});
}

function initTopNav() {
	//Auf alle topnavi_items eine Hoverfunktion setzen
	$('.topnavi_item').hover(function() {
				//Wenn es sich um kein inaktives Element handelt, dann nichts machen
				if (!$(this).hasClass("navi_inactive")) return ;
				//Inaktive Klasse entfernen
				$(this).removeClass("navi_inactive");
				//und Hovered Klasse hinzufügen
				$(this).addClass("navi_hovered");
			}, function() {
				//Wenn es sich um kein gehovertes element handelt, dann nichts machen
				if (!$(this).hasClass("navi_hovered")) return ;
				//Hovered Klasse entfernen
				$(this).removeClass("navi_hovered");
				//und inaktive Klasse hinzufügen
				$(this).addClass("navi_inactive");
			}
			);
}

function doSiteLoadEvents() {
	setFooterSpacer();
}

function setFooterSpacer() {
	windowHeight = typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight;
	pageHeight = document.getElementById("overall_layer").clientHeight;
	//alert(windowHeight);
	//alert(pageHeight);
	if (windowHeight > pageHeight) {
		footerSpacerHeight = windowHeight - pageHeight;		
		document.getElementById("footerSpacer").style.height = footerSpacerHeight + 'px';
		//alert("adjusting height to " + footerSpacerHeight);
		//alert(document.getElementById("footerSpacer").style.height);
	}
	else {
		$('#footerSpacer').css("display", "none");
		//alert("hiding footerSpacer");
	}
}
