var ie_55 = false;
var browser = navigator.userAgent;
var re = /M\SIE (.+);/i;
var platform = new String(navigator.platform);
if(platform.indexOf("Win") != -1){
	result = browser.match(re);
	if(result != null){
		if (parseFloat(result[1]) < 5.5) ie_55 = true;
	}
}

// Coded by Travis Beckham
// http://www.squidfingers.com | http://www.podlob.com
// If want to use this code, feel free to do so, but please leave this message intact.

if(!window.Node){
	var Node = {ELEMENT_NODE : 1, TEXT_NODE : 3};
}
function checkNode(node, filter){
	return (filter == null || node.nodeType == Node[filter] || node.nodeName.toUpperCase() == filter.toUpperCase());
}
function getChildren(node, filter){
	var result = new Array();
	var children = node.childNodes;
	for(var i = 0; i < children.length; i++){
		if(checkNode(children[i], filter)) result[result.length] = children[i];
	}
	return result;
}
function getChildrenByElement(node){
	return getChildren(node, "ELEMENT_NODE");
}
function getFirstChild(node, filter){
	var child;
	var children = node.childNodes;
	for(var i = 0; i < children.length; i++){
		child = children[i];
		if(checkNode(child, filter)) return child;
	}
	return null;
}
function getFirstChildByText(node){
	return getFirstChild(node, "TEXT_NODE");
}
function getFirstChildByTagName(node, tag){
  return getFirstChild(node, tag);
}
function getNextSibling(node, filter){
	for(var sibling = node.nextSibling; sibling != null; sibling = sibling.nextSibling){
		if(checkNode(sibling, filter)) return sibling;
	}
	return null;
}
function getNextSiblingByElement(node){
	return getNextSibling(node, "ELEMENT_NODE");
}

function getAncestors(node){
  var result = new Array();
  while(node.parentNode != null){
    result[result.length] = node.parentNode;
    node = node.parentNode;
  }
  return result;
}

// ||||||||||||||||||||||||||||||||||||||||||||||||||
// Menu Functions & Properties

var activeMenu = null;

function showMenu(){
	var parent;
	if(activeMenu){
		activeMenu.className = "";
		parent = getAncestors(activeMenu);
		getNextSiblingByElement(parent[0]).style.display = "none";
	}
	if(this == activeMenu){
		activeMenu = null;
	}else{
		this.className = "active";
		parent = getAncestors(this);
		getNextSiblingByElement(parent[0]).style.display = "block";
		activeMenu = this;
	}
	return false;
}
function initMenu(){
	var menus, menu, text, a, i, span, uls;
	menus = getChildrenByElement(document.getElementById("menu"));
	for(i = 0; i < menus.length; i++){
		menu = menus[i];
		if(span = getFirstChildByTagName(menu, "strong")){
			if(uls = getFirstChildByTagName(menu, "ul")){
				if(uls != document.getElementById("menu")){
					uls.style.display = "none";
					text = getFirstChildByText(span);
					a = document.createElement("a");
					span.replaceChild(a, text);
					a.appendChild(text);
					a.href = "#";
					a.onclick = showMenu;
					a.onfocus = function(){this.blur()};
					a.setAttribute("title", "Öffnen/Schliessen des Bereichs");
					span.style.padding = "0";
					if(menu.className == "open"){
						uls.style.display = "block";
						a.className = "active";
						activeMenu = a;
					}
				}
			}
		}
	}
}

function blurAnchors(){
  if(document.getElementsByTagName){
    var a = document.getElementsByTagName("a");
    for(var i = 0; i < a.length; i++){
      a[i].onfocus = function(){this.blur()};
    }
  }
}


if(document.createElement && !ie_55) {
	window.onload = function() { initMenu(); blurAnchors();}
}
if(ie_55) {
	window.onload = function() { blurAnchors();}
}



