function menuItem() {
  this.disabled = false;
  this.group = String("");
  this.html = String("");
  this.href = String("javascript:void(0)");
  this.icon = String("menulinkimagefile");
  this.target = String("_self");
  this.text = String("unnamed menuItem");
}

function menu(name) {
  this.name = name;
  if ( name != null ) eval(name+" = this;");
  this.isOffset = false;
  if ( name != null ) this.isOffset = true;
  this.width = "150px";
  this.useFX = true;
  this.useFX2 = true;
  this.count = Number(0);
  this.clickOnly = false;
  this.text = String("unnamed menu");
  this.href = String("");
  this.target = String("_self");
  this.html = String("");
  this.icon = String("menulinkimagefolder");
  this.group = String("");
  this.items = Array();
  this.path = Array(this);
  this.pathNames = Array(this.name);
  this.position = Number(0);
  this.add = _add;
  this.serialize = _serialize;
  this.getLink = _get_link;
  this.render = _render;
  this.getMenuById = _get_menu_by_id;
  this.showMenu = _show_menu;
  this.hideMenu = _hide_menu;
  this.showMenuById = _show_menu_by_id;
  this.hideMenuById = _hide_menu_by_id;
  this.disabled = false;
  this.hideDisabled = false;
  this.getPath = _get_path;
  this.registerEvent = _register_event;
  this.clearWorkspace = _clear_workspace;

  this.styleOffsetTop = Number(6);
  this.styleOffsetRight = Number(6);
  this.styleOffsetLeft = Number(6);
  this.styleOffsetBottom = Number(22);

  this.selectedSkin = new String('default');

  var body = document.getElementsByTagName('body')[0];
  body.style.height = "100%";

  var menuHTML = this.html;

  function _register_event(that) {
    if ( that == null ) that = this;
    // .attachEvent for IE only
    if (body.attachEvent)      body.attachEvent('onclick', function(event) { that.clearWorkspace(event) });
    // .addEventListener for all other browsers
    if (body.addEventListener) body.addEventListener('click', function(event) { that.clearWorkspace(event) }, false);
  }

  function _clear_workspace(event) {
    if ( event == null ) { this.hideMenu(); return true; };
    if ( window.event ) {
      event = window.event;
      if (event.srcElement.getAttribute('menuItem') != 'true' ) {
        this.hideMenu();
        if ( document.getElementById('menuhelper') ) document.getElementById('menuhelper').style.display='none';
      }
    } else {
      if (event.target.getAttribute('menuItem') == null ) {
        this.hideMenu();
        if ( document.getElementById('menuhelper') ) document.getElementById('menuhelper').style.display='none';
      }
    }
    return true;
  }

  function _render(that) {
    // rendert das menu und returned es als html code...
    var init = false;
    if ( that == null ) {
      that = this;
      init = true;
    }

    var previousGroup = "";

    if ( init == true ) {
      // namen erzeugen...
      that.serialize();
      menuHTML += "<div class='menucontainer' id='"+that.name+"' style='width:"+that.width+";'>";
    } else {
      menuHTML += "<div class='menucontainer_sub' id='"+that.name+"' style='width:"+that.width+";'>";
    }

    //  links und menus rendern
    for ( var i=0; i<that.items.length; i++ ) {
      if ( i==0 ) menuHTML += _menu_lead_in(that);
      //if ( that.items[i] instanceof menu && that.items[i].disabled != true ) _render(that.items[i]);

      // gruppierungen rendern
      if ( that.items[i].group.length > 0 && that.items[i].group != previousGroup ) {
        if ( previousGroup == "" ) { menuHTML += "<div class=menugroup>"; } else { menuHTML += "<div class=menugroup_adjacent>"; }
      }
      if ( previousGroup != "" && that.items[i].group != previousGroup ) menuHTML += "</div>";
      menuHTML += that.getLink(that.items[i]);
      previousGroup = that.items[i].group;
      if ( i==(that.items.length-1) ) menuHTML += _menu_lead_out(that);
    }

    for ( var i=0; i<that.items.length; i++ ) {
      if ( that.items[i] instanceof menu && that.items[i].disabled != true ) _render(that.items[i]);
    }

    menuHTML += "</div>";
    if ( init == true) {
      _register_event(that);
      that.html = menuHTML;
      return that;
    }
  }

  function _get_link(item) {
    // erzeugt einen Link zum menu/menuItem
    if ( item.disabled == true && item.parent.path[0].hideDisabled == true ) return "";

    var itemID = '';
    var link = new String("");
    if ( item instanceof menuItem ) {
      if ( item.html.length > 0 ) return item.html;
      if ( item.disabled == true && item.parent.path[0].hideDisabled == false ) return "<a onMouseover=\"window.status='';return true;\" href=\"javascript:void(0)\" id="+item.parent.getPath(item)+" onFocus='this.blur()' class=\"menulink menulink_disabled\" name=menulink><div menuItem class=menulinkdiv><div menuItem=true class=\"" + item.icon + "\" id="+item.parent.getPath(item)+"_text>" + item.text + "</div></div></a>";
      if ( item.parent.path[0].clickOnly == false  ) {
        link = "<a xonMouseup=\""+item.parent.path[0].name+".clearWorkspace()\" xonMouseover=\""+item.parent.path[0].name+".showMenuById('"+item.parent.name+"');window.status='';return true;\" target=\""+item.target+"\" href=\""+item.href+"\" id="+item.parent.getPath(item)+" class=\"menulink\" name=menulink><div class=menulinkdiv><div class=\"" + item.icon + "\" id="+item.parent.getPath(item)+"_text>" + item.text + "</div></div></a>";
      } else {
        // clickOnly link...
        link = "<a onMouseover=\"window.status='';return true;\" onMouseup=\""+item.parent.path[0].name+".hideMenu()\" target=\""+item.target+"\" href=\""+item.href+ "\" id="+item.parent.getPath(item)+" class=\"menulink\" name=menulink><div class=menulinkdiv><div class=\"" + item.icon + "\" id="+item.parent.getPath(item)+"_text>" + item.text + "</div></div></a>";
      }
    } else if ( item instanceof menu ) {
      if ( item.disabled == true && item.parent.path[0].hideDisabled == false ) return "<a onMouseover=\"window.status='';return true;\" href=\"javascript:void(0)\" id="+item.parent.getPath(item)+" onFocus='this.blur()' class=\"menulink menulink_disabled\" name=menulink><div menuItem=true class=menulinkdiv><div menuItem class=\"" + item.icon + "\" id="+item.parent.getPath(item)+"_text>" + item.text + "</div></div></a>";
      if ( item.href.length > 0 && item.path[0].clickOnly == false  ) {
        link = "<a onMouseover=\""+item.path[0].name+".showMenuById('"+item.name+"');window.status='';return true;\" target=\""+item.target+"\" href=\""+item.href+"\" id="+item.parent.getPath(item)+" class=\"menulink menulink_submenu\" name=menulink><div menuItem=true class=menulinkdiv><div menuItem class=\"" + item.icon + "\" id="+item.parent.getPath(item)+"_text>" + item.text + "</div></div></a>";
      } else {
        if ( item.path[0].clickOnly == true ) {
          // clickOnly link...
          link = "<a menuItem=true onMouseover=\"window.status='';return true;\" onMousedown=\""+item.path[0].name+".showMenuById('"+item.name+"')\" href=\"javascript:void(0)\" id="+item.parent.getPath(item)+" class=\"menulink menulink_submenu\" name=menulink><div menuItem=true class=menulinkdiv><div menuItem=true class=\"" + item.icon + "\" id="+item.parent.getPath(item)+"_text>" + item.text + "</div></div></a>";
        } else {
          link = "<a menuItem=true onMouseover=\""+item.path[0].name+".showMenuById('"+item.name+"');window.status='';return true;\" target=\""+item.target+"\" href=\"javascript:void(0)\" id="+item.parent.getPath(item)+" class=\"menulink menulink_submenu\" name=menulink><div class=menulinkdiv><div menuItem=true class=\"" + item.icon + "\" id="+item.parent.getPath(item)+"_text>" + item.text + "</div></div></a>";
        }
      }
    } else {
      link = "[ERROR]";
    }
    return link;
  }


  function _get_menu_by_id(menuid) {
    // ermittelt ein menu über die id
    if ( this.name == menuid ) return this;
    var target;
    for ( var i=0; i<this.items.length; i++ ) {
      if ( this.items[i] instanceof menu ) {
        if ( this.items[i].name != menuid ) {
          target = this.items[i].getMenuById(menuid);
          if ( target instanceof menu && target.name == menuid ) return target;
        } else {
          return this.items[i];
        }
      }
    }
    return false;
  }

  function _get_path(itemobj) {
    var path = this.path[0].name;
    for ( var i=1; i<this.path.length; i++ ) {
      switch(i) {
        default: path += ".items["+this.path[i].id+"]";break;
      }
    }
    if ( itemobj != null ) path += ".items["+itemobj.id+"]";
    return path;
  }

  function _show_menu(menuobj) {
    if ( menuobj == null ) return false;

    if ( ! document.getElementById('menuhelper') ) {
      var newDiv = document.createElement('div');
      newDiv.id = 'menuhelper';
      newDiv.style.position = "absolute";
      newDiv.style.width = "100%";
      newDiv.style.height = "100%";
      newDiv.style.top = 0;
      newDiv.style.left = 0;
      newDiv.style.backgroundImage = 'url(images/10pxtrans.gif)';
      newDiv.style.display = "block";
      newDiv.style.zIndex = 999;
      newDiv.setAttribute('currentMenu', menuobj.path[0].name);
      body.appendChild(newDiv);
    } else {
      newDiv = document.getElementById('menuhelper');
      if ( newDiv.getAttribute('currentMenu').length > 0 ) if ( newDiv.getAttribute('currentMenu') != menuobj.path[0].name ) try { eval(newDiv.getAttribute('currentMenu')+".clearWorkspace();"); } catch(e){ alert("ERROR: "+e.message+"\nFILE: "+e.fileName+"\nLINE: "+e.lineNumber+"\nSTACK: "+e.stack+"\nNAME: "+e.name)};
      newDiv.setAttribute('currentMenu', menuobj.path[0].name);
      document.getElementById('menuhelper').style.display = 'block';
    }

    // for IE hide possibly disturbing <select>'s in UpApplication.UpAppMain
    if ( document.all && navigator.appVersion.indexOf("MSIE 6") > 0 && UpApplication.UpAppMain) {
      for ( var i=0; i < UpApplication.UpAppMain.document.getElementsByTagName("select").length; i++ ) {
        UpApplication.UpAppMain.document.getElementsByTagName("select")[i].style.visibility = "hidden";
      }
    }

    if ( menuobj.path[0].current != null ) {
      if ( menuobj.path[0].current.name != menuobj.name ) _hide_menu(menuobj);
      menuobj.path[0].current = menuobj;
    }

    for ( var i=0; i<menuobj.path.length; i++ ) {
      if ( menuobj.name != menuobj.path[i].name && i<(menuobj.path.length-2) ) {
        document.getElementById(menuobj.path[i].name+"_table").className = "menutable menu_blur";
      } else {
        document.getElementById(menuobj.path[i].name+"_table").className = "menutable";
      }
      if ( document.getElementById(menuobj.path[i].name).style.display != 'block' ) {
        _open(menuobj.path[i]);
        _fade_in(menuobj.path[i]);
        _fly_in(menuobj.path[i]);
      }
    }
    menuobj.path[0].current = menuobj;
    return true;
  }

  function _hide_menu(menuobj) {
    if ( menuobj != null ) {
      document.getElementById('menuhelper').setAttribute('currentMenu', '')
      // schliesst den current pfad _differentiell_ zum menuobj!
      // menuobj ist _NICHT_ das menu das geschlossen werden soll
      for ( var i=menuobj.path[0].current.path.length-1; i>=0; i-- ) {
        if ( i>=menuobj.path.length ) {
          _close(menuobj.path[0].current.path[i]);
        } else {
          if ( menuobj.path[i].name != menuobj.path[0].current.path[i].name ) {
            _close(menuobj.path[0].current.path[i]);
          } else {
            break;
          }
        }
      }
      return true;
    } else {
      // kein ziel, jetzt schliessen wir alles...
      if ( this.current == null ) return true;
      for ( var i=this.current.path.length-1; i>-1; i-- ) {
        _close(this.current.path[i]);
      }

      // in IE 6 make <select>'s visible again
      if ( document.all && navigator.appVersion.indexOf("MSIE 7") == -1 && UpApplication.UpAppMain) {
        for ( var i=0; i < UpApplication.UpAppMain.document.getElementsByTagName("select").length; i++ ) {
          UpApplication.UpAppMain.document.getElementsByTagName("select")[i].style.visibility = "";
        }
      }

      //this.current = this;
      return true;
    }
  }

  function _show_menu_by_id(menuid) {
    //_show_menu(this.getMenuById(menuid));
    this.showMenu(this.getMenuById(menuid));
  }

  function _hide_menu_by_id(menuid) {
    this.hideMenu(this.getMenuById(menuid));
  }

  function _close(menuobj) {
    if ( menuobj.disabled == true ) return false;
    _fade_out(menuobj);
    _fly_out(menuobj);
    return true;
  }

  function _fade_in(menuobj) {
    var fadeMenu = document.getElementById(menuobj.name);

    if ( menuobj.path[0].useFX == false ) {
      fadeMenu.style.visibility = "visible";
      return false;
    }
    var fullX = fadeMenu.offsetWidth;
    var fullY = fadeMenu.offsetHeight;

    var time = 0;
    var command = "void(0)";

    document.getElementById(menuobj.name+"_fade").style.clip = "rect(0 0 0 0)";
    fadeMenu.style.visibility = "visible";

    if ( Math.random() <= 0.25 ) {
    // fade left -> right...
      for ( var x=1; x<11; x++ ) {
        time = (x*15)+1;
        command = "document.getElementById('"+menuobj.name+"_fade').style.clip='rect(0px "+((fullX/10)*x)+" "+fullY+" 0px)'";
        if ( x == 10 ) command = "document.getElementById('"+menuobj.name+"_fade').style.clip='rect(auto auto auto auto)';";
        window.setTimeout(command,time);
      }
    } else if ( Math.random() <= 0.5 ) {
      // fade top -> bottom...
      for ( var x=1; x<11; x++ ) {
        time = (x*15)+1;
        command = "document.getElementById('"+menuobj.name+"_fade').style.clip='rect(0px "+fullX+" "+((fullY/10)*x)+" 0px)'";
        if ( x == 10 ) command = "document.getElementById('"+menuobj.name+"_fade').style.clip='rect(auto auto auto auto)';";
        window.setTimeout(command,time);
      }
    } else if ( Math.random() <= 0.75 ) {
      // fade diagonal left top -> right bottom...
      for ( var x=1; x<11; x++ ) {
        time = (x*15)+1;
        command = "document.getElementById('"+menuobj.name+"_fade').style.clip='rect(0px "+((fullX/10)*x)+" "+((fullY/10)*x)+" 0px)'";
        if ( x == 10 ) command = "document.getElementById('"+menuobj.name+"_fade').style.clip='rect(auto auto auto auto)';";
        window.setTimeout(command,time);
      }
    } else {
      // fade inside -> out...
      var y=0;
      for ( var x=10; x>0; x-- ) {
        y++
        time = (y*15)+1;
        command = "document.getElementById('"+menuobj.name+"_fade').style.clip='rect("+parseInt((fullY/10)*x)+"px "+parseInt((fullX/10)*y)+"px "+parseInt((fullY/10)*y)+"px "+parseInt((fullX/10)*x)+"px)'";
        if ( x == 1 || y == 10 ) { command = "document.getElementById('"+menuobj.name+"_fade').style.clip='rect(auto auto auto auto)'"; }
        window.setTimeout(command,time);
      }
    }
    return true;
  }

  function _fade_out(menuobj) {
    var fadeMenu = document.getElementById(menuobj.name);
    if ( menuobj.path[0].useFX == false ) {
      if ( menuobj.path[0].useFX2 == false ) fadeMenu.style.visibility = "hidden";
      return false;
    }
    return true;
  }

  function _fly_in(menuobj) {
    if ( menuobj.name != menuobj.path[menuobj.path.length-1].name ) return false;
    var fadeMenu = document.getElementById(menuobj.name);

    if ( menuobj.path[0].useFX2 == false ) {
      fadeMenu.style.opacity = "1";
      return false;
    }

    var body = document.getElementsByTagName('body')[0];

    var targetX = parseInt(fadeMenu.style.left,10);
    var targetY = parseInt(fadeMenu.style.top,10);

    if ( ! targetY ) targetY = 0;
    if ( ! targetX ) targetX = 0;

    var offsetX = parseInt(body.offsetWidth*Math.random()+1)*-1;
    var offsetY = parseInt(body.offsetHeight*Math.random()+1)*-1;

    fadeMenu.style.left = targetX+offsetX;
    fadeMenu.style.top = targetY+offsetY;
    //fadeMenu.style.zIndex = 5;

    var flySteps = 80;
    var myStep = flySteps;
    for ( var i=0; i<flySteps; i++ ) {
      var time = (i*5)+0;
      myStep--;
      command = "document.getElementById('"+menuobj.name+"').style.top ='"+ parseInt(targetY+((offsetY)/flySteps)*myStep,10) +"';";
      command += "document.getElementById('"+menuobj.name+"').style.left ='"+ parseInt(targetX+((offsetX)/flySteps)*myStep,10) +"'";
      if ( i == flySteps-1 ) {
        command = "document.getElementById('"+menuobj.name+"').style.top ='"+ targetY +"';";
        command += "document.getElementById('"+menuobj.name+"').style.left ='"+ targetX +"'";
      }
      window.setTimeout(command,time);
    }

    fadeMenu.style.opacity = '0';
    var opacitySteps = 30;
    for ( var j=1; j<=opacitySteps; j++ ) {
      var time = (j*20)+200;
      command = "document.getElementById('"+menuobj.name+"').style.opacity ='"+j/opacitySteps+"';";
      window.setTimeout(command,time);
    }
    //fadeMenu.style.zIndex = 1;
    return true;
  }


  function _fly_out(menuobj) {
    if ( menuobj.name != menuobj.path[menuobj.path.length-1].name ) return false;
    var fadeMenu = document.getElementById(menuobj.name);

    if ( menuobj.path[0].useFX2 == false ) {
      fadeMenu.style.display = "none";
      fadeMenu.style.opacity = "1";
      return false;
    }

    var body = document.getElementsByTagName('body')[0];

    var targetX = parseInt(fadeMenu.style.left,10);
    var targetY = parseInt(fadeMenu.style.top,10);

    var offsetX = ((body.offsetWidth)*-1)*Math.random()+1;
    var offsetY = (body.offsetHeight*-1)*Math.random()+1;

    //fadeMenu.style.zIndex = 0;
    var flySteps = 20;
    var myStep = flySteps;
    for ( var i=0; i<=flySteps; i++ ) {
      var time = (i*25)+250;
      myStep--;
      command =  "document.getElementById('"+menuobj.name+"').style.top ='"+ parseInt(targetY+((offsetY)/flySteps)*i,10) +"';";
      command += "document.getElementById('"+menuobj.name+"').style.left ='"+ parseInt(targetY+((offsetX)/flySteps)*i,10) +"'";
      if ( i == flySteps ) {
        command =  "document.getElementById('"+menuobj.name+"').style.display='none';";
        command += "document.getElementById('"+menuobj.name+"').style.top ='"+ targetX +"';";
        command += "document.getElementById('"+menuobj.name+"').style.left ='"+ targetY +"'";
      }
      window.setTimeout(command,time);
    }

    fadeMenu.style.opacity = '1';
    var opacitySteps = 30;
    myStep = opacitySteps;
    for ( var j=1; j<=opacitySteps; j++ ) {
      var time = (j*20)+100;
      myStep--;
      command = "document.getElementById('"+menuobj.name+"').style.opacity ='"+myStep/opacitySteps+"';";
      window.setTimeout(command,time);
    }

    //fadeMenu.style.zIndex = 1;
    return true;
  }

  function _open(menuobj) {
    var styleOffsetTop    = 0;
    var styleOffsetRight  = 0;
    var styleOffsetLeft   = 0;
    var styleOffsetBottom = 0;

    if ( menuobj.name != menuobj.path[0].name ) {
      styleOffsetTop    = document.getElementById(menuobj.name+'_padding_top').offsetHeight+menuobj.path[0].styleOffsetTop;
      styleOffsetRight  = document.getElementById(menuobj.name+'_padding_right').offsetWidth+menuobj.path[0].styleOffsetRight;
      styleOffsetLeft   = document.getElementById(menuobj.name+'_padding_left').offsetWidth+menuobj.path[0].styleOffsetLeft;
      styleOffsetBottom = document.getElementById(menuobj.name+'_padding_bottom').offsetHeight+menuobj.path[0].styleOffsetBottom;
    }

    var body = document.getElementsByTagName('body')[0];

    var childMenu = document.getElementById(menuobj.name);
    childMenu.style.margin = '0';

    var childTable = document.getElementById(menuobj.name+'_table');
    var childContent = document.getElementById(menuobj.name+'_content');
    var childInnerContent = document.getElementById(menuobj.name+'_innercontent');
    if ( menuobj.parent != null ) {
      var parentMenu = document.getElementById(menuobj.parent.name);
    } else {
      var parentMenu = null;
    }

    var totalTop = 0-(styleOffsetBottom);
    var totalLeft = 0-(styleOffsetLeft);
    var myparent = parentMenu;

    childMenu.style.display='block';
    myHeight = childContent.offsetHeight.toString();
    childTable.style.height=myHeight;
    childMenu.style.height=myHeight;

    // beim rootmenü bis hierhin und nicht weiter...
    if ( menuobj.name == menuobj.path[0].name ) return false;

    // get total offset position
    while ( myparent != null ) {
      try {
        if ( myparent.tagName.toLowerCase() == 'body' ) break;
        totalLeft += (myparent.offsetLeft);
        totalTop += (myparent.offsetTop);
      } catch(e) { void(0) }
      myparent = myparent.offsetParent;
    }

    //if ( parentMenu != null ) totalLeft += (parentMenu.offsetWidth);
    totalLeft += (childMenu.offsetWidth);
    totalLeft += (childMenu.offsetWidth);
    totalTop  += (childMenu.offsetTop)+(childMenu.offsetHeight);
  
  
    var position = 0;
    var dirY = true;
    var dirX = true;
  
    if ( totalTop-childMenu.offsetHeight > body.offsetHeight ) dirY = false;
    if ( totalTop > body.offsetHeight ) dirY = false;
    if ( totalTop < body.offsetHeight ) dirY = true;
    if ( totalTop-childMenu.offsetHeight < 0 ) dirY = false;
  
    if ( totalLeft > body.offsetWidth ) dirX = false;
    //if ( totalLeft-childMenu.offsetWidth < body.offsetWidth ) dirX = true;
    if ( totalLeft-childMenu.offsetWidth < 0 && dirX == false ) dirX = true;
  
    if ( dirX == true && dirY == true )   position = 0;
    if ( dirX == true && dirY == false )  position = 1;
    if ( dirX == false && dirY == true )  position = 2;
    if ( dirX == false && dirY == false ) position = 3;
  
    var offsetLink = document.getElementById(menuobj.getPath());
  //alert("offsetLink: "+offsetLink.innerHTML);
  //alert(position+"- dirX:"+dirX+" dirY:"+dirY+"\n\ntotalLeft:"+totalLeft+" / "+body.offsetWidth);
    switch (position) {
      case 0: // left to right bottom
  //alert(offsetLink.offsetTop +" - "+ styleOffsetTop);
        childMenu.style.top = offsetLink.offsetTop - styleOffsetTop;
        if ( parentMenu != null ) {
          childMenu.style.left = parentMenu.offsetWidth - styleOffsetLeft;
        } else {
          childMenu.style.left = 0-childInnerContent.offsetWidth - styleOffsetRight;
        }
      break;
  
      case 1: // left to right top
        childMenu.style.top = offsetLink.offsetTop-childInnerContent.offsetHeight + styleOffsetBottom;
        if ( parentMenu != null ) {
          childMenu.style.left = parentMenu.offsetWidth - styleOffsetLeft;
        } else {
          childMenu.style.left = 0-childInnerContent.offsetWidth - styleOffsetRight;
        }
      break;
  
      case 2: // right to left bottom
        childMenu.style.top = offsetLink.offsetTop - styleOffsetTop;
        childMenu.style.left = 0 - childMenu.offsetWidth + styleOffsetRight;
      break;
  
      case 3: // right to left top
        childMenu.style.top = offsetLink.offsetTop-childInnerContent.offsetHeight + styleOffsetBottom;
        childMenu.style.left = 0 - childMenu.offsetWidth + styleOffsetRight;
      break;
    }
    menuobj.position = position;
    return true;
  }

  function _serialize(that) {
    // vergibt jedem submenu einen eindeutigen namen
    if ( that == null ) that = this;
    for ( var i=0; i<that.items.length; i++ ) {
      that.items[i].id = i;
      if ( that.items[i] instanceof menuItem && that.items[i].disabled != true ) {
        that.items[i].name = that.name + "." + that.count;
      }
      // wenn keine items im menu dann disablen
      if ( that.items[i] instanceof menu && that.items[i].items.length == 0 ) that.items[i].disabled = true;
      if ( that.items[i] instanceof menu && that.items[i].disabled != true ) {
        that.count++;
        that.items[i].name = that.name.toString() + "." + that.count.toString();
        that.items[i].path = that.path.concat(new Array(that.items[i]));
        _serialize(that.items[i]);
      }
    }
    return true;
  }

  function _add(item) {
    // fügt ein menu/menuItem einem menu hinzu
    var i = this.items.length;
    item.parent = this;
    this.items[i] = item;
    return this.items[i];
  }

  function _menu_lead_in(menu) {
    // anfang des html konstrukts
    var leadIn = new String();
    leadIn += "      <div menuItem class=menufade id='"+menu.name+"_fade"+"'>";
    leadIn += "      <table menuItem class=menutable id='"+menu.name+"_table"+"' cellpadding=0 cellspacing=0 border=0 style=\"\">";
    leadIn += "      <tr>";
    leadIn += "        <td menuItem class=menu_top_left><img src=\"images/10pxtrans.gif\" width=1 height=1></td>";
    leadIn += "        <td menuItem class=menu_top><img src=\"images/10pxtrans.gif\" width=1 height=1></td>";
    leadIn += "        <td menuItem class=menu_top_right><img src=\"images/10pxtrans.gif\" width=1 height=1></td>";
    leadIn += "      </tr>";
    leadIn += "      <tr>";
    leadIn += "        <td menuItem class=menu_mid_left><img src=\"images/10pxtrans.gif\" width=1 height=1></td>";
    leadIn += "        <td menuItem class=menu_mid id=menu2_content><img src=\"images/10pxtrans.gif\" width=1 height=1></td>";
    leadIn += "        <td menuItem class=menu_mid_right><img src=\"images/10pxtrans.gif\" width=1 height=1></td>";
    leadIn += "      </tr>";
    leadIn += "      <tr>";
    leadIn += "        <td menuItem class=menu_bot_left><img src=\"images/10pxtrans.gif\" width=1 height=1></td>";
    leadIn += "        <td menuItem class=menu_bot><img src=\"images/10pxtrans.gif\" width=1 height=1></td>";
    leadIn += "        <td menuItem class=menu_bot_right><img src=\"images/10pxtrans.gif\" width=1 height=1></td>";
    leadIn += "      </tr>";
    leadIn += "      </table>";
    leadIn += "      <div menuItem class=menucontent id='"+menu.name+"_content"+"'>";
    leadIn += "        <table menuItem class=menutable cellpadding=0 cellspacing=0 border=0>";
    leadIn += "        <tr>";
    leadIn += "          <td menuItem class=menupadding_top colspan=3 id='"+menu.name+"_padding_top"+"'><img src=\"images/10pxtrans.gif\" width=1 height=1></td>";
    leadIn += "        </tr>";
    leadIn += "        <tr>";
    leadIn += "          <td menuItem class=menupadding_left id='"+menu.name+"_padding_left"+"'><img src=\"images/10pxtrans.gif\" width=1 height=1></td>";
    leadIn += "          <td menuItem class=menupadding_content id='"+menu.name+"_innercontent"+"' valign=top>";
    return leadIn;
  }

  function _menu_lead_out(menu) {
    // abschluss des html konstrukts
    var leadOut = new String();
    leadOut += "          </td>";
    leadOut += "          <td menuItem class=menupadding_right id='"+menu.name+"_padding_right"+"'><img src=\"images/10pxtrans.gif\" width=1 height=1></td>";
    leadOut += "        </tr>";
    leadOut += "        <tr>";
    leadOut += "          <td menuItem class=menupadding_bot colspan=3 id='"+menu.name+"_padding_bottom"+"'><img src=\"images/10pxtrans.gif\" width=1 height=1></td>";
    leadOut += "        </tr>";
    leadOut += "        </table>";
    leadOut += "      </div>";
    leadOut += "      </div>";
    return leadOut;
  }
}

