<%@page import="java.util.Hashtable"%>
<%
  Hashtable commands = (Hashtable) request.getAttribute("provider_cmds");
  String size = (String) request.getAttribute("size");
  String title = (String) request.getAttribute("title");
  boolean hasFrame = ((Boolean) request.getAttribute("hasFrame")).booleanValue();
  boolean minimized = ((Boolean) request.getAttribute("isMinimized")).booleanValue();
  boolean borderless = ((Boolean) request.getAttribute("borderlessChannel")).booleanValue();

  Map contentMap = (Map) request.getAttribute("contentMap");
  String containedChannel = (String) request.getAttribute("containedChannel");
%>
<%

// channel toolbar commands (embedded with markup)
//
String minMaximizeCommand = (String)commands.get("minMaximizeCommand");
String maximizeCommand    = (String)commands.get("maximizeCommand");
String helpCommand        = (String)commands.get("helpCommand");
String editCommand        = (String)commands.get("editCommand");
String detachAtachCommand = (String)commands.get("detachAtachCommand");
String removeCommand      = (String)commands.get("removeCommand");

// command locations (href)
//
String minMaxLocation       = null;
String maximizeLocation     = null;
String helpLocation         = null;
String editLocation         = null;
String detachAttachLocation = null;
String removeLocation       = null;

// check to see if we should build and display the menu
//
boolean showMenu = true;

if ((minMaximizeCommand == "") &&
    (maximizeCommand == "") &&
    (editCommand == "") &&
    (detachAtachCommand == "") &&
    (removeCommand == "")) {
    showMenu = false;
}

// generate pattern and split based on double quote (") delimiter
//
java.util.regex.Pattern pattern    = java.util.regex.Pattern.compile("\"");
String[] regexArray = null;

if (showMenu) {
    try {
        regexArray = pattern.split(minMaximizeCommand);

        if (regexArray.length > 1) {
            minMaxLocation = regexArray[1];
        }

        regexArray = pattern.split(maximizeCommand);

        if (regexArray.length > 1) {
            maximizeLocation = regexArray[1];
        }

        regexArray = pattern.split(helpCommand);

        if (regexArray.length > 1) {
            helpLocation = regexArray[1];
        }

        regexArray = pattern.split(editCommand);

        if (regexArray.length > 1) {
            editLocation = regexArray[1];
        }

        regexArray = pattern.split(detachAtachCommand);

        if (regexArray.length > 1) {
            detachAttachLocation = regexArray[1];
        }

        regexArray = pattern.split(removeCommand);

        if (regexArray.length > 1) {
            removeLocation = regexArray[1];
        }
    } catch (Exception e) {
    }
}
%>
<dt:obtainContainer container="$JSPProvider">
<%String docRoot = "/portal/esmportal/dt";%>
<%
  String channelName = "m" + new Long(java.lang.System.currentTimeMillis()).toString();
  long startTime = java.lang.System.currentTimeMillis();
%>
<!--begin Channel -->
<script language="JavaScript1.2" type="text/JavaScript">

			 window.<%=channelName%> = new Menu(null, "10");
			 window.<%=channelName%>.addMenuItem("&#8212;&nbsp;Options&nbsp;&#8212;");
		
		
			<% if (editLocation != null) { %>
				window.<%=channelName%>.addMenuItem("Edit Content", "location='<%=editLocation%>'");
				window.<%=channelName%>.addMenuSeparator();
			<% } %>

			<% if ((!minimized) && (minMaxLocation != null)) { %>
					window.<%=channelName%>.addMenuItem("Minimize", "location='<%=minMaxLocation%>'");
					<% } else if (minMaxLocation != null) { %>
					window.<%=channelName%>.addMenuItem("Restore", "location='<%=minMaxLocation%>'");
				<% } %>
			
			//<% if (detachAttachLocation != null) { %>
			//	window.<%=channelName%>.addMenuItem("Show in new window", "location='<%=detachAttachLocation%>'");
			//	<% } %>
			
			
			//	<% if (removeLocation != null) { %>
			//	window.<%=channelName%>.addMenuSeparator();
			//	window.<%=channelName%>.addMenuItem("Remove", "confirmRemove(\"<%=channelName%>\",'<%=removeLocation%>')");
			//	<% } %>

		
			<% if (helpLocation != null) { %>
				window.<%=channelName%>.addMenuSeparator();
				window.<%=channelName%>.addMenuItem("Help", "javascript:openHelp('<%=helpLocation%>');");
				//window.<%=channelName%>.addMenuItem("View channel help...", "javascript:openWindow('<dtpc:getDesktopURL/>?provider=OnlineHelpContainer&topic=channelControls&last=false','Help');");
			<% } %>

            window.<%=channelName%>.fontColorHilite = "#FFFFFF";
            window.<%=channelName%>.menuHiliteBgColor = "#aaaaaa";//"#F68947";
            window.<%=channelName%>.disableDrag = true;
 </script>


		<!-- begin channel title ------------------------------->
		<div class="TtldBoxTtlDiv" id="<%=channelName%>">
		  <table border="0" cellpadding="0" cellspacing="0" width="100%"   >
			<tr>
			  <td style="vertical-align:top; white-space:nowrap" ><div class="TtldBoxTtlTxt"><%=title%></div></td>
			  <td style="vertical-align:top;text-align:right; white-space:nowrap" >
				<div class="TtldBoxTtlImg">
				 <a href="javascript:void(0)" 
					onmouseover="swap('<%=title%>_help3', '<%=docRoot%>/images/titledbox/titledbox_help_roll.gif')" 
					onmouseout="swap('<%=title%>_help3', '<%=docRoot%>/images/titledbox/titledbox_help.gif')" 
					onClick="javascript:openHelp('<%=helpLocation%>');return false" 
					title="Help">

				 <img name="<%=title%>_help3" id="<%=title%>_help3" src="<%=docRoot%>/images/titledbox/titledbox_help.gif" width="19" height="19" border="0" /> 
				</a> 

<a href="javascript:void(0)" 
							onmouseover="swap('<%=title%>_control1', '<%=docRoot%>/images/titledbox/titledbox_control_roll.gif')" 
							onmouseout="swap('<%=title%>_control1', '<%=docRoot%>/images/titledbox/titledbox_control.gif')" 
							onClick="showMenu(window.<%=channelName%>);"
							title="Edit Settings For This Portlet"> <img name="<%=title%>_control1" id="<%=title%>_control1" src="<%=docRoot%>/images/titledbox/titledbox_control.gif" width="19" height="19" border="0" /> </a> </div></td>
			</tr>
		  </table>
		</div>
<!--		<div class="TtldBoxSepDiv">&nbsp;</div> -->
		<!-- end channel title -->

	<!-- Begin channel content ------------------------------->
	<%if (!minimized) {%>
		<div id="<%=title%>" class="TtldBoxOutDiv"> 
		  <div class="TtldBoxInrDiv" id="<%=title%>_box" >
	<table><tr>
		<td width="10"></td>
		<td width="99%">
			 <dtcpc:containerProviderContext>
			  <%out.print(contentMap.get(containedChannel));							%>
			<!--	  Time: <%=new Long( java.lang.System.currentTimeMillis() - startTime).toString()%> ms <br> -->
			 </dtcpc:containerProviderContext> 
		</td>
		<td width = "10"></td>
	</tr></table>
			<!-- channel content end -->
		  </div> 
		  <!-- class="TtldBoxInrDiv" -->
		</div>
	<%} else { %>
		<div class="TtldBoxSepDiv">&nbsp;</div>
	<%}  //if not minimized%>

</dt:obtainContainer>
<!-- end Channel -->
