function Menu(parentMenu,name,script,ebene,target)
{
 this.items=new Array();
 this.menuEbene=ebene;
 this.menuText=name;
 this.menuParent=parentMenu;
 this.menuScript=script;
 if (target) this.menuTarget=target; else this.menuTarget="";
 this.draw=Draw;
 this.pfad="";   // Internes Verwaltungselement, wird durch die InitMenu() nach Deklaration des Menus
 if (parentMenu != null) parentMenu.items[parentMenu.items.length]=this;
 return this;
}

function Ebene(ib,ibt,ab,abt,width,ident,insertMode,bgcolor,bgbild)
{
 this.activeButton=ab; // CSS-Class
 this.activeButtonText=abt; // CSS-Class
 this.inactiveButton=ib; // CSS-Class
 this.inactiveButtonText=ibt; // CSS-Class
 if (insertMode) this.nextMenuInsertMode=insertMode; else this.nextMenuInsertMode="inline";//inline,behind  Anordung des nächsten Menüs
 if (ident) this.buttonIdent=ident; else this.buttonIdent=0;   //linker Einzug des Buttons
 this.buttonWidth=width;  // Breite des Buttons ohne Spot
 if (bgcolor) this.bgColor=bgcolor; else this.bgColor="";  //Hintergrundfarbe gesamte Ebene
 if (bgbild) this.bgBild=bgbild; else this.bgBild="";  //Hintergrundbild geamte Ebene
 this.activeSpot=""; // CSS-Class
 this.inactiveSpot=""; // CSS-Class
 this.activeContentSpot=""; //text oder HTML
 this.inactiveContentSpot=""; //text oder HTML
 this.spotAlign="left";  //Ausrichtung des Spots
 this.spotWidth=0;  // Breite des Spots
 this.buttonSpacing=0;  // Abstand zwischen den Buttons
 this.topIdent=0;  // Oberer Abstand der Menuebene
 this.bottomIdent=0;  // Unterer Abstand der Menuebene
 this.spacerColor="";  //Farbe für den Zwischenabstand
 this.paddingColor=""; //Farbe für  Menüabstände
 this.visibility=true;  //Sichtbarkeit der Ebene
 this.draw=Draw;  
 this.defineSpot=Spotdefinition;
 this.defineSpaces=Spacedefinitions;
}

function MENUGLOBALS()
 {
  this.width=170;
  this.bild="clear.gif"
  this.ebenenID=null;//intern
  this.menuFrame=""; //intern
  this.mainFrame="main";
  this.root=null; //intern
  this.ebene=new Array(); // Layoutinformationen zu den einzelnen Menuebenen
  this.displaySpot="allways";  //never, allways, present  Darstellungsmodus des Spots
  this.displayActiveButton="present"; //never, allways, present  Darstellungsmodus des aktuellen Buttons
  this.spacerSpot=true;
  this.update=true; //intern
  this.lastScript=""; //intern
  this.msie4=false; //intern
  this.minEbenen=1;
  this.styleFile="menu.css";
  this.header="<Body>";
  this.footer="</body>";
  this.popupParam="width=640";
  this.sitemapStart="<html><head><title>SITEMAP</title></head><body>"
  this.sitemapFinal="</body></html>"
 }  

function Spotdefinition(width,as,is,ac,ic,align)
 { 
  if (as) this.activeSpot=as;
  if (is) this.inactiveSpot=is;
  if (ac) this.activeContentSpot=ac; 
  if (ic) this.inactiveContentSpot=ic; 
  if (width) this.spotWidth=width; 
  if (align) this.spotAlign=align;
 }
 
function Spacedefinitions(sw,sc,ao,au,ac)
{
 this.buttonSpacing=sw; 
 if (ao) this.topIdent=ao;
 if (au) this.bottomIdent=au;
 if (sc) this.spacerColor=sc;
 if (ac) this.paddingColor=ac; 
} 

var MGlobals=new MENUGLOBALS();
 
function Draw()
{
 var m=this;
 if ((m.menuScript!='') && !MGlobals.update) 
   {
     var ziel=(m.menuTarget=='') ? MGlobals.mainFrame : m.menuTarget;
	 if (ziel==MGlobals.mainFrame) eval("parent."+ziel+'.location.href="'+m.menuScript+'"');
	 else
	   {
	    MGpopupfenster=open(m.menuScript,ziel,MGlobals.popupParam);
	   }
	 //alert(ziel+"\n"+m.menuTarget+"\n"+MGlobals.mainFrame);
     //MGlobals.lastScript=m.menuScript;eval("parent."+ziel+'.location.href="'+m.menuScript+'"');
   }
 MGlobals.update=false;
 MGlobals.ebenenID=new Array();
 while (m.menuParent!=null)
  {
   var a=m;
   m=m.menuParent;
   for (b=0;b<m.items.length;b++) if (m.items[b]==a) MGlobals.ebenenID[MGlobals.ebenenID.length]=b;
  }
 MGlobals.ebenenID.reverse(); 
 setTimeout("drawMenu()",10);
}

function drawMenu()
{
 var tableEnd='</td></tr></table>\n';
 var out=parent.frames[MGlobals.menuFrame].document;
 //eval("var out=parent."+MGlobals.menuFrame);

 
function DrawM(m,mName,richtigerPfad)
  {
   if (navigator.appVersion.indexOf("MSIE 4.")!=-1 && MGlobals.msie4==false)
 	{alert("Warnung!\n\nSie benutzen ein sehr alte Version des Internet Explorers.\nEs könnten einige Schwierigkeiten mit dieser Version auftreten.\nWir empfehlen Ihnen auf eine aktuelle Version umzusteigen.");MGlobals.msie4=true;}
   //alert('Neuer Draw in Ebene: '+m.menuEbene+'; '+m.menuText);
   var e=MGlobals.ebene[m.menuEbene+1];
   var restWidth=MGlobals.width-e.buttonIdent-e.spotWidth-e.buttonWidth;
   var tableHead='<tr><td'+(e.bgColor!='' ? ' bgcolor="'+e.bgColor+'"':'')+(e.bgBild!=''? ' background="'+e.bgBild+'"':'')+'>'
                    +'<table width="100%" cellpadding="0" cellspacing="0" border="0" background="gifs/clear.gif">\n';
   //alert('Begin Ebene: '+m.menuEbene);			
   if (m.items.length !=0) 
    {
	 if (e.visibility) out.write(tableHead);
	 var tableOpend=true;
	 // Oberer Menu-Abstand
	 if (e.topIdent>0)
	  {
	   s='<tr>';color=(e.paddingColor!='') ? ' bgcolor="'+e.paddingColor+'"' : '';
	   spot=(e.spotWidth != 0) ? '<td'+(MGlobals.spacerSpot?color:'')+'><img src="'+MGlobals.bild+'" width="'+e.spotWidth+'" height="'+e.topIdent+'"></td>' : '';
	   s+=(e.buttonIdent != 0) ? '<td><img src="'+MGlobals.bild+'" width="'+e.buttonIdent+'" height="'+e.topIdent+'"></td>' : '';
       if (e.spotAlign=='left') s+=spot;
       s+='<td'+color+'><img src="'+MGlobals.bild+'" width="'+e.buttonWidth+'" height="'+e.topIdent+'"></td>';
       if (e.spotAlign=='right') s+=spot;
	   s+=(restWidth != 0) ? '<td><img src="'+MGlobals.bild+'" width="'+restWidth+'" height="'+e.topIdent+'"></td>' : '';
       s+='</tr>\n';
	   if (e.visibility) out.write(s);
	  } 
     for (var a=0;a<m.items.length;a++)
      {
	   // Verwendete Klassen berechnen
	   var classSpot=(e.inactiveSpot!='') ? ' class="'+e.inactiveSpot+'"' : '';
	   var classButton=(e.inactiveButton!='') ? ' class="'+e.inactiveButton+'"' : '';
	   var classButtonText=(e.inactiveButtonText!='') ? ' class="'+e.inactiveButtonText+'"' : '';
	   var spotContent=(e.inactiveContentSpot!='') ? spotContent=e.inactiveContentSpot :'<img src="'+MGlobals.bild+'" width="'+e.spotWidth+'" height="1" border="0">';
	   var knoten=false;
	   var href='"javascript:'+mName+a+'].draw()"'
	   if ((m.menuEbene<MGlobals.ebenenID.length) && (MGlobals.ebenenID[m.menuEbene]==a) && richtigerPfad) 
	    { 
		 knoten=true;
		 if (m.menuEbene+1==MGlobals.ebenenID.length) // present
		  {
		   classSpot=(e.activeSpot!='') ? ' class="'+e.activeSpot+'"' : '';
		   spotContent=(e.activeContentSpot!='') ? e.activeContentSpot : '<img src="'+MGlobals.bild+'" width="'+e.spotWidth+'" height="1" border="0">';
		   classButton=(e.activeButton!='') ? ' class="'+e.activeButton+'"' : '';
		   classButtonText=(e.activeButtonText!='') ? ' class="'+e.activeButtonText+'"' : '';
		  }
 	     if (MGlobals.displaySpot=="never") 
		  {
		   classSpot=(e.inactiveSpot!='') ? ' class="'+e.inactiveSpot+'"' : '';
		   spotContent=(e.inactiveContentSpot!='') ? e.inactiveContentSpot : '<img src="'+MGlobals.bild+'" width="'+e.spotWidth+'" height="1" border="0">';
		  }
	     if (MGlobals.displaySpot=="allways") 
		  {
		   classSpot=(e.activeSpot!='') ? ' class="'+e.activeSpot+'"' : '';
		   spotContent=(e.activeContentSpot!='') ? e.activeContentSpot : '<img src="'+MGlobals.bild+'" width="'+e.spotWidth+'" height="1" border="0">';
		  }
 	     if (MGlobals.displayActiveButton=="never") 
		  {
	   		classButton=(e.inactiveButton!='') ? ' class="'+e.inactiveButton+'"' : '';
	  	    classButtonText=(e.inactiveButtonText!='') ? ' class="'+e.inactiveButtonText+'"' : '';
		  }
	     if (MGlobals.displayActiveButton=="allways") 
		  {
			classButton=(e.activeButton!='') ? ' class="'+e.activeButton+'"' : '';
			classButtonText=(e.activeButtonText!='') ? ' class="'+e.activeButtonText+'"' : '';
		  }
		}
	   //  Start zusammensetzung des Buttons
	   s='<tr>';
	   spot=(e.spotWidth != 0) ? '<td width="'+e.spotWidth+'"'+classSpot+'><a href='+href+classButtonText+'>'+spotContent+'</a></td>' : '';
	   s+=(e.buttonIdent != 0) ? '<td width="'+e.buttonIdent+'"><img src="'+MGlobals.bild+'" width="'+e.buttonIdent+'" height="1"></td>' : '';
       if (e.spotAlign=='left') s+=spot;
       s+='<td width="'+e.buttonWidth+'"'+classButton+'><a href='+href+classButtonText+'>'+m.items[a].menuText+'</a></td>';
       if (e.spotAlign=='right') s+=spot;
	   s+=(restWidth != 0) ? '<td width="'+restWidth+'"><img src="'+MGlobals.bild+'" width="'+restWidth+'" height="1"></td>' : '';
       s+='</tr>\n';
	   if (e.visibility) out.write(s);
	   // Bei inline-Untermenü aufrufen
	   var allowSpacer=true;
	   // alert('Ebene: '+m.menuEbene+';   Element: '+a+';  Länge nächstes Menü: '+m.items[a].items.length);
	   // || ((m.menuEbene<MGlobals.minEbenen) && (m.items[a].items.length!=0))
	   if ((knoten && (e.nextMenuInsertMode=="inline")) || ((m.menuEbene+1)<MGlobals.minEbenen))
	    {
		 if (e.visibility) out.write(tableEnd);tableOpend=false;
		 allowSpacer=!DrawM(m.items[a],mName+a+'].items[',knoten);
		 if (a!=m.items.length-1) {if (e.visibility) out.write(tableHead);tableOpend=true;}
		}
	   // Zwischenabstand zwischen Buttons zeichnen
	   if ((a!=(m.items.length-1)) && (e.buttonSpacing>0) && allowSpacer)
	    {
		 s='<tr>';color=(e.spacerColor!='') ? ' bgcolor="'+e.spacerColor+'"' : '';
		 spot=(e.spotWidth != 0) ? '<td'+(MGlobals.spacerSpot?color:'')+'><img src="'+MGlobals.bild+'" width="'+e.spotWidth+'" height="'+e.buttonSpacing+'" border="0"></td>' : '';
	     s+=(e.buttonIdent != 0) ? '<td><img src="'+MGlobals.bild+'" width="'+e.buttonIdent+'" height="'+e.buttonSpacing+'" border="0"></td>' : '';
         if (e.spotAlign=='left') s+=spot;
         s+='<td'+color+'><img src="'+MGlobals.bild+'" width="'+e.buttonWidth+'" height="'+e.buttonSpacing+'" border="0"></td>';
         if (e.spotAlign=='right') s+=spot;
	     s+=(restWidth != 0) ? '<td><img src="'+MGlobals.bild+'" width="'+restWidth+'" height="'+e.buttonSpacing+'" border="0"></td>' : '';
         s+='</tr>\n';
		 if (e.visibility) out.write(s);
		} 
	  } // ENDE for-schleife
	 // Unteren Menü-Abstand 
	 if (e.bottomIdent>0)
	  {
	   if (!tableOpend) {out.write(tableHead);tableOpend=true;}
	   s='<tr>';color=(e.paddingColor!='') ? ' bgcolor="'+e.paddingColor+'"' : '';
	   spot=(e.spotWidth != 0) ? '<td'+(MGlobals.spacerSpot?color:'')+'><img src="'+MGlobals.bild+'" width="'+e.spotWidth+'" height="'+e.bottomIdent+'" border="0"></td>' : '';
	   s+=(e.buttonIdent != 0) ? '<td><img src="'+MGlobals.bild+'" width="'+e.buttonIdent+'" height="'+e.bottomIdent+'" border="0"></td>' : '';
       if (e.spotAlign=='left') s+=spot;
       s+='<td'+color+'><img src="'+MGlobals.bild+'" width="'+e.buttonWidth+'" height="'+e.bottomIdent+'" border="0"></td>';
       if (e.spotAlign=='right') s+=spot;
	   s+=(restWidth != 0) ? '<td><img src="'+MGlobals.bild+'" width="'+restWidth+'" height="'+e.bottomIdent+'" border="0"></td>' : '';
       s+='</tr>\n';
	   if (e.visibility) out.write(s);
	  } 
     if (tableOpend && e.visibility) out.write(tableEnd);
	 if ((e.nextMenuInsertMode=="behind") && (m.menuEbene<MGlobals.ebenenID.length))
	  { 
	  DrawM(m.items[MGlobals.ebenenID[m.menuEbene]],mName+MGlobals.ebenenID[m.menuEbene]+'].items[',true);}
	 return true;
	} //ENDE if
   return false;
  }  // Ende UnterFunktion

 out.open();
 //alert("start");
 out.write('<html><head><title>Strait Menu 2001</title><link rel=stylesheet type="text/css" href="'+MGlobals.styleFile+'"></head>\n'+MGlobals.header+'\n<table width="'+MGlobals.width+'" cellpadding="0" cellspacing="0" border="0">\n');
 //alert("vor Funktionsaufruf");
 DrawM(MGlobals.root,"parent.MGlobals.root.items[",true);
 out.write('</table>'+MGlobals.footer+'</html>');
 out.close();
}

function initMenu(root,frame)
{
 MGlobals.menuFrame=frame;
 MGlobals.root=root;
 var a=MGlobals.ebene[MGlobals.ebene.length]=new Ebene("","","","",0,0,"","");
}

// Update-Funktion

function updateMenu()
{ 
 var l=parent.frames(MGlobals.mainFrame).location.pathname+parent.frames(MGlobals.mainFrame).location.search;
 var rootpath=parent.location.pathname;
 var m=null;

 function durchsuchen(mo)
  {
   if (mo.menuScript==l) {m=mo;return true;}
   else if (mo.items.length > 0) for (var a=0;a<mo.items.length;a++) if (durchsuchen(mo.items[a])) return true;
   return false;
  }
 if (l.indexOf(rootpath)==0) l=l.substring(rootpath.length,l.length);
 if (l!=MGlobals.lastScript) if (durchsuchen(MGlobals.root)) {MGlobals.update=true;m.draw();}
}

function makeSitemap()
{
/*  function drawSitemap(m,einrueckung,win)
   {
    var s='';var a=einrueckung;
	var ziel=(m.menuTarget=='') ? MGlobals.mainFrame : m.menuTarget;
	while (a-->0) s+="&nbsp;";
    win.document.writeln(s+"<a href='"+m.menuScript+"' target='"+ziel+"' onclick='window.close()'>"+m.menuText+"</a><br>");
	a=0;while (a++<m.items.length) drawSitemap(m.items[a-1],einrueckung+3,win);
   }
 var a=0;
 sm=open("","SiteMap","width=240");
 sm.document.open();sm.document.writeln(MGlobals.sitemapStart);
 while (a<MGlobals.root.items.length) {drawSitemap(MGlobals.root.items[a],0,sm);a++;}
 sm.document.writeln(MGlobals.sitemapFinal);sm.document.close(); */
}

