<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8"  import="java.util.*,com.novell.emframe.dev.eMFrameUtils,com.novell.emframe.dev.eMFrameFactory,com.novell.webaccess.common.JSPConduit"%>
<%@ taglib uri="/WEB-INF/iman.tld" prefix="iman" %>

<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/x.tld" prefix="x" %>
<iman:stringtable bundle="DevResources" />
<iman:stringtable bundle="FwResources" />

<%
   JSPConduit c = JSPConduit.getJSPConduit(request);
%>

<x:parse xml="${edas}" var="edasXml"/>

<HTML>
<HEAD>
   <TITLE><iman:string key="ProductName"/></TITLE>
   <iman:stylesheet/>
   <iman:uihandlerTools/>
   <iman:pageScripts/>
   <iman:eMFrameScripts/>
   <iman:mvedScripts mode="mvsel" />
   <iman:validateNumberScripts/>
   <iman:osScripts/>

   <SCRIPT>
      function onInit()
      {
         returnFromOS();
         <% if((c.var("myTaskName").equals("MooGroupMembers")) && (!(c.var("UniqueMembersParam").equals("")))) { %> 	 
		   mvLoadFromPack("_Member","<c:out value="${UniqueMembersParam}"/>");
		 <% } %>
      }

      function isPageValid()
      {
         var form=document.forms[0];
         return notifyAllOfExit();
      }
      
      function mvMooGroupValues(name)
	  {		
		var mvse=eval("window.mv"+name);
		var list = getValuesAsArray(mvse);
		var mode = eval("document.forms[0]." + name + "_mode");
        var modeStr = (mode ? " mode='" + mode.value + "'" : "");
         		
		var str = "<mvstring" + modeStr + ">";
		if(mode.value == "remove")
		{
		      for(var i=0; i<list.length; i++)
     	      str += "<value>" + xmlEncode(list[i]) + "</value>";
		}
		else
		{
			  for(var i=0; i<list.length; i++)
		       str += "<value>" + xmlEncode(list[i]) + "</value>";
		}      
		str += "</mvstring>";
		return str;
	}
	
	function uih_mvMooGroup(name, uiControl, xmlControl)
	{
		xmlControl.value = mvMooGroupValues("_" + name);
		return true;
	}
      
   </SCRIPT>
</HEAD>

<BODY onLoad="onInit();">
<FORM name="form" method=post action="webacc">
   <iman:messagebar />
   <iman:bookvars/>

   <TABLE class="mediumtext" border="0" cellpadding="0" cellspacing="0">
      <TR>
         <TD align="left" colspan="2">
            <c:out value="${MemberDisplayName}"/>:&nbsp;&nbsp;
         </TD>
      </TR>
      <TR>
         <TD>
            <c:if test="${edasRights.target.Member.writeable}">
               <INPUT type="hidden" name="eDir$target$Member" value="<c:out value="${eDir$target$Member}" escapeXml="false"/>">
               <c:if test="${myTaskName == 'MooGroupMembers'}">
                   <SCRIPT>addToNotificationList('Member', 'uih_mvMooGroup');</SCRIPT>
               </c:if>
               <c:if test="${myTaskName != 'MooGroupMembers'}">
                   <SCRIPT>addToNotificationList('Member', 'uih_mvStringEditor');</SCRIPT>
               </c:if>
            </c:if>
            <x:set var="MembersValue" select="$edasXml/edas/Member" scope="request"/>
                  <c:if test="${not empty MembersValue}">
                        <% List XMLSelections = new ArrayList();%>
                        <x:forEach select="$MembersValue/value">
                           <x:set var="node" select="string(.)"/>
                           <jsp:useBean id="node" type="java.lang.String"/>
                           <% XMLSelections.add(node);
                           %>
                        </x:forEach>
                        <% 
                        Collections.sort(XMLSelections);
                        int len = XMLSelections.size();
        				String[] values = new String[len];
        				for (int i = 0; i < XMLSelections.size(); i++) {
        					values[i] = XMLSelections.get(i).toString();

        				}
        				request.setAttribute("values", values);
						%>
                     </c:if>
          <iman:mved readonly="${!edasRights.target.Member.writeable}" enforceUnique="true" name="_Member" objectTypeName="User" mode="mvsel" size="10" showCount="true" history="true" items="${values}" />
          </TD>
         <TD valign="top">
            <c:set var="mode"><x:out select="$edasXml/edas/Member/@mode"/></c:set>
            <iman:mooMode name="_Member_mode" value="${mode}" multi="true" />
         </TD>
      </TR>
      <TR><TD height="9"></TD></TR>
   </TABLE>

</FORM>
<iman:osFooter/>
</BODY>
</HTML>
