private void SetMenu()
		{
			ITATMenuGroup menuGroup;
			Type currentPageType = this.Page.GetType();
			//string pageFileName = GetPageBaseFileName();
			string urlQueryString;
			if (TemplatePage.Template.IsManagedItem)
			{
				ManagedItem managedItem = TemplatePage.Template as ManagedItem;
				urlQueryString = Utility.TextHelper.QueryString(true,
					Common.Names._QS_MANAGED_ITEM_ID, managedItem.ManagedItemID.ToString(),
					Common.Names._QS_ITAT_SYSTEM_ID, this.TemplatePage.ITATSystem.ID.ToString(), 
					Common.Names._QS_TEMPLATE_ID, this.TemplatePage.Template.ID.ToString());
			}
			else
				urlQueryString = Utility.TextHelper.QueryString(true, Common.Names._QS_ITAT_SYSTEM_ID, this.TemplatePage.ITATSystem.ID.ToString(), Common.Names._QS_TEMPLATE_ID, this.TemplatePage.Template.ID.ToString());

			menuGroup = new ITATMenuGroup(menu, "Content", "", 100, 100, true);


            //2011 changes - Multiple documents
            if (TemplatePage.Template.CanGenerateUserDocuments)
                menuGroup.Controls.Add(new ITATMenuItem(menuGroup.Caption, "Documents", "~/TemplateDocuments.aspx" + urlQueryString, this.menuLink_Command, this.Page is TemplateDocuments));                
            else
                menuGroup.Controls.Add(new ITATMenuItem(menuGroup.Caption, "Clauses", "~/TemplateClauses.aspx" + urlQueryString, this.menuLink_Command, this.Page is TemplateClauses));
                

            if (TemplatePage.Template.CanGenerateDocument)
			    menuGroup.Controls.Add(new ITATMenuItem(menuGroup.Caption, "Extensions", "~/TemplateExtensions.aspx" + urlQueryString, this.menuLink_Command, this.Page is TemplateExtensions));

			menuGroup = new ITATMenuGroup(menu, "Tracking", "", 100, 100, true);
			menuGroup.Controls.Add(new ITATMenuItem(menuGroup.Caption, "Workflows", "~/TemplateWorkflows.aspx" + urlQueryString, this.menuLink_Command, this.Page is TemplateWorkflowMain));
			menuGroup.Controls.Add(new ITATMenuItem(menuGroup.Caption, "Notifications", "~/TemplateNotifications.aspx" + urlQueryString, this.menuLink_Command, this.Page is TemplateNotifications));

			menuGroup = new ITATMenuGroup(menu, "Template", "", 110, 100, true);
			if (TemplatePage.Template.IsManagedItem)
				menuGroup.Controls.Add(new ITATMenuItem(menuGroup.Caption, TemplatePage.ITATSystem.ManagedItemName, "~/ManagedItemProfile.aspx" + urlQueryString, this.menuLink_Command, this.Page is TemplateMain));
			else
				menuGroup.Controls.Add(new ITATMenuItem(menuGroup.Caption, "Main", "~/TemplateMain.aspx" + urlQueryString, this.menuLink_Command, this.Page is TemplateMain));
			menuGroup.Controls.Add(new ITATMenuItem(menuGroup.Caption, "Terms", "~/TemplateTerms.aspx" + urlQueryString, this.menuLink_Command, this.Page is TemplateTerms));
            menuGroup.Controls.Add(new ITATMenuItem(menuGroup.Caption, "Dependencies", "~/TemplateTermDependencies.aspx" + urlQueryString, this.menuLink_Command, this.Page is TemplateTermDependencies));

            ITATMenuItem complexListMenuItem = new ITATMenuItem(menuGroup.Caption, "Complex Lists", "~/TemplateComplexLists.aspx" + urlQueryString, this.menuLink_Command, this.Page is TemplateComplexLists);
            menuGroup.Controls.Add(complexListMenuItem);

            

            ITATMenuItem historyMenuItem = null;
            if (!TemplatePage.Template.IsManagedItem && TemplatePage.ITATSystem.UserIsInRole(Business.XMLNames._AF_RetroAdmin))
            {
                historyMenuItem = new ITATMenuItem(menuGroup.Caption, "History", "~/TemplateRollback.aspx" + urlQueryString, this.menuLink_Command, this.Page is TemplateRollback);
                menuGroup.Controls.Add(historyMenuItem);
            }

            //Set the border only if Retro History is shown
            if (historyMenuItem != null)
            {
                complexListMenuItem.CssClass = "menuLink menuLinkSeparator";
            }


            
		}
		private void SetMenu()
		{
			if (HideMenu)
			{
				return;
			}

			ITATMenuGroup menuGroup1, menuGroup2;
			Type currentPageType = this.Page.GetType();
			string itemName = ManagedItemPage.ITATSystem.ManagedItemName;
			string systemID = ManagedItemPage.ITATSystem.ID.ToString();

			string urlQueryString = Utility.TextHelper.QueryString(
				true,
				Common.Names._QS_ITAT_SYSTEM_ID,
				this.ManagedItemPage.ITATSystem.ID.ToString(),
				Common.Names._QS_MANAGED_ITEM_ID,
				this.ManagedItemPage.ManagedItem.ManagedItemID.ToString()
				);

			//*** IMPORTANT: *** 
			//    Since the menu groups have a style of "float:right", 
			//    they are listed here in order from RIGHT TO LEFT
			//******************
			menuGroup1 = new ITATMenuGroup(menu, "View/Print", "", 130, 130, true);


			bool bDocumentPrinter = Utility.ListHelper.HaveAMatch(ManagedItemPage.ManagedItem.DocumentPrinters.ConvertAll<string>(Role.StringConverter), ManagedItemPage.SecurityHelper.UserRoles);
			bool bAdminViewer = Utility.ListHelper.HaveAMatch(ManagedItemPage.ITATSystem.AllowedRoles(Business.XMLNames._AF_AdminViewer), ManagedItemPage.SecurityHelper.UserRoles);
            bool bUserDocumentPrinter = Utility.ListHelper.HaveAMatch(ManagedItemPage.ManagedItem.UserDocumentPrinters.ConvertAll<string>(Role.StringConverter), ManagedItemPage.SecurityHelper.UserRoles);
            ITATMenuItem documentLink = null;

            //System Document
			if (ManagedItemPage.ManagedItem.CanGenerateDocument && (bDocumentPrinter || bAdminViewer))
			{                
                ITATDocument defaultDocument = ManagedItemPage.ManagedItem.GetDefaultITATDocument();
                if (defaultDocument != null)
                {
                    string urlViewPrintManagedItem = "~/DocumentDialog.aspx" + Utility.TextHelper.QueryString(true, Common.Names._QS_DOC_DLG_ACTION, Common.Names._QS_DOC_DLG_ACTION_VIEW, Common.Names._QS_MANAGED_ITEM_ID, this.ManagedItemPage.ManagedItem.ManagedItemID.ToString(), Common.Names._QS_ITAT_SYSTEM_ID, systemID, Common.Names._QS_ITAT_DOCUMENT_ID, defaultDocument.ITATDocumentID.ToString());
                    documentLink = new ITATMenuItem(menuGroup1.Caption, itemName, urlViewPrintManagedItem, this.menuLink_Command, this.Page == null, true);
                    menuGroup1.Controls.Add(documentLink);
                }
			}



            //User Documents
            if (ManagedItemPage.ManagedItem.CanGenerateUserDocuments && (bUserDocumentPrinter || bAdminViewer))
            {
                List<ITATDocument> userDocuments = ManagedItemPage.ManagedItem.Documents.FindAll(delegate(ITATDocument d) { return d.DefaultDocument==false; });

                foreach (ITATDocument document in userDocuments)
                {
                    string urlViewPrintManagedItem = "~/DocumentDialog.aspx" + Utility.TextHelper.QueryString(true, Common.Names._QS_DOC_DLG_ACTION, Common.Names._QS_DOC_DLG_ACTION_VIEW, Common.Names._QS_MANAGED_ITEM_ID, this.ManagedItemPage.ManagedItem.ManagedItemID.ToString(), Common.Names._QS_ITAT_SYSTEM_ID, systemID, Common.Names._QS_ITAT_DOCUMENT_ID, document.ITATDocumentID.ToString());
                    documentLink = new ITATMenuItem(menuGroup1.Caption, document.DocumentName, urlViewPrintManagedItem, this.menuLink_Command, this.Page == null, true);
                    menuGroup1.Controls.Add(documentLink);
                }
            }


            //Add a seperator style after the last document link.
            if (documentLink != null)
                documentLink.CssClass = "menuLink menuLinkSeparator";


			if (ManagedItemPage.ITATSystem.TrackAudit ?? false)
				menuGroup1.Controls.Add(new ITATMenuItem(menuGroup1.Caption, "History", "~/ManagedItemHistory.aspx" + urlQueryString, this.menuLink_Command, this.Page == null));

			//Item Rollback
			if (ManagedItemPage.ITATSystem.UserIsInRole(Business.XMLNames._AF_RetroAdmin))
			{
				menuGroup1.Controls.Add(new ITATMenuItem(menuGroup1.Caption, string.Format("{0} Rollback", ManagedItemPage.ITATSystem.ManagedItemName), "~/ManagedItemRollback.aspx" + urlQueryString, this.menuLink_Command, this.Page == null));
			}

			string urlViewPrintSummary = "~/DocumentDialog.aspx" + Utility.TextHelper.QueryString(true, Common.Names._QS_DOC_DLG_ACTION, Common.Names._QS_DOC_DLG_ACTION_SUMMARY, Common.Names._QS_MANAGED_ITEM_ID, this.ManagedItemPage.ManagedItem.ManagedItemID.ToString(), Common.Names._QS_ITAT_SYSTEM_ID, systemID);
			menuGroup1.Controls.Add(new ITATMenuItem(menuGroup1.Caption, "Summary", urlViewPrintSummary, this.menuLink_Command, this.Page == null, true));

			if ((Utility.ListHelper.HaveAMatch(ManagedItemPage.ITATSystem.AllowedRoles(Business.XMLNames._AF_EditLanguage), ManagedItemPage.SecurityHelper.UserRoles)))
			{
				bool displayEditLanguage = true;
				if (ManagedItemPage.ITATSystem.AllowRetro)
				{
					if (ManagedItemPage.ManagedItem.RetroModel == Retro.RetroModel.OnWithoutEditLanguage)
					{
						displayEditLanguage = false;
					}
				}
				if (displayEditLanguage)
				{
                    //TODO: If this MI could be Orphaned, should warn the user that a 'Save' will Orphan it
                    bool couldBeOrphaned = !ManagedItemPage.ManagedItem.IsOrphaned && ManagedItemPage.ManagedItem.RetroModel == Retro.RetroModel.OnWithEditLanguage;
					string urlQueryString2 = Utility.TextHelper.QueryString(true, Common.Names._QS_ITAT_SYSTEM_ID, this.ManagedItemPage.ITATSystem.ID.ToString(), Common.Names._QS_MANAGED_ITEM_ID, this.ManagedItemPage.ManagedItem.ManagedItemID.ToString());
					menuGroup1.Controls.Add(new ITATMenuItem(menuGroup1.Caption, "Edit Language", "~/TemplateTerms.aspx" + urlQueryString2, this.menuLink_Command, this.Page == null));
				}
			}

			menuGroup2 = new ITATMenuGroup(menu, itemName, "", 130, 130, true);
			ITATMenuItem mostRecentItem = null;
			if (ManagedItemPage.ManagedItem.SecurityModel == SecurityModel.Advanced)
			{
				if (ManagedItemPage.ManagedItem.TermGroups != null)
				{
					foreach (TermGroup tg in ManagedItemPage.ManagedItem.GetTermGroups(TermGroup.TermGroupType.AdvancedBasicTerm))
					{
						if (ManagedItemPage.ManagedItem.CanAccessTermGroup(tg, ManagedItemPage.SecurityHelper.UserRoles))
						{
							if (ManagedItemPage is ManagedItemProfile)
							{
								mostRecentItem = new ITATMenuItem(menuGroup2.Caption, tg.Name, "", null, false);
								mostRecentItem.Attributes["onclick"] = string.Format("javascript:DisplayTermGroup('{0}', '{1}')", tg.ID, tg.Name);
							}
							else
							{
								string linkUrl = string.Format("~/ManagedItemProfile.aspx{0}&{1}={2}", urlQueryString, Common.Names._QS_MANAGED_ITEM_TERMGROUP, tg.ID);
								mostRecentItem = new ITATMenuItem(menuGroup2.Caption, tg.Name, linkUrl, null, false);
							}
							menuGroup2.Controls.Add(mostRecentItem);
						}
					}
				}
			}
			else
			{
				TermGroup tg = ManagedItemPage.ManagedItem.TermGroups[0];
				string linkUrl = string.Format("~/ManagedItemProfile.aspx{0}&{1}={2}", urlQueryString, Common.Names._QS_MANAGED_ITEM_TERMGROUP, tg.ID);
				mostRecentItem = new ITATMenuItem(menuGroup2.Caption, tg.Name, linkUrl, null, false);
				menuGroup2.Controls.Add(mostRecentItem);
			}
			//set thick border on last TermGroup menu item
			if (mostRecentItem != null)
			{
				mostRecentItem.CssClass = "menuLink menuLinkSeparator";
			}
			//add complex lists
			if (ManagedItemPage.ManagedItem.ComplexLists != null)
			{
				foreach (Business.ComplexList complexList in ManagedItemPage.ManagedItem.ComplexLists)
				{
					if (ManagedItemPage.ManagedItem.CanAccessTermGroup(complexList.TermGroupID, ManagedItemPage.SecurityHelper.UserRoles))
					{
                        ITATMenuItem complexListMenuItem = new ITATMenuItem(menuGroup2.Caption, complexList.Name, string.Format("~/ManagedItemComplexList.aspx{0}&list={1}", urlQueryString, complexList.Name), this.menuLink_Command, this.Page == null);
						menuGroup2.Controls.Add(complexListMenuItem);
					}
				}
			}
		}