﻿
function MenuContainer() {
	this.arrMenus = new Array();
	this.init();
}

MenuContainer.prototype.isInRightMenu					= MenuContainer_isInRightMenu;
MenuContainer.prototype.combinationExists				= MenuContainer_combinationExists;
MenuContainer.prototype.getAncestorDocument				= MenuContainer_getAncestorDocument;
MenuContainer.prototype.getAncestorMenuItem				= MenuContainer_getAncestorMenuItem;
MenuContainer.prototype.init							= MenuContainer_init;

// this function detects whether a menuitem, document combination exists in the right menu of a parent menuitem, document combination
// the child combination is given as a parameter
function MenuContainer_isInRightMenu(intMenuItemID, intDocumentID) {
	// this.arrMenus is an index of child (document id, menuitem id) mapped to the ancestor (document id, menuitem id) 	
	return this.getAncestorMenuItem(intMenuItemID, intDocumentID) != -1;
}

// get the ancestor document id which contains this menuitem, document combination in the right menu
function MenuContainer_getAncestorDocument(intMenuItemID, intDocumentID) {
	if (this.combinationExists(intMenuItemID, intDocumentID)) {
		return (this.arrMenus[intMenuItemID][intDocumentID][0]).intDocumentID;
	}
	return -1;
}

// get the ancestor menuitem id which contains this menuitem, document combination in the right menu
function MenuContainer_getAncestorMenuItem(intMenuItemID, intDocumentID) {
	if (this.combinationExists(intMenuItemID, intDocumentID)) {
		return (this.arrMenus[intMenuItemID][intDocumentID][0]).intMenuItemID;
	}
	return -1;
}

function MenuContainer_combinationExists(intMenuItemID, intDocumentID) {
	return (typeof(this.arrMenus[intMenuItemID]) != "undefined" && this.arrMenus[intMenuItemID].length > 0) &&
			(typeof(this.arrMenus[intMenuItemID][intDocumentID]) != "undefined" && this.arrMenus[intMenuItemID][intDocumentID].length > 0);
}

function MenuContainer_init() {
	var objParentCombination = null;
	
}

