<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" import="com.novell.webaccess.common.JSPConduit, com.novell.emframe.dev.eMFrameUtils" %>
<%   JSPConduit c = JSPConduit.getJSPConduit(request);
   c.stringTable("DevResources");
   c.stringTable("FwResources"); %>
<HTML>
<HEAD>
<TITLE><%= c.toHTML(c.string("RBSManagement.CreateRoleTitle")) %></TITLE>
<LINK href="<%= c.getModulesUrl() + "/dev/css/hf_style.css" %>" rel="styleSheet" type="text/css">
<jsp:include page='<%= c.getPath("dev/eMFrameScripts_inc.jsp") %>' flush="true" />
<jsp:include page='<%= c.getPath("dev/OSScripts_inc.jsp") %>' flush="true" />
<style>
.gray
{
background-color: #bfbfbf;
}
</style>
<SCRIPT language="JavaScript">


   function onPageLoad()
   {
   	// Set this for the ObjectSelector
      returnFromOS();

      setFocusToFormElement();
   }


   function setWaitCursor()
   {
	   document.body.style.cursor="wait";
   }


   function checkCreateRoleNullInput()
   {
      var strContainerInput = document.CreateRoleForm.CreateRoleContext.value;
      var strRoleNameInput = document.CreateRoleForm.CreateRoleName.value;

      if ((null == strRoleNameInput) || (0 == strRoleNameInput.length))
      {
         alert("<%= c.toScript(c.string("CreateRole.InvalidRoleName")) %>");
         return false;
      }

      if ((null == strContainerInput) || (0 == strContainerInput.length))
      {
         alert("<%= c.toScript(c.string("CreateRole.InvalidRoleContext")) %>");
         return false;
      }

      //	Make sure they haven't entered more than 1024 characters.
      var sizeOk = checkFinalTextAreaSize();
      if (sizeOk == false)
      {
      	document.CreateRoleForm.CreateRoleDescription.focus();
         return false;
      }
      // Everything is ok. Get the new role name.
      getSelectedRoleName();

      setWaitCursor();
      return true;
   }


   function setFocusToFormElement()
   {
      document.CreateRoleForm.CreateRoleName.focus();
   }


   function getSelectedRoleName()
   {
      var strCreateRoleName 		= document.CreateRoleForm.elements["CreateRoleName"].value;
      var strCreateRoleContext 	= document.CreateRoleForm.elements["CreateRoleContext"].value;
      var strCreateRoleFullName 	= strCreateRoleName + "." + strCreateRoleContext;

      document.CreateRoleForm.elements["CreateRoleFullName"].value=strCreateRoleFullName;
      document.CreateRoleForm.elements["CreateRoleDisplayName"].value=strCreateRoleName;
   }

   // Check to make sure the description attribute max size is not exceeded.
   function checkFinalTextAreaSize()
   {
      var maxlimit = 1024;

      if (document.CreateRoleForm.CreateRoleDescription.value.length > maxlimit) // if too long...trim it!
		{
         var limitMessage = "<%= c.toScript(c.string("ModifyRBSObjectDescription.ExceededLimit")) %>";
         alert(limitMessage);
         document.CreateRoleForm.CreateRoleDescription.value = document.CreateRoleForm.CreateRoleDescription.value.substring(0, maxlimit);
         return false;
      }
      else
      {
      	return true;
      }
   }


</SCRIPT>
</HEAD>

<BODY TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#FFFFFF" onLoad="onPageLoad();">
<FORM name="CreateRoleForm" method=post action="webacc" onSubmit="return(checkCreateRoleNullInput())">
   <input type=hidden name="taskId" value="<%= c.var("taskId") %>">
   <input type=hidden name="merge" value="fw.ChooseTasks">
   <input type=hidden name="error" value="dev.GenErr">
   <input type=hidden name="User.context" value="<%= c.var("User.context") %>">
   <input type=hidden name="nextState" value="getTasksForRole">
   <input type=hidden name="CreateRolePreviousPage" value="CrtRole">
   <input type=hidden name="CreateRoleFullName" value="<%= c.toHTML(c.var("CreateRoleFullName")) %>">
   <input type=hidden name="CreateRoleDisplayName" value="<%= c.toHTML(c.var("CreateRoleDisplayName")) %>">
   <input type=hidden name="SelfProvisioningRole" value="false">
   <input type=hidden name="RBSAdmin_RoleType" value="iManager">
   <input type=hidden name="RBSAdmin_TaskDelegate" value="<%= c.var("RBSAdmin_TaskDelegate") %>">
   <!-- End of hidden tags -->

<% if (session.getAttribute("DeviceType").equals("browser")) { %>
	<DIV id="Layer2" style="position:absolute; left:5px; top:4px; width:650px; height:400px; z-index:2">
<% }
	  c.set("WizardHeader.title", c.toHTML(c.string("CreateRole.WizardTitle")));
      c.set("WizardHeader.subtitle", c.toHTML(c.string("CreateRole.Subtitle")));
      c.set("WizardHeader.helpFile", "base/createimanagerrole.html");
      c.set("WizardHeader.HelpWindowWidth", "500");
      c.set("WizardHeader.HelpWindowHeight", "500"); %>
   <jsp:include page='<%= c.getPath("dev/WizardHeader_inc.jsp") %>' flush="true" />
   <TABLE width="100%" border="0" cellspacing="0" cellpadding="3">
   	<TR>
      	<TD class="mediumtext" width="48%" valign="bottom"><%= c.toHTML(c.string("CreateRole.RoleName")) %><BR>
         <input type=text name="CreateRoleName" value="<%= c.toHTML(c.var("CreateRoleDisplayName")) %>" size=35 maxlength=64></TD>
         <TD width="2%" bgcolor="#FFFFFF">&nbsp;</TD>
         <TD width="50%" bgcolor="#FFFFFF" class="instructions"><%= c.toHTML(c.string("CreateRole.Example")) %></TD>
      </TR>
      <TR>
      	<TD class="mediumtext" width="48%" valign="bottom"><%= c.toHTML(c.string("CreateRole.Collection")) %><BR>
            <% if (c.var("RBSAdmin_TaskDelegate").equals("taskDelegate") == true) { %>
               <input class="gray" type="text" name="CreateRoleContext" value="<%= c.toHTML(c.var("CreateRoleContext")) %>" size="35" readonly>
            <% } else { %>
               <input type=text name="CreateRoleContext" value="<%= c.toHTML(c.var("CreateRoleContext")) %>" size=35>
                  <% c.set("OS.TypeFilter", "rbsCollection2");
                  c.set("OS.Control", "CreateRoleContext");
                  c.set("OS.Mode", "search");
                  c.set("OS.History", "true"); %>
		   	      <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
            <% } %>
         </TD>
         <TD width="2%" bgcolor="#FFFFFF">&nbsp;</TD>
      	<TD width="50%" bgcolor="#FFFFFF" class="instructions"><%= c.toHTML(c.string("CreateRole.EnterPath")) %></TD>
      </TR>
      <TR>
      	<TD class="mediumtext" width="48%" valign="bottom"><%= c.toHTML(c.string("CreateRole.Description")) %><BR>
         <TEXTAREA name="CreateRoleDescription" value="<%= c.var("CreateRoleDescription") %>" rows="3" cols=30 wrap="VIRTUAL"><%= c.var("CreateRoleDescription") %></TEXTAREA>
         </TD>
         <TD width="2%">&nbsp;</TD>
      	<TD width="50%">&nbsp;</TD>
      </TR>
   </TABLE>
<% if (session.getAttribute("DeviceType").equals("browser")) { %>
	</DIV>
   <DIV id="Layer1" style="position:absolute; left:6px; top:480px; width:650px; height:80px; z-index:3">
<% } %>
   <TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
      <TR>
      	<TD class="ruleabove">
         	<a href="#"><IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.BackDisabled.image") %>" alt="<%= c.toHTML(c.string("Button.BackDisabled.alt")) %>" title="<%= c.toHTML(c.string("Button.BackDisabled.alt")) %>" border=0></a>
            <INPUT type=image name="Next" alt="<%= c.toHTML(c.string("Button.Next.alt")) %>" src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.Next.image") %>" border=0>
            <jsp:include page='<%= c.getPath("dev/Cancel_inc.jsp") %>' flush="true" />
         </TD>
      </TR>
   </TABLE>
<% if (session.getAttribute("DeviceType").equals("browser")) { %>
	</DIV>
<% } %>
</FORM>
<jsp:include page='<%= c.getPath("dev/OSFooter_inc.jsp") %>' flush="true" />
</BODY></HTML>
