// ## Variablendeklarationen

  // Ausblendzeit des Menüs einstellen in Millisekunden: nicht unter 50!
  var MenuStayTime = 500;

  // "Ausblendzeit" der Metanavigation einstellen in Millisekunden
  var MetaStayTime = 500;

  // Anzahl der maximalen Divs (=Anzahl der 2. Menü-Ebenen; wird zum Ausblenden gebraucht)
  var MaxAnzMenuDivs = 10;

  // Anzahl der maximalen Einträge in der 2. Menü-Ebene
  var MaxAnz2ndMenu = 10;

  // Anzahl der maximalen Punkte in der Metanavigation
  var MaxAnzMetanavig = 10;

  var VisibleDivNr = 0;

  var menuvisible = false;
  var metavisible = false;


// ## Hauptmenü

function SetMenuStay(divname) {
  if (menuvisible == false) {
    menufade = eval("window.setTimeout(\"HideDiv('" + divname + "');menu_default();\",MenuStayTime);");
    menuvisible = true;
  }
}

function ClearMenuStay() {
  if (menuvisible == true) {
    window.clearTimeout(menufade);
    menuvisible = false;
  }
}

function highlight(obj) {
  dehighlight_2nd(VisibleDivNr);
  if (obj.className.substr(obj.className.length-12,12) != "_highlighted") {
    obj.className = obj.className + "_highlighted";
  }
  ClearMenuStay();
}

function dehighlight(obj,divname) {
  if (obj.className.substr(obj.className.length-12,12) == "_highlighted") {
    obj.className = obj.className.substr(0,obj.className.lastIndexOf("_"));
  }
  if (divname != '') {
    eval("SetMenuStay('" + divname + "');");
  }
}

function dehighlightdivall() {
  for (j=1; j<=MaxAnzMenuDivs; j++) {
    try { HideDiv('div'+j); }
    catch(e) { }
//    catch(e) { break; }
  }
}

function highlightdiv(divname) {
  dehighlightdivall();
  ShowDiv(divname);
  ClearMenuStay();
}

function HideDiv(divname) {
  if (divname != 'div0')
    document.getElementById(divname).style.visibility = "hidden";
  dehighlight_2nd(divname.substr(divname.length-1,1));
}

function ShowDiv(divname) {
  VisibleDivNr = parseInt(divname.substr(divname.length-1,1)) + 1;
try {
  if (divname != 'div0')
    document.getElementById(divname).style.visibility = "visible";
}
    catch(e) { }

}

function dehighlightdiv(divname) {
  eval("SetMenuStay('" + divname + "');");
}

function switch_1st(id, zielklasse) {
  // zielklasse = "_hell" || "_dunkel"

try {
  obj = document.getElementById('menu1_' + id);
  pfeilobj = document.getElementById('menu1_' + id + 'pfeil');

  obj.className = obj.className.substr(0,obj.className.lastIndexOf("_")) + zielklasse;
  pfeilobj.className = pfeilobj.className.substr(0,obj.className.lastIndexOf("_")) + zielklasse;
}
    catch(e) { }

}

function menu_default() {
  dehighlightall_1st();

  // 1. Menüebene auf default setzen
  if (menu_1st != 0) {

    switch_1st(menu_1st,"_hell");

    // 2. Menüebene auf default setzen
    if (menu_2nd != 0) {
      highlightdiv('div' + (menu_1st - 1));
      highlight(document.getElementById('menu' + menu_1st + '_' + menu_2nd));
    }
    if (menu_2nd == 0) {
      highlightdiv('div' + (menu_1st - 1));

    }
  }
}

function dehighlightall_1st() {
  for (i=1; i<=MaxAnzMenuDivs; i++) {
    try { switch_1st(i,"_dunkel"); }
//    catch(e) { break; }
    catch(e) { }
  }
}

function dehighlight_2nd(divnr) {
  for (k=1; k<=MaxAnz2ndMenu; k++) {
    try {
      obj = document.getElementById('menu' + divnr + '_' + k);
      if (obj.className.substr(obj.className.length-12,12) == "_highlighted") {
        obj.className = obj.className.substr(0,obj.className.lastIndexOf("_"));
      }
    }
    catch(e) { break; }
  }
}

function dehighlightall_2nd() {
  for (l=1; l<=MaxAnzMenuDivs; l++) {
    try {
      dehighlight_2nd(l);
    }
    catch(e) { break; }
  }
}

function highlight_1st(nr) {
  dehighlightall_1st();
  dehighlightdivall();
  switch_1st(nr,"_hell");
}




// ## Funktionen Meta-Navigation

function meta_default() {
  if (menu_meta != 0) {
    activateobj = document.getElementById('meta' + menu_meta);
    HighlightMeta(activateobj);
  }
}

function HighlightMeta(obj) {
  ClearMetaStay();
  FlatMeta();
  if (obj.className.substr(obj.className.length-12,12) != "_highlighted") {
    obj.className = obj.className + "_highlighted";
  }
}

function DeHighlightMeta(obj) {
  SetMetaStay();
}

function FlatMeta() {
  for (n=1; n<=MaxAnzMetanavig; n++) {
    try {
      obj = document.getElementById('meta' + n);
      if (obj.className.substr(obj.className.length-12,12) == "_highlighted") {
        obj.className = obj.className.substr(0,obj.className.lastIndexOf("_"));
      }
    }
    catch(e) { break; }
  }
}

function SetMetaStay() {
  if (metavisible == false) {
    metafade = eval("window.setTimeout(\"FlatMeta();meta_default();\",MetaStayTime);");
    metavisible = true;
  }
}

function ClearMetaStay() {
  if (metavisible == true) {
    window.clearTimeout(metafade);
    metavisible = false;
  }
}




// ## Sonstige Funktionen

  function openGalerieMitParam(link) {
    galeriePopup = window.open(link,"motivePopup","width=491,height=580,left=150,top=70,resizable=yes,scrollbars=yes,status=yes");
  }



function simpleHighlight(obj) {
  if (obj.className.substr(obj.className.length-12,12) != "_highlighted") {
    obj.className = obj.className + "_highlighted";
  }
}

function simpleDeHighlight(obj) {
  if (obj.className.substr(obj.className.length-12,12) == "_highlighted") {
        obj.className = obj.className.substr(0,obj.className.lastIndexOf("_"));
  }
}
function simpleHighlightSitemap(obj) {

  if (obj.id.substr(obj.id.length-6,6) == "_pfeil") {
    nichtpfeilobject = document.getElementById(obj.id.substr(0,obj.id.lastIndexOf("_")));
    nichtpfeilobject.className = nichtpfeilobject.className + "_highlighted";
    obj.className = obj.className + "_highlighted";
  }
  else {
    pfeilobject = document.getElementById(obj.id + "_pfeil");
    obj.className = obj.className + "_highlighted";
    pfeilobject.className = pfeilobject.className + "_highlighted";
  }
}

function simpleDeHighlightSitemap(obj) {
  if (obj.id.substr(obj.id.length-6,6) == "_pfeil") {
    nichtpfeilobject = document.getElementById(obj.id.substr(0,obj.id.lastIndexOf("_")));
    nichtpfeilobject.className = nichtpfeilobject.className.substr(0,obj.className.lastIndexOf("_"));
    obj.className = obj.className.substr(0,obj.className.lastIndexOf("_"));

  }
  else {
    pfeilobject = document.getElementById(obj.id + "_pfeil");
    obj.className = obj.className.substr(0,obj.className.lastIndexOf("_"));
    pfeilobject.className = pfeilobject.className.substr(0,pfeilobject.className.lastIndexOf("_"));
  }
}


function openWin(link, w, h) {
  imgPopup = eval('window.open(link,"ImagePopup","width='+w+',height='+h+',left=100,top=100");');
}




/* SLIDESHOW */

var slideTime = 5000;

function autoRun() {
  if ((parent.getStatus() == true) && (typeof(nextSide) != "undefined") ) {
    slideEvent = window.setTimeout("location.href='"+nextSide+"';",slideTime);
  }
}

function togglePause() {
  if (parent.getStatus() == true) {
    try {
      window.clearTimeout(slideEvent);
    } catch (e) {}
    document.getElementById("playknopf").innerHTML = '<p class="close"><img src="images/galerie/play.gif" width="7" height="6" border="0" alt="">play</p>';
    parent.setStatus(false);
  }
  else if (parent.getStatus() == false) {
    try {
      window.clearTimeout(slideEvent);
    } catch (e) {}
	  if (typeof(nextSide) != "undefined")
	    slideEvent = window.setTimeout("location.href='"+nextSide+"';",slideTime);
    document.getElementById("playknopf").innerHTML = '<p class="close"><img src="images/galerie/pause.gif" width="7" height="6" border="0" alt="">pause</p>';
    parent.setStatus(true);
  }
}

function initKnopf() {
  if (parent.getStatus() == false) {
    document.getElementById("playknopf").innerHTML = '<p class="close"><img src="images/galerie/play.gif" width="7" height="6" border="0" alt="">play</p>';
  }
  else if (parent.getStatus() == true) {
    document.getElementById("playknopf").innerHTML = '<p class="close"><img src="images/galerie/pause.gif" width="7" height="6" border="0" alt="">pause</p>';
  }
}




/* SCROLLBAR-TABELLE: HÖHE AN FENSTER ANPASSEN */
function scrollAdjust(korrektur, seite) {
  if (((document.body.offsetHeight-460+korrektur)>50) && (document.all))
    document.getElementById("scrollbarliste_"+seite).style.height = (document.body.offsetHeight-460+korrektur) + 'px';
}

function anpassungNS() {
  if (!document.all && document.getElementById) {
    document.getElementById("ns_anpassung_lnb_links").style.width = '147px';
    document.getElementById("ns_anpassung_lnb_rechts").style.width = '199px';
  }
}