if (NS) {n=1;ie=0;fShow="show";   fHide="hide";}
if (DOM)  {n=0;ie=1;fShow="visible";fHide="hidden";}

var SmenuFonte = "bold 11px Arial";
var SmenuFontn = "bold 11px Arial";
var SfontColor = "#2f53a7";
var SbgColor   = "#a1b6df";
var SMenuWidth = 150;
var SMenuLeft  = 5;
var SMenuTop   = 2;
if (DOM && !MS){
 SMenuTop   = 12;
}
////////////////////////////////////////////////////////////////////////////
// Function Menu()                                                        //
////////////////////////////////////////////////////////////////////////////
function Menu()
{
	this.bgColor     = "#2f53a7";
	if (ie) this.menuFont = "bold 11px Arial";
	if (n)  this.menuFont = "bold 11px Arial";
	this.fontColor   = "#eeeeee";

	this.addItem    = addItem;
	this.addSubItem = addSubItem;
	this.showMenu   = showMenu;
	this.mainPaneBorder = 0;
	this.subMenuPaneBorder = 0;

	this.subMenuPaneWidth = 150;

	lastMenu = null;

	rightY = 0;
	rightX = 0;
	leftY = 0;
	leftX = 0;

	HTMLstr = "";
	HTMLstr += "<!-- MENU PANE DECLARATION BEGINS -->\n";
	HTMLstr += "\n";
	if (ie) HTMLstr += "<div id='MainTable'>\n";
//	if (n)  HTMLstr += "<layer name='MainTable'>\n";
	HTMLstr += "<table width='100%' bgcolor='"+this.bgColor+"' border='"+this.mainPaneBorder+"'>\n";
	HTMLstr += "<tr>";
	HTMLstr += "<td style='width: "+this.subMenuPaneWidth+"'>\n";
    HTMLstr += "<table width='100%' bgcolor='"+this.bgColor+"' border='"+this.mainPaneBorder+"'>\n";
	HTMLstr += "<tr>";
	if (n) HTMLstr += "<td>&nbsp;";
	HTMLstr += "<!-- HOME MENU STARTS -->\n";
	HTMLstr += "<!-- HOME_MENU -->\n";
	HTMLstr += "<!-- HOME MENU ENDS -->\n";
	if (n) HTMLstr += "</td>";
	HTMLstr += "</tr>\n";
	HTMLstr += "</table>\n";
	HTMLstr += "</td>\n";
	HTMLstr += "<td>";
    HTMLstr += "<table width='100%' bgcolor='"+this.bgColor+"' border='"+this.mainPaneBorder+"'>\n";
	HTMLstr += "<tr>";
	if (n) HTMLstr += "<td>&nbsp;";
	HTMLstr += "<!-- MAIN MENU STARTS -->\n";
	HTMLstr += "<!-- MAIN_MENU -->\n";
	HTMLstr += "<!-- MAIN MENU ENDS -->\n";
	if (n) HTMLstr += "</td>";
	HTMLstr += "</tr>\n";
	HTMLstr += "</table>\n";
	HTMLstr += "</td>\n";
	HTMLstr += "</tr>\n";
	HTMLstr += "</table>\n";
	HTMLstr += "\n";
	HTMLstr += "<!-- SUB MENU STARTS -->\n";
	HTMLstr += "<!-- SUB_MENU -->\n";
	HTMLstr += "<!-- SUB MENU ENDS -->\n";
	HTMLstr += "\n";
	if (ie) HTMLstr+= "</div>\n";
	HTMLstr += "<br>\n";
	HTMLstr += "<!-- SUB MENUS STARTS -->\n";
	HTMLstr += "<!-- SUB_MENUS -->\n";
	HTMLstr += "<!-- SUB MENUS ENDS -->\n";
	HTMLstr += "\n";
//	if (ie) HTMLstr += "<div id='STable' style='position:relative'>";
//    HTMLstr += "<A HREF='../services/software.html' target='mainFrame'><IMG class='OraclePartner' SRC='../zentral/images/ALL_LRG.GIF' BORDER=0 HEIGHT=62 WIDTH=127></A>\n";
    if (aktSubM == "") {
      HTMLstr += "<IMG class='home' SRC='../zentral/images/pc_innen3.gif' BORDER=0>\n";
      HTMLstr += "<IMG class='home1' SRC='../zentral/images/tast5.gif' BORDER=0>\n";
      HTMLstr += "<IMG class='home2' SRC='../zentral/images/rz3.gif' BORDER=0>\n";
    } else if (aktSubM == "Telekommunikation") {
      HTMLstr += "<IMG class='tele1' SRC='../zentral/images/tele11.gif' BORDER=0 >\n";
      HTMLstr += "<IMG class='tele2' SRC='../zentral/images/tele2.gif' BORDER=0 >\n";
      HTMLstr += "<IMG class='tele3' SRC='../zentral/images/uhr11.gif' BORDER=0 >\n";
    } else if ((aktSubM == "Automobillogistik")||(aktSubM == "Logistik Standard")) {
      HTMLstr += "<IMG class='solut1' SRC='../zentral/images/strasse1.gif' BORDER=0 >\n"; 
      HTMLstr += "<IMG class='solut2' SRC='../zentral/images/old_auto.gif' BORDER=0 WIDTH=127>\n";
      HTMLstr += "<IMG class='solut3' SRC='../zentral/images/strasse2.gif' BORDER=0>\n";
    } else if ((aktSubM == "Supply Chain Event Management")||(aktSubM == "Logistik Standard")) {
      HTMLstr += "<IMG class='solut1' SRC='../zentral/images/strasse1.gif' BORDER=0 >\n"; 
      HTMLstr += "<IMG class='solut2' SRC='../zentral/images/old_auto.gif' BORDER=0 WIDTH=127>\n";
      HTMLstr += "<IMG class='solut3' SRC='../zentral/images/strasse2.gif' BORDER=0>\n";
    } else if ((aktSubM == "Mautberechnung")||(aktSubM == "Logistik Standard")) {
      HTMLstr += "<IMG class='solut1' SRC='../zentral/images/strasse1.gif' BORDER=0 >\n"; 
      HTMLstr += "<IMG class='solut2' SRC='../zentral/images/old_auto.gif' BORDER=0 WIDTH=127>\n";
      HTMLstr += "<IMG class='solut3' SRC='../zentral/images/strasse2.gif' BORDER=0>\n";
    } else if (aktSubM == "EDI-Tools") {
      HTMLstr += "<IMG class='edi1' SRC='../zentral/images/tast4.gif' BORDER=0>\n";
      HTMLstr += "<IMG class='edi2' SRC='../zentral/images/uhr3.gif' BORDER=0>\n";
      HTMLstr += "<IMG class='edi3' SRC='../zentral/images/disc31.gif' BORDER=0>\n";
    } else if (aktSubM == "EDI-Outsourcing") {
      HTMLstr += "<IMG class='Outs1' SRC='../zentral/images/rz1.gif' BORDER=0>\n";
      HTMLstr += "<IMG class='Outs2' SRC='../zentral/images/rz2.gif' BORDER=0>\n";
      HTMLstr += "<IMG class='Outs3' SRC='../zentral/images/rz4.gif' BORDER=0>\n";
    } else if (aktSubM == "Softwareentwicklung") {
      HTMLstr += "<IMG class='Soft1' SRC='../zentral/images/tast4.gif' BORDER=0>\n";
      HTMLstr += "<IMG class='Soft2' SRC='../zentral/images/uhr3.gif' BORDER=0>\n";
      HTMLstr += "<IMG class='Soft3' SRC='../zentral/images/disc31.gif' BORDER=0>\n";
    }
//	if (ie) HTMLstr+= "</div>\n";
//	if (n)  HTMLstr+= "</layer>\n";
	HTMLstr += "<!-- MENU PANE DECALARATION ENDS -->\n";
}

function addItem(idItem, text, hint, location, altLocation)
{
	var Lookup = "<!-- ITEM "+idItem+" -->";
	if (HTMLstr.indexOf(Lookup) != -1)
	{
		alert(idParent + " already exist");
		return;
	}
	var MENUitem = "";
	MENUitem += "\n<!-- ITEM "+idItem+" -->\n";
	if (n)
	{
		if (idItem == aktMenu) MENUitem += "<ilayer name="+idItem+" bgcolor="+this.fontColor+" ";
		else  MENUitem += "<ilayer name="+idItem+" ";
		if (idItem == "home") MENUitem += "style='width: "+this.subMenuPaneWidth+"'>\n";
		else MENUitem += ">\n";
		MENUitem += "<a href='.' ";
		MENUitem += "class=clsMenuItemNS ";
		if (idItem == aktMenu) MENUitem += "style='text-decoration: none; font: "+this.menuFont+"; color: "+this.bgColor+"; cursor: hand;' ";
		MENUitem += "onmouseover=\"displaySubMenu('"+idItem+"')\" onclick=\"return false;\">";
		MENUitem += "|&nbsp;";
		MENUitem += text;
		MENUitem += "</a>";
		MENUitem += "</ilayer>";
	}
	if (ie)
	{
		if (idItem == aktMenu) MENUitem += "<td bgcolor="+this.fontColor+" ";
		else MENUitem += "<td bgcolor="+this.bgColor+" ";
		if (idItem == "home") MENUitem += "style='width: "+this.subMenuPaneWidth+"'>\n";
		else MENUitem += "Width=\"12%\">\n";
		MENUitem += "<div id='"+idItem+"' style='position:relative; font: "+this.menuFont+";'>\n";
		MENUitem += "<a ";
		MENUitem += "class=clsMenuItemIE ";
		if (idItem == aktMenu) MENUitem += "style='text-decoration: none; font: "+this.menuFont+"; color: "+this.bgColor+"; cursor: hand;' ";
		if (hint != null)
			MENUitem += "title='"+hint+"' ";
		if (location != null)
		{
			MENUitem += "href='"+location+"' ";
			MENUitem += "onmouseover=\"hideAll()\" ";
		}
		else
		{
			if (altLocation != null)
				MENUitem += "href='"+altLocation+"' ";
			else
				MENUitem += "href='.' ";
			MENUitem += "onmouseover=\"displaySubMenu('"+idItem+"')\" ";
//			MENUitem += "onclick=\"return false;\" "
		}
		MENUitem += ">";
		MENUitem += "|&nbsp;\n";
		MENUitem += text;
		MENUitem += "</a>\n";
		MENUitem += "</div>\n";
  	    MENUitem += "</td>\n";
	}
	MENUitem += "<!-- END OF ITEM "+idItem+" -->\n\n";
	if (idItem == "home") MENUitem += "<!-- HOME_MENU -->\n";
	else MENUitem += "<!-- MAIN_MENU -->\n";
    if (idItem == "home") HTMLstr = HTMLstr.replace("<!-- HOME_MENU -->\n", MENUitem);
    else HTMLstr = HTMLstr.replace("<!-- MAIN_MENU -->\n", MENUitem);
}

function addSubItemLeft(idParent, text, hint, location)
{
	var MENSitem = "";
	LookupS = "<!-- ITEMS "+idParent+" -->";
	if (idParent == aktMenu)
	{
  	  LookupS = "<!-- NEXT ITEMS OF SUB MENUS "+ idParent +" -->";
	  if (HTMLstr.indexOf(LookupS) == -1)
	  {
		  if (n)
		  {
			  MENSitem += "\n";
			  MENSitem += "<layer id='"+idParent+"Ssubmenu' bgcolor='"+SbgColor+"'>\n";
			  MENSitem += "<table border='0' bgcolor='"+SbgColor+"' width="+SMenuWidth+">\n";
			  MENSitem += "<!-- NEXT ITEMS OF SUB MENUS "+ idParent +" -->\n";
			  MENSitem += "</table>\n";
			  MENSitem += "</layer>\n";
			  MENSitem += "\n";
		  }
		  if (ie)
		  {
			  MENSitem += "\n";
			  MENSitem += "<div id='"+idParent+"Ssubmenu' style='position:absolute; margin-left: "+SMenuLeft+"; margin-top: "+SMenuTop+"; width: "+SMenuWidth+"; font: "+SmenuFonte+";'>\n";
			  MENSitem += "<table border='0' bgcolor='"+SbgColor+"' width="+SMenuWidth+">\n";
			  MENSitem += "<!-- NEXT ITEMS OF SUB MENUS "+ idParent +" -->\n";
			  MENSitem += "</table>\n";
			  MENSitem += "</div>\n";
			  MENSitem += "\n";
		  }
		  MENSitem += "<!-- SUB_MENUS -->\n";
		  HTMLstr = HTMLstr.replace("<!-- SUB_MENUS -->\n", MENSitem);
	  }

	  LookupS = "<!-- NEXT ITEMS OF SUB MENUS "+ idParent +" -->\n";
	  if (n) { MENSitem = "<tr>";
	         if (text == aktSubM) MENSitem += "<td bgcolor="+SfontColor+">";
	         else MENSitem += "<td>";
	         MENSitem += "<a class=clsMenuItemNS ";
		     if (text == aktSubM) MENSitem += "style='text-decoration: none; font: "+SmenuFontn+"; color: "+SbgColor+"; cursor: hand;' ";
	         MENSitem += " title='"+hint+"' href='"+location+"'>"+text+"</a><br></td></tr>\n";}
	  if (ie){ MENSitem = "<tr>";
	         if (text == aktSubM) MENSitem += "<td bgcolor="+SfontColor+">";
	         else MENSitem += "<td>";
	         MENSitem += "<a class=clsMenuItemLeftIE ";
		     if (text == aktSubM) MENSitem += "style='text-decoration: none; font: "+SmenuFonte+"; color: "+SbgColor+"; cursor: hand;' ";
	         MENSitem += " title='"+hint+"' href='"+location+"'>"+text+"</a><br></td></tr>\n";}
	  MENSitem += LookupS;
	  HTMLstr = HTMLstr.replace(LookupS, MENSitem);
    }
}

function addSubItem(idParent, text, hint, location)
{
	var MENUitem = "";
	Lookup = "<!-- ITEM "+idParent+" -->";
	if (HTMLstr.indexOf(Lookup) == -1)
	{
		alert(idParent + " not found");
		return;
	}
	Lookup = "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->";
	if (HTMLstr.indexOf(Lookup) == -1)
	{
		if (n)
		{
			MENUitem += "\n";
			MENUitem += "<layer id='"+idParent+"submenu' visibility=hide bgcolor='"+this.bgColor+"'>\n";
			MENUitem += "<table border='"+this.subMenuPaneBorder+"' bgcolor='"+this.bgColor+"' width="+this.subMenuPaneWidth+">\n";
			MENUitem += "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
			MENUitem += "</table>\n";
			MENUitem += "</layer>\n";
			MENUitem += "\n";
		}
		if (ie)
		{
			MENUitem += "\n";
			MENUitem += "<div id='"+idParent+"submenu' style='position:absolute; visibility: hidden; width: "+this.subMenuPaneWidth+"; font: "+this.menuFont+"; top: -300;'>\n";
			MENUitem += "<table border='"+this.subMenuPaneBorder+"' bgcolor='"+this.bgColor+"' width="+this.subMenuPaneWidth+">\n";
			MENUitem += "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
			MENUitem += "</table>\n";
			MENUitem += "</div>\n";
			MENUitem += "\n";
		}
		MENUitem += "<!-- SUB_MENU -->\n";
		HTMLstr = HTMLstr.replace("<!-- SUB_MENU -->\n", MENUitem);
	}

	Lookup = "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
	if (n) { MENUitem = "<tr>";
	         if (text == aktSubM) MENUitem += "<td bgcolor="+this.fontColor+">";
	         else MENUitem += "<td>";
	         MENUitem += "<a class=clsMenuItemNS ";
		     if (text == aktSubM) MENUitem += "style='text-decoration: none; font: "+this.menuFont+"; color: "+this.bgColor+"; cursor: hand;' ";
	         MENUitem += " title='"+hint+"' href='"+location+"'>"+text+"</a><br></td></tr>\n";}
	if (ie){ MENUitem = "<tr>";
	         if (text == aktSubM) MENUitem += "<td bgcolor="+this.fontColor+">";
	         else MENUitem += "<td>";
	         MENUitem += "<a class=clsMenuItemIE ";
		     if (text == aktSubM) MENUitem += "style='text-decoration: none; font: "+this.menuFont+"; color: "+this.bgColor+"; cursor: hand;' ";
	         MENUitem += " title='"+hint+"' href='"+location+"'>"+text+"</a><br></td></tr>\n";}
	MENUitem += Lookup;
	HTMLstr = HTMLstr.replace(Lookup, MENUitem);
    addSubItemLeft(idParent, text, hint, location);
}

function showMenu()
{
	document.writeln(HTMLstr);
}

////////////////////////////////////////////////////////////////////////////
// Private declaration
function displaySubMenu(idMainMenu)
{
	var menu;
	var submenu;
	if (n)
	{
		submenu = document.layers[idMainMenu+"submenu"];
		if (lastMenu != null && lastMenu != submenu) hideAll();
		submenu.left = document.layers[idMainMenu].pageX;
		submenu.top  = document.layers[idMainMenu].pageY + 25;
		submenu.visibility = fShow;

		leftX  = document.layers[idMainMenu+"submenu"].left;
		rightX = leftX + document.layers[idMainMenu+"submenu"].clip.width;
		leftY  = document.layers[idMainMenu+"submenu"].top+
			document.layers[idMainMenu+"submenu"].clip.height;
		rightY = leftY;
	} else if (ie) {
		menu = getElem("id",idMainMenu,null);
		submenu = getElem("id",idMainMenu+"submenu",null);
        submenu.style.left = calculateSumOffset(menu, 'offsetLeft');
//      submenu.style.top  = calculateSumOffset(menu, 'offsetTop') + 30;
        submenu.style.top  = menu.style.top+23;
        submenu.style.visibility = fShow;
		if (lastMenu != null && lastMenu != submenu) hideAll();

		leftX  = submenu.style.posLeft;
		rightX = leftX + submenu.offsetWidth;

		leftY  = submenu.style.posTop+
			submenu.offsetHeight;
		rightY = leftY;
	}
	lastMenu = submenu;
}

function hideAll()
{
	if (lastMenu != null) {lastMenu.style.visibility = fHide;lastMenu.style.left = 0;}
}

function calculateSumOffset(idItem, offsetName)
{
	var totalOffset = 0;
	var item = idItem;
	do
	{
		totalOffset += eval('item.'+offsetName);
		item = eval('item.offsetParent');
	} while (item != null);
	return totalOffset;
}

function updateIt1(e)
{
	if (ie)
	{
		var x = window.event.clientX;
		var y = window.event.clientY;

		if (x > rightX || x < leftX) hideAll();
		else if (y > rightY) hideAll();
	}
	if (n)
	{
		var x = e.pageX;
		var y = e.pageY;

		if (x > rightX || x < leftX) hideAll();
		else if (y > rightY) hideAll();
	}
}

function Fensterweite()
{
 if (window.innerWidth) return window.innerWidth;
 else if (document.body && document.body.offsetWidth) return document.body.offsetWidth;
 else return 0;
}

function Fensterhoehe()
{
 if (window.innerHeight) return window.innerWidth;
 else if (document.body && document.body.offsetHeight) return document.body.offsetHeight;
 else return 0;
}

function neuAufbau()
{
 if (Weite != Fensterweite() || Hoehe != Fensterhoehe())
 window.history.go(0);
}

if(!window.Weite && window.innerWidth)
  {
   window.onresize = neuAufbau;
   Weite = Fensterweite();
   Hoehe = Fensterhoehe();
  }

 if(!window.Weite && document.body && document.body.offsetWidth)
  {
   window.onresize = neuAufbau;
   Weite = Fensterweite();
   Hoehe = Fensterhoehe();
  }


if (DOM)
{
	document.body.onclick=hideAll;
	document.body.onscroll=hideAll;
	document.body.onmousemove=updateIt1;
}
if (NS)
{
	document.onmousedown=hideAll;
	window.captureEvents(Event.MOUSEMOVE);
	window.onmousemove=updateIt1;
}