// Copyright Notize: This source code is property of WebAge and is NOT free
// for usage/reproduction or distribution without an explicit release of 
// WebAge. Please contact service@webage.de to order a legal copy.
// Version: 2.0
// Date: 23.3.2001

NN = false;
MS = false;
W3C = false;
Opera = false;

menuHist = new Array();
markerHist = new Array();
orgMouseMove = "";
topPos = 0;
leftPos = 0;
rightPos = 0;
downPos = 0;
menuName = "";
orientation = "";
language = "de";
first = 0;
showCnt = 0;
actParentAndSubMenu = "";
menuCacheDe = "";
menuCacheEn = "";

initNavigator();


function changeLng()
{
   if( Opera || W3C )
   {
      self.Main.window.location.replace( getOtherLangPath( self.Main.window.location.href ));
   }
   else if( NN )
      self.Main.window.location.replace( getOtherLangPath( self.Main.document.URL ));
   else
      self.Main.document.URL = getOtherLangPath( self.Main.document.URL );
}

function setBegin( in_menuName, menuWidth, in_orientation )
{
   var baseDiv;

   menuName = in_menuName;
   orientation = in_orientation;
   first = 1;

   if( self.Main && self.Main.useOwnFunction ) // for generated sitemap !!
      return( self.Main.setBeginCB(in_menuName) );

   if( NN )
   {
      menuWidth += 3;

      baseDiv = '<div ID="' + menuName + '" style="position : absolute; left : 0; top : 0; width : 120; VISIBILITY: hide">' + 
                '<table border="0" cellpadding="0" cellspacing="0" class="baseMenuNN"><tr><td>' +
                '<table border="0" cellpadding="0" cellspacing="0" width="' + menuWidth + '">';

   }
   else if( MS )
   {
      baseDiv = '<div class="menuDiv" ID="' + menuName + '">' +
                '<table class="menuTable" bgcolor="#CBCED0" border="0" cellpadding="0" cellspacing="0" width="' + menuWidth + '">';
   }
   else // W3C
   {
      baseDiv = '<div ID="' + menuName + '" style="position : absolute; left : 0; top : 0; width : ' + menuWidth + '; VISIBILITY: hidden";>' +
                '<table border="0" cellpadding="0" cellspacing="0" width="' + menuWidth + '">';
   }
   
   return baseDiv;
}

function addItem( entryStringEn, entyStringDe, entryLink, entryTarget, subMenu, tooltipEn, tooltipDe, useRelative )
{
   var str = "";
   var entryString;

   if( entryLink )
   {

      if( entryLink.charAt(0) == "/" ||
          entryLink.charAt(1) == ":" ||
          entryLink.indexOf('http://') > -1 ||
          entryLink.indexOf('https://') > -1 ||  
          entryLink.indexOf('file:/') > -1 ||
          entryLink.indexOf('ftp://') > -1 ||
	  entryLink.indexOf('mailto:') > -1 ||
	  entryLink.indexOf('mms://') > -1 ||
	  entryLink.indexOf('#') > -1 ||
          entryLink.indexOf('javascript:') > -1 )
         docPath = entryLink;
      else if( useRelative )
         docPath = entryLink;
      else   
         docPath = mainDir + "/" + language + "/" + entryLink;
   }

   if( language == "de" )
      entryString = entyStringDe;
   else
      entryString = entryStringEn;

   if( self.Main && self.Main.useOwnFunction ) // for generated sitemap !!
      return( self.Main.addItemCB(entryStringEn, entyStringDe, entryLink, entryTarget, subMenu) );

   if( entryString == "" )
      return "";

   var firstTr = "";
   
   if( first == 0 )
   {
      if (NN || W3C)
         str = '<tr bgcolor="#FFFFFF"><td colspan="3" height="1"><img border="0" src="' + images + '/10x1.gif" width="1" height="1"></td></tr>';  
   }
   else 
   {  
      if( MS )
         firstTr = 'class="menuTableFirst"';
   }
   
   first = 0;
   
   if( !entryTarget )
      entryTarget = "";

   if( subMenu )
   {
      spike = images + "/spike2.gif";

      if( NN )
      {
         str += '<tr bgcolor="#CBCED0">' +
                '<td class="menuTxt" width="4">&nbsp;</td><td class="menuTxt" height="18">' +
                '<a href="' + docPath + '" onmouseOver="parent.sSM(this,' + "'" + menuName + "','" + subMenu + "' ,event)" + '" onmouseOut="parent.cB(this)" target="' + entryTarget + '">' + entryString + '</a>' +
                '</td><td align="right"><img src="' + spike + '"></td>';
      }
      else if( MS )
      {
         str += '<tr ' + firstTr + ' onClick="parent.onC(' + "'" + docPath + "','" + entryTarget + "'" + ')" ' + getTooltip(tooltipEn, tooltipDe) + ' onmouseOver="parent.sSM(this,' + "'" + menuName + "','" + subMenu + "' ,event)" + '"><td>' +
                 entryString + '</td><td align="right"><img src="' + spike + '"></td>';
      }
      else // W3C
      {
         str += '<tr onClick="parent.onC(' + "'" + docPath + "','" + entryTarget + "'" + ')" bgcolor="#CBCED0" onmouseOver="parent.sSM(this,' + "'" + menuName + "','" + subMenu + "' ,event)" + '">' +
                '<td class="menuTxt" width="4">&nbsp;</td></td><td class="menuTxt" height="18">' +
                '<a href="' + docPath + '" target="' + entryTarget + '" onClick="parent.canB()">' + entryString + '</a>' +
                '</td><td align="right"><img src="' + spike + '"></td>';
      }      
   }
   else // kein subMenue
   {
      if( MS )
      {
         if( entryLink )
         {
            str += '<tr ' + firstTr + ' onClick="parent.onC(' + "'" + docPath + "','" + entryTarget + "'" + ')" ' + getTooltip(tooltipEn, tooltipDe) + ' onmouseOver="parent.hSM(this,' + "'" + menuName + "'" + ')"><td colspan="2">' +
                entryString + '</td>';
         }
         else
         {
            str += '<tr style="cursor:auto;"' + firstTr + ' onmouseOver="parent.hideSubMenu(' + "'" + menuName + "'" + ')"><td colspan="2">' + entryString + '</td>';
         }
      }
      else
      {
         if( entryLink )
         {
            str += '<tr onClick="parent.onC(' + "'" + docPath + "','" + entryTarget + "'" + ')" bgcolor="#CBCED0" onmouseOver="parent.hSM(this,' + "'" + menuName + "'" + ')">' +
	        '<td class="menuTxt" width="4">&nbsp;</td></td><td class="menuTxt" height="18">' +
                '<a href="' + docPath + '" target="' + entryTarget + '" onClick="parent.canB()">' + entryString + '</a></td><td class="menuTxt">&nbsp;</td>';
         }
         else
         {
            str += '<tr bgcolor="#CBCED0" onmouseOver="parent.hideSubMenu(' + "'" + menuName + "'" + ')">' +
	           '<td class="menuTxt" width="4">&nbsp;</td></td><td class="menuTxt" height="18">' +
                   entryString + '</td><td class="menuTxt">&nbsp;</td>';

         }  
      }
   } 

   return str + '</tr>\n';
}

function getTooltip(tooltipEn, tooltipDe)
{
   if( !tooltipEn )
   return "";
   
   if( language == "de" )
      return 'TITLE="' + tooltipDe + '"';
   else
      return 'TITLE="' + tooltipEn + '"';
}


function onC( doc, target )
{

   if( target == "Main" || target == "_Main" || target == "" )
     self.Main.document.location = doc;
   else
      window.open( doc, target, "" );     
   
}

function canB()
{
   if( document.all )
      self.Main.event.cancelBubble = true;
}

function cC( obj, menuName )
{

   if( MS || W3C)
      showCnt = obj.rowIndex;
   else   
      showCnt++;



   if( NN )
      return;

   if( markerHist[menuName] ) // set back
   {
      markerHist[menuName].style.backgroundColor = "#CBCED0";
      
      if( MS )
         markerHist[menuName].style.color = "#000000";
      else if( W3C )
         markerHist[menuName].getElementsByTagName('a')[0].style.color = "#000000";
   }


   obj.style.backgroundColor = "#606261";
   
   if( MS )
      obj.style.color="#FFFFFF";
   else if( W3C )
      obj.getElementsByTagName('a')[0].style.color = "#FFFFFF";
   
   markerHist[menuName] = obj;

}

function cB( menuName )
{

   if( NN || !markerHist[menuName] )
      return;

   markerHist[menuName].style.backgroundColor = "#CBCED0";

   if( MS )
      markerHist[menuName].style.color = "#000000";
   else if( W3C )
      markerHist[menuName].getElementsByTagName('a')[0].style.color = "#000000";
}

function changeDoc( obj )
{
//    alert( obj.sourceIndex );
}


function setEnd()
{
   if( self.Main && self.Main.useOwnFunction ) // for generated sitemap !!
      return( self.Main.setEndCB() );

   if( NN )
      return '</table></td></tr></table></div>';
   else
      return '</table></div>';
}


function toggleLang()
{
   if( language == "de" )
      language = "en";
   else
      language = "de";
}

function getLangStrForILP()
{
   if( language == "de" )
      return( "Language=d" );
   else
      return( "Language=e" );
}

function getLang()
{
   return( language );
}

function getOtherLang( _lang )
{
   if( _lang == "de" )
      return( "en" );
   else
      return( "de" );
}

function getOtherLangILP( _lang )
{
   if( _lang == "de" )
      return( "Language=e" );
   else
      return( "Language=d" );
}

function getOtherLangPath( urlPath ) 
{

   if( urlPath.indexOf( "Language=de-DE" ) > -1 )
      return( urlPath.replace( "Language=de-DE", "Language=en-US" ));
   if( urlPath.indexOf( "Language=en-US" ) > -1 )
      return( urlPath.replace( "Language=en-US", "Language=de-DE" ));

   if( urlPath.indexOf( "Language=d" ) > -1 )
      return( urlPath.replace( "Language=d", "Language=e" ));
   if( urlPath.indexOf( "Language=e" ) > -1 )
      return( urlPath.replace( "Language=e", "Language=d" ));

   if( urlPath.indexOf( "lang=de" ) > -1 )
      return( urlPath.replace( "lang=de", "lang=en" ));
   if( urlPath.indexOf( "lang=en" ) > -1 )
      return( urlPath.replace( "lang=en", "lang=de" ));
  

   return( urlPath.replace( "/" + language + "/", "/" + getOtherLang( language ) + "/" ) );
}

function getLangOfPage( urlPath ) 
{
   // attention: ILP has a language directory /de/ which does not
   // show the real language !! only language=d/e is the sign !
   if( urlPath.indexOf( "Language=d" ) > -1 )
      return( "de" );
   if( urlPath.indexOf( "Language=e" ) > -1 )
      return( "en" );

   if( urlPath.indexOf( "lang=de" ) > -1 ||
       urlPath.indexOf( "/de/" ) > -1 )
      return( "de" );

   return( "en" );
}

function writeLayer( navName, addHTML, lng )
{

   menuHist = new Array();
   markerHist = new Array();
   
   if( !NN && !MS && !W3C )
      initNavigator();

   language = lng ? lng : getLangOfPage(self.Main.document.URL);


   if( !NN && !MS && !W3C )
      return;

   str = "";
   
   if( NN )
      str = '<div ID="dummy" style="position : absolute; width : 120;"></div>';
      
   if( addHTML )
      str += addHTML;

   if( menuCacheDe != "" && language == "de" && !(self.Main && self.Main.useOwnFunction) )
      str += menuCacheDe;
   else if( menuCacheEn != "" && language == "en" && !self.Main.useOwnFunction )   
      str += menuCacheEn;
   else
   {
      if( self.Main && !(self.Main && self.Main.useOwnFunction) )
      {
         if( language == "de" )
            str += (menuCacheDe = setMenus());
         else
            str += (menuCacheEn = setMenus());
      }
      else
      {
         str += setMenus();
      }
   }
   
   document.title = self.Main.document.title;
   
   self.Main.document.write( str );
   setNav( navName );   
   if ( typeof setUserDefinedCode == "function" ) 
      setUserDefinedCode();
       
}


function getDocuName( docName )
{
   for( i = docName.length; docName.charAt(i-1) != '/' && docName.charAt(i-1) != '\\' && i != 1; i-- );

   return( docName.substr(i) );
}

function initNavigator()
{
   if (document.layers)
   {
      NN = true;
      sichtbar   = "show";
      unsichtbar = "hide";
   }
   else if (document.all)
   {
      MS = true;
      sichtbar   = "visible";	  
      unsichtbar = "hidden";
   }
   else if( document.getElementById )
   {
      W3C = true;
      sichtbar   = "visible";	  
      unsichtbar = "hidden";
   }
}

function isNN()
{
   if( document.layers )
      return true;
   return false;
}

function showMenu( menuName, state, x, y, ankerBeginY )
{
   // hide open menus
   setVisibility( self.Main.document.activeMenu, unsichtbar );
   setMenuUp( self.Main.document.activeMenu );
   hideSubMenu( self.Main.document.activeMenu );
   showOverlayingItems();

   if( state == "sichtbar" )
   {
      setPos( menuName, x, y )
      setVisibility( menuName, sichtbar );
  
      setActiveMenu( menuName, ankerBeginY );
   }
   else // unsichtbar
   {
      setVisibility( menuName, unsichtbar );
      setMenuUp( menuName );

      setActiveMenu( "invisible" );
   }
   calculateDim( ankerBeginY );
}

function setMenuUp( menuName )
{
   if( menuName == "invisible" )
	return;

   setPos( menuName, 0, 0 );
}


function checkEnvironment( menuName )
{
   if( !NN && !MS && !W3C)
   {
	// try it again to initialze, because of a bug in netscape !
	initNavigator()

	if( !NN )
	   return false;
   }


   if( !self.Main )
	return false;


   if( !self.Main.document )
	return false;

   if( NN )
   {
	if( !self.Main.document.layers[menuName] &&
            !self.Nav.document.layers[menuName] )
        {
	   return false;
        }
   }
   else if( MS )
   {
	if( !self.Main.document.all[menuName] &&
            !self.Nav.document.all[menuName] )
	   return false;
   }
   else if( W3C )
   {
        if( !self.Main.document.getElementById(menuName) &&
            !self.Nav.document.getElementById(menuName))
           return false;
   }


   if( NN )
   {
	self.Main.document.onmousemove = myMouseMove;
	self.Main.document.captureEvents(Event.MOUSEMOVE);
   }

   if( !self.Main.document.activeMenu )
   {
	// init of menus

	setActiveMenu( "invisible" );
   }

   return true;
}


function on_resize()
{
   if( NN )
   {
	self.Main.window.location.reload();
	self.Nav.window.location.reload();
   }
}

function popMainMenu( ankerLayer, menuName, direction )
{

   if( checkEnvironment( menuName ) != true )
	return true;

   if( self.Main.document.activeMenu == menuName )
	return true; // menu is already shown

   var offset = 0;
   if( NN )
	offset = 4;
   else if( MS || W3C )
	offset = 4;

   if( direction == "top" )
   {
      var yPos = getTop( ankerLayer ) - offset - getHeight( menuName );
      if( yPos < 0 )
         yPos = 3;
      showMenu( menuName, "sichtbar", getLeft( ankerLayer ), 
	        yPos, 
	        getDown( ankerLayer));
   }
   else
   {
      showMenu( menuName, "sichtbar", getLeft( ankerLayer ), 
	        getDown( ankerLayer ) + offset, 
	       getTop( ankerLayer));  
   }
 
   hideOverlayingItems( menuName );
   setTimeout("setMouseMove()",200);
   return true;
}

function popMenu( ankerLayer, menuName )
{
   if( checkEnvironment( menuName ) != true )
	return true;

   if( self.Main.document.activeMenu == menuName )
	return true; // menu is already shown

   lPos = getLeft( ankerLayer, "Nav" );
   if( lPos + getWidth( menuName ) + 10 > getMainWidth() )
      lPos = getMainWidth() - getWidth( menuName ) - 14;

   showMenu( menuName, "sichtbar", lPos, getMainHeight() - getHeight( menuName ) -  getHorScrollHeigth() +5);  
   setMouseMove();
   hideOverlayingItems( menuName );

    
   return true;
}

function getHorScrollHeigth()
{
   return 4;
}


function hideMenu(e, myLay)
{

   if( checkEnvironment( myLay ) != true )
	return;

   if( self.Main.document.activeMenu == "invisible" )
	return;


   if( NN )
   {
	if( self.Nav.document.layers[myLay] )
	{
	   if( getEventX(e) <= self.Nav.document.layers[myLay].left ||
	       getEventX(e) >= ( self.Nav.document.layers[myLay].left + self.Nav.document.layers[myLay].clip.width ))
	   {
	      showMenu( self.Main.document.activeMenu, "unsichtbar" );
	      setMouseMoveBack();
	   }
	}
   }
   else if( MS )
   {
	if( self.Nav.document.all[myLay] )
	{
	   if( ( getEventX(e) <= self.Nav.document.all[myLay].style.pixelLeft && e.clientX > 0 )||
	       ( getEventX(e) >= ( self.Nav.document.all[myLay].style.pixelLeft + self.Nav.document.all[myLay].style.pixelWidth ) && e.clientX > 0 ))
	  {
	     showMenu( self.Main.document.activeMenu, "unsichtbar" );
	     setMouseMoveBack();
	  }
	}
   }
}

var moveCnt = 0;
function myMouseMove(e) 
{
   if( moveCnt > 0 )
   {
      moveCnt = 0;
      return;
   }
   moveCnt++; // performance !
  
   if( self.Main.document.activeMenu == "invisible")
      return;

   var x = getMainEventX( e );
   var y = getMainEventY( e );

   if( y <= topPos ||
       x <= leftPos ||
       x >= rightPos ||
       (downPos != 0 && y > downPos) )
   {   
         showMenu( self.Main.document.activeMenu, "unsichtbar" );
         setMouseMoveBack();
         self.Nav.cB(); // menu Marker back
   }
}

function calculateDim( ankerBeginY ) 
{
   var i;

   if( self.Main.document.activeMenu == "invisible")
      return;

   if( self.Main.document.isFreeMenu )
   {
      if( getTop( self.Main.document.activeMenu ) > self.Main.document.isFreeMenu )
      {  // menu under anker
         topPos = self.Main.document.isFreeMenu;
         downPos = getDown( self.Main.document.activeMenu );
      }
      else
      { // menu over anker
         topPos = getTop( self.Main.document.activeMenu );
         downPos = self.Main.document.isFreeMenu;
      }
   }
   else
   {
      topPos = getTop( self.Main.document.activeMenu );
      downPos = 0;
   }

   leftPos = getLeft( self.Main.document.activeMenu );
   rightPos = getRight( self.Main.document.activeMenu );

   if( getSonMenu( self.Main.document.activeMenu ) != "" )
   {
      for( i = 0; i < menuHist.length; i++ )
      {
         if( topPos > getTop( menuHist[i] ) )
               topPos = getTop( menuHist[i] );

         if( rightPos < getRight( menuHist[i] ))
            rightPos = getRight( menuHist[i] );
        
         if( leftPos > getLeft( menuHist[i] ))
            leftPos = getLeft( menuHist[i] );  

         if( self.Main.document.isFreeMenu )
         {
            if( downPos < getDown( menuHist[i] ))
            downPos = getDown( menuHist[i] ); 
         }
      }
   }

   topPos -= 10;
   leftPos -= 10;
   if( downPos >=10 ) downPos += 10;
   rightPos +=10;


}

function sSM( obj, parentMenu, subMenu, e )
{
   cC( obj, parentMenu );
   showSubMenu( obj, parentMenu, subMenu, e );
}

function showSubMenu( obj, parentMenu, subMenu, e )
{
   if( !document.layers )
   {
      if( actParentAndSubMenu == ( obj.sourceIndex + subMenu ) ||
         self.Main.document.activeMenu == "invisible" )
         return;

   actParentAndSubMenu = obj.sourceIndex + subMenu;

   }

   var ePos;

   if( NN || W3C)
      ePos = e.pageY;
   else
      ePos = e.clientY+self.Main.document.body.scrollTop;
 
   var x = calcBestXPos( parentMenu, subMenu );
   
//   showCnt++;

   setTimeout("_showSubMenu('" + parentMenu + "','" + subMenu + "','" + x + "','" + ePos + "','" + showCnt + "')",300);

}

function _showSubMenu( parentMenu, subMenu, x, ePos, cnt )
{

   if( cnt != showCnt )
      return;

   var parentIdx = getHistIndex( parentMenu );

   hideSubMenuIdx( parentIdx, 0 );

   // show the new menu
   setPos( subMenu, x, calcBestPos( parentMenu, subMenu, ePos ) );

   setVisibility( subMenu, sichtbar );
   setSonMenuIdx( parentIdx, parentMenu, subMenu );
   setTimeout("calculateDim()",1); // performance !
   hideOverlayingItems( subMenu ); 

   // closed again ?
   if( self.Main.document.activeMenu == "invisible" )
      setVisibility( subMenu, unsichtbar );

   if( self.Main.document.activeMenu != menuHist[0] )
      setVisibility( subMenu, unsichtbar );

}



function calcBestXPos( parentMenu, subMenu )
{
   var subMenuWidth = getWidth( subMenu );
   var parentMenuRight = getRight( parentMenu );

   if( ( parentMenuRight + subMenuWidth ) < getMainInnerWidth() )
      return( parentMenuRight - 3 );

   return( getLeft( parentMenu ) - subMenuWidth + 3 );

}

function calcBestPos( parentMenu, subMenu, eventPosY )
{
   pos = eventPosY - getHeight( subMenu ) + 3;

   if( pos < 0 )
      pos = 4;

   return( pos );
}

function hSM( obj, menuName )
{
   cC(obj, menuName);
   hideSubMenu(menuName,0);
}

function hideSubMenu( menuName, doCalc )
{
   var i = getHistIndex( menuName );
   var x = i;

   actParentAndSubMenu = "";

   if( i == -1 )
      return;

   for( i++; i < menuHist.length; i++ )
   {
      setVisibility( menuHist[i], unsichtbar );
      setPos( menuHist[i], 0, 0 );
   }
   menuHist.length = x+1;
   
   if( doCalc )
      calculateDim();

}

function hideSubMenuIdx( idx, doCalc )
{
   if( idx == -1 )
      return;

   var x = idx;

   for( idx++; idx < menuHist.length; idx++ )
   {
      setVisibility( menuHist[idx], unsichtbar );
      setPos( menuHist[idx], 0, 0 );
   }
   menuHist.length = x+1;
   
   if( doCalc )
      calculateDim();

}

function setSonMenu( parentMenu, subMenu )
{
   var i = getHistIndex( parentMenu );

   if( i == -1 )
   {
      menuHist.length = 0;
      menuHist[0] = parentMenu;
      menuHist[1] = subMenu;
      return;
   }
   
   menuHist[i+1] = subMenu;
   menuHist.length = i + 2;
}

function setSonMenuIdx( idx, parentMenu, subMenu )
{
   if( idx == -1 )
   {
      menuHist.length = 0;
      menuHist[0] = parentMenu;
      menuHist[1] = subMenu;
      return;
   }
   
   menuHist[idx+1] = subMenu;
   menuHist.length = idx + 2;
}

function getSonMenu( parentMenu )
{
   var i = getHistIndex( parentMenu );
 
   if( i == -1 )
      return "";

   if( i+1 < menuHist.length )
      return( menuHist[i+1] );

   return "";
}


function getHistIndex( menuName )
{
   for( i = 0; i < menuHist.length; i++ )
      if( menuName == menuHist[i] )
         return i;
   return -1;
}

function setMouseMove()
{

   if( NN )
   {
      self.Main.document.onmousemove = myMouseMove;
      self.Main.document.captureEvents(Event.MOUSEMOVE);
   }
   if (MS || W3C)
      self.Main.document.onmousemove = myMouseMove;
}

function getMouseMove()
{
 
   if( self.Main.document.onmousemove )
      return self.Main.document.onmousemove;
   else
      return "";
}

function setMouseMoveBack()
{
   if( NN )
   {
      self.Main.document.onmousemove = orgMouseMove;
      self.Main.document.captureEvents(Event.MOUSEMOVE);
   }
   if (MS || W3C)
      self.Main.document.onmousemove = orgMouseMove;


}

function getMainInnerWidth()
{
   if (NN || W3C)
      return self.Main.window.innerWidth;
   else if (MS)
      return self.Main.document.body.offsetWidth;
}

function getMainHeight()
{
   if (NN)
      return self.Main.window.innerHeight + self.Main.window.pageYOffset;
   else if (MS)
   {
      if( Opera )
         return self.Main.window.innerHeight -4 + self.Main.window.pageYOffset;

      return self.Main.document.body.offsetHeight - 4 + self.Main.document.body.scrollTop;
   }
   else if (W3C)
      return self.Main.window.innerHeight -4 + self.Main.window.pageYOffset;
}

function getMainWidth()
{
   if (NN || W3C)
      return self.Main.window.innerWidth + self.Main.window.pageXOffset;
   else if (MS)
      return self.Main.document.body.offsetWidth - 4 + self.Main.document.body.scrollLeft;
}

function getScrollOffsetY()
{
   if (NN || W3C)
      return self.Main.window.pageYOffset;
   else if (MS)
      return self.Main.document.body.scrollTop;
}

function getScrollOffsetX()
{
   if (NN || W3C)
      return self.Main.window.pageXOffset;
   else if (MS)
      return self.Main.document.body.scrollLeft;
}

function getTop( menuName )
{
   if (NN)
      return self.Main.document.layers[menuName].top;
   else if (MS)
      return self.Main.document.all[menuName].style.pixelTop;
   else if (W3C)
      return removePx( self.Main.document.getElementById(menuName).style.top );
}

function getDown( menuName )
{
   return( getTop( menuName ) + getHeight( menuName ));
}

function getLeft( menuName, usedFrame )
{

   if( usedFrame == "Nav" )
   {
      if (NN)
         return self.Nav.document.layers[menuName].left;
      else if (MS)
         return self.Nav.document.all[menuName].style.pixelLeft;
      else if (W3C)
         return removePx( self.Nav.document.getElementById(menuName).style.left );
   }
   else
   {
      if (NN)
         return self.Main.document.layers[menuName].left;
      else if (MS)
         return self.Main.document.all[menuName].style.pixelLeft;
      else if (W3C)
         return removePx( self.Main.document.getElementById(menuName).style.left );
   }
}

function removePx( val )
{
  var str = new String( val );
  arrayOfStrings = str.split("px")
  return( Number(arrayOfStrings[0]));   
}

function getRight( menuName )
{
   if (NN)
      return getLeft( menuName ) + self.Main.document.layers[menuName].clip.width;
   else if (Opera)
      return removePx(getLeft( menuName )) + removePx(self.Main.document.getElementById(menuName).style.width);
   else if (MS)
      return getLeft( menuName ) + self.Main.document.all[menuName].scrollWidth;
   else if (W3C)
      return removePx(getLeft( menuName )) + removePx(self.Main.document.getElementById(menuName).style.width);
}

function getWidth( menuName )
{
   if (NN)
      return self.Main.document.layers[menuName].clip.width;
   else if (Opera)
      return removePx(self.Main.document.getElementById(menuName).style.width);
   else if (MS)
      return self.Main.document.all[menuName].scrollWidth;
   else if (W3C)
      return removePx(self.Main.document.getElementById(menuName).style.width);
}

function getHeight( menuName )
{
   if (NN)
      return self.Main.document.layers[menuName].clip.height;
   else if( Opera ) 
      return self.Main.document.getElementById(menuName).offsetHeight;
   else if (MS)
      return self.Main.document.all[menuName].scrollHeight;
   else if (W3C)
      return self.Main.document.getElementById(menuName).offsetHeight;

}


function getMainEventX( e )
{
   if (NN || W3C)
      return e.pageX;// + getScrollOffsetX();
   else if (MS)
      return self.Main.event.clientX + getScrollOffsetX();
}

function getMainEventY( e )
{
   if (NN || W3C)
      return e.pageY;// + getScrollOffsetY();
   else if (MS)
      return self.Main.event.clientY + getScrollOffsetY();
}

function getEventX( e )
{
   if (NN)
      return e.pageX;
   else if (MS || W3C)
      return e.clientX
}

function getEventY( e )
{
   if (NN)
      return e.pageY;
   else if (MS || W3C)
      return e.clientY;
}

function setPos( menuName, x, y )
{
   if (NN)
   {
      self.Main.document.layers[menuName].left = x;
      self.Main.document.layers[menuName].top = y;
      self.Main.document.layers[menuName].zIndex = 1;   
   }
   else if( MS )
   {
     self.Main.document.all[menuName].style.pixelLeft = x;
     self.Main.document.all[menuName].style.pixelTop = y;
     self.Main.document.all[menuName].style.zIndex = 1;
   }
   else if( W3C )
   {
     self.Main.document.getElementById(menuName).style.left = x;
     self.Main.document.getElementById(menuName).style.top = y;
     self.Main.document.getElementById(menuName).style.zIndex = 1;
   }
}

function setVisibility( menuName, arg )
{
   if( menuName == "invisible" )
      return;

   if(NN)
      self.Main.document.layers[menuName].visibility = arg;
   else if( MS )
   {
//      self.Main.document.all[menuName].style.filter="alpha(opacity=96)";
      self.Main.document.all[menuName].style.visibility = arg;

      cB( menuName ); // set amnu marker back;
   }
   else if( W3C )
   {
      self.Main.document.getElementById(menuName).style.visibility = arg;
   }
}

function setHeight( menuName, menuHeight )
{
   if( NN ) 
      self.Main.document.layers[menuName].clip.height = menuHeight;
   else if( MS )
      self.Main.document.all[menuName].style.pixelHeight = menuHeight;
   else if( W3C )
      self.Main.document.getElementById(menuName).style.pixelHeight = menuHeight;
}

function layExists( menuName )
{
   if( NN )
      if( self.Nav.document.layers[menuName] )
         return true;
   else if( MS )
      if( self.Nav.document.all[menuName] )
         return true;
   else if( W3C )
      if( self.Nav.document.getElementById(menuName) )
         return true;

   return false;
}

function setActiveMenu( menuName, ankerBeginY )
{
   if( ankerBeginY )
      self.Main.document.isFreeMenu = ankerBeginY;
   else
      self.Main.document.isFreeMenu = 0;
   self.Main.document.activeMenu = menuName;
}

function setNav( navName )
{
   if( !NN && !MS && !W3C )
      initNavigator();

   strA = new String( self.Nav.location );
   subStrA = strA.substring( strA.lastIndexOf( '/' ) +1);

   strB = new String( navName );
   subStrB = strB.substring( strB.lastIndexOf( '/' ) +1);

   if( !W3C )
   {
      if( self.Nav.cB )
         self.Nav.cB();
   }

   if( subStrA != subStrB )
      self.Nav.location.replace( navName );
}

Browser = "unbekannt";
function Browser_Version( showMessage )
{
   if ((navigator.userAgent.indexOf('StarOffice') > -1) || (navigator.appName.indexOf('StarOffice') > -1))
      Browser = "SO" + navigator.appVersion.charAt(0);
   else
      if (navigator.userAgent.indexOf('Opera 6') > -1)
         Browser = "Opera";
      else
         if (navigator.appName == "Microsoft Internet Explorer")
            if (navigator.appVersion.indexOf('Macintosh') > -1)
               Browser = "MAC-MSIE" + navigator.appVersion.charAt(0);
            else	
               Browser = "MSIE" + navigator.appVersion.charAt(0);
      else
         if (navigator.appName == "Netscape")
         {
            Browser = "NN" + navigator.appVersion.charAt(0);
         }

   if (Browser.indexOf('Opera') > -1)
   {
      Opera = true;
   }

   if( showMessage && showMessage == "true" && !NN && !MS )
      alert("Sorry, Ihre Browserversion wird leider nicht unterstuetzt !" );
}


function start()
{
   Browser_Version();
   orgMouseMove = getMouseMove;
}

function hideOverlayingItems( menuName )
{
   if( !self.Main.overlayingLayer )
      return;

   var i;

   for( i=0; i < self.Main.overlayingLayer.length; i++ )
   {
      if( NN )
      {
         if( !self.Main.document.layers[self.Main.overlayingLayer[i]] )
            continue;  
      }
      else
      {
         if( !self.Main.document.all[self.Main.overlayingLayer[i]] )
           continue;                    
      }  

      leftt = getLeft( self.Main.overlayingLayer[i] );
      topp = getTop( self.Main.overlayingLayer[i] );
      rightt = leftt + getWidth( self.Main.overlayingLayer[i] );
      downn = topp + getHeight( self.Main.overlayingLayer[i] );

      leftM = getLeft( menuName );
      topM = getTop( menuName );
      rightM = leftM + getWidth( menuName );
      downM = topM + getHeight( menuName );

      if( divsUeberlappen( leftM, topM, rightM, downM, leftt, topp, rightt, downn ))
      {
         setVisibility( self.Main.overlayingLayer[i], unsichtbar );
      }
   }
}


function divsUeberlappen( minX1, minY1, maxX1, maxY1, minX2, minY2, maxX2, maxY2 )
{
   if( minX1 <= maxX2 &&
       minX2 <= maxX1 && 
       minY1 <= maxY2 &&
       minY2 <= maxY1 )
      return 1;

   return 0;
}

function showOverlayingItems()
{
   if( !self.Main.overlayingLayer )
      return;

   var i;

   for( i=0; i < self.Main.overlayingLayer.length; i++ )
   {
      if( NN )
      {
         if( !self.Main.document.layers[self.Main.overlayingLayer[i]] )
            continue;  
      }
      else
      {
         if( !self.Main.document.all[self.Main.overlayingLayer[i]] )
           continue;                    
      } 
         
      setVisibility( self.Main.overlayingLayer[i], sichtbar );           
   }
}