<%@page contentType="text/html;charset=UTF-8" pageEncoding="ISO-8859-1" session="true"
%><%@page errorPage="Exception.jsp"
%><%@page import="com.fujitsu.iflow.model.bpm.BPMSession"
%><%@page import="com.fujitsu.iflow.model.util.URLEncoder"
%><%@page import="com.fujitsu.iflow.model.util.QuickForm"
%><%
    request.setCharacterEncoding("UTF-8");request.getParameterNames(); //Need dummy call for WL9.1
    BPMSession bps = (BPMSession) session.getAttribute("BPMSession");
    if (bps == null) {
        throw new Exception("Somehow got to the TemplateMenu.jsp without a valid session.  Any page including the TemplateMenu.jsp must first assure there is a valid session");
    }
    String selectedPlanID = (String)request.getParameter("planId");
    String editMode = (String) request.getParameter("editMode");
    String isEditableStr = (String) request.getParameter("isEditable");
    String referralURL = (String) request.getParameter("referralURL");

    boolean isEditMode = false;
    if(editMode!=null && editMode.equalsIgnoreCase("true")) isEditMode = true;

    boolean isEditable = false;
    if(isEditableStr!=null && isEditableStr.equalsIgnoreCase("true")) isEditable = true;

    String xpdlURL = "XPDLGenerator.jsp?planId="+selectedPlanID  + "&fromConsole=true";
    String bpelURL = "BPELGenerator.jsp?planId="+selectedPlanID;
    String exportXpdloneURL = "ExportXPDL.jsp?planId="+selectedPlanID;
    String exportXpdltwoURL = "ExportXPDL.jsp?planId="+selectedPlanID + "&version=XPDL2.0";
    String graphicalURL = "PDGraphic.jsp?planId="+selectedPlanID;
    String graphicalBPMNURL = "PDGraphicBPMN.jsp?planId="+selectedPlanID;
    String graphicalEditorURL = "ProcessEditor.jsp?AppletCommand=EditTemplate&TemplateID="+selectedPlanID+"&referralURL="+URLEncoder.encode(referralURL,"UTF-8");
    String appletViewURL = "ProcessEditor.jsp?AppletCommand=DisplayTemplate&TemplateID="+selectedPlanID+"&referralURL="+URLEncoder.encode(referralURL,"UTF-8");
    String commandURL = "TemplateCommands.jsp?pdId="+selectedPlanID+"&mode=";
    String textViewURL = "ProcessDefinition.jsp?planID="+selectedPlanID+"&isEditable="+isEditMode;

%>


<script type='text/javascript'>
function Go(){return}
</script>
<script type='text/javascript' src='styles/menu_settings.js'></script>
<script>

// Menu tree
//  MenuX=new Array(Text to show, Link, background image (optional), number of sub elements, height, width);
//  For rollover images set "Text to show" to:  "rollover:Image1.jpg:Image2.jpg"

Menu1=new Array("rollover:images/but_export.gif:images/but_export.gif","","",3,24,85);
    Menu1_1=new Array("XPDL1.0","<%= exportXpdloneURL %>","",0,16,83);
    Menu1_2=new Array("XPDL2.0","<%= exportXpdltwoURL %>","",0,16,83);
    Menu1_3=new Array("BPEL","<%= bpelURL %>","",0,16,83);

Menu2=new Array("rollover:images/but_view.gif:images/but_view.gif","","",4,24,85);
    Menu2_1=new Array("Snapshot","<%= graphicalURL %>","",0,16,83);
    Menu2_2=new Array("BPMN","<%= graphicalBPMNURL %>","",0,16,83);
    Menu2_3=new Array("Graphical","<% QuickForm.writeHtml(out, appletViewURL); %>","",0,16,83);
    Menu2_4=new Array("Text","<% QuickForm.writeHtml(out, textViewURL); %>","",0,16,83);
<%
	if(isEditMode)
	{
%>
		Menu3=new Array("rollover:images/but_edit.gif:images/but_edit.gif","","",2,24,85);
			Menu3_1=new Array("Commit","<% QuickForm.writeHtml(out, commandURL); %>Save","",0,16,77);
			Menu3_2=new Array("Cancel","<% QuickForm.writeHtml(out, commandURL); %>Cancel","",0,16,77);
<%
	}
	else
	{
%>
		Menu3=new Array("rollover:images/but_edit.gif:images/but_edit.gif","","",2,24,85);
			Menu3_1=new Array("Graphical","<% QuickForm.writeHtml(out, graphicalEditorURL); %>","",0,16,77);
			Menu3_2=new Array("Text","<% QuickForm.writeHtml(out, commandURL );%>Edit","",0,16,77);

<%
	}
%>

</script>
<script type='text/javascript' src='styles/menu_com.js'></script>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr><td height="13"></td></tr>
  <tr>
    <td><div id='MenuPos' style='position:relative; width:120; height:30;'></div>
    </td>
    <%
    StringBuffer MyURL = request.getRequestURL();
    if(MyURL.indexOf("PDGraphic") == -1)
    {
    %>
        <td align="right">
        <a href="<% QuickForm.writeHtml(out, commandURL); %>Copy"><img src="images/but_copy.gif" border="0"></a>
        <a href="<% QuickForm.writeHtml(out, commandURL); %>Delete"><img src="images/but_delete.gif" border="0"></a>
        </td>
    <%
    }
    %>
  </tr>
  <tr><td height="17"></td></tr>
</table>
<!-- end floating menu-->
