/*
	Script:       Baummenü
	Version:      1.01
	Datum:        31.05.2000
	Autor:        Andreas Zierhut
	E-Mail:       Andreas.Zierhut@gmx.de
	Homepage:     http://www.dhtml-now.de
	Beschreibung: Erstellt ein Menü im Stil des Window-Explorers
	Copyright (c) 2000 by Andreas Zierhut. Alle Rechte vorbehalten.
	Das Script darf kostenlos weiterverwendet werden.
	Der Kommentar darf nicht aus dem Script entfernt werden.
*/

/*
	Update am 31.05.2000
	~~~~~~~~~~~~~~~~~~~~

	  - Neuer Parameter: CloseSubfolders
	    bestimmt, ob eventuell geöffnete Unterordner geschlossen werden sollen
	  - Gestrichelter Rahmen erscheint im IE nicht mehr bei Klick auf einen Link / Ordner
	  - Für einen Ordner kann ein Link angegeben werden (nur sinnvoll in Frames)
	  - Die Links werden im NN nicht mehr überlagert, sondern erst wird der Platz reserviert
	    und anschließend werden die neuen Links angezeigt
*/

var neues_Fenster_exist = false;

function showinfowindow(infotext)
{
if (neues_Fenster_exist == true) {neues_Fenster.close()};
Titel = 'info';
Fenster_Hoehe = 300; Fenster_Breite = 200;
Optionen = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,left=200,top=200,height='+Fenster_Hoehe+',width='+Fenster_Breite;
if (infotext !="") 
 {
neues_Fenster = window.open('','',Optionen)
with (neues_Fenster)
{document.writeln('<HTML><HEAD><TITLE>' + Titel+ '</TITLE></HEAD<');
 document.writeln('<BODY topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">');
 document.writeln('<p> ' + infotext + '</p>');
 document.writeln('</BODY><HTML>');
 neues_Fenster_exist = true;}
 }
}


var ie = document.all ? true : false;
var ns = document.layers ? true : false;

var marked = false;
var itt = new Array();
var itc;
var allitc = 0;

var actlogo;


function Folder(Ordner, Nr, Name, Text, URL, Target, ImgName, Font, Icon, ClickIcon, LogoIcon)
{
  this.Ordner = Ordner;
  this.Nr = Nr;
  this.Name = Name;
  this.Text = Text;
  this.URL = URL;
  if (URL) {
    if (Target)
      this.Target = Target;
    else
      this.Target = BaseTarget;
  }
  else
    this.Target = '';
  this.ImgName = ImgName;
  this.Font = Font;
  this.Icon = Icon;
  if (ClickIcon)
    this.ClickIcon = ClickIcon;
  else
    this.ClickIcon = Icon;
  this.isFolder = true;

  this.Items = new Array();
  this.addFolder = addFolder;
  this.addLink = addLink;
  this.getLink = getLink;
  this.build = build;

  this.IconSpace = 5;

  this.MarginTop = 4;
  this.MarginBottom = 4;

// logoicon
this.LogoIcon = LogoIcon;
}


function addFolder(Unterordner, Text, URL, Target, Font, Icon, ClickIcon, LogoIcon)
{
  allitc++;
  this.Items[this.Items.length] = new Folder(this.Name, this.Items.length, Unterordner, Text, URL, Target, 'ExplImg'+allitc, Font, Icon, ClickIcon, LogoIcon);
  window[Unterordner] = this.Items[this.Items.length-1];
  window[Unterordner].ParentNr = this.Items.length-1;
  window[Unterordner].ParentOrdner = this;
}

function Link(Text, URL, Target, ImgName, Font, Icon, LogoIcon)
{
  this.Text = Text;
  this.URL = URL;
  if (Target)
    this.Target = Target;
  else
    this.Target = BaseTarget;
  this.ImgName = ImgName;
  this.Font = Font;
  this.Icon = Icon;
  this.getLink = getLink;
  this.isFolder = false;

  this.IconSpace = 5;

  this.MarginTop = 4;
  this.MarginBottom = 4;

// logoicon
 this.LogoIcon = LogoIcon;
}

function addLink(Text, URL, Target, Font, Icon, LogoIcon)
{
  allitc++;
  this.Items[this.Items.length] = new Link(Text, URL, Target, 'ExplImg'+allitc, Font, Icon, LogoIcon);
}

function ShowLogoIconLP1(){document.LPic.src = LP1.Picture.src;}
function ShowLogoIconLP2(){document.LPic.src = LP2.Picture.src;}
function ShowLogoIconLP3(){document.LPic.src = LP3.Picture.src;}
function ShowLogoIconLP4(){document.LPic.src = LP4.Picture.src;}
function ShowLogoIconLP5(){document.LPic.src = LP5.Picture.src;}

function ShowLogoIconLP1old()
{
infotext = 'abalödflk' + actlogo;
//infotext =actlogo;
//infotext = this.Picture.src;
showinfowindow(infotext);
document.LPic.src = LP2.Picture.src;
}

function HideLogoIcon()
{
LogoLayer1.style.visibility='hidden';
LogoLayer2.style.visibility='hidden';
LogoLayer3.style.visibility='hidden';
LogoLayer4.style.visibility='hidden';
LogoLayer5.style.visibility='hidden';
LogoLayer6.style.visibility='hidden';

//if (parent.fshow.location == startfshow) 
//{
//parent.fshow.lhome.style.visibility='hidden';
//parent.fshow.lpaintings.style.visibility='hidden';
//parent.fshow.lpoems.style.visibility='hidden';
//parent.fshow.lscience.style.visibility='hidden';
//parent.fshow.lguestbook.style.visibility='hidden';
//parent.fshow.llinks.style.visibility='hidden';
//}
//for (var i=1; i < 6; i++) {eval('"LogoLayer"+ i +".style.visibility='hidden'"')}
}

function ShowLogoIcon(x)
{
HideLogoIcon()
if (x==1){LogoLayer1.style.visibility='visible';}
if (x==2){LogoLayer2.style.visibility='visible';}
if (x==3){LogoLayer3.style.visibility='visible';}
if (x==4){LogoLayer4.style.visibility='visible';}
if (x==5){LogoLayer5.style.visibility='visible';}
if (x==6){LogoLayer6.style.visibility='visible';}

//if (parent.fshow.location == startfshow) 
//{
//if (x==1){parent.fshow.lhome.style.visibility='visible';}
//if (x==2){parent.fshow.lpaintings.style.visibility='visible';}
//if (x==3){parent.fshow.lpoems.style.visibility='visible';}
//if (x==4){parent.fshow.lscience.style.visibility='visible';}
//if (x==5){parent.fshow.lguestbook.style.visibility='visible';}
//if (x==6){parent.fshow.llinks.style.visibility='visible';}
//}
}


function getLink()
{ 
//var actlogo = this.Nr;
  var actlogo = this.LogoIcon;
//  var actlogo = '1';
//  var smouseorder = '';
  var actalt=' alt ="Home" ';
//  var smouseorder = ' onMouseOver= "ShowLogoIcon('+actlogo+')"  onMouseOut= "HideLogoIcon()"';
  var smouseorder = ' onMouseOver= "ShowLogoIcon('+actlogo+')"';
  var A;
  if (!this.isFolder)
    A = '<a href="'+this.URL+'" target="'+this.Target+'"'+smouseorder+' onFocus="this.blur()"';
  else
    A = '<a href="'+(this.URL ? this.URL : 'javascript:void(0)')+'"'+(this.Target ? ' target="'+this.Target+'"' : '')+smouseorder+' onClick="openFolder(\''+this.Ordner+'\', '+this.Nr+', \''+this.Name+'\');return false;" onFocus="this.blur()"';

  return('<table border=0 cellspacing=0 cellpadding=0>' + (this.MarginTop ? '<tr><td>'+sp(1,this.MarginTop)+'</td></tr>' : '') +
         '<tr><td nowrap>' + A + ' class="'+this.Font+'">'+this.Icon.getTag(this.ImgName)+sp(this.IconSpace,1)+this.Text+'</a></td></tr>' +
         (this.MarginBottom ? '<tr><td>'+sp(1,this.MarginBottom)+'</td></tr>' : '') + '</table>');
}


function getLinkold()
{
  var A;
  if (!this.isFolder)
    A = '<a href="'+this.URL+'" target="'+this.Target+'" onFocus="this.blur()"';
  else
    A = '<a href="'+(this.URL ? this.URL : 'javascript:void(0)')+'"'+(this.Target ? ' target="'+this.Target+'"' : '')+' onClick="openFolder(\''+this.Ordner+'\', '+this.Nr+', \''+this.Name+'\');return false;" onFocus="this.blur()"';

  return('<table border=0 cellspacing=0 cellpadding=0>' + (this.MarginTop ? '<tr><td>'+sp(1,this.MarginTop)+'</td></tr>' : '') +
         '<tr><td nowrap>' + A + ' class="'+this.Font+'">'+this.Icon.getTag(this.ImgName)+sp(this.IconSpace,1)+this.Text+'</a></td></tr>' +
         (this.MarginBottom ? '<tr><td>'+sp(1,this.MarginBottom)+'</td></tr>' : '') + '</table>');
}

function showlogo()
{
  var LPic = 'pictures/pamahal.gif';
  document.write("<table BORDER=0 CELLSPACING=0 CELLPADDING=0 COLS=1 ><tr><td><center> ");
  document.write("<img SRC='" +LPic+"' NAME='LPic' align='absmiddle' alt='logo' width='80' height='80' border='0' > ");
  document.write("</center></td></tr></table>");
}


function MM_swapImgRestore() 
{ 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) 
{ 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() 
{ 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function CreateLogoLayer()
{
 document.write("<div id='LogoLayer1' style='position:absolute; left:10px; top:10px; width:80px; height:80px; z-index:7; visibility: visible'><img src='pictures/pamahal.gif' width='80' height='80' name='LogoPic' border='0'></div>");
 document.write("<div id='LogoLayer2' style='position:absolute; left:10px; top:10px; width:80px; height:80px; z-index:7; visibility: hidden'><img src='pictures/paeye.gif' width='80' height='80' name='LogoPic' border='0'></div>");
 //document.write("<div id='LogoLayer2' style='position:absolute; left:10px; top:10px; width:80px; height:80px; z-index:7; visibility: hidden'><a href='#' onMouseOut='MM_swapImgRestore()' onMouseOver='MM_swapImage('peye.gif','','pictures/paeye.gif',1)'><img src='pictures/peye.gif' width='80' height='80' name='LogoPic' border='0'></a></div>");
 document.write("<div id='LogoLayer3' style='position:absolute; left:10px; top:10px; width:80px; height:80px; z-index:7; visibility: hidden'><img src='pictures/pabutterfly.gif' width='80' height='80' name='LogoPic' border='0'></div>");
 document.write("<div id='LogoLayer4' style='position:absolute; left:10px; top:10px; width:80px; height:80px; z-index:7; visibility: hidden'><img src='pictures/pafeuerball.gif' width='80' height='80' name='LogoPic' border='0'></div>");
 document.write("<div id='LogoLayer5' style='position:absolute; left:10px; top:10px; width:80px; height:80px; z-index:7; visibility: hidden'><img src='pictures/pabook.gif' width='80' height='80' name='LogoPic' border='0'></div>");
 document.write("<div id='LogoLayer6' style='position:absolute; left:10px; top:10px; width:80px; height:80px; z-index:7; visibility: hidden'><img src='pictures/parotateearth.gif' width='80' height='80' name='LogoPic' border='0'></div>");
}

function ShowCounter()
{
//document.write("<br><br><br><br><br><br><br><br><br><br><br><br><br><br>");
//document.write("<br><br><br><br><br><br><br><br><br><br><br><br><br><br>");
//document.write(&nbsp; &nbsp;");
document.write("<br><br><br><br><br><br> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;");
document.write("<!--WEBBOT bot='HTMLMarkup' startspan ALT='Site Meter' -->");
document.write("<script type='text/javascript' language='JavaScript'>var site='sm4gueststatistic'</script>");
document.write("<script type='text/javascript' language='JavaScript1.2' src='http://sm4.sitemeter.com/js/counter.js?site=sm4gueststatistic' align='bottom'></script>");
//<noscript>
//<a href="http://sm4.sitemeter.com/stats.asp?site=sm4gueststatistic" target="_top">
//<img src="http://sm4.sitemeter.com/meter.asp?site=sm4gueststatistic" alt="Site Meter" border=0></a>
//</noscript>
//<!-- Copyright (c)2002 Site Meter -->
//<!--WEBBOT bot="HTMLMarkup" Endspan -->
}

function build()
{
  CreateLogoLayer(); 
  //LogoLayer.style.visibility='visible';
  ShowCounter();

  var Style = '<style type="text/css">\n';
  for (var i=0; i < Fonts.length; i++)
      Style += '.' + Fonts[i].Name + ' { ' + Fonts[i].getStyle() + ' }\n';
  Style += '</style>';

  document.write(Style);

  var its = FirstFolder.Items;
  itc = 0;
  for (var i=0; i < its.length; i++) {

    var PosLeft = Left(itt[itc]);
    var PosTop  = Top(itt[itc])+Height(itt[itc]);
    if (!i) {
      PosLeft += StartX; PosTop += StartY;
      if (marked) { PosLeft += Left('ExPos'); PosTop += Top('ExPos'); }
    }

    itc = free();
    if (ns)
      with(document.ids[itt[itc]]) { position = 'absolute'; left = PosLeft; top = PosTop; }
    its[i].LName = itt[itc];
    document.write('<div id="'+itt[itc]+'"' + (ie ? ' style="position: absolute; left: '+PosLeft+'; top: '+PosTop+'"' : '') + '>'+its[i].getLink()+'</div>');
  }
}

var FolderTree = new Array();

function openFolder(Ordner, Nr, Unterordner)
{
 
  var fol = window[Unterordner];
  var FNr = offen(fol);
  if (FNr != -1) {

    if (ns)
      document[fol.LName].document.images[0].src=fol.Icon.Picture.src;
    else
      document[fol.ImgName].src = fol.Icon.Picture.src;
    var tmpo = FolderTree[FNr].ParentOrdner;
    var tmpn = FolderTree[FNr].ParentNr;
    schliessen(FNr);
    arr.getLayers(tmpo, tmpn);
    for (var i=1; i < arr.Layers.length; i++)
      move(arr.Layers[i], null, RTop(arr.Layers[i-1]) + Height(arr.Layers[i-1]));

  }
  else {

    if (ns)
      document[fol.LName].document.images[0].src=fol.ClickIcon.Picture.src;
    else
      document[fol.ImgName].src = fol.ClickIcon.Picture.src;

    if (CloseSubfolders)
      for (var i=0; i<window[Ordner].Items.length; i++)
        if (window[Ordner].Items[i].isFolder && offen(window[Ordner].Items[i]) != -1)
          openFolder(Ordner, i, window[Ordner].Items[i].Name, null);

    FolderTree[FolderTree.length] = fol;
    window[Unterordner].Nr = Nr;
    var its = fol.Items;
    var op = window[Ordner].Items[Nr].LName;
    for (var i=0; i < its.length; i++) {

      itc = free();
      var Name = itt[itc];
      make(Name);
      hide(Name);
      move(Name, Left(op)+Indent, RTop(!i ? op : its[i-1].LName) + Height(!i ? op : its[i-1].LName));
      its[i].LName = Name;
      its[i].it = itc;
      write(Name, its[i].getLink());
    }

    arr.getLayers(window[Ordner], Nr);
    for (var i=1; i < arr.Layers.length; i++)
      move(arr.Layers[i], null, RTop(arr.Layers[i-1]) + Height(arr.Layers[i-1]));

    for (var i=0; i < its.length; i++)
      show(its[i].LName);

  }
}
var arr = new MyArr();
function MyArr() { this.Layers = null; this.getLayers = getLayers; }

var start;
function getLayers(Ordner, Nr, NeuOrdner)
{
  if (Nr != -1) { this.Layers = new Array(); start = false; } else Nr = 0;
  if (!NeuOrdner) NeuOrdner = FirstFolder;
  var akt = NeuOrdner.Items;
  for (var i=0; i < akt.length; i++) {
    if (i == Nr && Ordner == NeuOrdner && !start)
      start = true;
    if (start)
      this.Layers[this.Layers.length] = akt[i].LName;
    if (akt[i].Items && offen(akt[i]) != -1)
      this.getLayers(Ordner, -1, akt[i]);
  }
}

function schliessen(FNr)
{
  var fol = FolderTree[FNr];
  var its = fol.Items;
  for (var i=0; i < its.length; i++) {
    hide(its[i].LName);
    itt[its[i].it] = null;
  }
  FolderTree[FNr] = FolderTree[FolderTree.length-1];
  FolderTree = FolderTree.slice(0, -1);

  for (var i=0; i < its.length; i++)
    if (its[i].Items && offen(its[i]) != -1)
      schliessen(offen(its[i]));
}

function offen(Ordner)
{
  for (var i=0; i < FolderTree.length; i++)
    if (FolderTree[i] == Ordner)
      return i;

  return -1;
}

function free()
{
  for (var i=0; i < itt.length; i++) {
    if (!itt[i]) {
      itt[i] = 'Link'+i;
      return i;
    }
  }
  itt[itt.length] = 'Link'+itt.length;
  return itt.length-1;
}

function LogoPic(ieURL, nsURL, Breite, Hoehe)
{
  this.Picture = new Image();
  if (document.all || !nsURL)
    this.Picture.src = ieURL;
  else
    this.Picture.src = nsURL;
  this.Breite = Breite;
  this.Hoehe = Hoehe;
  this.getTag = getTag;
}


function Icons(ieURL, nsURL, Breite, Hoehe)
{
  this.Picture = new Image();
  if (document.all || !nsURL)
    this.Picture.src = ieURL;
  else
    this.Picture.src = nsURL;
  this.Breite = Breite;
  this.Hoehe = Hoehe;
  this.getTag = getTag;
}

function getTag(Name)
{
  return('<img src="'+this.Picture.src+'" width='+this.Breite+' height='+this.Hoehe+' name="'+Name+'" border=0 alt="">');
}

function Font(Name, fontColor, fontFamily, fontSize, fontWeight, fontStyle, textDecoration)
{
  this.Name = Name;
  this.fontColor = fontColor;
  this.fontFamily = fontFamily;
  this.fontSize = fontSize;
  this.fontWeight = fontWeight;
  this.textDecoration = textDecoration;
  this.fontStyle = fontStyle;
  this.getStyle = getStyle;
}
function getStyle()
{
  return('color: '+this.fontColor+'; font-family: '+this.fontFamily+'; font-size: '+this.fontSize+'; font-weight: '+this.fontWeight+'; text-decoration: '+this.textDecoration+'; font-style: '+this.fontStyle+';');
//  return('color: '+this.fontColor+'; font-family: '+this.fontFamily+'; font-size: '+this.fontSize+'; font-weight: '+this.fontWeight+'; text-decoration: '+this.textDecoration+'; font-style: '+this.fontStyle+'; A: active {color="#ff0000";text-decoration: underline;font-weight: bold;');
//  return('A: link {color: '+this.fontColor+'; font-family: '+this.fontFamily+'; font-size: '+this.fontSize+'; font-weight: '+this.fontWeight+'; text-decoration: '+this.textDecoration+'; font-style: '+this.fontStyle+';}');
//  return('hover {color="#ff0000";text-decoration: underline;font-weight: bold;');
//  A:link {color="#32CD32";text-decoration: none;font-weight: bold;})
//  A:active {color="#ff0000";font-weight: bold;}
//  A:visited {color="#32CD32";text-decoration: none;font-weight: bold;}
//  A:hover {color="#ff0000";text-decoration: underline;font-weight: bold;}
}

function mark()
{
  marked = true;
  if (ie)
    document.write('<span id="ExPos">'+sp(1,1)+'</span>');
  else if (ns)
    document.write('<ilayer name="ExPos">'+sp(1,1)+'</ilayer>');
}

function reserve(Hoehe)
{
  if (ns)
    document.write('<table border=0 cellspacing=0 cellpadding=0 height="'+Hoehe+'"><tr><td>'+sp(1,1)+'</td></tr></table>');
}

function Left(l)
{
  if (ns && document[l])
    return document[l].pageX;
  else if (ie && document.all[l])
    return absLeft(document.all[l]);
  return 0;
}

function RTop(l){if(document.all) { if(document.all[l])return(document.all[l].style.posTop); } else return(Top(l)); return 0}

function Top(l)
{
  if (ns && document[l])
    return document[l].pageY;
  else if (ie && document.all[l])
    return absTop(document.all[l]);
  return 0;
}

function Width(l)
{
  if (ns && document[l])
    return document[l].document.width;
  else if (ie && document.all[l])
    return document.all[l].offsetWidth;
  return 0;
}

function Height(l)
{
  if (ns && document[l])
    return document[l].document.height;
  else if (ie && document.all[l])
    return document.all[l].offsetHeight;
  return 0;
}

function absLeft(l)
{
  if (l.offsetParent) return (l.offsetLeft + absLeft(l.offsetParent));
  else return (l.offsetLeft);
}

function absTop(l)
{
  if (l.offsetParent) return (l.offsetTop + absTop(l.offsetParent));
  else return (l.offsetTop);
}

function sp(w,h)
{
  if (ie) return('<img src="spacer.gif" width='+w+' height='+h+' border=0 alt="">');
  else if (ns) return('<spacer type=block width='+w+' height='+h+'>');
  return;
}
function make(l)
{
  if (ns && !document[l])
    document[l] = new Layer(1);
  else if (ie && !document.all[l])
    document.body.insertAdjacentHTML('AfterBegin', '<span id="'+l+'" style="position: absolute">&nbsp;</span>');
}
function show(l)
{
  if (ie) document.all[l].style.visibility = 'visible';
  else if (ns) document[l].visibility = 'show';
}
function hide(l)
{
  if (ie) document.all[l].style.visibility = 'hidden';
  else if (ns) document[l].visibility = 'hide';
}
function move(l,x,y)
{
  if (ie) { if(x) document.all[l].style.posLeft=x; if(y) document.all[l].style.posTop=y; }
  else if (ns) { if(x) document[l].pageX=x; if(y) document[l].pageY=y; }
}
function write(l,i)
{
  if (ie) document.all[l].innerHTML = i;
  else if (ns) { with(document[l].document) { open(); write(i); close(); } }
}





