<%@page contentType="text/html;charset=UTF-8" pageEncoding="ISO-8859-1" session="true"
%><%@page import="com.fujitsu.iflow.model.workflow.WFSession"
%><%@page import="com.fujitsu.iflow.model.workflow.WFObjectFactory"
%><%@page import="com.fujitsu.iflow.model.workflow.DirectoryServices"
%><%@page import="com.fujitsu.iflow.model.bpm.BPMSession"
%><%@page import="com.fujitsu.ibpm.dtm.DecisionTableConfig"
%><%
    request.setCharacterEncoding("UTF-8");request.getParameterNames(); //Need dummy call for WL9.1
    StringBuffer s1 = request.getRequestURL();
    s1.append("?");
    String pageURL = s1.toString();
    pageURL = pageURL.substring(pageURL.lastIndexOf("/")+1,pageURL.lastIndexOf(".jsp"));
    s1.append(request.getQueryString());
    String goPage = s1.toString();
    String type = request.getParameter("type");
    String hlploc = request.getParameter("hlploc");

    String topPage = "Top.jsp";
    if(type == null)
    {
        type = "devmgr";
    }

    if(type.equalsIgnoreCase("admin"))
    {
        topPage = "AdminTop.jsp";
    }

    if(pageURL.equals("UserPreferences"))
    {
        hlploc = "devmgr";
    }
    else
       hlploc = type;

    String hlpPageURL = pageURL;
    String advSearch = request.getParameter("srchnm");
    if (advSearch != null &&
        advSearch.length() > 0 &&
        (hlpPageURL.equals("WorkList") || hlpPageURL.equals("ProcessList")))
    {
        hlpPageURL = "Adv" + hlpPageURL;
    }
    
    String user = (String) session.getAttribute("userName");
    boolean validDtm=false;
    String DTMUsers = DecisionTableConfig.getString("DecisionTableManagerUsers");
    if(DTMUsers!=null && DTMUsers.length()>0)
    {
        String[] result = DTMUsers.split(",");
        for (int x=0; x<result.length; x++)
        {
            if(user.equals(result[x]))
            {
                validDtm = true;
                break;
            }
        }
    }
%>

<center>
<script language="JavaScript">
function winpop(url) {
window.open(url,"","height=350,width=480,status=no,toolbar=no,directories=no,menubar=no,location=no,resizable=yes,scrollbars=no, left=100,top=50");
}
</script>


<table cellspacing="0" cellpadding="0" border="0" align="center" width="100%" valign="top">
<tr>
<td><jsp:include page="<%=topPage%>" flush="true"/></td>
</tr>
<tr>
<td >
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td><img src="images/clear.gif" width="1" height="27"></td>
    <td>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
        <td><img src="images/clear.gif" width="1" height="27"></td>
              <td>
                <table border="0" align="right" cellpadding="0" cellspacing="0">
                  <tr class="titletext">
                     <%
                        String transportType = (String) session.getAttribute("TransportType");
                        if (transportType.equalsIgnoreCase("LE")) {
                    %>
                            <td width="14"><img src="images/tab/left_circle.gif" width="14" height="27"></td>
                            <td width="80" valign="middle" background="images/tab/but_main_bg.gif">
                                <div align="center"><a href="javascript:winpop('<%= response.encodeURL("About.jsp") %>')"><strong><font face="Arial, Helvetica, sans-serif">
                                About</font></strong></a> </div>
                            </td>
                    <% } else { %>
                        <td width="14"><img src="images/tab/left_circle.gif" width="14" height="27"></td>
                        <td width="80" valign="middle" background="images/tab/but_main_bg.gif">
                          <div align="center"><a href="<%= response.encodeURL("UserPreferences.jsp?type=" + type +"&pageName="+pageURL) %>"><strong><font face="Arial, Helvetica, sans-serif">Preference</font></strong></a>
                          </div>
                        </td>
                        <td width="2" background="images/tab/but_main_bg.gif"><img src="images/tab/but_divider.gif" width="2" height="27"></td>
                        <td width="70" valign="middle" background="images/tab/but_main_bg.gif">
                          <div align="center"><a href="javascript:winpop('<%= response.encodeURL("About.jsp") %>')"><strong><font face="Arial, Helvetica, sans-serif">
                            About</font></strong></a> </div>
                        </td>
                    <% } %>
                    <td width="2" background="images/tab/but_main_bg.gif"><img src="images/tab/but_divider.gif" width="2" height="27"></td>
                    <td width="70" valign="middle" background="images/tab/but_main_bg.gif">
                      <div align="center">
                        <table cellpadding="0" cellspacing="0" border="0">
                          <tr class="titletext">
                            <td><a href="<%= response.encodeURL("Help.jsp?helpLocation=" + hlploc + "&pageName="+hlpPageURL) %>" class="help-cursor" target="helpwindow"><img src="images/icons/question.gif" width="17" height="17" border="0"></a></td>
                            <td>&nbsp; <a href="<%= response.encodeURL("Help.jsp?helpLocation=" + hlploc + "&pageName="+hlpPageURL)  %>" class="help-cursor" target="helpwindow"><strong><font face="Arial, Helvetica, sans-serif">Help</font></strong></a></td>
                          </tr>
                        </table>
                      </div>
                    </td>
                    <td width="14"><img src="images/tab/right_circle.gif" width="14" height="27"></td>
                  </tr>
                </table>
              </td>
        </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr><td>
        <table border="0" cellspacing="0" cellpadding="0">
        <tr class="titletext">
     <%
        String transPortType = (String)session.getAttribute("TransportType");
        String isAdminUser = (String)session.getAttribute("isAdminUser");
      String[] tabs = null;
        String[] tabsURL = null;
        if((transPortType != null && transPortType.equalsIgnoreCase("LE")))
        {
         tabs = new String[]
              {"Work List",
               "Process Instances",
               "Process Definitions"};

         tabsURL = new String[]
                 {"WorkList.jsp",
                "ProcessList.jsp",
                "TemplateList.jsp"};
        }
        else if(type.equalsIgnoreCase("admin"))
        {
         tabs = new String[]
              {"Process Definitions",
               "Process Instances",
               "Login Sessions",
                     "User Management",
                     "Console"};

         tabsURL = new String[]
                 {"SortedPlanList.jsp",
                "SortedProcessList.jsp",
                "LoginSessions.jsp",
                "UserMgmt.jsp",
                "WorkList.jsp"};
        }
        else if((isAdminUser != null && isAdminUser.equalsIgnoreCase("true")))
        {
         tabs = new String[]
                    {"Work List",
               "Process Instances",
               "Process Definitions",
                     "Dashboard",
                     "Decision Tables",
                     "Administration"};

         tabsURL = new String[]
                       {"WorkList.jsp",
                "ProcessList.jsp",
                "TemplateList.jsp",
                "Dashboard.jsp",
                "DecisionTableManagement.jsp",
                "SortedPlanList.jsp"};
        }
        else
        {
             if(!validDtm)    
             {
                 tabs = new String[]
                            {"Work List",
                       "Process Instances",
                       "Process Definitions",
                             "Dashboard"};

                 tabsURL = new String[]
                               {"WorkList.jsp",
                        "ProcessList.jsp",
                        "TemplateList.jsp",
                        "Dashboard.jsp"};
             }
             else
             {
                 tabs = new String[]
                            {"Work List",
                       "Process Instances",
                       "Process Definitions",
                             "Dashboard",
                        "Decision Tables"};

                 tabsURL = new String[]
                               {"WorkList.jsp",
                        "ProcessList.jsp",
                        "TemplateList.jsp",
                        "Dashboard.jsp",
                        "DecisionTableManagement.jsp"};
             }
        }
        int activeIndex = 0;
        Object tabIndexObj = session.getAttribute("TabIndex");
        if(tabIndexObj!=null){
            activeIndex = (new Integer(tabIndexObj.toString())).intValue();
        }

     for(int index=0;index<tabs.length;index++){
     String leftImage = "inactive_left.gif";
     String rightImage = "inactive_right.gif";
     String tabBg = "background=\"images/tab/other_tab_bg.gif\"";
     String fontColor = "#FFFFFF";

   if(index==activeIndex){
     leftImage = "active_left.gif";
     rightImage = "active_right.gif";
     tabBg = "bgcolor=\"#FFFFFF\"";
     fontColor = "#006699";
     }
     %>

            <td width="5"><div align="right"><img src="images/tab/<%= leftImage %>" width="5" height="25"></div></td>
                 <td width="125" nowrap <%= tabBg%>>
                 <div align="center"><a href="<%= response.encodeURL(tabsURL[index]) %>"><font color="<%= fontColor%>" face="Arial, Helvetica, sans-serif"><strong><%= tabs[index] %></strong></font></a></div></td>
               <td width="7"><img src="images/tab/<%= rightImage %>" width="7" height="25"></td>
   <%
     }
     %>
        </tr>
        </table>
        </td><td valign="top">
        <table align="right" border="0" cellspacing="0" cellpadding="0">
            <td width="150"></td>
            <td width="7">&nbsp;</td>
            <td width="300" nowrap><div align="right"><small><font color='#ffffff' face='verdana' size='1'><span id="clock"><script> showDate('<%=new java.util.Date().getTime() %>'); </script></span></font></small></div></td>
            <td width="7">&nbsp;</td>
            </table>
        </td></tr>
    </table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>