<%@  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("BaseResources");
   c.stringTable("FwResources");
%>

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


<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" />
   <SCRIPT language="JavaScript">
      var ENABLED_COLOR = "white";
      var DISABLED_COLOR = "#EFEEE9";
      function onInit()
      {
         var form=document.forms[0];
         initWidgetFromXml(form._Account_Balance, "<%= c.toScript(c.var("eDir$target$Account_Balance")) %>");

         var xStr="<%= c.toScript(c.var("eDir$target$Allow_Unlimited_Credit")) %>";
         if(getValueFromXml(xStr) == 'true' || getValueFromXml(xStr) == '')
            form._eDir$target$Allow_Unlimited_Credit.checked=true;
         initMooMode("_Allow_Unlimited_Credit", xStr);

         initWidgetFromXml(form._Minimum_Account_Balance, "<%= c.toScript(c.var("eDir$target$Minimum_Account_Balance")) %>");
         window.saved_Minimum_Account_Balance = form._Minimum_Account_Balance.value;

         <% if (c.var("eDirRights$target$Account_Balance").equals("RW")) { %>
            <% if (!session.getAttribute("DeviceType").equals("pocket")) { %>EnableDisableControls();<% } %>
         <% } %>
      }

      function isPageValid() // called when user leaves this page or applys changes
      {
         <% if (c.var("eDirRights$target$Account_Balance").equals("RW")) { %>
            var form=document.forms[0];
            form.eDir$target$Account_Balance.value = getWidgetValueAsXml(form._Account_Balance);   // for Account Balance
            form.eDir$target$Allow_Unlimited_Credit.value = toXmlString((form._eDir$target$Allow_Unlimited_Credit.checked?'true':'false')<% if (c.var("Task.moo").equals("true")) { %>, form._Allow_Unlimited_Credit_mode.value<% } %>);
            form.eDir$target$Minimum_Account_Balance.value = getWidgetValueAsXml(form._Minimum_Account_Balance);   // for Minimum Account Balance
         <% } %>

         return true;
      }

      function EnableDisableControls()
      {
         with(document.forms[0])
         {
            if (_eDir$target$Allow_Unlimited_Credit.checked == true)
            {
               _Minimum_Account_Balance.disabled = true;
               _Minimum_Account_Balance.style.backgroundColor = DISABLED_COLOR;
               window.saved_Minimum_Account_Balance = _Minimum_Account_Balance.value;
               _Minimum_Account_Balance.value = "";
               eDir$target$Allow_Unlimited_Credit.value = false;
            }
            else
            {
               _Minimum_Account_Balance.disabled = false;
               _Minimum_Account_Balance.focus();

               _Minimum_Account_Balance.style.backgroundColor = ENABLED_COLOR;
               _Minimum_Account_Balance.value = window.saved_Minimum_Account_Balance;
               eDir$target$Allow_Unlimited_Credit.value = true;

               if(_Minimum_Account_Balance.value=="")
                  _Minimum_Account_Balance.value = "0";
            }
         }
      }

   </SCRIPT>

</HEAD>

<BODY onLoad="onInit()">

<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" />


   <!---- UI Created by UiHandlers ---->

      <TABLE class="mediumtext" border='0' bgcolor='#FFFFFF' cellpadding='0' cellspacing='0'>
      <!-- Account Balance -->
      <TR>
         <TD align=left colspan=2>
            <%= c.var("Account_BalanceDisplayName") %>:&nbsp;
         </TD>

         <TD>
            <% if (c.var("eDirRights$target$Account_Balance").equals("RW")) { %>
               <INPUT name='eDir$target$Account_Balance' type=hidden value="<%= c.var("eDir$target$Account_Balance") %>">
            <% } %>

            <TABLE cellpadding="0" cellspacing="0">
               <TR><TD><INPUT type=text name=_Account_Balance id="accountBalanceTF" style="padding-left:3;padding-right:3;" size=<%= c.string("UI.numberboxSize") %> style="width:<%= c.string("UI.numberboxPixel") %>"   <% if (c.var("eDirRights$target$Account_Balance").equals("R") || c.var("eDirRights$target$Account_Balance").equals("NONE")) { %>DISABLED<% } %> onChange='if(!validateIntegerField(this,-99999999,999999999)){this.focus();return false;}'></TD><TD><iman:spinner elementId="accountBalanceTF"/></TD></TR>
            </TABLE>
         </TD>
         <TD valign=top>
            <% if (c.var("Task.moo").equals("true")) {    c.set("ModeSelector.name", "_Account_Balance_mode"); %>&nbsp;&nbsp;<jsp:include page='<%= c.getPath("dev/ModeSelector_inc.jsp") %>' flush="true" /><% } %>
         </TD>
      </TR>
      <TR><TD height=5></TD></TR>

      <!-- Allow Unlimited Credit -->
      <TR>
         <TD align=left>&nbsp;&nbsp;&nbsp;&nbsp;

         <% if (c.var("eDirRights$target$Account_Balance").equals("RW")) { %>
            <INPUT name='eDir$target$Allow_Unlimited_Credit' type=hidden>
         <% } %>

         <INPUT onClick="EnableDisableControls();" name='_eDir$target$Allow_Unlimited_Credit' type=checkbox <% if (c.var("eDirRights$target$Allow_Unlimited_Credit").equals("R") || c.var("eDirRights$target$Allow_Unlimited_Credit").equals("NONE")) { %>DISABLED<% } %> >
         <%= c.var("Allow_Unlimited_CreditDisplayName") %>
         </TD>
         <TD>
            <% if (c.var("Task.moo").equals("true")) {    c.set("ModeSelector.name", "_Allow_Unlimited_Credit_mode"); %>&nbsp;&nbsp;<jsp:include page='<%= c.getPath("dev/ModeSelector_inc.jsp") %>' flush="true" /><% } %>
         </TD>
      </TR>
      <TR><TD height=15></TD></TR>


      <!-- Minimum Account Balance -->
      <TR>
         <TD align=left colspan=2>
            <%= c.var("Minimum_Account_BalanceDisplayName") %>:&nbsp;
         </TD>
         <TD>
            <% if (c.var("eDirRights$target$Account_Balance").equals("RW")) { %>
               <INPUT name='eDir$target$Minimum_Account_Balance' type=hidden value="<%= c.var("eDir$target$Minimum_Account_Balance") %>">
            <% } %>

            <TABLE cellpadding="0" cellspacing="0"><TR>
               <TD><INPUT type=text name=_Minimum_Account_Balance id="mabId" size="<%= c.string("UI.numberboxSize") %>" style="padding-left:3;padding-right:3;width:<%= c.string("UI.numberboxPixel") %>"   <% if (c.var("eDirRights$target$Minimum_Account_Balance").equals("R") || c.var("eDirRights$target$Minimum_Account_Balance").equals("NONE")) { %>DISABLED<% } %> onChange='if(!validateIntegerField(this,-99999999,999999999)){this.focus();return false;}'></TD>
               <TD><iman:spinner elementId="mabId" /></TD>
            </TR></TABLE>
         </TD>
         <TD valign=top>
            <% if (c.var("Task.moo").equals("true")) {    c.set("ModeSelector.name", "_Minimum_Account_Balance_mode"); %>&nbsp;&nbsp;<jsp:include page='<%= c.getPath("dev/ModeSelector_inc.jsp") %>' flush="true" /><% } %>
         </TD>
      </TR>

      <TR><TD height=9></TD></TR>
      </TABLE>

</FORM>
</BODY>
</HTML>
