// menu navigation (common.js is required to set var language)

function menuItem (symName, deText, enText, url, subMenu) {
  this.symName = symName    // symbolic name
  this.deText  = deText     // german text displayed
  this.enText  = enText     // english text displayed
  this.url     = url        // (relative) URL
  this.subMenu = subMenu    // optional submenu
}

var menu = new Array()
function addMenu(item) {
  menu[menu.length] = item
}

addMenu(new menuItem("HOME", "Startseite", "Home", "index.html", null))

var tt1 = new menuItem("SETUP", "Projekt aufsetzen", "Project Setup", "t_setup.html", null)
var tt2 = new menuItem("MAPPING", "Objektabbildung", "Object Mapping", "t_mapping.html", null)
var tt3 = new menuItem("RELATIONS", "Objektbeziehungen", "Object Relations", "t_relations.html", null)
var tt4 = new menuItem("REFINT", "Referentielle Integrität", "Referential Integrity", "t_refint.html", null)
var tt5 = new menuItem("PANEL", "Stammdaten GUI", "Master Data GUI", "t_panel.html", null)
var tt6 = new menuItem("APP", "Die erste Applikation", "The First Application", "t_app.html", null)
var tt7 = new menuItem("GUI", "GUI Politur", "GUI Polish", "t_gui.html", null)
var tt8 = new menuItem("TABLES", "Tabellen", "Tables", "t_tables.html", null)
var tt9 = new menuItem("INVOICE", "Die Rechnung", "Invoice Panel", "t_invoice.html", null)
var tt10 = new menuItem("INVOICE2", "Die Rechnung verbessert", "Invoice Panel Reloaded", "t_invoice_2.html", null)
var tt11 = new menuItem("SEARCH", "Queries und Panels", "Queries & Panels", "t_search.html", null)
var tt12 = new menuItem("NTIER", "Going 3-tier", "Going 3-tier", "t_ntier.html", null)
var tt13 = new menuItem("APPSERV", "Middle Tier Server", "Middle Tier Server", "t_appserv.html", null)
var tt14 = new menuItem("ROLES", "Benutzergruppen", "User Groups", "t_roles.html", null)
var tt15 = new menuItem("SECURITY", "Sicherheit I", "Security I", "t_security.html", null)
var tt16 = new menuItem("SECURITY2", "Sicherheit II", "Security II", "t_security2.html", null)
var tt17 = new menuItem("RAILS", "JRuby on Rails", "JRuby on Rails", "t_rails.html", null)
var tt18 = new menuItem("PRINT", "Drucken", "Printing", "t_print.html", null)
var tt19 = new menuItem("WEBSTART", "Java Web Start", "Java Web Start", "t_webstart.html", null)
var tt20 = new menuItem("MTENANT", "Mandantenfähigkeit", "Multi-Tenancy", "t_mtenant.html", null)
var ttN = new menuItem("CONTD", "So geht's weiter...", "To be cont'd...", "t_contd.html", null)
addMenu(new menuItem("TUTORIAL", "Tutorial", "Tutorial", "tutorial.html",
   [tt1, tt2, tt3, tt4, tt5, tt6, tt7, tt8, tt9, tt10, tt11, tt12, tt13, tt14, tt15, tt16, tt17, tt18, tt19, tt20, ttN]))
var docapi = new menuItem("APIDOC", "API Javadoc", "API Javadoc", "../../download/docs/api/index.html", null)
addMenu(new menuItem("DOCS", "Dokumentation", "Documentation", "docs.html", 
   [docapi]))
addMenu(new menuItem("FAQ", "Fragen und Antworten", "FAQ", "faq.html", null))
addMenu(new menuItem("DOWNLOAD", "Download", "Download", "download.html", null))
addMenu(new menuItem("IMPRINT", "Impressum", "Imprint", "imprint.html", null))

// recursively create the menu
function createSubMenu (level, mlist, argPath) {
  document.write('<ul class="level' + level + '">')
  var pathElem = argPath[level]
  for (var i = 0; i < mlist.length; i++) {
    var item = mlist[i]
    var mText = language=='de' ? item.deText : item.enText;
    if (item.symName == pathElem) {
      if (item.subMenu == null) {
        document.write('<li class="leaf"><a class="open" href="' + item.url + '">' + mText + '</a></li>')
      }
      else  {
        if (level >= argPath.length - 1) {
          document.write('<li class="node"><a class="open" href="' + item.url + '">' + mText + '</a>')
        }
        else  {
          document.write('<li class="node"><a href="' + item.url + '">' + mText + '</a>')
        }
        createSubMenu(level+1, item.subMenu, argPath)
        document.write('</li>')
      }
    }
    else {
      document.write('<li class="leaf"><a href="' + item.url + '">' + mText + '</a></li>')
    }
  }
  document.write('</ul>')
}


// create menu
// ex.: createMenu(["DEVEL", "STRATEGY"])
function createMenu(argPath) {
  createSubMenu(0, menu, argPath)
}

