﻿/* 
    creates a relation between two or three menuitems
*/
function CreateRelation(menuitemId, parentId, ownerId)
{
    var menuitem = Menuitems[menuitemId]; if (menuitem == null) return;
    var parent = Menuitems[parentId]; if (parent == null) return;
    
    if (parent.Children == null) parent.Children = new Array();
    parent.Children.push(menuitem);
    menuitem.Parent = parent;
    
    if (ownerId != null){
        var owner = Menuitems[ownerId];
        menuitem.Owner = owner;
    }
}

if (window.Hierarchy == null) InitHierarchy();