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

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

   c.stringTable("DevResources");
   c.stringTable("BaseResources");
   c.stringTable("FwResources");
%>

<HTML>
<HEAD>
	<TITLE><%= c.string("ProductName") %></TITLE>
	<LINK rel='stylesheet' href='<%= c.getModulesUrl() %>/dev/css/hf_style.css'>

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

   <SCRIPT language="JavaScript">

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

      function isValid()
      {
         var form = document.forms[0];
         if(form.SetPswdNewPassword.value != form.SetPswdVerifyPassword.value)
         {
            alert("<%= c.string("SetPassword.PasswordsDontMatch") %>");
            return false;
         }

         if (form.SetPswdNewPassword.value.length == 0)
         {
            var message = "<%= c.toScript(c.string("CreateUser.PasswordAlert")) %>";
            if (!confirm(message))
            {
               form.SetPswdNewPassword.focus();
               return false;
            }
         }

      }

      function onPageLoad()
      {
         document.form.single.focus();
<% if (!session.getAttribute("DeviceType").equals("pocket") && c.var("Task.SetPassword.Param.Auth").equals("NDS"))
{ %>
         // added for simple password
         <% if(c.var("targetName").length() == 0)
         {%>
            if (document.form.single.value.length == 0)
            {
               document.form.enableUniversalPassword.value = 'false';
               document.form.enableUniversalPassword.disabled = true;
               document.form.enableUniversalPassword.style.backgroundColor = DISABLED_COLOR;
            }
         <%}
}%>
      }

<% if (!session.getAttribute("DeviceType").equals("pocket") && c.var("Task.SetPassword.Param.Auth").equals("NDS"))
{ %>
      function enableSimplePassword(control)
      {
         with(document.form)
         {
            control = eval(control);
            if (control.value != " " || control.value.length>0)
            {
               enableUniversalPassword.value = 'true';
               enableUniversalPassword.disabled = false;
               enableUniversalPassword.style.backgroundColor = ENABLED_COLOR;
               enableUniversalPassword.checked = false;
            }
         }
      }

      function enableSimplePasswordCallBack(control, results)
      {
         with(document.form)
         {
            control = eval(control);
            control.value = results[0];
            enableSimplePassword(control);
         }
      }
<% } %>
   </SCRIPT>
</HEAD>

<BODY TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#FFFFFF" onLoad="returnFromOS(); onPageLoad();">
<FORM name="form" method=post action="webacc" onSubmit="return isValid();" >

   <!-- MFRAME VARIABLES -->
   <INPUT type=hidden name="taskId"            value="<%= c.var("taskId") %>">
   <INPUT type=hidden name="error"             value="dev.GenErr">
   <INPUT type=hidden name="nextState"         value="doSetPassword">
   <INPUT type=hidden name="nextPage"          value="">
   <INPUT type=hidden name="activePage"        value="">
   <INPUT type=hidden name="eDirCommand"       value="read">
   <INPUT type=hidden name="eDirSearch"        value="<%= c.var("eDirSearch") %>">
   <INPUT type=hidden name="merge"	           value="dev.GenConf">


   <% c.set("TaskHeader.title", c.string("SetPassword.Header"));
      c.set("TaskHeader.iconUrl", "dir/User.gif");
      c.set("TaskHeader.iconAlt", c.string("ObjectType.User"));

      c.set("SimplePassword.formName", "document.form");
      c.set("SimplePassword.contextControlName", "document.form.single");
      c.set("SimplePassword.labelsAbove", "true");
      c.set("SimplePassword.tableCellPadding", "1");
      c.set("SimplePassword.dsPasswordControlName", "document.form.SetPswdNewPassword");

      String onFieldSize = "";
      String passwordFieldSize = "";
      if (!session.getAttribute("DeviceType").equals("pocket"))
      {
         onFieldSize = c.string("UI.textboxSize");
         passwordFieldSize = c.string("UI.textboxSize");
      }
      else
      {
         onFieldSize = c.string("PocketUI.textboxSizeOneButton");
         passwordFieldSize = c.string("PocketUI.textboxSize");
      }
   %>

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

<TABLE width="100%" border="0" cellspacing="0" cellpadding="1">
   <tr>
      <td class=mediumtext>
         <NOBR><%= c.string("General.objectName") %>: </NOBR><BR>
         <INPUT <% if (!session.getAttribute("DeviceType").equals("pocket") && c.var("Task.SetPassword.Param.Auth").equals("NDS")) { %>onchange="enableSimplePassword(this);" <%}%>type=text name="single" value="<%= Utils.toTag(c.var("targetName")) %>" size=<%= onFieldSize %>>
         <% c.set("OS.History", "true");
         if (c.var("Task.SetPassword.Param.Auth").equals("LDAP"))
         {
            c.set("OS.TypeFilter", "*");
         }
         else
         {
            c.set("OS.TypeFilter", "ndsLoginProperties");
            if (!session.getAttribute("DeviceType").equals("pocket"))
            {
               c.set("OS.CallBack", "enableSimplePasswordCallBack");
            }
         }

         c.set("OS.Control", "single"); %>
         <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
      </td>
   </tr>

   <tr><td class=mediumtext><%= c.string("SetPassword.NewPassword") %></td></tr>
   <tr><td><input type=password name="SetPswdNewPassword" value="" size=<%= passwordFieldSize %> maxlength="127"></td></tr>

   <tr><td class=mediumtext><%= c.string("SetPassword.RenterPassword") %></td></tr>
   <tr><td><input type=password name="SetPswdVerifyPassword" value="" size=<%= passwordFieldSize %> maxlength="127"></td></tr>

<% if(!session.getAttribute("DeviceType").equals("pocket") && c.var("Task.SetPassword.Param.Auth").equals("NDS")){%>
   <tr><td colspan="3"><hr noshade size="1"></td></tr>

   <jsp:include page='<%= c.getPath("base/SetSimplePassword_inc.jsp") %>' flush="true" />
<% } %>

</TABLE>

   <jsp:include page='<%= c.getPath("dev/Bar_inc.jsp") %>' flush="true" />
   <INPUT type=image name="OkButton" alt="<%= c.string("Button.OK.alt") %>" src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.OK.image") %>" border=0><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>






