function initPulldownMenuForNode(elementOrId) {
	// for IE only!
	if (document.all && document.getElementById) {
		if (typeof(elementOrId) == "string") {
			elementOrId = document.getElementById(elementOrId);
		}
		if (elementOrId != null) {
			elementOrId.onmouseover = function() {
				this.className += " hover";
			}
			elementOrId.onmouseout=function() {
				this.className = this.className.replace(" hover", "");
			}
		}
	}
}

function initPulldownMenu(elementOrId) {
	// for IE only!
	if (document.all && document.getElementById) {
		if (typeof(elementOrId) == "string") {
			elementOrId = document.getElementById(elementOrId);
		}
		if (elementOrId != null) {
			for (i = 0; i < elementOrId.childNodes.length; i++) {
				node = elementOrId.childNodes[i];
				if (node.nodeName == "LI") {
					node.onmouseover = function() {
						this.className += " hover";
					}
					node.onmouseout=function() {
						this.className = this.className.replace(" hover", "");
					}
				} else {
					initPulldownMenu(node);
				}
			}
		}
	}
}



// Div ausblenden

function hideElementById(elemId) { document.getElementById(elemId).style.display = "none"; }
function hideVisibleElementById(elemId) {document.getElementById(elemId).style.visibility = "hidden"; }


// Div anzeigen

function showElementById(elemId) { document.getElementById(elemId).style.display = "block"; }
function showVisibleElementById(elemId) {  document.getElementById(elemId).style.visibility = "visible"; }

// Divs austauschen

function toggleElementsById(oldElemId, newElemId) { hideElementById(oldElemId); showElementById(newElemId)}
function toggleVisibleElementsById(oldElemId, newElemId) { hideVisibleElementById(oldElemId); showVisibleElementById(newElemId)}



jQuery(function(){
	if (jQuery('html').hasClass('ie6')) {
		initPulldownMenu("PrimaryNavigation");

		/*fixing all flickering for ie6 */
		//document.execCommand("BackgroundImageCache", false, true)
	}
	
	if (jQuery('#PrimaryNavigation').length) {
		jQuery('#PrimaryNavigation > ul > li').slice(-2, -1).addClass("PrimaryNavigationOneBeforeLast");
		
		var minWin = 1155;
		function mainNaviOverflowHandler() {
			var winWidth = jQuery(window).width();
			
			if (winWidth > minWin) {
				jQuery("#PrimaryNavigation").addClass("lastRightDirection");
			}else{
				jQuery("#PrimaryNavigation").removeClass("lastRightDirection");
			}
		}
		
		mainNaviOverflowHandler();
		jQuery(window).resize(function() {
			mainNaviOverflowHandler();
		});
	}
});
