<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" import="com.novell.emframe.dev.MUtils" %>
<!-- //File: browser/Launch.jsp -->
<%@ taglib uri="/WEB-INF/iman.tld" prefix="iman" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/c-rt.tld" prefix="c-rt" %>

<iman:stringtable bundle="DevResources"/>
<iman:stringtable bundle="FwResources"/>
<c:set var="RoleCount"><c:out value="${requestScope['Task_Role_Count']}" /></c:set>
<html>
<head>
<iman:eMFrameScripts />
<LINK rel='stylesheet' href='<%= MUtils.getModulesUrl(request) + "/fw/css/HF_style1.css" %>'>
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
<title><iman:string key="ProductName" /></title>

<script type="text/javascript" src="<%= MUtils.getModulesUrl(request) %>/fw/javascripts/mtmcode.js"> //Copyright (c) 2001, Morten Wang & contributors </script>

<script type="text/javascript">

window.LookAndFeel_MenuColor = "<c:out value="${menuColor}" />";

function showHiddenTaskMessage()
{
   parent.parent.Content.location.href="webacc?taskId=fw.HomePage&merge=fw.HomePage&User.context=<c:out value="${requsetScope['User.context']}" />";
   //parent.parent.Content.showHiddenTaskMessage();
}


//local variables
var headingGif = '<iman:toScript><c:out value="${hGif}" /></iman:toScript>';
var headingText = '<iman:toScript><c:out value="${requestScope['Launch.HeadingText']}" /></iman:toScript>';
var noRolesText = '<iman:toScript><iman:string key="Launch.NoRolesText" /></iman:toScript>';
<c:if test="${User.disconnected == 'true'}">noRolesText = '<iman:toScript><iman:string key="Launch.DisconnNoRolesText" /></iman:toScript>';</c:if>
var plusGifUrl = '<%= MUtils.getModulesUrl(request)  %>/fw/images/<iman:string key="Button.Plus.image" />';
var minusGifUrl = '<%= MUtils.getModulesUrl(request)  %>/fw/images/<iman:string key="Button.Minus.image" />';
var stylesheetUrl = '<%= MUtils.getModulesUrl(request) %>/fw/css/HF_style1.css';

//build the memory image of the menu structure
var menu = new iManageMenu();
<%	 int roleCount = ((Integer)request.getAttribute("Task_Role_Count")).intValue(); %>
<c-rt:if test="<%=roleCount > 0 %>">
	<c-rt:forEach var="currRoleIdx" begin="0" end="<%= roleCount -1 %>" >
		<c:set var="menuItemNameParam">Task_Role_<c:out value="${currRoleIdx}" />_Name</c:set>
      menu.addItem(new menuItem("<iman:toScript><c:out value="${requestScope[menuItemNameParam]}" /></iman:toScript>"));
      var submenu<c:out value="${currRoleIdx}" /> = new iManageMenu();
<%	 	int taskCount = ((Integer)request.getAttribute("Task_Role_" + pageContext.getAttribute("currRoleIdx")+"_Task_Count")).intValue(); %>
		<c-rt:if test="<%= taskCount > 0 %>">
			<c-rt:forEach var="currTaskIdx" begin="0" end="<%=taskCount - 1%>">
				<c:set var="currTaskParam">Task_Role_<c:out value="${currRoleIdx}" />_Task_<c:out value="${currTaskIdx}" /></c:set>
				<c-rt:set var="currTaskUrl" value="<%=request.getAttribute((String)pageContext.getAttribute("currTaskParam")+"_Url")%>" />
		      <c:if test="${empty currTaskUrl}">  <%-- to launch iManager task --%>
		      	<c:set var="currTaskUrl">frameservice?NPService=fw.LaunchService&NPAction=Delegate&delegate=<%=request.getAttribute((String)pageContext.getAttribute("currTaskParam")+"_TaskId")%>&launcher=fw.HomePage&lifecycle=Recreate&repeatable=true</c:set>
		      </c:if>
		      submenu<c:out value="${currRoleIdx}" />.addItem(new menuItem("<iman:toScript><c-rt:out value="<%=request.getAttribute((String)pageContext.getAttribute("currTaskParam")+"_Name")%>" /></iman:toScript>", '<c:out value="${currTaskUrl}" />', "Content"));
			</c-rt:forEach>
		</c-rt:if>
	   menu.items[<c:out value="${currRoleIdx}" />].addSubMenu(submenu<c:out value="${currRoleIdx}" />);
	</c-rt:forEach>
</c-rt:if>
   
   function onCategoryChange()
   {
      var idx = document.getElementById("categoryList").selectedIndex;
      var selectedCategoryId = parent.m_categoryId[idx];
      var url="webacc?taskId=fw.Launch&merge=fw.Launch&tasksMode=<c:out value="${tasksMode}" />&category="+selectedCategoryId+"&view=<c:out value="${view}" /><c:if test="${requestScope['Launch.ShowHiddenTasksMessage'] != null }">&Launch.ShowHiddenTasksMessage=<c:out value="${requestScope['Launch.ShowHiddenTasksMessage']}" /></c:if>";
      //alert("new url = "+url);
      parent.m_selectedCategoryIdx = idx;
      self.location = url;
   }
   
   function doResize()
   {
      var newWidth = document.body.clientWidth-8; 
      document.getElementById("categoryList").style.width=((newWidth>0)?newWidth:0);
   }

   function init()
   {
      //populate category selection list
      doResize();
      var cnt = parent.m_categoryCnt;
      var lst = document.getElementById("categoryList");
      if (lst!=null)
      {
         if (parent.m_categoryCnt>0)
         {
            for (i=0; i<cnt; i++)
            {
               //add options to select list
               lst.options[lst.options.length] = new Option(parent.m_categoryDisplayName[i], parent.m_categoryId);
            }
            
            //make select list visible
            lst.selectedIndex = parent.m_selectedCategoryIdx;
            lst.style.display="inline";
            lst.disabled = false;
         }
         else
         {
            lst.style.display="none";
            lst.disabled = true;
         }
      }
      
	<c:choose>
		<c:when test="${RoleCount == '1' || expandFirstRole == 'true'}">
         <!-- //display menu with first role expanded -->
         doSubMenu(menu.items[0]);
		</c:when>
		<c:otherwise>
        <!-- //display menu -->
         displayMenu();
		</c:otherwise>
	</c:choose>
   }
</script>
</head>
<c:set var="onLoadValue" >init();<c:if test="${requestScope['Launch.ShowHiddenTasksMessage'] == 'true'}" >showHiddenTaskMessage();</c:if></c:set>
<body style="background-color: #efeeec" onResize="doResize();" onload="<c:out value='${onLoadValue}' escapeXml='false' />" >

<table style="border:0; padding:0" cellpadding=0 cellspacing=0 width="100%">
<tr>
<td class="padding4" style="width:100%; font-weight: bold; background: url(<%= MUtils.getModulesUrl(request) %>/fw/images/header_pattern4.gif) repeat-x; background-color: <c:out value='${headerColor}' />">
    <img class="margin5l" src="<c:out value="${hGif}" />" width="16" height="16" align="top" />&nbsp;&nbsp;<iman:toScript><c:out value="${requestScope['Launch.HeadingText']}" /></iman:toScript>
</td></tr>
<tr>
<td class="padding4" style="width:100%; font-weight: bold">
	<select style="background-color: white; color:black" id="categoryList" onChange="onCategoryChange();">
	</select>
</td></tr>
</table>
</body>
</html>
