

function writeNavi(location){
	
	location= new String(location);
	documentName=location.substring(location.lastIndexOf("/")+1,location.lastIndexOf("."));
	
	MainMenuDisplay = ['Home','Hof','Angebote','Projekte','Landschaftsentwicklung','Kontakt'];
	MainMenuDocument = ['index','hof','angebote','projekte','landschaftsentwicklung','kontakt'];
	MainMenuLink = ['index.html','hof.html','angebote.html','projekte.html','landschaftsentwicklung.html','kontakt.html'];
	
	SubmenuIndex = [];
	SubmenuHof = [['Landwirtschaft','landwirtschaft','landwirtschaft.html'],['Pferdehof','pferdehof','pferdehof.html']];
	SubmenuAngebote = [['Ferien auf dem Bauernhof','ferien','ferien.html']];
	SubmenuProjekte = [['Projekt Feld-Wald-Weide','feldwaldweide','feldwaldweide.html'],['Projekt Säume für ökologischen Ausgleich','saeume','saeume.html'],['Projekt Bedeutung Randstrukturen für Biodiversität','randstrukturen','randstrukturen.html'],['Projekt Aufwertungsmassnahmen für Insekten und Vogelfauna','aufwertung','aufwertung.html']];
	SubmenuLandschaftsentwicklung = [['LEK Litzibuch','lek','lek.html'],['Geschichte','geschichte','geschichte.html'],['Aktueller Stand','stand','stand.html'],['Bachrevitalisierung','bach','bach.html']];
	SubmenuKontakt = [];
	
	SubmenuList = [SubmenuIndex,SubmenuHof,SubmenuAngebote,SubmenuProjekte,SubmenuLandschaftsentwicklung,SubmenuKontakt];

	
	for(i=0;i<=SubmenuList.length-1;i++) {
		//alert(MainMenuDisplay[i]);
		if (documentName != MainMenuDocument[i]) {
			document.writeln('<div class="menu_item"><img src="img/arrow_down.jpg" width="10" height="13" /><a href="'+MainMenuLink[i]+'">&nbsp;&nbsp;'+ MainMenuDisplay[i]  +'</a></div>');
			//check if submenu exists and if should be open
			submenuOpen = false;
			//alert(SubmenuList[i].length);
			if (SubmenuList[i].length > 0) {
				
				for (o=0;o<=SubmenuList[i].length-1;o++) {
					
					if (String(SubmenuList[i][o][1]) == String(documentName)) {
						submenuOpen = true;
					}	 
				}
			}
			if (submenuOpen == true) {
				
				writeSubmenu(i,documentName);
			}
		}
		else {
			document.writeln(' <div class="menu_item_highlight"><img src="img/arrow_down.jpg" width="10" height="13" />&nbsp;&nbsp;'+ MainMenuDisplay[i] +'</div>');
			writeSubmenu(i,documentName);
		}
	
	}
	
}

function writeSubmenu(indexMainMenu,documentName) {
	// Check if Submenu exists
	//alert(SubmenuList[indexMainMenu].length);
	if (SubmenuList[indexMainMenu].length > 0) {
		for(s=0;s<=SubmenuList[indexMainMenu].length-1;s++) {
			
			if (documentName != SubmenuList[indexMainMenu][s][1]) {
				document.writeln('<div class="submenu_item"><img src="img/arrow_down.jpg" width="10" height="13" /><a href="'+SubmenuList[indexMainMenu][s][2]+'" style="font-weight:normal;">&nbsp;&nbsp;'+ SubmenuList[indexMainMenu][s][0]  +'</a></div>');
			
			}
			else {
				document.writeln(' <div class="submenu_item_highlight" style="font-weight:normal;"><img src="img/arrow_down.jpg" width="10" height="13" />&nbsp;&nbsp;'+ SubmenuList[indexMainMenu][s][0] +'</div>');
			
			}
	
		}
	}
}

