/*  Projekt:         Menübaum
    Version:         1.2
    Autor:           Leander Welter

    Beschreibung:

    Erstellt am:     16.03.2002
    Änderungen :     17.03.2002
           1.2 :     15.10.2009

*/

// globale Variablen

var root = null;
var yOffSet = 0;

// Parameter

var body_bgcolor  = "#000080";
var body_text   = "#CCCCCC";
var body_link   = "#FFFFFF";
var body_alink    = "#FFFFFF";//"#FFCCCC";
var body_vlink    = "#FFFFFF";//"#CCFFCC";
var body_hover    = "#FFFFFF";//"#CCCCFF";
var link_hover    = " color:#000080; font-weight:BOLD; background-color:#FFFFFF; ";
var a_underline   = false;
var menue_pre   = "<b><small>";
var menue_post    = "</small></b>";
var eintrag_pre   = "<small>";
var eintrag_post  = "</small>";
var menue_style   = "font-family: Tahoma, Verdana, Arial, sans-serif; font-size:12pt;";
var rand      = 0;
var menue_titel   = "";
var bild_leer   = "leer.gif";
var bild_eintrag  = "normal.gif";
var bild_menue_offen= "offen.gif";
var bild_menue_geschlossen  = "geschlossen.gif";
var bild_breite   = 12;
var bild_hoehe    = 12;
var frame_name    = "links";


// ****** Knotenobjekt **************
function isBlatt()
{
  return ((this.submenu == null) || (this.submenu.length == 0));
}

function change(path)
{
  var trennerPos = path.indexOf("/");
  if (trennerPos == -1)
  {
    this.submenu[parseInt(path)].isOpen = !this.submenu[parseInt(path)].isOpen;
  if((this.submenu[parseInt(path)].isOpen) && (this.submenu[parseInt(path)].target != null) && (this.submenu[parseInt(path)].url != null))
    frames[this.submenu[parseInt(path)].target].location.href= this.submenu[parseInt(path)].url;
  }
  else
  {
    var subPos = parseInt(path.substring(0,trennerPos));
    this.submenu[subPos].change(path.substring(trennerPos+1));
  }
}

function schreiben(curDeep, curPos, curPath)
{
  with(self[frame_name].document)
  {
    var i;
    var node;
  var tag_a_anfang= "";
  var tag_a_ende  = "</a>";
  var tags_pre  = "";
  var tags_post = "";
  var tag_img   = "";
  var hinttext  = "";
  var bild    = "";

  write("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n<tr align=\"left\" valign=\"center\">\n<td>");
  if (curDeep > 0)
  {
    if (curDeep > 1)
      write("<img src=\"" + bild_leer + "\" width=\"" + String(bild_breite * (curDeep - 1)) + "\" height=\"" + String(bild_hoehe) + "\" border=\"0\" alt=\"\">");

    if (this.isBlatt())
    {
      hinttext = this.description ? this.description : this.name;
      bild     = bild_eintrag;
    tags_pre = eintrag_pre;
    tags_post= eintrag_post;
    tag_a_anfang = "<a href=\"" + this.url + "\" " +
             "onMouseOver=\"parent.hint('" + hinttext + "'); return true\" " +
             "onMouseOut=\"parent.cls()\" " +
             "onMousedown=\"parent.hint('" + hinttext + "'); return true\" " +
             (this.target ? (" target=\"" + this.target + "\" ") : "") +
             "title=\"" + hinttext + "\">";
    }
    else
    {
    hinttext = this.description ? this.description : this.name;
    bild     = (this.isOpen) ? bild_menue_offen : bild_menue_geschlossen;
    tags_pre = menue_pre;
    tags_post= menue_post;
      tag_a_anfang = "<a href=\"javascript:parent.doChange('" + curPath + "')\" " +
               "onMouseOver=\"parent.hint('" + hinttext + "'); return true\" " +
             "onMouseOut=\"parent.cls()\" " +
             "onMousedown=\"parent.hint('" + hinttext + "'); return true\" " +
             "title=\"" + hinttext + "\">";
    }

    tag_img = "<img src=\"" + bild + "\" " +
          "width=\"" + String(bild_breite) + "\" " +
          "height=\"" + String(bild_hoehe) + "\" " +
          "border=\"0\" " +
          "alt=\"" + hinttext + "\">";

      write(tag_a_anfang + tag_img + tag_a_ende);
    write("</td>\n<td>");
    write(tag_a_anfang + tags_pre + this.name + tags_post + tag_a_ende);
  }
    writeln("</td>\n</tr>\n</table>");
    // eventuell geöffnetes Untermenü ausgeben
  if (this.isOpen)
    for(i = 0;i < this.submenu.length; i++)
        this.submenu[i].schreiben(curDeep+1, i, curPath+"/"+String(i));
  }
}

function Knoten(name, url, target, submenu, isOpen, description)
{
  this.name = name;
  this.url = url;
  this.target = target;
  this.submenu = submenu;
  this.isOpen = isOpen;
  this.description = description;
  this.isBlatt = isBlatt;
  this.schreiben = schreiben;
  this.change = change;
}

function Node(name, submenu)
{
  this.name = name;
  this.url = null;
  this.target = null;
  this.submenu = submenu;
  this.isOpen = false;
  this.description = false;
  this.isBlatt = isBlatt;
  this.schreiben = schreiben;
  this.change = change;
}

function NodeD(name, submenu, description)
{
  this.name = name;
  this.url = null;
  this.target = null;
  this.submenu = submenu;
  this.isOpen = false;
  this.description = description;
  this.isBlatt = isBlatt;
  this.schreiben = schreiben;
  this.change = change;
}

function NodeX(name, url, submenu)
{
  this.name = name;
  this.url = url;
  this.target = "main";
  this.submenu = submenu;
  this.isOpen = false;
  this.description = null;
  this.isBlatt = isBlatt;
  this.schreiben = schreiben;
  this.change = change;
}

function NodeDX(name, url, submenu, description)
{
  this.name = name;
  this.url = url;
  this.target = "main";
  this.submenu = submenu;
  this.isOpen = false;
  this.description = description;
  this.isBlatt = isBlatt;
  this.schreiben = schreiben;
  this.change = change;
}

function Leaf(name, url)
{
  this.name = name;
  this.url = url;
  this.target = "main";
  this.submenu = null;
  this.isOpen = false;
  this.description = null;
  this.isBlatt = isBlatt;
  this.schreiben = schreiben;
  this.change = change;
}

function LeafD(name, url, description)
{
  this.name = name;
  this.url = url;
  this.target = "main";
  this.submenu = null;
  this.isOpen = false;
  this.description = description;
  this.isBlatt = isBlatt;
  this.schreiben = schreiben;
  this.change = change;
}

function LeafND(name, url, description)
{
  this.name = name;
  this.url = url;
  this.target = null;
  this.submenu = null;
  this.isOpen = false;
  this.description = description;
  this.isBlatt = isBlatt;
  this.schreiben = schreiben;
  this.change = change;
}

// ************ Funktionen ************************

function hint(text)
{
  window.status = text;
}

function cls()
{
  window.status = "";
}

function doChange(path)
{
  if (document.all)
    yOffSet = self[frame_name].document.body.scrollTop;
  else
    yOffSet = self[frame_name].pageYOffset;

  var pos =path.indexOf("/");
  root.change(path.substring(pos+1));
  write_document();

  // an die richtige stelle springen (doppelt, sonst funzt nicht richtig!)
  self[frame_name].scrollTo(0, yOffSet);
  self[frame_name].scrollTo(0, yOffSet);
}

// Menü schreiben
function write_document()
{
  with(self[frame_name].document)
  {
    open("text/html", "replace");
  // Dokumentenkopf
  writeln("<html>\n<head>\n<title>Men&uumlbaum;</title>");
  writeln("<meta name=\"Author\" content=\"Leander Welter\">");
  writeln("<meta name=\"Copyright\" content=\"Leander Welter, Gau-Algesheim\">");
  writeln("<meta name=\"ROBOTS\" content=\"NONE\">");
    writeln("<meta http-equiv=\"Content-Language\" content=\"de\">");
  writeln("<style type=\"text/css\">\n<!--");
  if(!a_underline)
    writeln("a {text-decoration: none; }");
  writeln("a:hover, a:active {" + link_hover + ";}");
  if(menue_style != "")
    writeln("body, a, p, td, h1, h2, h3, h4, h5, h6 {" + menue_style + "}");
//  writeln("body {scrollbar-base-color:#8C8CC6;}");
  writeln("body { scrollbar-arrow-color:#00BCFA; scrollbar-face-color: #6666CC;scrollbar-highlight-color: #6666CC;scrollbar-3dlight-color: #6666CC;scrollbar-darkshadow-color: #6666CC;scrollbar-shadow-color: #6666CC;scrollbar-arrow-color: #6666CC;scrollbar-track-color: #333399;}");
  writeln("//-->\n</style>");
  writeln("</head>");
  // Dokumentenkörper
  writeln("<body background=\"bgMenue.png\" text=\"" + body_text +
        "\" link=\"" + body_link + "\" alink=\"" + body_alink +
        "\" vlink=\"" + body_vlink + "\" leftmargin=\"" + rand +
        "\" topmargin=\"" + rand + "\" marginwidth=\"" + rand +
        "\"marginheight=\"" + rand + "\">");
  if(menue_titel != "")
    writeln(menue_titel);
  // Der eigentliche Menübaum
  write("<p>");
  if (root == null)
    alert("Der Menübaum wurde nicht angelegt und initialisiert !");
  else
    root.schreiben(0,0,"0");
  writeln("</p>");
  //Haftungsausschluss
  writeln("<p align=\"center\"><a href=\"http://www.disclaimer.de/disclaimer.htm\" target=\"main\" onmousemove=\"javascript: status='Haftungsausschluss';\" onmouseout=\"javascript: status='';\">");
  writeln("<font size=\"-1\" color=\"lime\"><b>-Haftungsausschluss-</b></font></a></p>");
  writeln("</body>");
  writeln("</html>");
  close();
  }
}

function setYOffsetTo(y)
{
  yOffSet = y;
}

function rW(saison, spTag)
{
var isNS=(document.layers)?true:false;
var isNS6=(navigator.userAgent.indexOf('Gecko')>=0);
var wo = "teams/saison" + saison +"/herren1/Bericht/";
wo += spTag;
wo += ".html";
if ((isNS) && !(isNS6))
  BFenster = window.open(wo, "Berichtfenster", "scrollbars,status, width=740, height=520, left=50, top=80");
else
  BFenster = window.open(wo, "Berichtfenster", "width=700, height=520, resizable=yes, scrollbars=yes, left=100, top=100");
BFenster.focus();
}

function showERSTE()
{
  setYOffsetTo(0);
  teams.isOpen = true;
  aktiveTeams_10.isOpen = true;
  herren1_10.isOpen = true;
  write_document();
  frames['main'].location.href = "http://www.superzaubermaus.de/tsg/team.php?mannschaftsID=11011";
}

function showDAMEN()
{
  setYOffsetTo(0);
  teams.isOpen = true;
  aktiveTeams_10.isOpen = true;
  write_document();
  self['main'].location.href = "http://www.superzaubermaus.de/tsg/team.php?mannschaftsID=41011";
}

function showZWEITE()
{
  setYOffsetTo(0);
  teams.isOpen = true;
  aktiveTeams_10.isOpen = true;
  write_document();
  self['main'].location.href = "http://www.superzaubermaus.de/tsg/team.php?mannschaftsID=21011";
}

function showAKTIVE(saison, pX)
{
  setYOffsetTo(0);
  teams.isOpen = true;
  aktiveTeams_10.isOpen = true;
  if (saison != null)
  {
    eval("aktiveTeams_"+saison+".isOpen = true;");
  }
  else
    aktiveTeams_10.isOpen = true;
  if (pX != null)
    eval(pX);
  write_document();
}

function showJUGEND(saison)
{
  setYOffsetTo(0);
  teams.isOpen = true;
  if (saison != null)
    eval("jugendTeams_"+saison+".isOpen = true;");
  else
    jugendTeams_10.isOpen = true;
  write_document();
}

function showWAJ()
{
  setYOffsetTo(0);
  teams.isOpen = true;
//  saison_06.isOpen = true;
  jugendTeams_10.isOpen = true;
  write_document();
}

function showWBJ()
{
  setYOffsetTo(0);
  teams.isOpen = true;
//  saison_06.isOpen = true;
  jugendTeams_10.isOpen = true;
  write_document();
}

function showCJ()
{
  setYOffsetTo(0);
  teams.isOpen = true;
  jugendTeams_10.isOpen = true;
  write_document();
  frames['main'].location.href = mbj_10.url;
}

function showSCHIRIS()
{
  setYOffsetTo(0);
  abteilung.isOpen = true;
  schiedsrichter.isOpen = true;
  write_document();
  frames['main'].location.href = "abteilung/neulingslehrgang/termine.html";
}

function showINFO(url)
{
  setYOffsetTo(0);
  abteilung.isOpen = true;
  mitgliederInfo.isOpen = true;
  write_document();
  self['main'].location.href = url;
}

function showSCAMP(p)
{
  setYOffsetTo(0);
  jsg.isOpen = true;
  scamp06.isOpen = true;
  write_document();
  self['main'].location.href = "sommercamp/2006/start.html";
}

function showFAN()
{
  frames['main'].location.href = fanshop.url;
}

function showAkt()
{
  setYOffsetTo(0);
  aktuelles.isOpen = true;
  write_document();
//  self['main'].location.href = "aktuelles.html";
  self['main'].location.href = "http://www.superzaubermaus.de/tsg/aktuelles.php";
}

function showShow()
{
  setYOffsetTo(0);
  shwtnz.isOpen = true;
  write_document();
  frames['main'].location.href = "http://www.oh-handball.de/showtanz/atlantic.html";
}

function showGuestBook()
{
  frames['main'].location.href = guestbook.url;
}
