//Begin: Open Window1
var fenster = null;
function openWin(link,width,height) {
  parameter =
"width="+width+",height="+height+",scrollbars=yes,toolbar=no,top=50,left=10";
  link2=""+link;
  if (fenster != null) {
	 if (!fenster.closed) fenster.close();
	 }
     fenster = window.open(link2, 'fenster', parameter);
}
//End: Open Window1

//Begin: Open Window2
var fenster = null;
function openWin2(link,width,height) {
  parameter =
"width="+width+",height="+height+",scrollbars=no,toolbar=no, resizable=no, top=50,left=10";
  link2=""+link;
  if (fenster != null) {
	 if (!fenster.closed) fenster.close();
	 }
     fenster = window.open(link2, 'fenster', parameter);
}
//End: Open Window2

//Start: Netscape Bug
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//End: Netscape Bug>

//Start: Foldertree
var temp, temp2, cookieArray, cookieArray2, cookieCount;

function initiate(){

  cookieCount=0;

  if(document.cookie){

    cookieArray=document.cookie.split(";");
    cookieArray2=new Array();

    for(i in cookieArray){
      cookieArray2[cookieArray[i].split("=")[0].replace(/ /g,"")]=cookieArray[i].split("=")[1].replace(/ /g,"");
    }

  }

  cookieArray=(document.cookie.indexOf("state=")>=0)?cookieArray2["state"].split(","):new Array();

  temp=document.getElementById("containerul");

  for(var o=0;o<temp.getElementsByTagName("li").length;o++){

    if(temp.getElementsByTagName("li")[o].getElementsByTagName("ul").length>0){

      temp2                                = document.createElement("span");
      temp2.className                        = "symbols";
      temp2.style.backgroundImage        = (cookieArray.length>0)?((cookieArray[cookieCount]=="true")?"url(../sitemap/minus01.gif)":"url(../sitemap/plus01.gif)"):"url(../sitemap/plus01.gif)";
      temp2.onclick=function(){
        showhide(this.parentNode);
        writeCookie();
      }

      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild)

      temp.getElementsByTagName("li")[o].getElementsByTagName("ul")[0].style.display = "none";

      if(cookieArray[cookieCount]=="true"){
        showhide(temp.getElementsByTagName("li")[o]);
      }

      cookieCount++;

    }
    else{

      temp2                                = document.createElement("span");
      temp2.className                        = "symbols";
      temp2.style.backgroundImage        = "url(../sitemap/spacer.gif)";

      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild);

    }

  }

}



function showhide(el){

  el.getElementsByTagName("ul")[0].style.display=(el.getElementsByTagName("ul")[0].style.display=="block")?"none":"block";

  el.getElementsByTagName("span")[0].style.backgroundImage=(el.getElementsByTagName("ul")[0].style.display=="block")?"url(../sitemap/minus01.gif)":"url(../sitemap/plus01.gif)";

}



function writeCookie(){                // Runs through the menu and puts the "states" of each nested list into an array, the array is then joined together and assigned to a cookie.

  cookieArray=new Array()

  for(var q=0;q<temp.getElementsByTagName("li").length;q++){

    if(temp.getElementsByTagName("li")[q].childNodes.length>0){
      if(temp.getElementsByTagName("li")[q].childNodes[0].nodeName=="SPAN" && temp.getElementsByTagName("li")[q].getElementsByTagName("ul").length>0){

        cookieArray[cookieArray.length]=(temp.getElementsByTagName("li")[q].getElementsByTagName("ul")[0].style.display=="block");

      }
    }

  }

  document.cookie="state="+cookieArray.join(",")+";expires="+new Date(new Date().getTime() + 365*24*60*60*1000).toGMTString();

}
//End: Foldertree

//Begin: Link aus Popup

function ShowDocument(URL)
{
opener.location.href=URL;
return;
}
//End: Link aus Popup

// Benötigter JavaScript-Code: navigation


var DOM = document.getElementById;

function menu(obj) {
  if (DOM) {
    if(obj.getElementsByTagName("div")[0].style.visibility=='visible') {
      obj.getElementsByTagName("div")[0].style.visibility='hidden';
	  } else {
      obj.getElementsByTagName("div")[0].style.visibility='visible';  
	  }
  }
}

function attach_event() {
	if(document.getElementById("navi")) {
		var sub,i;
		sub = document.getElementById("navi").getElementsByTagName("div");
		for(i=0;i<sub.length;i++) {
			sub[i].parentNode.onmouseover = function() {menu(this)};
			sub[i].parentNode.onmouseout = function() {menu(this)};
			sub[i].parentNode.onfocus  = function() {menu(this)};
		}
	}
}

if(DOM) {
	window.onload = function() {
		attach_event();
	}
}