var menuOpenItems = 0;
var menuItemsCount = 0;

startList = function() {
  if ((document.all && document.getElementById)||true) {
    navRoot = menu_gid("navigation_root");
    processList(navRoot);
  }
  window.setInterval('recoverMenu()',1000);
}

function processList(navRoot) {
  if(navRoot && navRoot.childNodes) {
    for (var i=0; i<navRoot.childNodes.length; i++) {
      menuItemsCount++;
      node = navRoot.childNodes[i];
      if (node.nodeName=="LI") {
        //node.className = "off";
        node.onmouseover=function() {
          this.className="over";
          menuOpenItems++;
        }
        node.onmouseout=function() {
          this.className="";
          //this.className=this.className.replace(" over", "");
          menuOpenItems--;
        }
        subLists = node.getElementsByTagName('ul');
        for (j in subLists) {
          processList(subLists[j]);
        }
      }
    }
  }
}

/* window.onload=startList; */

function recoverMenu() {
  var ids;
  if(menuOpenItems == 0 && window.generic_recover_menu) {
    ids = generic_recover_menu();
    for(i in ids) {
      menu_gid(ids[i]).className = "over";
    }
  }
}

function gtn(tag) {
  return document.getElementsByTagName(tag);
}

function dw(str) {
  document.write(str);
}

function menu_gid(id) {
  return document.getElementById(id);
}

function rec_sprachlink(seite) {
	var a=window.location.href;
	/* URL am ? trennen */
	var b = a.split("?");
	/* Parameter am & trennen */
	var c = b[1].split("&");
	/* Nach Parameter L suchen und ersetzen */
	var gefunden=false;
	for (i=0;i<c.length;i++){
		if(c[i].slice(0,2)=="L="){
			gefunden=true;
			var sprache=c[i].slice(2,3);
		}
		/* Falls gar kein L-Parameter existierte ergnzen */
		if(gefunden==true){
		   c[i]="L="+sprache;
		}
	}
	var neueurl=b[0]+"?id="+seite;
	/* restliche Parameter anhngen */
	for (i=0;i<c.length;i++){
		if(i>0) neueurl=neueurl+"&";
		if(c[i].slice(0,3)!="id=") neueurl=neueurl + c[i];
	}
	/* Sprache = 0, wenn vorher nicht definiert! */
	if(gefunden==false){
		neueurl=neueurl+"&L=0";
	}
	lastpage=window.location.href;
	neueurl=neueurl+"&lastpage="+escape(lastpage);
	
	//alert(neueurl);
	setTimeout('location.href="'+neueurl+'"',10);
}
