/*
* Menu
*/

var topMenuOffset = 55;
var mainsectionId;
var lastElement;
var visibleSubMenu = true;
var visiblePopupMenu = true;

// Popup anzeigen (ueber Name des Elements)
function showSection(thisElement, elementName)
{
  visiblePopupMenu = true;
  var subElement = document.getElementById(elementName);
  var pos = findPos(thisElement);
  subElement.style.left = pos[0] - topMenuOffset - 3;
  subElement.style.display = 'block';
  lastElement = subElement;
  hideSubMenu();
}

// Popup anzeigen
function showSubSection(thisElement)
{
  visiblePopupMenu = true;
  thisElement.parentNode.style.display = 'block';
  hideSubMenu();
}

// Popup ausblenden verzoegert
function delayHideSection()
{
  visiblePopupMenu = false;
  window.setTimeout("autoHideSection()", 1500);
}
function autoHideSection()
{
  if(lastElement != null && !visiblePopupMenu)
  {
    lastElement.style.display = 'none';
    visibleSubMenu = true;
    delayShowSubMenu();
  }
}

// Popup sofort ausblenden
function hideSection()
{
  if(lastElement != null)
  {
    lastElement.style.display = 'none';
  }
  visibleSubMenu = true;
  visiblePopupMenu = false;
  delayShowSubMenu();
}


// Untermenue verzoegert anzeigen
function delayShowSubMenu()
{
  window.setTimeout("autoShowSubMenu()", 3000);
}
function autoShowSubMenu()
{
  showSubMenu(mainsectionId);
}

// Untermenue anzeigen
function showSubMenu(thisMainsectionId)
{
  if(thisMainsectionId != null && visibleSubMenu)
  {
    var mainElement = document.getElementById(thisMainsectionId);
    var subElement = document.getElementById("menu_sub_select");
    var pos = findPos(mainElement);
    subElement.style.left = pos[0] - topMenuOffset;
    subElement.style.display = 'block';
    mainsectionId = thisMainsectionId;
  }
}

// Untermenue ausblenden
function hideSubMenu()
{
  var subElement = document.getElementById("menu_sub_select");
  subElement.style.display = 'none';
  visibleSubMenu = false;
}

// Position ermitteln
function findPos(thisElement) 
{
  var curleft = 0;
  var curtop = 0;
  if (thisElement.offsetParent) 
  {
    curleft = thisElement.offsetLeft;
    curtop = thisElement.offsetTop;
    while (thisElement = thisElement.offsetParent) 
    {
      curleft += thisElement.offsetLeft;
      curtop += thisElement.offsetTop;
    }
  }
  return new Array(curleft, curtop);
}


/*
* Inhalt
*/

// Check Frameset
window.onload=CheckFrameset;
function CheckFrameset()
{
  if(top.frames.length > 0)
  {
    top.location.href=self.location;
  }
}

// Statuszeile
function message(txt)
{
  window.status = txt;
}

// Fullscreen
function fullscreen(docpath, pagetitle, showhint)
{
  if(showhint)
  {
    alert('Sie haben die Vollbild Ansicht aktiviert. Klicken Sie auf das Symbol unten rechts oder die Tastenkombination Alt+F4 um die Vollbild Ansicht wieder zu beenden.');
  }
  fullscreenwin = window.open(docpath,pagetitle,"fullscreen, scrollbars=yes");
  fullscreenwin.focus();
}

// Zurueck Button
function goBack()
{
  if(history.length > 0)
  {
    history.back();
  }
  else
  {
    top.window.close();
  }
}

// neues Fenster
function openWindow(pfad)
{
  Fenster = top.window.open(pfad, "Information", "width=500, height=600, location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes");
  Fenster.focus();
}

// Lupe
function openWindow2(pfad, width, height)
{
  Lupe = top.window.open(pfad, "Information", "width=" + width + ", height=" + height + ", location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes");
  Lupe.focus();
}

// Lupe
function lupe(pfad, width, height)
{
  Lupe = top.window.open(pfad, "Information", "width=" + width + ", height=" + height + ", location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no");
  Lupe.focus();
}


