/* ======================================

   Farben für die einzelnen Menüs

====================================== */
// function tMenu (menuName, bgColorDefault, bgColorHighlight, bgColorActive, ...)
var menu = new Array ();
menu[0] = new tMenu ('navi', '#153B63', '#1B528C', '#2269B5');
menu[1] = new tMenu ('navigreen', '#00664A', '#008F68', '#00CF88');
menu[2] = new tMenu ('navigreen02', '#00826C', '#12A592', '#23C8B8');
menu[3] = new tMenu ('navicontent', '#1B528C', '#2269B5', '#2269B5');
menu[4] = new tMenu ('navicontentgreen', '#E9F5EE', '#A7DCBC', '#A7DCBC');
menu[5] = new tMenu ('navicontentgreen02', '#DEF3EF', '#83D0B8', '#83D0B8');
menu[6] = new tMenu ('navilist', '#FFFFFF', '#DFE9F4', '#DFE9F4');
menu[7] = new tMenu ('navilistgreen', '#FFFFFF', '#E9F5EE', '#E9F5EE');
menu[8] = new tMenu ('navilistgreen02', '#FFFFFF', '#DEF3EF', '#DEF3EF');
menu[9] = new tMenu ('navirechts', '#B4C6D9', '#8CA8C5', '#8CA8C5');
menu[10] = new tMenu ('navirechtsgreen', '#E9F5EE', '#A7DCBC', '#A7DCBC');
menu[11] = new tMenu ('navirechtsgreen02', '#DEF3EF', '#83D0B8', '#83D0B8');
menu[12] = new tMenu ('naviunten', '#B4C6D9', '#A0B7CF', '#A0B7CF');
menu[13] = new tMenu ('navirechts2', '#DFE9F4', '#B4C6D9', '#B4C6D9');



/* ======================================
2
   Menü-Funktionen

====================================== */

// Highlight or un-highlight menu items
function MenuHighlight (MenuItemID, Highlight, menuId) {

  if (debug && !Highlight) window.status = 'Menüpunkt-ID: ' + MenuItemID + ', Menü-ID: ' + menuId;
  menuId = (menuId == null) ? 0 : menuId;

  if (Highlight == 2) {
    menu[menuId].curItemName = MenuItemID;
  }

  var tdIterator = 0;
  var DocMenuItemTD = '';
  var Color = Highlight ? menu[menuId].bgColorHighlight : menu[menuId].bgColorDefault;
  Color = (Highlight == 2) ? menu[menuId].bgColorActive : Color; // Highlight Page Menu Item
 
  // Highlight all TDs which build the menu item
	if (document.all) {
	  while ( (DocMenuItemTD = eval ('document.all.td' + MenuItemID + 't' + tdIterator) ) && ( (MenuItemID != menu[menuId].curItemName) || (Highlight == 2) ) ) {
 		  DocMenuItemTD.style.backgroundColor = Color;
  		tdIterator++;
		} 
	} else if (document.body) {
	  DocMenuItemTD = document.getElementsByTagName ('td')['td' + MenuItemID + 't' + tdIterator];
	  while ( DocMenuItemTD && ( (MenuItemID != menu[menuId].curItemName) || (Highlight == 2) ) ) {
  	  DocMenuItemTD.style.backgroundColor = Color;
  		tdIterator++;
  		DocMenuItemTD = document.getElementsByTagName ('td')['td' + MenuItemID + 't' + tdIterator] 
		} 
	}

} // function MenuHighlight


function PageStartup () {

	// Select whether position properties need to be set as numbers or e. g. '12px'
	if (document.body) {
		document.getElementsByTagName ('body')[0].style.left = 0;
		px = (String(document.getElementsByTagName ('body')[0].style.left).indexOf ('p') == -1) ? '' : 'px';
	} else {
		px = 0;
	}
	
  // Highlight current page menu item(s)
  var menuItemId, menuId;
  for (var i=0; i < PageStartup.arguments.length; i=i+2) {
    menuItemId = PageStartup.arguments[i];
    menuId = (PageStartup.arguments[i+1] != null) ? PageStartup.arguments[i+1] : 0;
    MenuHighlight (menuItemId, 2, menuId);
    menu[menuId].pageItemName = menuItemId;
    // open all menu items above menuItemId
    itemNameArray = menuItemId.split('cm');
    var predecItemName = 'dv';
    for (var l = 1; l < itemNameArray.length; l++) {
      predecItemName += 'cm' + itemNameArray[1];
      if (l > 1) clickItem (getItemById (predecItemName), menuId, true);
    }
  }	

} // function PageStartup





/* --------------------------------------

   Funktion, um neues Browserfenster zu öffnen

-------------------------------------- */

// Browser-Fenster öffnen (V3)
function OpenWindow (URL, Width, Height, Left, Top, Name, Resizable, ScrollBars, MenuBar, ToolBar, LocationBar, BookmarkBar, StatusBar, Dependent, HotKeys) {

	// Vorsicht bei NN: Wird die MenuBar angezeigt, wird ab Breiten kleiner 303 die Fensterhöhe vom NN falsch berechnet.

	// Testen, ob Positions- und Größen-Parameter angegeben und nicht zu groß sind
	if ( (Top == null) || isNaN (Top) ) Top = 20;
	if ( (Left == null) || isNaN (Left) ) Left = 20;
	if ( (Height == null) || isNaN (Height) || (Height + Top > screen.availHeight - 10) ) Height = screen.availHeight - 10 - Top;
	if ( (Width == null) || isNaN (Width) || (Width + Left > screen.availWidth - 10) ) Width = screen.availWidth - 10 - Left;
	Name = (Name == null) ? '' : Name; // Name = Leerstring, wenn kein Name angegeben ist
	// Testen, ob alle Parameter vorhanden sind, sonst Default-Werte vergeben

	Resizable = ((Resizable == null) || (Resizable == true)) ? 'yes' : 'no';
	ScrollBars = ((ScrollBars == null) || (ScrollBars == true)) ? 'yes' : 'no';
	MenuBar = ((MenuBar == null) || (MenuBar == false)) ? 'no' : 'yes';
	ToolBar = ((ToolBar == null) || (ToolBar == false)) ? 'no' : 'yes';
	LocationBar = ((LocationBar == null) || (LocationBar == false)) ? 'no' : 'yes';
	BookmarkBar = ((BookmarkBar == null) || (BookmarkBar == false)) ? 'no' : 'yes';
	StatusBar = ((StatusBar == null) || (StatusBar == true)) ? 'yes' : 'no';
	Dependent = ((Dependent == null) || (Dependent == true)) ? 'yes' : 'no';
	HotKeys = ((HotKeys == null) || (HotKeys == true)) ? 'yes' : 'no';

	// Für IE Fenstergrößen extra berechnen, da IE "innerWidth" und "InnerHeight" nicht beachtet.
	if (document.all) {
		Height += 31; // 31 Pixel höher für Fensterrahmen und Titelleiste des Fensters
		Width = Width + 12; // 12 Pixel breiter für den Fensterrahmen
		Height = (Resizable == 'no') ? Height - 2 : Height; // Der Fensterrahmen von Nicht-"Resizable"-Fenstern ist 2 Pixel schmaler.
		Width = (Resizable == 'no') ? Width - 2 : Width; // dto.
		Width = (ScrollBars == 'yes') ? Width + 16 : Width;
		Height = (MenuBar == 'yes') ? Height + 29 : Height;
		Height = (ToolBar == 'yes') ? Height + 47 : Height;
		Height = (LocationBar == 'yes') ? Height + 29 : Height; 
		var BarCompensation = (MenuBar == 'yes') ? 1 : 0; // je "Bar"-Paar werden wiederum 5 Pixel eingespart
		BarCompensation = (ToolBar == 'yes') ? BarCompensation + 1 : BarCompensation;
		BarCompensation = (LocationBar == 'yes') ? BarCompensation + 1 : BarCompensation;
		BarCompensation = (BarCompensation < 1) ? 1 : BarCompensation;
		Height -= ( (BarCompensation - 1) * 5);
		Height = (StatusBar == 'yes') ? Height + 20 : Height;
		// Fenster wieder verkleinern, falls es jetzt wieder zu groß ist
		if (!Width || isNaN (Width) || (Width > screen.availWidth - 10)) Width = screen.availWidth - 10;
		if (!Height || isNaN (Height) || (Height > screen.availHeight - 10)) Height = screen.availHeight - 10;
	}
	
	// Fenster mit den gegebenen Parametern öffnen
	NewWindow = window.open(URL, Name, 'screenX=' + Left + ',screenY=' + Top 
	+ ',height=' + Height + ',width=' + Width + ',innerHeight=' + Height + ',innerWidth=' + Width
	+ ',resizable=' + Resizable + ',scrollbars=' + ScrollBars + ',menubar=' + MenuBar 
	+ ',toolbar=' + ToolBar + ',location=' + LocationBar + ',directories=' + BookmarkBar 
	+ ',status=' + StatusBar + ',dependent=' + Dependent);

	if (navigator.appVersion.indexOf ('MSIE 5.0')) NewWindow.focus (); // IE 5.0 bricht hier sonst ab

	URL += ''; // IE versteht die URL nur so als String ...

	// Für IE muss extra positioniert. Der Fenster-Zugriff wird aber verweigert, wenn eine 
	// komplette HTTP-Adresse aufgerufen wird ...

	if (!NewWindow.innerWidth && (URL.indexOf ('http://') < 0)) {
		NewWindow.moveTo (Left, Top);
	}

	NewWindow.focus (); // Fenster ganz nach vorn stellen, also Focus auf das Fenster

	return false; // damit der HREF-Link nicht ausgeführt wird
	
} // function OpenWindow


/* ======================================

   Constants, global variables, type constructors

====================================== */


// "Konstanten" zur Browser-Kompatibilität
var px = '';
var visible = (document.layers) ? 'show' : 'visible';
var hidden = (document.layers) ? 'hide' : 'hidden';

function tMenu (menuName, bgColorDefault, bgColorHighlight, bgColorActive, left, top, isPopUp, opensOnMouseOver, opensOnlyOneItem) {
	
	this.name = menuName;
	this.bgColorDefault = bgColorDefault;
	this.bgColorHighlight = bgColorHighlight;
	this.bgColorActive = bgColorActive;
	this.left = left;
	this.top = top;
	this.isPopUp = isPopUp;
	this.opensOnMouseOver = opensOnMouseOver;
	this.opensOnlyOneItem = opensOnlyOneItem;

	this.curItemName = '';
	this.pageItemName = '';
	this.isCurItemOpen = false;
	this.MouseOutTimeout = 0;
	// this.item = new Array();
	
} // function tMenu 


/* ======================================

   Debug stuff

====================================== */

var debug = false;


function dm (message) {
  
  if ( debug && (document.forms.debug) ) alert (message); // document.forms.debug.elements.dta.value += message + '\n';
  
} // function dm 
