/*
    Titel: J|G JSExplorer
    Autor: Johannes Gamperl
    email: jg@jg.seite.net

    Copyright (c) J|G Webdesign & Programmierung - Johannes Gamperl, 1998.
    All rights reserved. Alle Rechte vorbehalten. URL: http://jg.seite.net

    Dieser Code darf für nicht-kommerzielle sowie kommerzielle Zwecke frei
    genutzt und angepaßt werden, solange dies unentgeltlich erfolgt und
    dieser Vermerk bestehen bleibt.
*/

//-----------------------------------------------------
// Array's initialisieren
//-----------------------------------------------------

var frm_menu;
if (frm_menu == null) frm_menu = 'mdisp';
// var doc = top.frames[frm_menu].document;
var doc = top.frames['mdisp'].document;
var abstand;
var grafik = new Array();
var indizes = new Array();

//-----------------------------------------------------
// Baumstruktur zeichnen, Ordner auf und zu
//-----------------------------------------------------


function zeichne_Baumstruktur(menu) {

  abstand = 0;
  titelsize = parseInt(fontsize)+1;
  doc.open('text/html', 'replace');
  doc.writeln('<HTML><HEAD>');
  if (style) doc.writeln('<STYLE Type="text/css">A:link{text-decoration: none;}</STYLE>');
  doc.writeln('<SCRIPT LANGUAGE="JavaScript" SRC="/java/frames.js"></SCRIPT>');
  doc.writeln('<SCRIPT LANGUAGE="JavaScript">');
  doc.writeln('<!--');
  doc.writeln(
    'var FormLocation = self;\n'
//mr  , 'if (top.body != null) { \n'
//mr  , '  if (top.body.fmain != null)\n'
//mr  , '    FormLocation = top.body.fmain;\n'
//mr  , '  else\n'
//mr  , '    FormLocation = top.body;\n'
//mr  , '}\n'
  );
  doc.writeln('function ShowHome () {');
  doc.writeln('    top.frames["body"].location.href  = "/welcome.php4";');
  doc.writeln('    top.frames["mdisp"].location.href = "/mdisp.php4";');
  doc.writeln('    top.frames["mmain"].location.href = "/mmain.php4/home.html";');
  doc.writeln('    top.frames["title"].titleform.hdDoTitle.value = 0;');
  doc.writeln('    top.frames["title"].titleform.submit();');
  doc.writeln('}');
  doc.writeln('//-->');
  doc.writeln('</SCRIPT>');
  doc.writeln('</HEAD>');
  al_col = "#0000F0";
  // vl_col = "#00FF00";
  doc.writeln('<BODY BGCOLOR="' +bg_col+ '" BACKGROUND="' +bg_pic+ '" TEXT="' +tx_col+
            '" LINK="' +li_col+ '" ALINK="' +al_col+ '" VLINK="' +vl_col+ '">');

  // -- [Ab hier Kopfbereich]
  // -- Mit doc.write kann eigener Inhalt geschrieben werden
  // -- z.B. doc.write('Dies ist meine eigene Kopfzeile!');

  doc.writeln('<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH='+menuwidth+'>');
  doc.writeln('<TR VALIGN=top><TD><IMG SRC="/images/menu/menu_root.gif"'+
              ' WIDTH=18 HEIGHT=18 ALIGN=left BORDER=0 VSPACE=0 HSPACE=0>');
  doc.write  ('<FONT FACE="' +fonttype+ '" SIZE="' +titelsize+ '"><B>');
  if (titel == null || titel == '') doc.write ('&nbsp,');
  doc.writeln(titel + '</B></FONT></TD></TR>');
  doc.writeln('<TR VALIGN=TOP><TD><IMG SRC="/images/menu/menu_linie.gif" '+
            'WIDTH=18 HEIGHT=18 ALIGN="left" BORDER=0 VSPACE=0 HSPACE=0>');
  zeige_Ordner_Inhalt(menu);
  doc.writeln('</TABLE>');

  // -- [Ab hier Fußbereich]
  // -- Mit doc.write kann eigener Inhalt geschrieben werden
  // -- z.B. doc.write('Dies ist meine eigene Fußzeile!');

  //doc.write('<a href="javascript:parent.source.test(true)">AUF</a>');
  //doc.write('<a href="javascript:parent.source.test(false)">ZU</a>');

  doc.writeln ("</BODY></HTML>");
  doc.close();
  return false;

}


function zeige_Ordner_Inhalt(menu) {

    for (var i = 0; i < menu.items.length; i++) {
         indizes[abstand] = i;
         zeichne_Ordnerstruktur(menu.items[i], (i == menu.items.length - 1));
         }
}


function zeichne_Ordnerstruktur(item, last, schalter) {

    var frm = "parent.frames['" +frm_source+ "']";
    var cmd = frm + ".zeichne_Baumstruktur(" + frm + ".menu)";
    var ref = frm + ".menu.items[" + indizes[0] + "]";
    var i, img, more;
    var srcPrefix;
    var o_auf, o_zu;

    doc.writeln('<TR VALIGN=TOP><TD>');

    for (i = 0; i < abstand; i++) {
         if (grafik[i])
             doc.writeln('<IMG SRC="/images/menu/menu_linie.gif" '+
                       'WIDTH=18 HEIGHT=18 ALIGN="left" BORDER=0 VSPACE=0 HSPACE=0>');
         else
             doc.writeln('<IMG SRC="/images/menu/menu_leer.gif" '+
                       'WIDTH=18 HEIGHT=18 ALIGN="left" BORDER=0 VSPACE=0 HSPACE=0>');

         more = false;
    }

    if (item.submenu) more = true;

    if (!more) {
        if (last) img = "/images/menu/menu_was_3.gif";
        else img = "/images/menu/menu_was_2.gif";

        doc.writeln('<img src="' + img + '" WIDTH=18 HEIGHT=18 ALIGN="left" '+
                  'BORDER=0 VSPACE=0 HSPACE=0>');
    }

    for (i = 1; i <= abstand; i++) {
         ref += ".submenu.items[" + indizes[i] + "]";
         }


    // -- [Menüpunkte und Verweise ausgeben]

    if (item.url != "")
        if (navbox)
            doc.writeln('<A HREF="JavaScript:void(0)" '+
                      'onClick="parent.window.opener.location.href=\'' + item.url + '\'" ' +
                      'onMouseOver="parent.window.opener.status=\''+item.maus+'\';return true" '+
                      'onMouseOut="parent.window.opener.status=\'\'">');
        else
            if (item.url.indexOf("JavaScript:") == 0)
                doc.writeln('<A HREF="' + item.url +
                          '" onMouseOver="window.status=\'' +item.maus+ '\';return true" '+
                          'onMouseOut="window.status=\'\'">');
            else
                doc.writeln('<A HREF="' + item.url + '" TARGET="' + item.target +
                          '" onMouseOver="window.status=\'' +item.maus+ '\';return true" '+
                          'onMouseOut="window.status=\'\'">');

    else
    {
        if (item.maus)
        {
            o_auf = ordner_auf + ": " + item.maus;
            o_zu  = ordner_zu  + ": " + item.maus;
        }
        else
        {
            o_auf = ordner_auf;
            o_zu  = ordner_zu;
        }

        if (item.expanded)
            doc.writeln('<A HREF="#" onClick="' + ref + '.expanded = false; return ' + cmd + ';"' +
                      'onMouseOver="window.status=\'' + o_auf + '\';return true" ' +
                      'onMouseOut="window.status=\'\'">');
            else
            doc.writeln('<A HREF="#" onClick="' + ref + '.expanded = true; return ' + cmd + ';"' +
                      'onMouseOver="window.status=\'' + o_zu + '\';return true" ' +
                      'onMouseOut="window.status=\'\'">');
    }

    // -- [Ordner auf/zu - Grafiken zeichnen (+/-)]

    if (more) {
        if (item.expanded) {
            if (last) img = "/images/menu/menu_minus_2.gif";
            else img = "/images/menu/menu_minus_1.gif";
        }
        else {
            if (last) img = "/images/menu/menu_plus_2.gif";
            else img = "/images/menu/menu_plus_1.gif";
        }

        doc.writeln('<IMG SRC="' + img + '" '+
                  'WIDTH=18 HEIGHT=18 ALIGN="left" BORDER=0 VSPACE=0 HSPACE=0>');
    }

    // -- [Item Icon]

    if (!item.imgs)
    {
        if (item.submenu)
        {
            if (item.expanded)
                img = "/images/menu/menu_ordner_auf.gif";
            else
                img = "/images/menu/menu_ordner_zu.gif";
        }
        else
            img = 'menu_doc_1.gif'; // default Grafik
    }
    else
    {
        img = item.imgs;
        if (item.submenu && !item.expanded && item.imgs_zu)  img = item.imgs_zu;
    }

    if ((img >= 1 && img <= 9) || (img >= 20 && img <= 21)) // Numbered icon
        img = 'menu_doc_'+ img +'.gif';

/*
    if (!item.submenu && url_img && item.url.indexOf("http://") == 0) // default URL
        img = "menu_doc_url.gif";
*/
    if (img.indexOf("/") == -1) // Without path
        img = '/images/menu/' + img;

    doc.writeln('<IMG SRC="' + img +
              '" WIDTH=18 HEIGHT=18 ALIGN="left" BORDER=0 VSPACE=0 HSPACE=0>');
    doc.write ('<FONT FACE="' + fonttype + '" SIZE="' +fontsize+ '"><B>');
    if (item.text == null || item.text == '') doc.write ('&nbsp,');
    doc.writeln(item.text + '</B></FONT></A>');
    doc.writeln('</TD></TR>');

    // -- [Ende]

    if (item.expanded) {
        if (!last) grafik[abstand] = true;
        else grafik[abstand] = false;

        abstand++;
        zeige_Ordner_Inhalt(item.submenu);
        abstand--;
    }
    else grafik[i] = false;
 }

