// {{{}}}
// {{{  sTab:  song definitions
sTabSize=4;
var sTabInit=1;
var sTab = new Array
(
  // {{{  1: Hier ist was los !
  "polkapik", "Polka Pikee",             1, "e_polkap",
  "jupheidi", "Juppheidi",               1, "",
  "kleinhex", "Sieben Hexenfraun",       1, "",
  // }}}
  // {{{  2: Tierisches
  "kleinfux", "Fuchs Karl August",       2, "",
  "froschfe", "Das Froschfest",          2, "froggie",
  "affnrasn", "Die Affen rasen",         2, "",
  "froshmae", "Frosch & Mädchen",        2, "",
  "3schwein", "Drei Schweine",           2, "",
  // }}}
  // {{{  3: Kinderlieder
  "oma_song", "Oma Song",                3, "",
  "bananbro", "Bananen Brot",            3, "banaboat",
  "kopfhang", "Kopf nicht hängen",       3, "hangdown",
  "herbstwi", "Herbstwind",              3, "",
  "miaumiau", "Miau Miau",               3, "",
  "fluck",    "Fluck",                   3, "puffmagi",
  // }}}
  // {{{  4: Volkslieder
  "chassebe", "Chasse de la bécasse",    4, "",
  "datdumee", "Dat du meen",             4, "",
  "uebrmain", "Ueber den Main",          4, "",
  "klapmueh", "Es klappert die Mühle",   4, "",
  "shoeland", "Kein schöner Land",       4, "",
  "samiotis", "Samoitissa",              4, "",
  // }}}
  // {{{  5: Seemann gib acht
  "muedseem", "Müde Seemann",            5, "whatshal",
  "lapaloma", "La Paloma",               5, "e_paloma",
  "reeprban", "Auf der Reeperbahn",      5, "",
  // }}}
  // {{{  6: Mittelalter
  "prunzel",  "Prunzelschütz",           6, "",
  "einmoenc", "Mönch im Nonnenkloster",  6, "",
  // }}}
  // {{{  7: Kundenlieder
  "jruenauj", "Jrüne Aujust",            7, "",
  "adweichs", "An der Weichsel",         7, "",
  // }}}
  // {{{  8: Auf ihr Brüder
  "buergerl", "Bürger Lied",             8, "",
  "einnacht", "Eine Nacht",              8, "",
  "wwwtrink", "Was wollen wir trinken",  8, "",
  "trotzall", "Trotz alledem",           8, "",
  "upflastr", "Unter dem Pflaster",      8, "",
  // }}}
  // {{{  9: Hits for all
  "rockmysl", "Rock My Soul",            9, "e_rockmy",
  "labamba",  "La Bamba",                9, "e_bamba",
  "marmorst", "Marmor, Stein & Eisen",   9, ""
  // }}}
);
// }}}
// {{{  seTab: song definitions english
var seTab = new Array
(
  // {{{  1: Let's go !
  "e_polkap", "Polka Pikee",             1, "polkapik",
  // }}}
  // {{{  2: Animal Spirits
  "froggie",  "Froggie Went A-Courtin",  2, "froschfe",
  // }}}
  // {{{  3: - Children's Song
  // }}}
  // {{{  4: - Folksong
  // }}}
  // {{{  5: Sailor be careful
  "whatshal", "What shall we do ?",      5, "muedseem",
  "e_paloma", "La Paloma",               5, "lapaloma",
  // }}}
  // {{{  6: - Medieval
  // }}}
  // {{{  7: - Vagrant Songs
  // }}}
  // {{{  8: - Stand up Brothers
  // }}}
  // {{{  9: Hits for all
  "hangdown", "Hang down",               9, "kopfhang",
  "banaboat", "Banana Boat",             9, "bananbro",
  "e_rockmy", "Rock My Soul",            9, "rockmysl",
  "puffmagi", "Puff the magic",          9, "fluck",
  "e_bamba",  "La Bamba",                9, "labamba"
  // }}}
);
// }}}
// {{{  rTab:  rubric names
var rTab = [ "Hier ist was los!",
             "Tierisches",
             "Kinderlieder",
             "Volkslieder",
             "Seemann gib acht",
             "Mittelalter",
             "Kundenlieder",
             "Auf ihr Brüder",
             "Hits für alle"
           ];
// }}}
// {{{  reTab: rubric names english
var reTab = [ "Let's go !",
              "Animal Spirits",
              "Children's Song",
              "Folksong",
              "Sailor be careful",
              "Medieval",
              "Vagrant Songs",
              "Stand up Brothers",
              "Hits for all"
            ];
// }}}

var fileN = new Array(); // extracted filenames
var songN = new Array(); // extracted songnames
var rubId = new Array(); // extracted rubrics
var fileA = new Array(); // extracted alternate filenames
var alphN = new Array(); // sorted songnames

// {{{  getSongId()                  find song id of name
function getSongId(songName)
{ var i;

  for (i=0; i<songN.length-1; i++)
    if (songN[i] == songName)
      return i;
  return i;
}
// }}}
// {{{  function writeSongNavi()     write navigation to document
function writeSongNavi(fName, lang)
{ var len;
  var currId;
  var i;

  // {{{  init ?
  //if (sTabInit==1)
    if (lang=="e")
      // {{{  init from english tables
      {
        len = seTab.length/sTabSize;
        for (currId=0, i=0; currId<len; currId++, i+=sTabSize)
          {
            fileN[currId]=seTab[i];
            songN[currId]=seTab[i+1];
            alphN[currId]=seTab[i+1];
            rubId[currId]=seTab[i+2];
            fileA[currId]=seTab[i+3];
          }
      }
      // }}}
    else
      // {{{  init from german tables
      {
        len = sTab.length/sTabSize;
      
        for (currId=0, i=0; currId<len; currId++, i+=sTabSize)
        {
          fileN[currId]=sTab[i];
          songN[currId]=sTab[i+1];
          alphN[currId]=sTab[i+1];
          rubId[currId]=sTab[i+2];
          fileA[currId]=sTab[i+3];
        }
      }
      // }}}
  
    alphN.sort();
    fileN[len]= "nix";
    songN[len]= "nix";
  
    for (currId=0; currId < len+1; currId++)
      if (fileN[currId] == fName)
        break;
  
    sTabInit=0;
  // }}}
  // {{{  start HTML
  document.write("<CENTER>");
  if (currId >= fileN.length)
  {
    document.write("No " + fName + " ! </CENTER>");
    return;
  }
  // }}}
  // {{{  up switch
  if (lang == "d")
  {
    if (fName == "nix")
      document.write("<A HREF='http://home.rhein-zeitung.de/~wachter/index.htm'>");
    else
      document.write("<A HREF='index.htm'>");
  
    document.write("<IMG SRC='arrow_up.gif' ALT='Zurück'" +
                   " BORDER='0' HSPACE='5' WIDTH='22' HEIGHT='15'></"+"A>");
  }
  else
  {
    if (fName == "nix")
      document.write("<A HREF='http://home.rhein-zeitung.de/~wachter/e_index.htm'>");
    else
      document.write("<A HREF='e_index.htm'>");
    document.write("<IMG SRC='arrow_up.gif' ALT='Back'" +
                   " BORDER='0' HSPACE='5' WIDTH='22' HEIGHT='15'></"+"A>");
  }
  // }}}
  // {{{  english switch
  document.write("<IMG SRC='0.gif' BORDER='0' WIDTH='20' HEIGHT='15'>");
  
  if ((lang == "e") || (fileA[currId] == ""))
  {
    document.write("<U><IMG SRC='flag_gb.gif'");
    if (fName != "nix")
      document.write(" ALT='" + fileN[currId] + "' ");
    document.write(" BORDER='0' HSPACE='5' WIDTH='22' HEIGHT='15'>" +
                   "English</U>");
  }
  else
  {
    if (fName == "nix")
      document.write("<A HREF='e_index.htm'><IMG SRC='flag_gb.gif'");
    else
      document.write("<A HREF='"+ fileA[currId] +".htm'>" +
                     "<IMG SRC='flag_gb.gif'"+
                     " ALT='" + fileA[currId] + "' ");
    document.write(" BORDER='0' HSPACE='5' WIDTH='22' HEIGHT='15'>" +
                   "English</"+"A>");
  }
  document.write("<IMG SRC='0.gif' BORDER='0' WIDTH='20' HEIGHT='15'>");
  // }}}
  // {{{  rubric arrows
  var prev = (currId == 0)     ? len-1 : currId-1;
  var next = (currId >= len-1) ?   0   : currId+1;
  
  document.write("<A ALIGN='MIDDLE' HREF='"+ fileN[prev] + ".htm'>");
  document.write("<IMG SRC='arrow_le.gif' ALT='" + songN[prev]);
  if (lang=="e")
    document.write(" (previous song of rubric)'");
  else
    document.write(" (voriges Lied in der Rubrik)'");
  document.write(" BORDER='0' WIDTH='15' HEIGHT='15'></"+"A> Rubriken: ");
  document.write("<A ALIGN='MIDDLE' HREF='" + fileN[next] + ".htm'>");
  document.write("<IMG SRC='arrow_ri.gif' ALT='" + songN[next]);
  if (lang=="e")
    document.write(" (next song of rubric)'");
  else
    document.write(" (nächstes Lied in der Rubrik)'");
  document.write(" BORDER='0' WIDTH='15' HEIGHT='15'></"+"A>");
  // }}}
  // {{{  german switch
  document.write("<IMG SRC='0.gif' BORDER='0' WIDTH='20' HEIGHT='15'>");
  
  if ((lang == "d") || (fileA[currId] == ""))
  {
    document.write("<U>German<IMG SRC='flag_de.gif'");
    if (fName != "nix")
      document.write(" ALT='" + fileN[currId] + "' ");
    document.write(" BORDER='0' HSPACE='5' WIDTH='22' HEIGHT='15'></U>");
  }
  else
  {
    if (fName == "nix")
      document.write("<A HREF='index.htm'>German<IMG SRC='flag_de.gif'");
    else
      document.write("<A HREF='" + fileA[currId] + ".htm'>German" +
                     "<IMG SRC='flag_de.gif'"+
                     " ALT='" + fileA[currId] + "' ");
    document.write(" BORDER='0' HSPACE='5' WIDTH='22' HEIGHT='15'></"+"A>");
  }
  // }}}
  // {{{  down switch
  document.write("<IMG SRC='0.gif' BORDER='0' WIDTH='20' HEIGHT='15'>");
  
  if (lang == "d")
  {
    document.write("<A HREF='inhalt.htm'>");
  
    document.write("<IMG SRC='arrow_do.gif' ALT='Inhalt'" +
                   " BORDER='0' HSPACE='5' WIDTH='22' HEIGHT='15'></"+"A>");
  }
  else
  {
    document.write("<A HREF='content.htm'>");
    document.write("<IMG SRC='arrow_do.gif' ALT='Content'" +
                   " BORDER='0' HSPACE='5' WIDTH='22' HEIGHT='15'></"+"A>");
  }
  // }}}
  // {{{  rubrics
  document.write("<BR><FONT SIZE='-1'>");
  for (i=0, r=-1; i<len; i++)
  { var rub = rubId[i]-1;
  
    if (rub == r)
      continue;
    if (rub<0 || rub>rTab.length)
      continue;
    r=rub;
    if (r == rubId[currId]-1)
      document.write("</FONT> ");
  
    document.write("<A HREF='" + fileN[i] + ".htm'" +
                   " NAME='" + songN[i] + "'>");
    if (lang=="e")
      document.write(reTab[r] + "</"+"A>");
    else
      document.write(rTab[r] + "</"+"A>");
  
    if (r == rubId[currId]-1)
      document.write(" <FONT SIZE='-1'>|");
    else
      document.write("|");
  }
  document.write("</FONT><BR>");
  // }}}
  // {{{  arrow left aplhabet
  var nameC=songN[currId];
  for (aId=0; aId <= len; aId++)
    if (alphN[aId] == nameC)
      break;
  
  pId= getSongId(alphN[(aId <= 0) ? len-1 : aId - 1]);
  
  document.write("<A ALIGN='MIDDLE' HREF='" + fileN[pId] + ".htm'>");
  document.write("<IMG SRC='arrow_le.gif'");
  document.write(" ALT='" + songN[pId]);
  if (lang == "e")
    document.write(" (previous song in alphabet)'");
  else
    document.write(" (voriges Lied im Alphabet)'");
  document.write(" BORDER='0' WIDTH='15' HEIGHT='15'></"+"A> | ");
  // }}}
  // {{{  alphabet
  { alpha = "_ABCDEFGHIJKLMNOPQRSTUVWXYZ_";
    var r;
  
    for (i=0, r=0; i<len; i++)
    {
      nameC=alphN[i];
      if (nameC[0] == alpha[r])
        continue;
      for (r=0; r<alpha.length-1; r++)
        if (nameC[0] == alpha[r])
        {
          document.write("<A HREF='" + fileN[getSongId(nameC)] + ".htm'> " +
                           alpha[r] + " </"+"A>|");
          break;
        }
    }
  }
  // }}}
  // {{{  write arrow right alphabet
  nId = getSongId(alphN[(aId >= len-1) ?   0 : aId+1]);
  
  document.write("<A ALIGN='MIDDLE' HREF='" + fileN[nId] + ".htm'>");
  document.write("<IMG SRC='arrow_ri.gif'");
  document.write(" ALT='" + songN[nId]);
  if (lang=="e")
    document.write(" (next song in alphabet)'");
  else
    document.write(" (nächstes Lied im Alphabet)'");
  document.write(" BORDER='0' WIDTH='15' HEIGHT='15'></" + "A>");
  // }}}
  // {{{  end HTML
  document.write("</CENTER> <HR SIZE='5' WIDTH='100%' COLOR='#808080'>");
  // }}}
}
// }}}
