var ActiveRoot = "";
var RootLink = "";

function MenueOn(trg) {
    var ParentOfStarter = trg.parentNode;
    var ParentOfParent = ParentOfStarter.parentNode;
    
    trg.style.backgroundColor = "#fff";
    trg.style.color = "#000";
	
	for (i=0;i<ParentOfParent.childNodes.length;i++) {
		if (ParentOfParent.childNodes[i] != ParentOfStarter) {
			ParentOfParent.childNodes[i].firstChild.style.backgroundColor = "#fff";
    		ParentOfParent.childNodes[i].firstChild.style.color = "#ccc";

			var tmpoff = ParentOfParent.childNodes[i].firstChild.nextSibling;
			if (tmpoff!=null) {
				tmpoff.style.display = "none";
			}
		}
	}

    for (j=0; j < ParentOfStarter.childNodes.length; j++) {
        var tmp = ParentOfStarter.childNodes[j];
        if (tmp.nodeName == "UL") {
        		tmp.style.display = "block";
        		for (k=0;k<tmp.childNodes.length;k++) {
	        		tmp.childNodes[k].firstChild.style.color = "#ccc";
	        		tmp.childNodes[k].firstChild.style.backgroundColor = "#fff";

	        		if (tmp.childNodes[k].firstChild.nextSibling != null) {
	        			tmp.childNodes[k].firstChild.nextSibling.style.display ="none";
	        		}
        		}
        } 
    }
    
	if (trg==ActiveRoot) {
		MarkMenue();
	}
}

function MarkMenue() {
	if(document.getElementById("active")){
	var trg = document.getElementById("active");
	var NextNode = trg.parentNode.parentNode;

	trg.style.backgroundColor = "#fff";
    trg.style.color = "#980019";
    ActiveRoot = trg;

	while (NextNode.className != "mainmenue") {
		NextNode.style.display = "block";
		NextNode.previousSibling.style.color = "#ccc";
		NextNode.previousSibling.style.backgroundColor = "#fff";
		RootLink = NextNode.previousSibling;
		NextNode = NextNode.parentNode.parentNode;
	}
	
	if (NextNode.className == "mainmenue" ) {
		if (RootLink !="") {
			ActiveRoot = RootLink;
		}
		
		for (i=0;i<document.getElementById("mainmenue").childNodes.length;i++) {
			if (document.getElementById("mainmenue").childNodes[i].firstChild != ActiveRoot) {
				document.getElementById("mainmenue").childNodes[i].firstChild.style.color = "#ccc";
				document.getElementById("mainmenue").childNodes[i].firstChild.style.backgroundColor = "#fff";
				if (document.getElementById("mainmenue").childNodes[i].firstChild.nextSibling!=null) {
					document.getElementById("mainmenue").childNodes[i].firstChild.nextSibling.style.display = "none";
				}
			}
		}
	}
	}
}

function FadeMenue() {
	setTimeout("MarkMenue()", 3000);
//MarkMenue();
}
