
var flags=new Array();
var flagsLoaded = 0;

var isStartPage = 0;


var menuIllustrationType = 1;    // 1:klein, 2:gross
var menuIllustrationHStepSize;
var menuIllustrationVStepSize;
var menuIllustrationZoomOutRunning = 0;
var menuIllustrationZoomInRunning = 0;
var menuIllustrationZoomTimeout = 0;
var menuIllustrationOriginalTop = 216;
var menuIllustrationOriginalLeft = 26;
var menuIllustrationImageSmall = new Image();
var menuIllustrationImageLarge = new Image();
var menuIllustrationDescription = "";
var menuIllustrationDescriptionTimeout = 0;

var menuItemBackgroundColor1 = "#c6d6c6";
var menuItemBackgroundColor2 = "#eaefea";

var submenuOpenTimeout = 500;
var submenuCloseTimeout = 4000;

var submenuVorstellungIds = new Array('td_submenu_vorstellung_personalia');
var submenuVorstellungHrefs = new Array('');
var submenuVorstellungTexts = new Array('Personalia');
var submenuVorstellungData = new Array(1,submenuVorstellungIds,submenuVorstellungHrefs,submenuVorstellungTexts,'tr_menu_vorstellung','td_menu_vorstellung',0,0,0);

var submenuVeranstaltungenIds = new Array('td_submenu_veranstaltungen_kolloquien','td_submenu_veranstaltungen_einzelvortraege','td_submenu_veranstaltungen_kongress','td_submenu_veranstaltungen_tagungen','td_submenu_veranstaltungen_sonstige','td_submenu_veranstaltungen_archiv');
var submenuVeranstaltungenHrefs = new Array('/veranstaltungen/kolloquien.htm','/veranstaltungen/einzelvortraege.htm','/veranstaltungen/kongress2013.htm','/veranstaltungen/tagungen.htm','/veranstaltungen/sonstige.htm','/veranstaltungen/archiv.htm');
var submenuVeranstaltungenTexts = new Array('Forschungskolloquien','Einzelvorträge','Kongress 2013','Tagungen & Arbeitskreise','Sonstige Veranstaltungen','Archiv');
var submenuVeranstaltungenData = new Array(6,submenuVeranstaltungenIds,submenuVeranstaltungenHrefs,submenuVeranstaltungenTexts,'tr_menu_veranstaltungen','td_menu_veranstaltungen',0,0,0);

var submenuProjekteIds = new Array('td_submenu_projekte_bibliographien','td_submenu_projekte_editionen','td_submenu_projekte_historiographie','td_submenu_projekte_pfarrerbuch');
var submenuProjekteHrefs = new Array('/projekte/bibliographien.htm','/projekte/editionen.htm','/projekte/historiographie.htm','/projekte/pfarrerbuch.htm');
var submenuProjekteTexts = new Array('Bibliographien','Editionen','Historiographische Projekte','Pfarrerbuch');
var submenuProjekteData = new Array(4,submenuProjekteIds,submenuProjekteHrefs,submenuProjekteTexts,'tr_menu_projekte','td_menu_projekte',0,0,0);

var submenuPublikationenIds = new Array('td_submenu_publikationen_pun','td_submenu_publikationen_hf','td_submenu_publikationen_einzel');
var submenuPublikationenHrefs = new Array('/publikationen/pun.htm','/publikationen/hallesche_forschungen.htm','/publikationen/einzel.htm');
var submenuPublikationenTexts = new Array('Pietismus und Neuzeit','Hallesche Forschungen','Einzelveröffentlichungen');
var submenuPublikationenData = new Array(3,submenuPublikationenIds,submenuPublikationenHrefs,submenuPublikationenTexts,'tr_menu_publikationen','td_menu_publikationen',0,0,0);

var submenuData = new Array(submenuVorstellungData,submenuVeranstaltungenData,submenuProjekteData,submenuPublikationenData);

var submenuLineHeight = 14;  // circa-Wert, wird benutzt bei der Erweiterung der Seitenhoehe bei Oeffnen der Submenus


var menuObject
var menuBaseOffset;
var menuActualOffset;
var menuOffsetToBe;
var menuHeight = 410;
var oldVerticalScrollPosition = 0;
var lastScrollDirection = 0;    // 1=down 2=up
var scrollPositionPeak = 0;
var menuMoveStep;
var menuMoveStep1 = 8;
var menuMoveDistance1 = 80;
var menuMoveStep2 = 6;
var menuMoveDistance2 = 60;
var menuMoveStep3 = 4;
var menuMoveDistance3 = 40;
var menuMoveStep4 = 2;
var menuMoveDistance4 = 20;
var menuShiftRunning = 0;
var menuShiftStartOffset = 0;
var scrollingJustStopped = 0;

var pictureString = "";




/* Ermittlung einer Objektvariable anhand der ID*/

function GetObj(objId,docObj)
{
  var i,objVar;

  if (!docObj) docObj=document;

  if (docObj.all)
    objVar=docObj.all[objId];
  if (docObj.layers)
    for (i=0; !objVar && i<docObj.layers.length; i++)
      objVar = GetObj(objId,docObj.layers[i].document);
  if (docObj.forms)
    for (i=0; !objVar && i<docObj.forms.length; i++)
      objVar = docObj.forms[i][objId];
  if (!objVar)
    objVar=docObj.getElementById(objId);

  return objVar;
}


function GetVerticalScrollPosition()
{
  var yOffset;

  if (self.pageYOffset)
    yOffset = self.pageYOffset;
  else if (document.documentElement && document.documentElement.scrollTop)
    yOffset = document.documentElement.scrollTop;
  else if (document.body)
    yOffset = document.body.scrollTop;

  return yOffset;
}


function GetWindowInnerHeight()
{
  var windowHeight;
  if (document.all)
    windowHeight = document.body.clientHeight;
  else
    windowHeight = window.innerHeight;
  return windowHeight;
}


function PreloadFlags(rootPath)
{
  for (i=0; i<4; i++) 
    flags[i] = new Image();

  flags[0].src =  rootPath + "/bilder/flaggen/de16.gif";
  flags[1].src =  rootPath + "/bilder/flaggen/de16_2.gif";
  flags[2].src =  rootPath + "/bilder/flaggen/en16.gif";
  flags[3].src =  rootPath + "/bilder/flaggen/en16_2.gif";

  flagsLoaded = 1;
}


function LoadImageSource(dstImgName,srcImg)
{
  document.images[dstImgName].src = srcImg.src;
}


function PreloadIllustrationImages(smallIllustrationPath,smallIllustrationWidth,smallIllustrationHeight,largeIllustrationPath,largeIllustrationWidth,largeIllustrationHeight,description)
{
  menuIllustrationImageSmall.src = smallIllustrationPath;
  menuIllustrationImageLarge.src = largeIllustrationPath;
  menuIllustrationImageSmall.width = smallIllustrationWidth;
  menuIllustrationImageSmall.height = smallIllustrationHeight;
  menuIllustrationImageLarge.width = largeIllustrationWidth;
  menuIllustrationImageLarge.height = largeIllustrationHeight;
  menuIllustrationDescription = description;
  
  if (smallIllustrationHeight < 160)
    SetGlobalVariables(smallIllustrationHeight + 235);
  else
    SetGlobalVariables(smallIllustrationHeight + 230);
}


function SetGlobalVariables(ActualMenuBaseOffset, ActualMenuMaxOffset)
{
  menuBaseOffset = ActualMenuBaseOffset;
  menuOffsetToBe = menuBaseOffset;
  menuMaxOffset = ActualMenuMaxOffset;
  menuActualOffset = menuBaseOffset;
}


function HeadScripts(rootPath,isStartPage,language)  // language: 1=deutsch 2=english
{
  if (!rootPath)
    rootPath = "";
  if (!isStartPage)
    isStartPage = 0;
  if (!language)
    language = 1;
  if(top.frames.length > 0)
    top.location.href=self.location;

  if (!flagsLoaded) PreloadFlags(rootPath);
}


function OnBodyLoadScripts()
{
  menuObject = GetObj('div_menue');
  SetMenuOffsetToBe();
}


function WriteBodyTag(attributes)
{
  if (!attributes)
    attributes = "";

  document.write("\
    <body leftMargin=0 topMargin=0 marginwidth=0 marginheight=0 onLoad='OnBodyLoadScripts()' " + attributes + ">\
  ");
}


function BodyScripts(rootPath)
{
  if (!rootPath)
    rootPath = "";
}


function SetBackgroundColor(id,color)
{
  var element = GetObj(id);
  element.style.backgroundColor = color;
}


function SetBackgroundColorForAllMenuItems(color)
{
  var trElement;
  var i;
  if (!isStartPage)
    trElement = GetObj('tr_menu_home');
  else
    trElement = GetObj('tr_menu_vorstellung');
  do
  {
    for (i=0; i<trElement.childNodes.length; i++)
    {
      if (trElement.childNodes[i].nodeName.search(/td/i) >= 0)
        trElement.childNodes[i].style.backgroundColor = color;
    }
    trElement = trElement.nextSibling;
  }
  while (trElement != null);
}


function OpenSubmenu(rootPath,submenuDataIdx,timeout)
{
  var htmlString, htmlSubString1, htmlSubString2, htmlStringDummy, htmlStringSubmenu="";
  var htmlStringSubmenuOffset;
  var i;

  var submenuItemCount = submenuData[submenuDataIdx][0];
  var submenuItemIds = submenuData[submenuDataIdx][1];
  var submenuHrefs = submenuData[submenuDataIdx][2];
  var submenuItemTexts = submenuData[submenuDataIdx][3];
  var submenuTrId = submenuData[submenuDataIdx][4];
  var submenuTdId = submenuData[submenuDataIdx][5];

  if (!timeout)
    timeout = submenuOpenTimeout;

  CloseAllSubmenus(rootPath);

  if (submenuData[submenuDataIdx][8])        // close-timeout ist gesetzt
  {
    window.clearTimeout(submenuData[submenuDataIdx][8]);
    submenuData[submenuDataIdx][8] = 0;
  }

  if ((submenuData[submenuDataIdx][7] == 0) && (timeout > 0))        // open-timeout ist nicht gesetzt, soll aber benutzt werden
  {
    submenuData[submenuDataIdx][7] = window.setTimeout("OpenSubmenu(\"" + rootPath + "\",\"" + submenuDataIdx + "\")",timeout);
  }
  else
  {


  if (submenuData[submenuDataIdx][6] == 0)  // ist noch nicht geoeffnet
  {
    if (document.all)
    {
      for (i=0; i<submenuItemCount; i++)
      {
        htmlStringSubmenu += "\
          <tr>\
            <td id='" + submenuItemIds[i] + "' class='submenu_item'>\
              <a class='submenu_item' href='" + rootPath + submenuHrefs[i] + "' target=_self\
                onMouseOver='SetBackgroundColor(\"" + submenuItemIds[i] + "\",\"" + menuItemBackgroundColor2 + "\");OpenSubmenu(\"" + rootPath + "\",\"" + submenuDataIdx + "\");'\
                onMouseOut='SetBackgroundColor(\"" + submenuItemIds[i] + "\",\"" + menuItemBackgroundColor1 + "\");CloseSubmenu(\"" + rootPath + "\",\"" + submenuDataIdx + "\");'>" + submenuItemTexts[i] + "</a></td>\
            </tr>\
          ";
      }
      htmlStringSubmenu += "\
         <tr>\
           <td class='menu_space'>\
             <img src='" + rootPath + "/bilder/blind.gif' width=1 height=2 border=0></td>\
         </tr>\
        ";
      htmlString = document.all.table_menu.outerHTML;
      htmlStringSubmenuOffset = htmlString.indexOf(submenuTdId);
      htmlStringDummy = htmlString.slice(htmlStringSubmenuOffset);
      htmlStringSubmenuOffset += htmlStringDummy.search(/<\/tr>/i) + 5;
      htmlSubString1 = htmlString.substr(0,htmlStringSubmenuOffset);
      htmlSubString2 = htmlString.substr(htmlStringSubmenuOffset);
      document.all.table_menu.outerHTML = htmlSubString1 + htmlStringSubmenu + htmlSubString2;
    }
    else
    {
      var trElement;
      var tdElement;
      var idAttribute;
      var classAttribute1;
      var classAttribute2;
      var aElement;
      var hrefAttribute;
      var targetAttribute;
      var onMouseOverAttribute;
      var onMouseOutAttribute;
      var textElement;
      var imgElement;
      var srcAttribute;
      var widthAttribute;
      var heightAttribute;
      var borderAttribute;

      trElement = document.createElement('tr');
      tdElement = document.createElement('td');
      classAttribute1 = document.createAttribute("class");
      classAttribute1.nodeValue = "menu_space";
      imgElement = document.createElement('img');
      srcAttribute = document.createAttribute("src");
      srcAttribute.nodeValue = rootPath + "/bilder/blind.gif";
      widthAttribute = document.createAttribute("width");
      widthAttribute.nodeValue = 1;
      heightAttribute = document.createAttribute("height");
      heightAttribute.nodeValue = 2;
      borderAttribute = document.createAttribute("border");
      borderAttribute.nodeValue = 0;
      imgElement.setAttributeNode(srcAttribute);
      imgElement.setAttributeNode(widthAttribute);
      imgElement.setAttributeNode(heightAttribute);
      imgElement.setAttributeNode(borderAttribute);
      tdElement.appendChild(imgElement);
      tdElement.setAttributeNode(classAttribute1);
      trElement.appendChild(tdElement);
      if (document.getElementById(submenuTrId).nextSibling != null)
        document.getElementById(submenuTrId).parentNode.insertBefore(trElement,document.getElementById(submenuTrId).nextSibling);
      else
        document.getElementById(submenuTrId).parentNode.appendChild(trElement);

      for (i=submenuItemCount-1; i>=0; i--)
      {
        trElement = document.createElement('tr');
        tdElement = document.createElement('td');
        idAttribute = document.createAttribute("id");
        idAttribute.nodeValue = submenuItemIds[i];
        classAttribute1 = document.createAttribute("class");
        classAttribute1.nodeValue = "submenu_item";
        classAttribute2 = document.createAttribute("class");
        classAttribute2.nodeValue = "submenu_item";
        aElement = document.createElement('a');
        hrefAttribute = document.createAttribute("href");
        hrefAttribute.nodeValue = rootPath + submenuHrefs[i];
        targetAttribute = document.createAttribute("target");
        targetAttribute.nodeValue = "_self";
        onMouseOverAttribute = document.createAttribute("onMouseOver");
        onMouseOverAttribute.nodeValue = "SetBackgroundColor(\"" + submenuItemIds[i] + "\",\"" + menuItemBackgroundColor2 + "\");OpenSubmenu(\"" + rootPath + "\",\"" + submenuDataIdx + "\");";
        onMouseOutAttribute = document.createAttribute("onMouseOut");
        onMouseOutAttribute.nodeValue = "SetBackgroundColor(\"" + submenuItemIds[i] + "\",\"" + menuItemBackgroundColor1 + "\");CloseSubmenu(\"" + rootPath + "\",\"" + submenuDataIdx + "\");";
        textElement = document.createTextNode(submenuItemTexts[i]);
        aElement.appendChild(textElement);
        aElement.setAttributeNode(classAttribute1);
        aElement.setAttributeNode(hrefAttribute);
        aElement.setAttributeNode(targetAttribute);
        aElement.setAttributeNode(onMouseOverAttribute);
        aElement.setAttributeNode(onMouseOutAttribute);
        tdElement.setAttributeNode(idAttribute);
        tdElement.appendChild(aElement);
        tdElement.setAttributeNode(classAttribute2);
        trElement.appendChild(tdElement);
        if (document.getElementById(submenuTrId).nextSibling != null)
          document.getElementById(submenuTrId).parentNode.insertBefore(trElement,document.getElementById(submenuTrId).nextSibling);
        else
          document.getElementById(submenuTrId).parentNode.appendChild(trElement);
      }      
    }
    if (!isStartPage)
      GetObj('td_main').height = parseInt(GetObj('td_main').height) + (submenuItemCount * submenuLineHeight);
    SetBackgroundColorForAllMenuItems(menuItemBackgroundColor1);
  }
  submenuData[submenuDataIdx][6] = 1;
  submenuData[submenuDataIdx][7] = 0;
  }
}


function CloseSubmenu(rootPath,submenuDataIdx)
{
  var htmlString, htmlSubString1, htmlSubString2, htmlStringDummy, htmlStringSubmenu="";
  var htmlSubStringOffset;
  var parentNode;
  var i;

  var submenuItemCount = submenuData[submenuDataIdx][0];
  var submenuItemIds = submenuData[submenuDataIdx][1];
  var submenuHrefs = submenuData[submenuDataIdx][2];
  var submenuItemTexts = submenuData[submenuDataIdx][3];
  var submenuTrId = submenuData[submenuDataIdx][4];
  var submenuTdId = submenuData[submenuDataIdx][5];

  if (submenuData[submenuDataIdx][7] != 0)        // open-timeout ist gesetzt
  {
    window.clearTimeout(submenuData[submenuDataIdx][7]);
    submenuData[submenuDataIdx][7] = 0;
  }

  if (submenuData[submenuDataIdx][8] == 0)   // erster CloseSubmenu-Aufruf
  {
    submenuData[submenuDataIdx][8] = setTimeout("CloseSubmenu(\"" + rootPath + "\",\"" + submenuDataIdx + "\");",submenuCloseTimeout);
  }
  else if (submenuData[submenuDataIdx][6] != 0)    // ist geoeffnet
  {
    if (document.all)
    {
      htmlString = document.all.table_menu.outerHTML;
      htmlSubStringOffset = htmlString.indexOf(submenuTdId);
      htmlStringDummy = htmlString.slice(htmlSubStringOffset);
      htmlSubStringOffset += htmlStringDummy.search(/<\/tr>/i) + 5;
      htmlSubString1 = htmlString.substr(0,htmlSubStringOffset);
      htmlSubString2 = htmlString.substr(htmlSubStringOffset);
      for (i=0; i<=submenuItemCount; i++)
      {
        htmlSubStringOffset = htmlSubString2.search(/<\/tr>/i) + 5;
        htmlSubString2 = htmlSubString2.substr(htmlSubStringOffset);
      }
      document.all.table_menu.outerHTML = htmlSubString1 + htmlSubString2;
    }
    else
    {
      parentNode = document.getElementById(submenuTrId).parentNode;
      for (i=0; i<submenuItemCount+1; i++)
        parentNode.removeChild(document.getElementById(submenuTrId).nextSibling);
    }
    if (!isStartPage)
      GetObj('td_main').height = parseInt(GetObj('td_main').height) - (submenuItemCount * submenuLineHeight);
    submenuData[submenuDataIdx][6] = 0;
    submenuData[submenuDataIdx][8] = 0;
    SetBackgroundColorForAllMenuItems(menuItemBackgroundColor1);
  }
}


function CloseAllSubmenus(rootPath)
{
  var i;
  for (i=0; i<submenuData.length; i++)
  {
    if ((submenuData[i][6]) && (submenuData[i][8] == 0))  // ist geoeffnet und close-timeout laeuft nicht
      CloseSubmenu(rootPath,i);
  }
}


function ZoomOutMenuIllustration()
{
  var imgElement = GetObj('img_menu_illustration');
  var divElement = GetObj('div_menu_illustration');
  var newWidth, newHeight, newLeft, newTop;

  if (menuIllustrationZoomTimeout != 0)
  {
    window.clearTimeout(menuIllustrationZoomTimeout);
    menuIllustrationZoomTimeout = 0;
  }
  
  if (menuIllustrationZoomOutRunning == 0)
  {  
    menuIllustrationZoomInRunning = 0;
    menuIllustrationZoomOutRunning = 1;
    imgElement.src = menuIllustrationImageLarge.src;
    menuIllustrationType = 2;
    imgElement.border = 1;
  }

  if ((parseInt(imgElement.width) == parseInt(menuIllustrationImageLarge.width)) && (parseInt(imgElement.height) == parseInt(menuIllustrationImageLarge.height)))
  {
    GetObj('div_menu_illustration_description').style.left = eval(parseInt(divElement.style.left) + parseInt(menuIllustrationImageLarge.width) - 10);
    ShowMenuIllustrationDescription();
    menuIllustrationZoomOutRunning = 0;
  }
  else
  {
    newWidth = parseInt(imgElement.width) + menuIllustrationHStepSize;
    if (newWidth > parseInt(menuIllustrationImageLarge.width))
      newWidth = parseInt(menuIllustrationImageLarge.width);
    newHeight = parseInt(imgElement.height) + menuIllustrationVStepSize;
    if (newHeight > parseInt(menuIllustrationImageLarge.height))
      newHeight = parseInt(menuIllustrationImageLarge.height);
    newLeft = parseInt(divElement.style.left) - 4;
    if (menuIllustrationOriginalLeft - newLeft > 40)
      newLeft = menuIllustrationOriginalLeft - 40;
    newTop = parseInt(divElement.style.top) - 4;
    if (menuIllustrationOriginalTop - newTop > 40)
      newTop = menuIllustrationOriginalTop - 40;
    imgElement.width = newWidth;
    imgElement.height = newHeight;
    divElement.style.left = newLeft;
    divElement.style.top = newTop;
    menuIllustrationZoomTimeout = window.setTimeout("ZoomOutMenuIllustration()",20);
  }
}

function ZoomInMenuIllustration()
{
  var imgElement = GetObj('img_menu_illustration');
  var divElement = GetObj('div_menu_illustration');
  var newWidth, newHeight, newLeft, newTop;

  if (menuIllustrationZoomTimeout != 0)
  {
    window.clearTimeout(menuIllustrationZoomTimeout);
    menuIllustrationZoomTimeout = 0;
  }

  if (menuIllustrationZoomInRunning == 0)
  {
    menuIllustrationZoomOutRunning = 0;
    menuIllustrationZoomInRunning = 1;
  }

  if ((parseInt(imgElement.width) == parseInt(menuIllustrationImageSmall.width)) && (parseInt(imgElement.height) == parseInt(menuIllustrationImageSmall.height)))
  {
    imgElement.src = menuIllustrationImageSmall.src;
    menuIllustrationType = 1;
    imgElement.border = 0;
    divElement.style.top = menuIllustrationOriginalTop;
    divElement.style.left = menuIllustrationOriginalLeft;
    GetObj('div_menu_illustration_description').style.left = eval(parseInt(divElement.style.left) + parseInt(menuIllustrationImageSmall.width) - 10);
    menuIllustrationZoomInRunning = 0;
  }
  else
  {
    newWidth = parseInt(imgElement.width) - menuIllustrationHStepSize;
    if (newWidth < parseInt(menuIllustrationImageSmall.width))
      newWidth = parseInt(menuIllustrationImageSmall.width);
    newHeight = parseInt(imgElement.height) - menuIllustrationVStepSize;
    if (newHeight < parseInt(menuIllustrationImageSmall.height))
      newHeight = parseInt(menuIllustrationImageSmall.height);
    newLeft = parseInt(divElement.style.left) + 4;
    if (newLeft > menuIllustrationOriginalLeft)
      newLeft = menuIllustrationOriginalLeft;
    newTop = parseInt(divElement.style.top) + 4;
    if (newTop > menuIllustrationOriginalTop)
      newTop = menuIllustrationOriginalTop;
    imgElement.width = newWidth;
    imgElement.height = newHeight;
    divElement.style.left = newLeft;
    divElement.style.top = newTop;
    menuIllustrationZoomTimeout = window.setTimeout("ZoomInMenuIllustration()",15);
  }  
}

function ZoomMenuIllustration()
{
  HideMenuIllustrationDescription();

  if (menuIllustrationZoomTimeout != 0)
  {
    window.clearTimeout(menuIllustrationZoomTimeout);
    menuIllustrationZoomTimeout = 0;
  }

  if ((menuIllustrationType == 1) || (menuIllustrationZoomInRunning))
    ZoomOutMenuIllustration();
  else
    ZoomInMenuIllustration();
}

function ShowMenuIllustrationDescription()
{
  if (menuIllustrationDescriptionTimeout == 0)
    menuIllustrationDescriptionTimeout = window.setTimeout("ShowMenuIllustrationDescription()",900);
  else
  {
    menuIllustrationDescriptionTimeout = 0;
    document.getElementById('div_menu_illustration_description').style.visibility = 'visible';
  }
}

function HideMenuIllustrationDescription()
{  
  if (menuIllustrationDescriptionTimeout != 0)
  {
    window.clearTimeout(menuIllustrationDescriptionTimeout);
    menuIllustrationDescriptionTimeout = 0;
  }
  document.getElementById('div_menu_illustration_description').style.visibility = 'hidden';
}


function WriteStartMenu(rootPath)
{  
  if (!rootPath)
    rootPath = ".";

  document.write("\
  \
    <div onMouseOut='CloseAllSubmenus(\"" + rootPath + "\");' style='position:absolute; top:139; left:25; width:171; visibility:visible; z-index:103;'>\
    \
    <table id='menu_frame' width=171 cellpadding=0 cellspacing=0 border=0>\
      <tr>\
        <td colspan=3><img src='" + rootPath + "/bilder/start/menue_oben.gif' border=0 height=30 width=171></td>\
      </tr>\
      <tr>\
        <td style=\"background-image:url(" + rootPath + "/bilder/start/menue_links.gif)\"><img src='" + rootPath + "/bilder/blind.gif' border=0 height=1 width=1></td>\
        <td>\
        <table id='table_menu' width=168 cellpadding=0 cellspacing=0 border=0>\
          <tr>\
            <td class='menu_space'><img src='" + rootPath + "/bilder/blind.gif' border=0 height=26 width=168></td>\
          </tr>\
          <tr id='tr_menu_vorstellung'>\
            <td id='td_menu_vorstellung' class='menu_item'>\
              <a class='menu_item' href='" + rootPath + "/vorstellung.htm' target=_self\
              onMouseOver='SetBackgroundColor(\"td_menu_vorstellung\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");'\
              onMouseOut='SetBackgroundColor(\"td_menu_vorstellung\",\"" + menuItemBackgroundColor1 + "\");'>Vorstellung&nbsp;&nbsp;&nbsp;</a></td>\
          </tr>\
          <tr id='tr_menu_personalia'>\
            <td id='td_menu_personalia' class='menu_item'>\
              <a class='menu_item' href='" + rootPath + "/personalia.htm' target=_self\
              onMouseOver='SetBackgroundColor(\"td_menu_personalia\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");'\
              onMouseOut='SetBackgroundColor(\"td_menu_personalia\",\"" + menuItemBackgroundColor1 + "\");'>Personalia&nbsp;&nbsp;&nbsp;</a></td>\
          </tr>\
          <tr id='tr_menu_veranstaltungen'>\
            <td id='td_menu_veranstaltungen' class='menu_item'>\
              <a class='menu_item' href='" + rootPath + "/veranstaltungen.htm' target=_self\
              onMouseOver='SetBackgroundColor(\"td_menu_veranstaltungen\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");OpenSubmenu(\"" + rootPath + "\",1);'\
              onMouseOut='SetBackgroundColor(\"td_menu_veranstaltungen\",\"" + menuItemBackgroundColor1 + "\");CloseSubmenu(\"" + rootPath + "\",1);'>Veranstaltungen</a></td>\
          </tr>\
          <tr id='tr_menu_projekte'>\
            <td id='td_menu_projekte' class='menu_item'\
              onMouseOver='SetBackgroundColor(\"td_menu_projekte\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");OpenSubmenu(\"" + rootPath + "\",2);'\
              onMouseOut='SetBackgroundColor(\"td_menu_projekte\",\"" + menuItemBackgroundColor1 + "\");CloseSubmenu(\"" + rootPath + "\",2);'\
              onMouseUp='OpenSubmenu(\"" + rootPath + "\",2,0);'>Projekte&nbsp;&nbsp;&nbsp;</td>\
          </tr>\
          <tr id='tr_menu_publikationen'>\
            <td class='menu_item' id='td_menu_publikationen'\
              onMouseOver='SetBackgroundColor(\"td_menu_publikationen\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");OpenSubmenu(\"" + rootPath + "\",3);'\
              onMouseOut='SetBackgroundColor(\"td_menu_publikationen\",\"" + menuItemBackgroundColor1 + "\");CloseSubmenu(\"" + rootPath + "\",3);'\
              onMouseUp='OpenSubmenu(\"" + rootPath + "\",3,0);'>Publikationen&nbsp;&nbsp;&nbsp;</td>\
          </tr>\
          <tr id='tr_menu_materialien'>\
            <td id='td_menu_materialien' class='menu_item'>\
              <a class='menu_item' href='" + rootPath + "/materialien.htm' target=_self\
              onMouseOver='SetBackgroundColor(\"td_menu_materialien\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");'\
              onMouseOut='SetBackgroundColor(\"td_menu_materialien\",\"" + menuItemBackgroundColor1 + "\")'>Materialien&nbsp;&nbsp;&nbsp;</a></td>\
          </tr>\
          <tr id='tr_menu_stipendien'>\
            <td id='td_menu_stipendien' class='menu_item'>\
              <a class='menu_item' href='" + rootPath + "/stipendien.htm' target=_self\
              onMouseOver='SetBackgroundColor(\"td_menu_stipendien\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");'\
              onMouseOut='SetBackgroundColor(\"td_menu_stipendien\",\"" + menuItemBackgroundColor1 + "\")'>Stipendien&nbsp;&nbsp;&nbsp;</a></td>\
          </tr>\
          <tr id='tr_menu_links'>\
            <td id='td_menu_links' class='menu_item'>\
              <a class='menu_item' href='" + rootPath + "/links.htm' target=_self\
              onMouseOver='SetBackgroundColor(\"td_menu_links\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");'\
              onMouseOut='SetBackgroundColor(\"td_menu_links\",\"" + menuItemBackgroundColor1 + "\")'>Links&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></td>\
          </tr>\
          <tr id='tr_menu_lageplan'>\
            <td id='td_menu_lageplan' class='menu_item'>\
              <a class='menu_item' href='" + rootPath + "/lageplan.htm' target=_blank\
              onMouseOver='SetBackgroundColor(\"td_menu_lageplan\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");'\
              onMouseOut='SetBackgroundColor(\"td_menu_lageplan\",\"" + menuItemBackgroundColor1 + "\")'>Lageplan&nbsp;&nbsp;&nbsp;</a></td>\
          </tr>\
          <tr id='tr_menu_impressum'>\
            <td id='td_menu_impressum' class='menu_item'>\
              <a class='menu_item' href='" + rootPath + "/impressum.htm' target=_self\
              onMouseOver='SetBackgroundColor(\"td_menu_impressum\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");'\
              onMouseOut='SetBackgroundColor(\"td_menu_impressum\",\"" + menuItemBackgroundColor1 + "\")'>Impressum&nbsp;&nbsp;&nbsp;</a></td>\
          </tr>\
          <tr>\
            <td class='menu_space'>\
              <img src='" + rootPath + "/bilder/blind.gif' border=0 height=26 width=168></td>\
          </tr>\
        </table>\
        </td>\
        <td style=\"background-image:url(" + rootPath + "/bilder/start/menue_rechts.gif)\"><img src='" + rootPath + "/bilder/blind.gif' border=0 height=1 width=2></td>\
      </tr>\
      <tr>\
        <td class='menu_space' colspan=3><img src='" + rootPath + "/bilder/start/menue_unten.gif' border=0 height=2 width=171></td>\
      </tr>\
    </table>\
    </div>\
  ");
}


function WriteTopCode(rootPath,title,paddingLeft,paddingRight,paddingTop,paddingBottom,showLinkToAlternateLanguage,linkToAlternateLanguage,language)
{
  var languageExtension;

  if (!language)
    language = 1;

  if (language == 1)
  {
    languageExtension = "";
  }
  else if (language == 2)
  {
    languageExtension = "_en";
  }

  if (!paddingLeft)
    paddingLeft = 0;

  if (!paddingRight)
    paddingRight = 0;

  if (!paddingTop)
    paddingTop = 0;

  if (!paddingBottom)
    paddingBottom = 0;


  menuIllustrationType = 1;
  menuIllustrationHStepSize = (menuIllustrationImageLarge.width - menuIllustrationImageSmall.width) / 10;
  menuIllustrationVStepSize = (menuIllustrationImageLarge.height - menuIllustrationImageSmall.height) / 10;

  document.write("\
\
<table align=center width=100% height=100% cellpadding=0 cellspacing=0 border=0>\
  <tr><td align=center style='vertical-align:top;'>\
\
\
<div style='position:relative; width:850; visibility:visible; z-index:100;'>\
\
  <div id='div_menue' onMouseOut='CloseAllSubmenus(\"" + rootPath + "\");' style='position:absolute; top:" + menuBaseOffset + "; left:26; width:168; visibility:visible; z-index:103;'>\
\
        <table id='table_menu' width=168 cellpadding=0 cellspacing=0 border=0>\
          <tr>\
            <td class='menu_space'><img src='" + rootPath + "/bilder/blind.gif' border=0 height=26 width=168></td>\
          </tr>\
          <tr id='tr_menu_home'>\
            <td id='td_menu_home' class='menu_item'>\
              <a class='menu_item' href='" + rootPath + "/index.htm' target=_self\
              onMouseOver='SetBackgroundColor(\"td_menu_home\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");'\
              onMouseOut='SetBackgroundColor(\"td_menu_home\",\"" + menuItemBackgroundColor1 + "\")'>Home&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></td>\
          </tr>\
          <tr id='tr_menu_vorstellung'>\
            <td id='td_menu_vorstellung' class='menu_item'>\
              <a class='menu_item' href='" + rootPath + "/vorstellung.htm' target=_self\
              onMouseOver='SetBackgroundColor(\"td_menu_vorstellung\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");'\
              onMouseOut='SetBackgroundColor(\"td_menu_vorstellung\",\"" + menuItemBackgroundColor1 + "\");'>Vorstellung&nbsp;&nbsp;&nbsp;</a></td>\
          </tr>\
          <tr id='tr_menu_personalia'>\
            <td id='td_menu_personalia' class='menu_item'>\
              <a class='menu_item' href='" + rootPath + "/personalia.htm' target=_self\
              onMouseOver='SetBackgroundColor(\"td_menu_personalia\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");'\
              onMouseOut='SetBackgroundColor(\"td_menu_personalia\",\"" + menuItemBackgroundColor1 + "\");'>Personalia&nbsp;&nbsp;&nbsp;</a></td>\
          </tr>\
          <tr id='tr_menu_veranstaltungen'>\
            <td id='td_menu_veranstaltungen' class='menu_item'>\
              <a class='menu_item' href='" + rootPath + "/veranstaltungen.htm' target=_self\
              onMouseOver='SetBackgroundColor(\"td_menu_veranstaltungen\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");OpenSubmenu(\"" + rootPath + "\",1);'\
              onMouseOut='SetBackgroundColor(\"td_menu_veranstaltungen\",\"" + menuItemBackgroundColor1 + "\");CloseSubmenu(\"" + rootPath + "\",1);'>Veranstaltungen</a></td>\
          </tr>\
          <tr id='tr_menu_projekte'>\
            <td id='td_menu_projekte' class='menu_item'\
              onMouseOver='SetBackgroundColor(\"td_menu_projekte\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");OpenSubmenu(\"" + rootPath + "\",2);'\
              onMouseOut='SetBackgroundColor(\"td_menu_projekte\",\"" + menuItemBackgroundColor1 + "\");CloseSubmenu(\"" + rootPath + "\",2);'\
              onMouseUp='OpenSubmenu(\"" + rootPath + "\",2,0);'>Projekte&nbsp;&nbsp;&nbsp;</td>\
          </tr>\
          <tr id='tr_menu_publikationen'>\
            <td class='menu_item' id='td_menu_publikationen'\
              onMouseOver='SetBackgroundColor(\"td_menu_publikationen\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");OpenSubmenu(\"" + rootPath + "\",3);'\
              onMouseOut='SetBackgroundColor(\"td_menu_publikationen\",\"" + menuItemBackgroundColor1 + "\");CloseSubmenu(\"" + rootPath + "\",3);'\
              onMouseUp='OpenSubmenu(\"" + rootPath + "\",3,0);'>Publikationen&nbsp;&nbsp;&nbsp;</td>\
          </tr>\
          <tr id='tr_menu_materialien'>\
            <td id='td_menu_materialien' class='menu_item'>\
              <a class='menu_item' href='" + rootPath + "/materialien.htm' target=_self\
              onMouseOver='SetBackgroundColor(\"td_menu_materialien\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");'\
              onMouseOut='SetBackgroundColor(\"td_menu_materialien\",\"" + menuItemBackgroundColor1 + "\")'>Materialien&nbsp;&nbsp;&nbsp;</a></td>\
          </tr>\
          <tr id='tr_menu_stipendien'>\
            <td id='td_menu_stipendien' class='menu_item'>\
              <a class='menu_item' href='" + rootPath + "/stipendien.htm' target=_self\
              onMouseOver='SetBackgroundColor(\"td_menu_stipendien\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");'\
              onMouseOut='SetBackgroundColor(\"td_menu_stipendien\",\"" + menuItemBackgroundColor1 + "\")'>Stipendien&nbsp;&nbsp;&nbsp;</a></td>\
          </tr>\
          <tr id='tr_menu_links'>\
            <td id='td_menu_links' class='menu_item'>\
              <a class='menu_item' href='" + rootPath + "/links.htm' target=_self\
              onMouseOver='SetBackgroundColor(\"td_menu_links\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");'\
              onMouseOut='SetBackgroundColor(\"td_menu_links\",\"" + menuItemBackgroundColor1 + "\")'>Links&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></td>\
          </tr>\
          <tr id='tr_menu_lageplan'>\
            <td id='td_menu_lageplan' class='menu_item'>\
              <a class='menu_item' href='" + rootPath + "/lageplan.htm' target=_blank\
              onMouseOver='SetBackgroundColor(\"td_menu_lageplan\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");'\
              onMouseOut='SetBackgroundColor(\"td_menu_lageplan\",\"" + menuItemBackgroundColor1 + "\")'>Lageplan&nbsp;&nbsp;&nbsp;</a></td>\
          </tr>\
          <tr id='tr_menu_impressum'>\
            <td id='td_menu_impressum' class='menu_item'>\
              <a class='menu_item' href='" + rootPath + "/impressum.htm' target=_self\
              onMouseOver='SetBackgroundColor(\"td_menu_impressum\",\"" + menuItemBackgroundColor2 + "\");CloseAllSubmenus(\"" + rootPath + "\");'\
              onMouseOut='SetBackgroundColor(\"td_menu_impressum\",\"" + menuItemBackgroundColor1 + "\")'>Impressum&nbsp;&nbsp;&nbsp;</a></td>\
          </tr>\
          <tr>\
            <td class='menu_space'>\
              <img src='" + rootPath + "/bilder/blind.gif' border=0 height=26 width=168></td>\
          </tr>\
        </table>\
  </div>\
  \
  <div style=\"position:absolute; top:101; left:130; width:111; height:59; visibility:visible; z-index:102;\">\
    <table cellpadding=0 cellspacing=0 border=0>\
      <tr>\
        <td><a href='http://www.uni-halle.de' target=_blank><img src='" + rootPath + "/bilder/blind.gif' width=111 height=59 border=0></a></td>\
      </tr>\
    </table>\
  </div>\
  \
  <div style=\"position:absolute; top:101; left:745; width:70; height:59; visibility:visible; z-index:102;\">\
    <table cellpadding=0 cellspacing=0 border=0>\
      <tr>\
        <td><a href='http://www.francke-halle.de' target=_blank><img src='" + rootPath + "/bilder/blind.gif' width=70 height=59 border=0></a></td>\
      </tr>\
    </table>\
  </div>\
  \
  <div id='div_menu_illustration' style=\"position:absolute; top:" + menuIllustrationOriginalTop + "; left:" + menuIllustrationOriginalLeft + "; width:" + menuIllustrationImageSmall.width + "; height:" + menuIllustrationImageSmall.height + "; visibility:visible; z-index:104;\">\
    <table cellpadding=0 cellspacing=0 border=0>\
      <tr>\
        <td><img id='img_menu_illustration' src='" + menuIllustrationImageSmall.src + "' width=" + menuIllustrationImageSmall.width + " height=" + menuIllustrationImageSmall.height + " border=0 onMouseUp='ZoomMenuIllustration()' onMouseOver='ShowMenuIllustrationDescription()' onMouseOut='HideMenuIllustrationDescription()' style='cursor:pointer;'></td>\
      </tr>\
    </table>\
  </div>\
  \
  <div id='div_menu_illustration_description' style=\"position:absolute; top:" + eval(menuIllustrationOriginalTop + 15) + "; left:" + eval(menuIllustrationOriginalLeft + menuIllustrationImageSmall.width - 10) + "; width:250; visibility:hidden; z-index:105;\">\
    <table cellpadding=0 cellspacing=0 border=0>\
      <tr>\
        <td class='menu_illustration_description'>" + menuIllustrationDescription + "</td>\
      </tr>\
    </table>\
  </div>\
  \
  <div style=\"position:absolute; top:186; left:257; width:478; height:31; visibility:visible; z-index:102;\">\
    <table cellpadding=0 cellspacing=0 border=0>\
      <tr>\
        <td width=478 height=31 class='content_headline' style='background-image:url(" + rootPath + "/bilder/ueberschrift.gif);'>" + title + "</td>\
      </tr>\
    </table>\
  </div>\
  \
  <div style=\"position:absolute; top:186; left:25; width:171; height:30; visibility:visible; z-index:102;\">\
    <table cellpadding=0 cellspacing=0 border=0>\
      <tr>\
        <td width=171 height=30><img src='" + rootPath + "/bilder/menue_titel.gif' width=171 height=30 border=0></td>\
      </tr>\
    </table>\
  </div>\
  ");

  if (pictureString.length > 0)
    document.write(pictureString);

  document.write("\
  <table width=850 cellpadding=0 cellspacing=0 border=0>\
    <tr>\
      <td colspan=9><img src='" + rootPath + "/bilder/blind.gif' width=850 height=15 border=0></td>\
    </tr>\
    <tr>\
      <td colspan=9 class='body'><img src='" + rootPath + "/bilder/blind.gif' width=850 height=25 border=0></td>\
    </tr>\
    <tr>\
      <td class='body'><img src='" + rootPath + "/bilder/blind.gif' width=25 height=1 border=0></td>\
      <td class='body' colspan=7><img src='" + rootPath + "/bilder/titel.gif' border=0 width=801 height=121></td>\
      <td class='body'><img src='" + rootPath + "/bilder/blind.gif' width=24 height=1 border=0></td>\
    </tr>\
    <tr>\
      <td colspan=9 class='body'><img src='" + rootPath + "/bilder/blind.gif' width=850 height=40 border=0></td>\
    </tr>\
    <tr>\
      <td class='body' colspan=5><img src='" + rootPath + "/bilder/blind.gif' width=226 height=1 border=0></td>\
      <td class='body' colspan=3><img src='" + rootPath + "/bilder/linie_oben.gif' width=600 height=2 border=0></td>\
      <td class='body'><img src='" + rootPath + "/bilder/blind.gif' width=24 height=1 border=0></td>\
    </tr>\
    <tr>\
      <td class='body'><img src='" + rootPath + "/bilder/blind.gif' width=25 height=1 border=0></td>\
      <td style='background-image:url(" + rootPath + "/bilder/linie_links.gif);'><img src='" + rootPath + "/bilder/blind.gif' width=1 height=1 border=0></td>\
      <td class='menu'><img src='" + rootPath + "/bilder/blind.gif' width=168 height=10 border=0></td>\
      <td style='background-image:url(" + rootPath + "/bilder/linie_rechts.gif);'><img src='" + rootPath + "/bilder/blind.gif' width=2 height=1 border=0></td>\
      <td class='body'><img src='" + rootPath + "/bilder/blind.gif' width=30 height=1 border=0></td>\
      <td style='background-image:url(" + rootPath + "/bilder/linie_links.gif);'><img src='" + rootPath + "/bilder/blind.gif' width=1 height=1 border=0></td>\
      <td class='content'>\
\
        <table cellpadding=0 cellspacing=0 border=0 width=100%>\
          <tr>\
            <td><img src='" + rootPath + "/bilder/blind.gif' width=597 height=1 border=0></td>\
          </tr>\
          <tr>\
            <td id='td_main' height=" + eval(menuActualOffset + 80) + " style='padding-left:" + paddingLeft + "px; padding-right:" + paddingRight + "px; padding-top:" + paddingTop + "px; padding-bottom:" + paddingBottom + "px;'>\
\
  ");
}


function WriteBottomCode(rootPath)
{
  document.write("\
            </td>\
          </tr>\
        </table>\
\
        </td>\
      <td style='background-image:url(" + rootPath + "/bilder/linie_rechts.gif);'><img src='" + rootPath + "/bilder/blind.gif' width=2 height=1 border=0></td>\
      <td class='body'><img src='" + rootPath + "/bilder/blind.gif' width=24 height=1 border=0>\
    </tr>\
    <tr>\
      <td class='body'><img src='" + rootPath + "/bilder/blind.gif' width=25 height=1 border=0></td>\
      <td class='body' colspan=3><img src='" + rootPath + "/bilder/linie_unten_2.gif' width=171 height=2 border=0></td>\
      <td class='body'><img src='" + rootPath + "/bilder/blind.gif' width=30 height=1 border=0></td>\
      <td class='body' colspan=3><img src='" + rootPath + "/bilder/linie_unten_1.gif' width=600 height=2 border=0></td>\
      <td class='body'><img src='" + rootPath + "/bilder/blind.gif' width=24 height=1 border=0></td>\
    </tr>\
    <tr>\
      <td colspan=9 class='body' height=25 align=right style='vertical-alignment:top; padding-right:36px; padding-top:3px; font-size:8pt;'>\
        &copy;&nbsp;IZP, Andreas Mohrig, 2007</td>\
    </tr>\
    <tr>\
      <td colspan=9><img src='" + rootPath + "/bilder/blind.gif' width=850 height=15 border=0></td>\
    </tr>\
  </table>\
</div>\
  </td></tr>\
</table>\
\
  ");
}


function SetMenuOffsetToBe()
{
  var vScrollPosition = GetVerticalScrollPosition();
  var windowHeight = GetWindowInnerHeight();

  if (vScrollPosition > scrollPositionPeak)
    scrollPositionPeak = vScrollPosition;
  if (vScrollPosition == oldVerticalScrollPosition)     // Korrektur von Verschiebungen bei schnellem Scrollen
  {
    if (scrollingJustStopped == 0)
    {
      scrollingJustStopped = 1;
    }
    else
    {
      scrollingJustStopped = 0;
      if ((menuOffsetToBe + menuHeight > windowHeight + vScrollPosition) && (menuOffsetToBe > menuBaseOffset) && (lastScrollDirection == 1))
        menuOffsetToBe = windowHeight + vScrollPosition - menuHeight;
      if ((menuOffsetToBe != menuActualOffset) && (menuShiftRunning == 0))
      {
        menuShiftRunning = 1;
        SetMenuOffset();
      }
    }
  }
  else if (vScrollPosition < oldVerticalScrollPosition)      // nach oben
  {
    if (lastScrollDirection != 2)
      menuShiftStartOffset = menuActualOffset;
    lastScrollDirection = 2;
    if (menuOffsetToBe >= vScrollPosition)  // zukuenftiger Startpunkt nicht ausserhalb der oberen Kante
    {
      menuOffsetToBe = menuOffsetToBe + vScrollPosition - oldVerticalScrollPosition;
    }
    if (menuOffsetToBe < menuBaseOffset)  // zukuenftiger Startpunkt waere oberhalb der Menueausgangshoehe
    {
      menuOffsetToBe = menuBaseOffset;
    }
  }
  else   // nach unten
  {
    if (lastScrollDirection != 1)
      menuShiftStartOffset = menuActualOffset;
    lastScrollDirection = 1;
    if ((menuOffsetToBe + menuHeight <= windowHeight + vScrollPosition) && (menuOffsetToBe >= menuBaseOffset))       // zukuenftiger Endpunkt unterhalb der unteren Kante
      menuOffsetToBe = menuOffsetToBe + vScrollPosition - oldVerticalScrollPosition;
  }

  oldVerticalScrollPosition = vScrollPosition;

  window.setTimeout("SetMenuOffsetToBe()",150);
}


function SetMenuOffset()
{
  var distance = menuOffsetToBe - menuActualOffset;
  if (distance < 0)
    distance = -distance;
  var distance2 = (menuShiftStartOffset - menuActualOffset) * 2;
  if (distance2 < 0)
    distance2 = -distance2;
  if (distance2 < distance)
    distance = distance2;

  if (distance > menuMoveDistance1)
    menuMoveStep = menuMoveStep1;
  else if (distance > menuMoveDistance2)
    menuMoveStep = menuMoveStep2;
  else if (distance > menuMoveDistance3)
    menuMoveStep = menuMoveStep3;
  else if (distance > menuMoveDistance4)
    menuMoveStep = menuMoveStep4;
  else
    menuMoveStep = 1;

  if (menuOffsetToBe > menuActualOffset)
  {
    if (menuOffsetToBe - menuActualOffset < menuMoveStep)
      menuActualOffset = menuOffsetToBe;
    else
      menuActualOffset = menuActualOffset + menuMoveStep;
  }
  else if (menuOffsetToBe < menuActualOffset)
  {
    if (menuActualOffset - menuOffsetToBe < menuMoveStep)
      menuActualOffset = menuOffsetToBe;
    else
      menuActualOffset = menuActualOffset - menuMoveStep;
  }
  menuObject.style.top = menuActualOffset;

  if (menuOffsetToBe != menuActualOffset)
    window.setTimeout("SetMenuOffset()",10);
  else
  {
    menuShiftRunning = 0;
    menuShiftStartOffset = menuActualOffset;
  }
}


