var LiveMenu = null;
var Timeout_id = null;


var topMenus = 8;
var menutext = "";

function makeArray(n){
  this.size = n;
  for(i=1; i<=n; i++){
    this[i] = 0;
  }
  return(this);
}

function topMenu(n, title, url) {
	this.size = n;
	this.menuTitle = title;
	this.menuURL = url;
	if (n > 0)
		this.subMenus = new makeArray(n);
	else
		this.subMenus = 0;
}

function subMenu(title, url) {
	this.menuTitle = title;
	this.menuURL = url;
}

var menus = new makeArray(topMenus);

/*Create Menus*/
/*Don't forget to create the right stylesheet*/
menus[1] = new topMenu(0, 'Home', 'index.html');
/*menus[1].subMenus[1] = new subMenu('Aktuell', 'actual.html');*/





menus[2] = new topMenu(2, 'Biol&auml;dile', 'shop.html');
menus[2].subMenus[1] = new subMenu('Biol&auml;dile', 'shop.html');
menus[2].subMenus[2] = new subMenu('Spezialit&auml;ten', 'action.html');

menus[3] = new topMenu(4, 'Acker', 'garden.html');
menus[3].subMenus[1] = new subMenu('Acker', 'garden.html');
menus[3].subMenus[2] = new subMenu('Kompost', 'kompost.html');
menus[3].subMenus[3] = new subMenu('Anbau', 'anbau.html');
menus[3].subMenus[4] = new subMenu('Diashow', 'bildshow_arti.html');

menus[4] = new topMenu(2, 'Produkte', 'products.html');
menus[4].subMenus[1] = new subMenu('Produkte', 'products.html');
menus[4].subMenus[2] = new subMenu('Produktliste', 'products_list.html');

menus[5] = new topMenu(3, '&Uuml;ber uns', 'team.html');
menus[5].subMenus[1] = new subMenu('Team', 'team.html');
menus[5].subMenus[2] = new subMenu('WWOOF', 'wwoof.html');
menus[5].subMenus[3] = new subMenu('Photos', 'pictures.html');

menus[6] = new topMenu(0, 'Geschichte', 'history.html');

menus[7] = new topMenu(0, 'Kontakt', 'contact.html');

menus[8] = new topMenu(0, 'Links', 'links.html');



function openMenu(id) {
	 // If DOM1 supported and element exists ...
  if((document.getElementById)&&(document.getElementById(id)!=null)){
    // If this menu is already open ...
    if(LiveMenu==document.getElementById(id)){
      // Do not close it
      clearTimeout(Timeout_id);
    }
    // Another might still be open ...
    else{
      // If another menu is open ...
      if(LiveMenu!=null){
        // Do not wait, shut it now
        clearTimeout(Timeout_id);
        hideNow();
      }
    }
    // This is the new 'live' menu, make it visible
    LiveMenu = document.getElementById(id);
    // LiveMenu.style.visibility is
    // initially empty in IE5 until
    // it is assigned by these
    // functions, so must check that
    // it's not null before proceeding...
    if((LiveMenu.style)&&(LiveMenu.style.visibility!=null)){
	  LiveMenu.style.visibility = 'visible';
	  
    }
  }

}


function hideMenu(id) {
// If DOM1 supported and a menu is open ...
  if((document.getElementById)&&(document.getElementById(id)!=null)){
    // Get the current live menu
    LiveMenu = document.getElementById(id);
    // Prepare to shut it in 250 milliseconds
    Timeout_id = window.setTimeout('hideNow();',150);
  }

}

function hideNow() {
	//document.getElementById(LiveMenu).style.visibility = "hidden";
	 if((LiveMenu.style)&&(LiveMenu.style.visibility)){
  	 	LiveMenu.style.visibility = 'hidden';
		LiveMenu.style.cursor = 'auto';
 	 }

}

function checkState(id) {
	 // If menuOver has not been called or the menu is hidden, do nothing
  if((LiveMenu==null)||((LiveMenu.style)&&(LiveMenu.style.visibility)&&(LiveMenu.style.visibility=='hidden')))return;
  else openMenu(id);

}

function writeMenu() {
	menutext = "<div id=\"menu\">";
	menutext += "<tr><td class=\"bord\">";
	for(i = 1; i <= topMenus; i++) {
		       menutext +=	"<div class=\"temp\" id=\"top"+i+"\" onMouseover=\"openMenu(\'sub" + i + "\'); this.style.background=\'#FFFF99\'; return;\"; onMouseout=\"hideMenu(\'sub"+i+"\'); this.style.background=\'#99CC99\'; return;\" onClick=\"window.location='"+menus[i].menuURL+"';return true;\"><a class=\"navcl\" href=\""+menus[i].menuURL+"\">"+menus[i].menuTitle+"</a></div>";

	   if (i < topMenus)
		  menutext += "</td><td>";
		else
		  menutext += "</td>";
	}
	menutext += "</tr></div>";
	menutext += "<div id=\'link\'>";
	menutext += "<tr>";
	for(i = 1; i <= topMenus; i++) {
		menutext += "<td valign=\"top\">";
		if (menus[i].size > 0) {
			menutext +=	"<div id=\"sub"+i+"\" class=\"temp2\">";
			for(j = 1; j <= menus[i].size; j++) {
			
			     if (i == 1) {
			     menutext += "<div class=\"temprl\" onMouseover=\"checkState(\'sub"+ i +"\'); this.style.background=\'#FFFF99\'; return;\"; onMouseout=\"hideMenu(\'sub"+ i +"\'); this.style.background=\'#ddffdd\'; return;\"; onClick=\"window.location='"+ menus[i].subMenus[j].menuURL +"';return true;\"><a class=\"navcl\" href=\""+  menus[i].subMenus[j].menuURL +"\">"+ menus[i].subMenus[j].menuTitle +"</a></div>";
			     } else if (i == topMenus) {
			         menutext += "<div class=\"temprr\" onMouseover=\"checkState(\'sub"+ i +"\'); this.style.background=\'#FFFF99\'; return;\"; onMouseout=\"hideMenu(\'sub"+ i +"\'); this.style.background=\'#ddffdd\'; return;\"; onClick=\"window.location='"+ menus[i].subMenus[j].menuURL +"';return true;\"><a class=\"navcl\" href=\""+  menus[i].subMenus[j].menuURL +"\">"+ menus[i].subMenus[j].menuTitle +"</a></div>";
			     } else {
				menutext += "<div class=\"tempr\" onMouseover=\"checkState(\'sub"+ i +"\'); this.style.background=\'#FFFF99\'; return;\"; onMouseout=\"hideMenu(\'sub"+ i +"\'); this.style.background=\'#ddffdd\'; return;\"; onClick=\"window.location='"+ menus[i].subMenus[j].menuURL +"';return true;\"><a class=\"navcl\" href=\""+  menus[i].subMenus[j].menuURL +"\">"+ menus[i].subMenus[j].menuTitle +"</a></div>";
                }
			}
			menutext += "</div>"
		}
		else
			menutext += "&nbsp;";
		menutext += "</td>";
	}
	menutext += "</tr></div>";
	document.write(menutext);
}
