/*********************************************************************
27 Apr 2003
Functions and objects to insert contents in every single page
of a non-framed web site design.
Copyright 2000-2003 Computer Science Software (Pty) Ltd., South Africa
**********************************************************************/

var html_extension = ".htm";    // HTML-Dateiendung: wird bei der automatischen link.erzeugung verwendet
var indexFile = "index.html";
var mouseover_effects = true;   // Mouseover-toggle: ja oder nein
var i = 0;
var j = 0;

var MenuEntries = new Object();
var current_entry = 0;

/* ------------------------------------------------------------------------------------*/
// add_subentry()
// fügt einen Untereintrag zu einem Menüpunkt hinzu
// Untereinträge werden automatisch angezeigt, wenn der Obereintrag ausgewählt ist
/* ------------------------------------------------------------------------------------*/

function add_subentry(ID, label, mother, folder, file, statusBar){
   if(MenuEntries[mother].child_counter == null){
      MenuEntries[mother].child_counter = 0;
      MenuEntries[mother].children = new Array();
   }

   var child_count = MenuEntries[mother].child_counter;
   MenuEntries[mother].children[child_count] = ID;
   MenuEntries[mother].child_counter++;

   add_entry(ID, label, folder, file, statusBar);
   MenuEntries[ID].mother = mother;
}

/* ------------------------------------------------------------------------------------*/
// add_entry()
// fügt einen eintrag zur Sammlung der Menüeinträge hinzu
// dabei werden default-einstellungen eingetragen, die man manuell ändern kann
/* ------------------------------------------------------------------------------------*/

function add_entry(ID, label, folder, file, statusBar){
   MenuEntries[ID] = new Object();
   MenuEntries[ID].ID = ID;
   MenuEntries[ID].label = label;
   MenuEntries[ID].file = file;

   if(folder == ""){
      MenuEntries[ID].link = file;
   } else {
      MenuEntries[ID].link = folder + "/" + file;
   }

   if(!statusBar){
   } else {
      MenuEntries[ID].statusBar = statusBar;

      if(mouseover_effects == true){
         MenuEntries[ID].toolTip = statusBar;
      }
   }

   current_entry++;
}

/* ------------------------------------------------------------------------------------*/
// build_nav()
// aufbau der navigationsleiste
/* ------------------------------------------------------------------------------------*/

function build_nav(page_menu, highlight){

   var mother="";
   var fileSuffix = numberOfFolders(highlight);


   // check for mother node
   if(highlight != null){
      if(MenuEntries[highlight].mother != null){
         mother = MenuEntries[highlight].mother;
      }
   }


   self.status=' Come in touch with the Yon-Wu School';

   document.write('<HR NOSHADE SIZE="1" CLASS="distanceTop" COLOR="#996600">');
   document.write('<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">');
   document.write('<TR VALIGN="middle">');
      document.write('<TD>');
         document.write('<IMG SRC="' + fileSuffix + 'graphics/arch.gif" ALT="Arch" WIDTH="110" HEIGHT="55" BORDER=0 ALIGN="absbottom">');
      document.write('</TD>');
      document.write('<TD WIDTH="20">');
         document.write('<IMG SRC="' + fileSuffix + 'graphics/transparent.gif" WIDTH="15" HEIGHT="1" BORDER="0">');
      document.write('</TD>');
      document.write('<TD WIDTH="500">');
         if(navigator.appName == "Netscape")
         {
            document.write('<H1 CLASS="distance">Tai Chi Chuan and Chi Kung');
            document.write('<BR><FONT SIZE="-1"><B>Yon-Wu School</B></FONT></H1>');
         }
         else
         {
            document.write('<H1 CLASS="distance">Tai Chi Chuan and Chi Kung</H1>');
            document.write('<BR><B>Yon-Wu School</B>');
         }
      document.write('</TD>');
      document.write('<TD WIDTH="3%">');
         document.write('<IMG SRC="' + fileSuffix + 'graphics/transparent.gif" WIDTH="3%" HEIGHT="1" BORDER="0">');
      document.write('</TD>');
      document.write('<TD>');
         document.write('<DIV CLASS="bookmark"><A HREF="javascript:window.external.AddFavorite(location.href, \'Tai Chi, Chi Kung and Karate-Jutsu\')" TITLE="Bookmark Tai Chi, Chi Kung and Karate-Jutsu" CLASS="bookmark">Bookmark&#160;&#160;&#160;<BR>this page!&#160;&#160;&#160;&#160;</A></DIV>');
      document.write('</TD>');

      document.write('<TD WIDTH="20">');
         document.write('<IMG SRC="' + fileSuffix + 'graphics/transparent.gif" WIDTH="15" HEIGHT="1" BORDER="0">');
      document.write('</TD>');
      document.write('<TD WIDTH="85">');
         mydate = new Date();
         formatDate(mydate);
         document.write('<B><FONT size=-2 FACE="Arial,Verdana,Helvetica,sans-serif">' + day + '<BR>' + myweekday + ' ' + month + year + '</FONT></B>');
      document.write('</TD>');
   document.write('</TR>');
   document.write('</TABLE>');

   document.write('<HR NOSHADE SIZE="1" CLASS="distanceBottom" COLOR="#996600">');

   //OPEN - In file index.html there is another boder used then in the other files
   if (MenuEntries[highlight].file == indexFile){
      document.write('<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="2"><TR VALIGN="top"><TD WIDTH="190" HEIGHT="100%" BGCOLOR="#000099" CLASS="alignLeft"><TABLE BORDER="0" WIDTH="100%" HEIGHT="100%" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEEEE"><TR VALIGN="top"><TD><DIV CLASS="contentsBorderTable">');
   }
   else
   {
      document.write('<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR VALIGN="top"><TD WIDTH="190" CLASS="alignLeft"><DIV CLASS="contentsBorder">');
   }


   for(i=0; i< page_menu.length; i++){
      var current_entry = page_menu[i];


      if(current_entry == mother){
         write_html(current_entry, highlight, fileSuffix, false, true);

         for(j=0; j<MenuEntries[current_entry].children.length; j++){
            write_html(MenuEntries[current_entry].children[j], highlight, fileSuffix, true);
         }
      }
      else {
         write_html(current_entry, highlight, fileSuffix);
      }

      if(MenuEntries[current_entry].label == highlight &&
         MenuEntries[current_entry].child_counter != null){

         // Untermenü vorhanden
         for(j=0; j<MenuEntries[current_entry].children.length; j++){
            write_html(MenuEntries[current_entry].children[j], highlight, fileSuffix, true);
         }
      }
   }

   //CLOSE - In file index.html there is another boder used then in the other files
   if (MenuEntries[highlight].file == indexFile){
      document.write('</DIV></TD></TR></TABLE></TD><TD WIDTH="7"><IMG SRC="' + fileSuffix + 'graphics/transparent.gif" WIDTH="5" HEIGHT="1" BORDER="0"></TD><TD>');
   }
   else
   {
      document.write('</TD><TD WIDTH="7"><IMG SRC="' + fileSuffix + 'graphics/transparent.gif" WIDTH="5" HEIGHT="1" BORDER="0"></TD><TD>');
   }
}

/* ------------------------------------------------------------------------------------*/
// write_html()
// ausgabe des html-codes für die navigationsleiste
/* ------------------------------------------------------------------------------------*/

function write_html(current_entry, highlight, fileSuffix, isChild, isMother){
   //var pathSuffix = numberOfFolders(highlight);
   var suffix = "";
   var classSet = "";
   output = "";

   if(isChild){
      suffix = '&#160;&#160;&#160;&#160;&#160;&#160;';
      classSet = "contentSub";
   }
   else {
      suffix = "";
      classSet = "content";
   }


   if(MenuEntries[current_entry].label != MenuEntries[highlight].label && isMother != true){
      output = suffix + '<A HREF="' + fileSuffix + MenuEntries[current_entry].link + '" CLASS="' + classSet + '"';

      if(mouseover_effects == true ){
         // mouse events einfügen
         output+= ' onMouseOver="self.status=\'' + MenuEntries[current_entry].statusBar + '\'; return true;"';
         output+= ' onMouseOut="self.status=\'Come in touch with the Yon-Wu School\';return true;"';
      }

      output += '>';
      output += MenuEntries[current_entry].label + '</A><BR>';
   }
   else {
      output += suffix + '<SPAN CLASS="' + classSet + '">' + MenuEntries[current_entry].label + '</SPAN><BR>';
   }

   document.write(output);
}


/* ------------------------------------------------------------------------------------*/
// numberOfFolders()
// Returns the number of sub-folders
/* ------------------------------------------------------------------------------------*/

function numberOfFolders(highlight){
   var fileName = MenuEntries[highlight].link;
   var tempfileName = "";
   var subFolderIndicator = "";
   var folderNo = 0;
   var tempPosition = 0;

   for (i=0; i < fileName.length-1; i++)
   {
      tempfileName = fileName.substr(i, fileName.length-1);
      tempPosition = tempfileName.indexOf("/");

      if (tempPosition > i)
      {
         i = tempfileName.indexOf("/");
         folderNo++;
      }
   }

   if (folderNo > 0)
   {
      subFolderIndicator = "../";
   }
   else
   {
      subFolderIndicator = "";
   }

   return subFolderIndicator;
}
