function MenuData() {

  this.Stack = function() {
    var stackArray = [ ];

    function StackUnit(node, action) {
      this.node = node;
      this.action = action;
    }

    this.stackArray = stackArray;

    this.put = function (node, action) {
      stackArray[stackArray.length] = new StackUnit(node, action);
    }
    this.clear = function (stopNode) {
      for (var i = stackArray.length - 1; i > -1 && stackArray[i].node != stopNode; stackArray[i--].action());
      stackArray.length = ++i;
    }
    this.isPresent = function (node) {
      for (var i = stackArray.length - 1; i > -1 && stackArray[i].node != node; --i);
      return ++i;
    }
  }

  this.Node = function(nodeData, parentNode) {
    var context = this,
        childNodes = [ ],
        i = parentNode ? parentNode.childNodes.length - 1 : -1,
        Node = this.constructor;

    if (i > -1) {
      (this.previousSibling = parentNode.childNodes[i]).nextSibling = this;
    }
    else {
      this.previousSibling = null;
    }

    this.nextSibling = null;

    this.parentNode = parentNode;
    this.childNodes = childNodes;
    this.data = nodeData;
    this.runtimeData = { };

    this.addChildNode = function (nodeData) {
      return childNodes[childNodes.length] = new Node(nodeData, context);
    }
    this.implement = function (Implementation) {
      return context.implementation = new Implementation(context);
    }
  }

}

var menuData = new MenuData();

/* -- User data types -- */

function MenuDataTypes() {

  this.HostMenu = function (baseZIndex) {
    this.baseZIndex = baseZIndex; // Next free zIndex is baseZIndex + 4
    this.hideDelay = 1000;
  }

  this.HostItem = function (id) {
    this.id = id;
    this.childMenuPosition = {
      h: "near", // near | middle | far
      v: "near",
      hParent: "near",
      vParent: "far",
      hOffset: 0, // in px
      vOffset: 0,
      hOptimize: "offset", // none | offset | mirror
      vOptimize: "none"
    }
  }

  this.Menu = function () {
    this.dir = "v"; // menu direction (one under another items), affects kb navigation
  }

  this.Item = function (itemHtml, href, target) {
    this.itemHtml = itemHtml;
    this.href = href == undefined ? "#" : href;
    this.target = target == undefined ? "" : " target='" + target + "'";
    this.childMenuPosition = {
      h: "near", // near | middle | far
      v: "near",
      hParent: "far",
      vParent: "near",
      hOffset: 0, // in px
      vOffset: 0,
      hOptimize: "mirror", // none | offset | mirror
      vOptimize: "offset"
    }
  }

}

var menuDataTypes = new MenuDataTypes();

/* -- End of user data types -- */

var navMenu = new menuData.Node(new menuDataTypes.HostMenu());

with (navMenu) {
  with (addChildNode(new menuDataTypes.HostItem('m2Company'))) {
    with (addChildNode(new menuDataTypes.Menu())) {
//      addChildNode(new menuDataTypes.Item('Corporate', '/company/corporate.htm'));
    }
  }
  with (addChildNode(new menuDataTypes.HostItem('m2Reels'))) {
    with (addChildNode(new menuDataTypes.Menu())) {
      addChildNode(new menuDataTypes.Item('Spokesperson', 'spokesperson.html'));
      addChildNode(new menuDataTypes.Item('Commercials', 'commercials.html'));
      addChildNode(new menuDataTypes.Item('Movies', 'movies.html'));
    }
  }
}
