<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" import="com.novell.webaccess.common.JSPConduit,
                  java.util.ResourceBundle,
                  com.novell.emframe.dev.eMFrameUtils,
                  com.novell.webaccess.common.JSPConduit, com.novell.emframe.dev.eMFrameUtils" %>

<%@ taglib uri="/WEB-INF/iman.tld" prefix="iman" %>
<%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/x.tld" prefix="x" %>

<%   JSPConduit c = JSPConduit.getJSPConduit(request);
   c.stringTable("DevResources");
   c.stringTable("BaseResources");
   c.stringTable("FwResources");
%>


<iman:stringtable bundle="DevResources"/>

<HTML>
	<HEAD>
	   <TITLE><%= c.string("CreateGroup.CreateGroupTitle") %></TITLE>
		<LINK rel="stylesheet" href="<%= c.getModulesUrl() + "/dev/css/hf_style.css" %>" type="text/css">
	   <iman:include page="fw/UiHandlerTools.jsp" />


	   <iman:include page="dev/eMFrameScripts_inc.jsp"/>
	   <iman:include page="dev/ValidateIntegerScripts_inc.jsp"/>
	   <iman:include page="dev/OSScripts_inc.jsp"/>

	   <SCRIPT>
	      function onInit()
	      {
	         var form = document.forms[0];
				<c:if test="${SelectedClass == 'dynamicGroup'}">
					form.makeDynamicGroup.checked = true;
				</c:if>
				window.uiObject_CN.m_type = "string";
	         form._CN.focus();

	         returnFromOS();
	      }

	      function onExit()
	      {
	         var form=document.forms[0];

	         var success = notifyAllOfExit();
	         if(!success)
	         {
	            return false;
	         }

	         form.eDir$target.value = getValueFromXml(form.eDir$target$CN.value);
	         if ((null == form.eDir$target.value) || (form.eDir$target.value.length == 0))
	         {
	            alert("<%= c.toScript(c.string("Creator.InvalidObjectName")) %>");
	            return false;
	         }


	         var containerInput = document.form.eDir$target$createContext.value;
	         var radioButton = (form.eDir$target$createContext[0] && form.eDir$target$createContext[0].type == "radio");
	         if(!radioButton)
	         {
	            if ((containerInput==null) || (containerInput.length==0))
	            {
	               alert("<%= c.toScript(c.string("Creator.InvalidContainerName")) %>");
	               return false;
	            }
	         }

				if ( form.makeDynamicGroup.checked == true )
				{
					form.eDir$target$createClassName.value = "dynamicGroup";
				}
				else
				{
					form.eDir$target$createClassName.value = "Group";
				}

	         return true;
	      }

	      var ENABLED_COLOR = "white";
	      var DISABLED_COLOR = "#EFEEE9";

	      function enableTemplate(control)
	      {
	         with(document.forms[0])
	         {
	            var tf = eDir$target$createSourceObjectForClone;
	            if (control.checked == true)
	            {
	               tf.disabled = false;
	               tf.style.backgroundColor = ENABLED_COLOR;
	            }
	            else
	            {
	               tf.disabled = true;
	               tf.value = "";
	               tf.style.backgroundColor = DISABLED_COLOR;
	            }
	         }
	      }

		   function checkDefaultKey(evt)
	      {
	         var form = document.forms[0];
	         var keyCode = evt.which ? evt.which : evt.keyCode;
	         // 13 is the Enter key code
	         if (keyCode == 13)
	         {
	            if(onExit() != false)
	            {
	               document.forms[0].submit();
	               return false;
	            }
	         }
	         return true;
	      }
	   </SCRIPT>
	</HEAD>


	<body text="#000000" bgcolor="#ffffff" onLoad="onInit();">
		<FORM name=form method=post action=webacc onSubmit="onExit();">


		   <!---- EDAS and System Variables ---->
		   <INPUT type=hidden name="taskId" 							value="<%= c.var("taskId") %>">
		   <INPUT type=hidden name="eDirCommand" 						value="create">
		   <INPUT type=hidden name="eDir$target" 						value="">
		   <INPUT type=hidden name="merge" 								value="dev.GenConf">
		   <INPUT type=hidden name="error" 								value="dev.GenErr">
		   <INPUT type=hidden name="nextState" 						value="eDasServiceAccess">
			<INPUT type=hidden name="eDir$target$createClassName"	value="">

			<% c.set("TaskHeader.title", 		c.string("CreateGroup.CreateGroupTitle"));
			   c.set("TaskHeader.iconUrl", 	"dir/Group.gif");
			   c.set("TaskHeader.iconAlt", 	c.string("CreateGroup.CreateGroupTitle"));%>

		   <jsp:include page='<%= c.getPath("dev/TaskHeader_inc.jsp") %>' flush="true" />

	      <p class="instructions"><%= c.string("DynamicGroup.CreatePrompt") %></p>

		   <TABLE class="mediumtext" border="0" bgcolor="#FFFFFF" cellpadding="0" cellspacing="0">


			   <%-- CN --%>
			   <TR>
			      <TD align="left" colspan="2">
			         <%= c.string("CreateGroup.GroupName") %>&nbsp;
			      </TD>
			   </TR>
			   <TR>
			      <TD>
		            <INPUT type="hidden" name="eDir$target$CN" value="<c:out value="${eDir$target$CN}" escapeXml="false"/>">
		            <SCRIPT>addToNotificationList('CN', 'uih_textfield');</SCRIPT>
			         <INPUT type="text" name="_CN" value="" size=<iman:string key="UI.textboxSize"/> style="width:<iman:string key="UI.textboxPixel"/>"   maxlength=64 onChange='validateLengthField(this, 1, 64)' onkeypress="return checkDefaultKey(event)"  >
						<SCRIPT>
							window.uiObject_CN = new UiObject("", "");
							window.uiObject_CN.m_lowerBound = 1;
							window.uiObject_CN.m_upperBound = 64;
							window.uiObject_CN.m_type = "string";
						</SCRIPT>
			      </TD>
			   </TR>
			   <TR><TD height="9"></TD></TR>

			   <%-- Create Context --%>
			   <TR>
			      <TD><%= c.string("Creator.Context") %></TD>
			   </TR>
			   <TR>
					<td>
			         <INPUT type=text name="eDir$target$createContext" value="<%= eMFrameUtils.getSingleTarget(request) %>"size="<%= c.string("UI.textboxSize") %>" style="width:<%= c.string("UI.textboxPixel") %>" onkeypress="return checkDefaultKey(event)">
			         <% c.set("OS.Control", "eDir$target$createContext");
			            c.set("OS.TypeFilter", "Organization,Organizational Unit,domain,container");
			            c.set("OS.History", "true");
			            c.set("OS.Windowed", "true"); %>
			         <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
			      </TD>
			   </TR>
			   <TR><TD height="9"></TD></TR>

				<%-- Make Group Dynamic --%>
				<tr>
					<td>
                     <input 
                     	type="checkbox" 
                     	name="makeDynamicGroup" 
	                   	<c:if test="${CanChangeDynamicParam == 'false'}">disabled</c:if>
                     	width="16" 
                     	height="16" /><%= c.string("DynamicGroup.UseDynamicSettings") %>
					</td>
				</tr>
				<tr>
					<td class="instructions"><%= c.string("CreateGroup.DynamicCheckBoxHint") %></td>
				</tr>
			   <TR><TD height="9"></TD></TR>

				<%-- Set Owner --%>
				<tr>
					<td>
                     <input 
                     	type="checkbox" 
                     	name="setOwner" 
	                   	checked
                     	width="16" 
                     	height="16" /><%= c.string("CreateGroup.SetOwner") %>
					</td>
				</tr>
				<tr>
					<td class="instructions"><%= c.string("CreateGroup.SetOwnerCheckboxHint") %></td>
				</tr>
		   </TABLE>
			<BR>

	   <iman:include page="dev/Bar_inc.jsp"/>
	   <A href="Javascript: if(onExit() != false) document.forms[0].submit();"><IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.OK.image") %>" alt="<%= c.string("Button.OK.alt") %>" title="<%= c.string("Button.OK.alt") %>" border=0></A> <jsp:include page='<%= c.getPath("dev/Cancel_inc.jsp") %>' flush="true" />
		</FORM>
		<jsp:include page='<%= c.getPath("dev/OSFooter_inc.jsp") %>' flush="true" />
	</body>
</HTML>



