﻿// menu.init();
menu.show();
location_array = new Array;
location_temparray = new Array;
array_pos = 0;
// Rekursives oeffnen der Menus, Mitschreiben des Pfades in Locationarray
function openmenu(i,array_pos) {
 var code_text = "";
 mEvent("MainMenu",menu.items[i].index,"o")
 location_array[array_pos] = new Array;
 // Kleinschreibung bis auf ersten Buchstaben jedes Wortes
 code_array = menu.items[i].code.split(" ");
 for(wort_zaehler=0;wort = code_array[wort_zaehler];wort_zaehler++){
  code_text += " "+wort.charAt(0) + wort.slice(1,wort.length).toLowerCase();
  }
  
 code_array = code_text.split("-");
 code_text = "";
 for(wort_zaehler=0;wort = code_array[wort_zaehler];wort_zaehler++){
  if(code_text != "")
   code_text += "-";
  code_text += wort.charAt(0).toUpperCase() + wort.slice(1,wort.length);
  }
 location_array[array_pos]['code'] = code_text;
 location_array[array_pos]['url'] = menu.items[i].url;
 array_pos++;
 if(menu.items[i].par.index >= 0) {
  openmenu(menu.items[i].par.index,array_pos);
 };
};
// SUCHE NACH seitenzugehörigem MENUEPUNKT
for(i=0;i<menu.items.length;i++) {
 if(menu.items[i].url == location.pathname+location.search) {
  openmenu(i,0)
 };
};

location_array.reverse()

if(DOM) {
 for(i=0;i<location_array.length;i++) {
  var pfeil_node = document.createTextNode(" > ");
  var text_node = document.createTextNode(location_array[i]['code']);
  var a_element = document.createElement("a");
  a_element.href = location_array[i]['url'];
  a_element.appendChild(text_node);
  document.getElementById("location").appendChild(pfeil_node);
  document.getElementById("location").appendChild(a_element);
  }
//DEBUG  alert('DOM');
 }
else
 setCont("id","location",null,"<a href=\"http://www.harperpetersen.com\">HOME</a> "+locationtext);