<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" import="com.novell.webaccess.common.JSPConduit, com.novell.emframe.dev.eMFrameUtils, com.novell.emframe.fw.ObjectSelector" %>
<%   JSPConduit c = JSPConduit.getJSPConduit(request);
   c.stringTable("DevResources");
   c.stringTable("BaseResources");
%>
<script>
   formName = "<%= c.var("SimplePassword.formName") %>";
   contextControlName = "<%= c.var("SimplePassword.contextControlName") %>";
   dsPasswordControlName = "<%= c.var("SimplePassword.dsPasswordControlName") %>";

   <%
      if (c.var("SimplePassword.tableCellPadding").equals(""))
      {
         c.set("SimplePassword.tableCellPadding", "3");
      }
   %>


   function toggleDivPassword(id, hideOrShow)
   {
      document.getElementById(id).style.display = hideOrShow;
   }

   function getUniversalState(container)
   {
      if ((null == container) || (0 == container.length))
      {
         alert("<%= c.string("CreateUser.InvalidContext") %>");
         <%= c.var("SimplePassword.formName") %>.enableUniversalPassword.checked = false;
         return;
      }

      // this will call into the java code SetSimplePasswordTask.java to send data back to exchanger
      window.upExchanger = new exchanger("exchangerFrame");
      upExchanger.sendData("webacc?taskId=fw.SetSimplePassword&merge=fw.SetSimplePasswordExchanger&error=fw.SetSimplePasswordExchanger&SPWDuserContext=" + urlEncode(container));
   }

   // this is called from SetSimplePasswordExchanger.jsp
   function upCheckReturned(error, universalPasswordEnabled)
   {
      if(error != '')
      {
         alert("<%= c.string("SimplePassErr.UPStatusFailure") %>" + "\n" + error);
         <%= c.var("SimplePassword.formName") %>.enableUniversalPassword.checked = false;
         return;
      }

      if (universalPasswordEnabled == 'true')
      {
         alert("<%= c.string("SimplePassword.ErrorUPEnabled") %>");
         <%= c.var("SimplePassword.formName") %>.enableUniversalPassword.checked = false;
         return;
      }
      else
      {
         toggleDivPassword('SpasswordDiv', 'block');
         toggleDivPassword('SpasswordURLDiv', 'none');
         <%= c.var("SimplePassword.formName") %>.resetUniversalPassword.checked = true;

         // copy the values from DSpassword field to simple password
         <%= c.var("SimplePassword.formName") %>.simplepassword.value = <%= c.var("SimplePassword.dsPasswordControlName") %>.value;
         <%= c.var("SimplePassword.formName") %>.retypesimplepassword.value = <%= c.var("SimplePassword.dsPasswordControlName") %>.value;
      }
   }

   function hideUniversalPassword()
   {
      toggleDivPassword('SpasswordDiv', 'none');
      toggleDivPassword('SpasswordURLDiv', 'block');
      <%= c.var("SimplePassword.formName") %>.simplepassword.value = "";
      <%= c.var("SimplePassword.formName") %>.retypesimplepassword.value = "";
      <%= c.var("SimplePassword.formName") %>.enableUniversalPassword.checked = false;
   }


</script>

<tr><td colspan="3">
<div align="left" id="SpasswordURLDiv" style="background-color: white; margin-top: 0; display:block; width:500;" title="<%= c.string("SimplePassword.SetSimplePassword") %>">
   <TABLE width="500" border="0" cellspacing="0" cellpadding="3">
     <tr>
          <td class="mediumtext">
            <input type="checkbox" name="enableUniversalPassword" value="checkbox" onClick='getUniversalState(<%= c.var("SimplePassword.contextControlName") %>.value);' >&nbsp;<%= c.string("SimplePassword.SetSimplePassword") %>
          </td>
     </tr>
     <tr>
       <td class="smalltext2d" ><%= c.string("SimplePassword.SimplePasswordNote") %></td>
     </tr>
   </TABLE>
</div>
</tr></td>

<tr><td colspan="3">
<div align="left" id="SpasswordDiv" style="background-color: white; margin-top: 0; display:none; width:500;<% if (c.var("Browser.name").equals("MSIE")) { %> height:100; <%} %>" title="<%= c.string("SimplePassword.SetSimplePassword") %>">
   <TABLE width="500" border="0" cellspacing="0" cellpadding=<%= c.var("SimplePassword.tableCellPadding") %> >
     <tr>
          <td class="mediumtext">
            <input type="checkbox" name="resetUniversalPassword" value="checkbox" onClick='hideUniversalPassword();' >&nbsp;<%= c.string("SimplePassword.SetSimplePassword") %>
          </td>
     </tr>
     <tr>
       <td class=mediumtext nowrap><%= c.string("SimplePassword.SimplePassword") %></td>
       <% if (c.var("SimplePassword.labelsAbove").equals("true")) { out.print("</tr><tr>"); }%>
       <td class=smalltext2d><input type=password name="simplepassword" size="<%= c.string("UI.textboxSize") %>" maxlength="127" ></td>
     </tr>
     <tr>
       <td class=mediumtext nowrap><%= c.string("SimplePassword.RetypeSimplePassword") %></td>
       <% if (c.var("SimplePassword.labelsAbove").equals("true")) { out.print("</tr><tr>"); }%>
       <td class=smalltext2d><input type=password name="retypesimplepassword" size="<%= c.string("UI.textboxSize") %>" maxlength="127" ></td>
     </tr>
     <tr>
       <td colspan="2" class="smalltext2d"><%= c.string("SimplePassword.SimplePasswordNote") %></td>
     </tr>
   </TABLE>
</div>
</tr></td>

<IFRAME src="/nps/Empty.html" style="visibility: hidden" name="exchangerFrame" id="exchangerFrame" width="0" height="0" marginwidth="0" marginheight="0"></IFRAME>



