<%@  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" %>
<%@ taglib uri="/WEB-INF/iman.tld" prefix="iman" %>

<iman:stringtable bundle="BaseResources"/>

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

<HTML>
<HEAD>
   <TITLE><%= c.string("ProductName") %></TITLE>

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

   <LINK rel='stylesheet' href='<%= c.getModulesUrl() + "/dev/css/hf_style.css" %>'>
   <jsp:include page='<%= c.getPath("dev/PageScripts_inc.jsp") %>' flush="true" />
   <jsp:include page='<%= c.getPath("dev/eMFrameScripts_inc.jsp") %>' flush="true" />
   <jsp:include page='<%= c.getPath("dev/OSScripts_inc.jsp") %>' flush="true" />
   <iman:calendarScripts/>
   <SCRIPT language="JavaScript">

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

     /*
      *This function sets the last login time, using a localized string that 
      *uses the client timezone.
      */
	  function populateLastLoginTimestamp(localizedString){
	  	 var form = document.forms[0];
	  	 form._Login_Time.value = localizedString;
	  }
	
      function onInit()
      {
         var form=document.forms[0];

         <%-- -------------- --%>
         <%-- Login Disabled --%>
         <%-- -------------- --%>
         var xml="<%= c.toScript(c.var("eDir$target$Login_Disabled")) %>";
         if(getValueFromXml(xml) == 'true')
            form._eDir$target$Login_Disabled.checked=true;
         initMooMode("_Login_Disabled", xml);

         <%-- ------------------------ --%>
         <%-- Password Expiration Time --%>
         <%-- ------------------------ --%>
         var strXml = "<%= c.toScript(c.var("eDir$target$Login_Expiration_Time")) %>";
         secStr = getValueFromXml(strXml);
         msecs = parseInt(secStr);

         if(msecs>0)
         {
            var date = new Date(msecs);
            form.expDay.value = date.getDate();
            form.expMonth.options[date.getMonth()].selected = true;
            form.expYear.value = date.getFullYear();
            form.expHour.options[date.getHours()].selected = true;
            form.expMinute.value = date.getMinutes();
            if(form.expMinute.value.length == 1)
            {
               form.expMinute.value = "0"+form.expMinute.value;
            }
            form.hasExpiration.checked = true;
         }

         initMooMode("_Login_Expiration_Time", strXml);

         // disable if no rights
         <% if (c.var("eDirRights$target$Login_Expiration_Time").equals("R") || c.var("eDirRights$target$Login_Expiration_Time").equals("NONE")){ %>
            disableControl(form.expDay);
            disableControl(form.expMonth);
            disableControl(form.expYear);
            disableControl(form.expHour);
            disableControl(form.expMinute);
         <% } %>


         <%-- -------------------------- --%>
         <%-- Login Maximum Simultaneous --%>
         <%-- -------------------------- --%>
         var strXml = "<%= c.toScript(c.var("eDir$target$Login_Maximum_Simultaneous")) %>";
         secStr = getValueFromXml(strXml);
         if( secStr.length != 0 )
         {
            msim = parseInt(getValueFromXml("<%= c.var("eDir$target$Login_Maximum_Simultaneous") %>"));
            form._Login_Maximum_Simultaneous.value = secStr;
            lmsTemp = secStr;
            form.limitConnections.checked = true;
         }

         initMooMode("_Login_Maximum_Simultaneous", strXml);


         <%-- disable if no rights --%>
         <% if (c.var("eDirRights$target$Login_Maximum_Simultaneous").equals("R") || c.var("eDirRights$target$Login_Maximum_Simultaneous").equals("NONE")){ %>
            form._Login_Maximum_Simultaneous.style.backgroundColor = DISABLED_COLOR;
            form._Login_Maximum_Simultaneous.disabled = true;
            form.limitConnections.disabled = true;
         <% } %>


         <%-- --------------- --%>
         <%-- Last Login Time --%>
         <%-- --------------- --%>
         secStr = getValueFromXml("<%= c.var("eDir$target$Login_Time") %>");

         if( secStr.length != 0 )
         {
            msecs = parseInt(getValueFromXml("<%= c.var("eDir$target$Login_Time") %>"));
            var date = new Date(msecs);
            var dateStr = date.toLocaleString();            
            var timezoneOffset = date.getTimezoneOffset() * 60*1000 *-1;
            window.upExchanger = new exchanger("dateFrame");
            
            var url = "webacc?taskId=dev.Empty&merge=base.DateExchanger&timezoneOffset="+timezoneOffset+"&fasttime="+msecs;
            
            upExchanger.sendData(url);
         }

         <%-- this sets up a default date --%>
         var date = new Date()
         defaultDateStr = date.toLocaleString();
         defaultDateStrLoc = defaultDateStr.indexOf(", ");
         defaultDateStr = defaultDateStr.substring(defaultDateStrLoc+2, defaultDateStr.length);
      }

      <%-- ---------------------------------------------------- --%>
      <%-- isPageValid                                          --%>
      <%-- called when user leaves this page or applys changes  --%>
      <%-- ---------------------------------------------------- --%>
      function isPageValid()
      {
         var form=document.forms[0];

         <%-- Login Disabled --%>
         form.eDir$target$Login_Disabled.value = toXmlString((form._eDir$target$Login_Disabled.checked?'true':'false')<% if (c.var("Task.moo").equals("true")) { %>, form._Login_Disabled_mode.value<% } %>);

         <%-- Password Expiration Time --%>
         if((form.hasExpiration.checked)&&(form.expDay.value.length != 0))
         {
            var date = new Date(form.expYear.value, form.expMonth.value, form.expDay.value, form.expHour.value, form.expMinute.value);
         	if(form.expYear.value<1970 || form.expYear.value>2037)
            {
               alert("<iman:string key="PasswordRestriction.TimeBefore2038"/>");
               return false;
            }
            var milliSeconds = date.valueOf();

            if( isNaN(milliSeconds))
            {
               alert("<%= c.string("PasswordRestrictionsFormatError") %>");
               form.expDay.focus();
               return false;
            }

            form.eDir$target$Login_Expiration_Time.value = toXmlString(""+milliSeconds <% if (c.var("Task.moo").equals("true")) { %>, form._Login_Expiration_Time_mode.value<% } %>);
         }
         else
         {
            form.eDir$target$Login_Expiration_Time.value = toXmlString(""<% if (c.var("Task.moo").equals("true")) { %>, form._Login_Expiration_Time_mode.value<% } %>);
         }

         <%-- Maximum Simultaneous Login --%>
         form.eDir$target$Login_Maximum_Simultaneous.value = getWidgetValueAsXml(form._Login_Maximum_Simultaneous);   // for Login Maximum Simultaneous

         return true;
      }

      function disableControl(control)
      {
         control.disabled = true;
         control.style.backgroundColor = DISABLED_COLOR;
      }

      function enableControl(control)
      {
         control.disabled = false;
         control.style.backgroundColor = ENABLED_COLOR;
      }

      function EnableDisableControls()
      {
      <% if (c.var("eDirRights$target$Login_Maximum_Simultaneous").equals("RW")){ %>

         with(document.forms[0])
         {
            if (_eDir$target$Login_Disabled.checked)
            {
               disableControl(hasExpiration);
               disableControl(expDay);
               disableControl(expMonth);
               disableControl(expYear);
               disableControl(expHour);
               disableControl(expMinute);
               disableControl(_Login_Maximum_Simultaneous);
               disableControl(limitConnections);
            }
            else
            {
               enableControl(hasExpiration);
               enableControl(limitConnections);

               if (hasExpiration.checked)
               {
                  enableControl(expDay);
                  enableControl(expMonth);
                  enableControl(expYear);
                  enableControl(expHour);
                  enableControl(expMinute);

                  if (expDay.value.length == 0)
                  {
                     // now default
                     var date = new Date();
                     expDay.value = date.getDate();
                     expMonth.options[date.getMonth()].selected = true;
                     expYear.value = date.getFullYear();
                     expMinute.value = "00";
                  }

                  if (expDay.disabled == false)
                  {
				        expDay.focus();
                  }
               }
               else
               {
                  disableControl(expDay);
                  disableControl(expMonth);
                  disableControl(expYear);
                  disableControl(expHour);
                  disableControl(expMinute);
               }

               if (limitConnections.checked == true)
               {
                  enableControl(_Login_Maximum_Simultaneous);

                  if (lmsTemp.length == 0)
                     _Login_Maximum_Simultaneous.value = 1;
                  else
                     _Login_Maximum_Simultaneous.value = lmsTemp;

                  if (!_Login_Maximum_Simultaneous.disabled)
                  {
                     _Login_Maximum_Simultaneous.focus();
                  }
               }
               else
               {
                  lmsTemp = _Login_Maximum_Simultaneous.value;
                  _Login_Maximum_Simultaneous.value = "";
                  _Login_Maximum_Simultaneous.style.backgroundColor = DISABLED_COLOR;
                  _Login_Maximum_Simultaneous.disabled = true;
               }

            }

            if (!_eDir$target$Login_Disabled.checked && !hasExpiration.checked && !limitConnections.checked && !_eDir$target$Login_Disabled.disabled)
            {
               _eDir$target$Login_Disabled.focus();
            }
         }
      <% } %>
      }
      
      /*callback function for calendar widget*/
      function getExpTime()
      {
         var form = document.form;
         if(form.hasExpiration.checked == true)
         {
            return new Date(form.expYear.value, form.expMonth.value, form.expDay.value, form.expHour.value, form.expMinute.value);
         }
         else
         {
            return new Date();
         }
      }
      
      /*callback function for calendar widget*/      
      function returnExpTime(date)
      {
         var form = document.form;
         if(form.hasExpiration.checked == true)
         {
            form.expDay.value = date.getDate();
            form.expMonth.options[date.getMonth()].selected = true;
            form.expYear.value = date.getFullYear();
            form.expHour.options[date.getHours()].selected = true;
            form.expMinute.value = date.getMinutes();
            if(form.expMinute.value.length == 1)
            {
               form.expMinute.value = "0"+form.expMinute.value;
            }
         }
      }
   </SCRIPT>
</HEAD>

<BODY onLoad="onInit();EnableDisableControls();">
<FORM name="form" method=post action="webacc">
   <jsp:include page='<%= c.getPath("dev/Messagebar_inc.jsp") %>' flush="true" />
	<jsp:include page='<%= c.getPath("dev/BookVars_inc.jsp") %>' flush="true" />


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

      <%-- -------------- --%>
      <%-- Login Disabled --%>
      <%-- -------------- --%>
      <TR>
         <TD style="padding-right:4"align=left valign=middle>
            <INPUT name='_eDir$target$Login_Disabled' onClick="EnableDisableControls()" type=checkbox <% if (c.var("eDirRights$target$Login_Disabled").equals("R") || c.var("eDirRights$target$Login_Disabled").equals("NONE")) { %>DISABLED<% } %> >
         </TD>
         <TD align=left valign=middle colspan=2>
            <INPUT name='eDir$target$Login_Disabled' type=hidden><%= c.toDisplay(c.string("LoginRestriction.AcctDisabled")) %>
         </TD>
         <TD>
            <% if (c.var("Task.moo").equals("true")) {    c.set("ModeSelector.name", "_Login_Disabled_mode"); %>&nbsp;&nbsp;<jsp:include page='<%= c.getPath("dev/ModeSelector_inc.jsp") %>' flush="true" /><% } %>
         </TD>
      </TR>
      <TR><TD height=9></TD></TR>


      <%-- --------------------- --%>
      <%-- Login Expiration Time --%>
      <%-- --------------------- --%>
      <TR>
         <TD align=left valign=middle>
            <input type=Checkbox name="hasExpiration" value="" <% if (c.var("eDirRights$target$Login_Expiration_Time").equals("RW")) {%> onClick="EnableDisableControls()" <%} %> <% if (c.var("eDirRights$target$Login_Expiration_Time").equals("R") || c.var("eDirRights$target$Login_Expiration_Time").equals("NONE")) { %>DISABLED<% } %> >
         </TD>
         <TD align=left valign=middle>
            <%= c.string("ModifyOrg.HasExpiration") %>
         </TD>
      </tr>
      <TR>
         <TD align=left></TD>
         <TD><NOBR><%= c.toDisplay(c.string("LoginExpir.DateTime")) %>:</NOBR></TD>
      </TR>

      <TR>
         <TD>&nbsp;</TD>

         <TD class=smalltext>
           &nbsp;&nbsp;&nbsp;<%= c.string("Date.Day") %>: <input type=text name=expDay size=2>&nbsp;
            <%= c.string("Date.Month") %>: <select name=expMonth size="1" style="width:130px">
                <option value=0><%= c.string("Date.Month.0") %>
                <option value=1><%= c.string("Date.Month.1") %>
                <option value=2><%= c.string("Date.Month.2") %>
                <option value=3><%= c.string("Date.Month.3") %>
                <option value=4><%= c.string("Date.Month.4") %>
                <option value=5><%= c.string("Date.Month.5") %>
                <option value=6><%= c.string("Date.Month.6") %>
                <option value=7><%= c.string("Date.Month.7") %>
                <option value=8><%= c.string("Date.Month.8") %>
                <option value=9><%= c.string("Date.Month.9") %>
                <option value=10><%= c.string("Date.Month.10") %>
                <option value=11><%= c.string("Date.Month.11") %>
            </select>&nbsp;
           <%= c.string("Date.Year") %>: <input type=text name=expYear size=4>&nbsp;
           <%= c.string("Date.Time") %>: <select name=expHour>
              <option value=00>00</option>
              <option value=01>01</option>
              <option value=02>02</option>
              <option value=03>03</option>
              <option value=04>04</option>
              <option value=05>05</option>
              <option value=06>06</option>
              <option value=07>07</option>
              <option value=08>08</option>
              <option value=09>09</option>
              <option value=10>10</option>
              <option value=11>11</option>
              <option value=12>12</option>
              <option value=13>13</option>
              <option value=14>14</option>
              <option value=15>15</option>
              <option value=16>16</option>
              <option value=17>17</option>
              <option value=18>18</option>
              <option value=19>19</option>
              <option value=20>20</option>
              <option value=21>21</option>
              <option value=22>22</option>
              <option value=23>23</option>
           </select>:<input type=text name=expMinute size=2 maxlength=2>&nbsp;
           <iman:calendar onLoadCallback="getExpTime" name="expTimeWidget" returnCallback="returnExpTime"/>

            <INPUT name='eDir$target$Login_Expiration_Time' type=hidden value="<%= c.var("eDir$target$Login_Expiration_Time") %>">
        </TD>

         <TD valign=top>
            <% if (c.var("Task.moo").equals("true")) {    c.set("ModeSelector.name", "_Login_Expiration_Time_mode"); %>&nbsp;&nbsp;<jsp:include page='<%= c.getPath("dev/ModeSelector_inc.jsp") %>' flush="true" /><% } %>
         </TD>
      </TR>
      <TR><TD height=9></TD></TR>


      <%-- -------------------------- --%>
      <%-- Login Maximum Simultaneous --%>
      <%-- -------------------------- --%>
      <TR>
         <TD colspan=3><input type=Checkbox name="limitConnections" value="" <% if (c.var("eDirRights$target$Login_Maximum_Simultaneous").equals("RW")) {%> onClick="EnableDisableControls()" <%} %>  <% if (c.var("eDirRights$target$Login_Maximum_Simultaneous").equals("R") || c.var("eDirRights$target$Login_Maximum_Simultaneous").equals("NONE")) { %>DISABLED<% } %> >&nbsp;<%= c.string("ModifyOrg.LimitConnections") %></TD>
      </tr>

      <TR>
         <TD>&nbsp;</TD>
         <TD align=left nowrap>
            <INPUT name='eDir$target$Login_Maximum_Simultaneous' type=hidden value="<%= c.var("eDir$target$Login_Maximum_Simultaneous") %>">
            <TABLE cellpadding="0" cellspacing="0">
               <TR>
                  <TD><%= c.toDisplay(c.string("LoginRestriction.MaxConn")) %>:&nbsp;</TD>
                  <TD><INPUT type=text id="spinner1" name=_Login_Maximum_Simultaneous size=<%= c.string("UI.numberboxSize") %> style="padding-left:3;padding-right:3;width:<%= c.string("UI.numberboxPixel") %>" onChange='if(!validateIntegerField(document.forms[0]._Login_Maximum_Simultaneous, 1, 32000)){this.focus();return false;}'   <% if (c.var("eDirRights$target$Login_Maximum_Simultaneous").equals("R") || c.var("eDirRights$target$Login_Maximum_Simultaneous").equals("NONE")) { %>READONLY<% } %> ></TD>
                  <TD><iman:spinner elementId="spinner1" /></TD>
               </TR>
            </TABLE>
         </TD>
         <TD>
         </TD>
         <TD valign=top>
            <% if (c.var("Task.moo").equals("true")) {    c.set("ModeSelector.name", "_Login_Maximum_Simultaneous_mode"); %>&nbsp;&nbsp;<jsp:include page='<%= c.getPath("dev/ModeSelector_inc.jsp") %>' flush="true" /><% } %>
         </TD>
      </TR>
      <TR><TD height=9></TD></TR>


      <%-- --------------- --%>
      <%-- Last Login Time --%>
      <%-- --------------- --%>
      <TR>
         <TD align=left colspan="2" nowrap>
            &nbsp;<%= c.toDisplay(c.string("LoginTime.LastLogin")) %>:&nbsp;
            &nbsp;<INPUT type=text name="_Login_Time" size=<%= c.string("UI.textboxSize") %> style="border:0;width:<%= c.string("UI.textboxPixel") %>" READONLY>
         </TD>
      </TR>
      <TR><TD height=9></TD></TR>
	  <IFRAME src="/nps/Empty.html" style="visibility: hidden" name="dateFrame" id="dateFrame" width="0" height="0" marginwidth="0" marginheight="0"></IFRAME>
   </TABLE>
</FORM>
</BODY>
</HTML>

