<?xml version="1.0" encoding="utf-8"?>
  <finScript version="1.00" exportedUtcDate="2026-04-29T00:00:00.0000000">
    <CreatedUserId>Admin</CreatedUserId>
    <CreatedUtcDate>2026-04-29T00:00:00.0000000</CreatedUtcDate>
    <UpdatedUserId>Admin</UpdatedUserId>
    <UpdatedUtcDate>2026-04-29T00:00:00.0000000</UpdatedUtcDate>
    <ScriptId>FINGSWID</ScriptId>
    <Description>Global Settings</Description>
    <ScriptType>HtmlWidget</ScriptType>
    <Active>true</Active>
    <AllowUI>false</AllowUI>
    <Bookmarks />
    <Category />
    <Code>' HtmlWidget_SettingsGlobalEdit
Option Explicit On
Option Strict On

' #################################################################
' Global Settings form HTML Widget
'
' Copyright (C) Intersoft Systems Limited 2026
'
' Version: 1.00 (02/06/2026)
'
' Usage: System-supplied HTML Widget to edit Global Settings
' #################################################################
' Version        Date  User     Job       Description
' -------  ----------  -------  --------  -------------------------
'    1.00  02/06/2026  ISS      J036836   Created (replaces SettingsGlobalEdit.ts/.htm and ISFormSettingsGlobalEditController.vb)
' #################################################################

' Constants
Private Const FORM_KEY As String = "SettingsGlobal"

' Objects
Private mCombinedParameters As ISKeyValueList
Private mParameters As ISKeyValueList
Private mStartupParameters As ISKeyValueList

' Standard Parameters
Private mPage As String
Private mReadOnly As Boolean

Public Function Main(eventId As String,
                     parametersJson As String,
                     startUpParametersJson As String,
                     hostingContext As isefinHtmlWidgetHostingContext,
                     requestInfo As finScriptRequestInfo,
                     ByRef returnValue As String) As Boolean

  ' Assume Success
  Main = True

  ' Get Parameters
  mParameters = finBL.CreateKeyValueList()
  mParameters.FromSimpleJsonString(parametersJson)
  mStartupParameters = finBL.CreateKeyValueList()
  mStartupParameters.FromSimpleJsonString(startUpParametersJson)

  ' Get Combined Parameters (Startup Parameters updated with event Parameters)
  mCombinedParameters = mStartupParameters.Clone()
  mCombinedParameters.UpdateFromKeyValueList(mParameters, True)

  ' Get Standard Parameters
  ' NOTE: Cloud caller passes "page" (lowercase); also accept "PageId" for desktop/script callers
  With mCombinedParameters
    mPage = .GetString("PageId")
    If Len(mPage) = 0 Then mPage = .GetString("page")
    mReadOnly = .GetBoolean("ReadOnly")
  End With

  ' Validate
  Main = finBL.HtmlWidgetUtilities.HasPermissionToViewFormKey(FORM_KEY)

  ' Handle Events
  If Main Then
    Select Case eventId
      Case ""
        ' Main event, i.e., return initial HTML content (excluding html and body tags)
        returnValue = ScriptInfo.TemplateText

      Case "Finish"
        ' Finish wizard
        Main = Finish(parametersJson, requestInfo, returnValue)

      Case "GetInitialisationInfo"
        ' Get Initialisation Information required for this wizard
        Main = GetInitialisationInfo(returnValue)

      Case Else
        Main = False
        finBL.Error.ErrorBeginFormat("Unhandled event '{0}'", eventId)
    End Select
  End If

End Function

''' &lt;summary&gt;
'''  Get Initialisation Information required for this wizard.
''' &lt;/summary&gt;
Public Function GetInitialisationInfo(ByRef response As String) As Boolean

  Dim FormInitialisationInfo As FormInitialisationInfo
  Dim Settings As finSettings
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Validate

  ' Load Settings
  If Success Then
    Settings = finBL.Settings
  End If

  ' Get Initialisation Info
  If Success Then
    FormInitialisationInfo = New FormInitialisationInfo()
    With FormInitialisationInfo
      ' Form
      .PageId = mPage
      If finBL.Database.IsReadOnly OrElse mReadOnly OrElse Not finBL.CurrentUser.IsAdministrator Then
        .ReadOnly = True
      Else
        .ReadOnly = False
      End If

      ' Configuration
      .DatabaseName = Settings.DatabaseName
      .PromptOnSave = True

      ' Add-On flags (used to hide irrelevant fields)
      .AddOnsLoanAny = Settings.AddOns.LoansAny
      .AddOnsDepositAccount = Settings.AddOns.DepositAccount
      .AddOnsCurrentAccount = Settings.AddOns.CurrentAccount
      .AddOnsExternalParty = Settings.AddOns.ExternalParty
      .AddOnsSecuritisation = Settings.AddOns.Securitisation
      .AddOnsBranch = Settings.AddOns.Branch
      .AddOnsPool = Settings.AddOns.Pool
      .AddOnsWorkflow = Settings.AddOns.Workflow
      .AddOnsSecurityRegisterPPSR = Settings.AddOns.SecurityRegisterPPSR

      ' -------
      ' General
      ' -------
      .IncludeSettingsGeneral = True

      ' General.Database
      .CountryCode = Settings.CountryCode
      .DatabaseOpenMessage = Settings.DatabaseOpenMessage
      .PhoneDialDefaultAreaCode = Settings.PhoneDialDefaultAreaCode
      .PhoneDialDefaultInternationalCode = Settings.PhoneDialDefaultInternationalCode

      ' General.Formatting
      .ConvertCodesToUpperCase = Settings.ConvertCodesToUpperCase
      .DateFormatLongDocuments = Settings.DateFormatLongDocuments
      .DateFormatShortDocuments = Settings.DateFormatShortDocuments

      ' General.Performance
      .PerformanceShowIncompleteAccountCount = Settings.PerformanceShowIncompleteAccountCount
      .PerformanceShowOpenWorkflowCount = Settings.PerformanceShowOpenWorkflowCount
      .PerformanceShowUnactionedLogCount = Settings.PerformanceShowUnactionedLogCount
      .PerformanceShowUnpublishedLogCount = Settings.PerformanceShowUnpublishedLogCount

      ' General.SummaryPages
      .SummaryPageStandardBlocksOverrideScriptId = Settings.SummaryPageStandardBlocksOverrideScriptId
      .SummaryPagesAlwaysShowTimeZoneInformationFromWeb = Settings.SummaryPagesAlwaysShowTimeZoneInformationFromWeb
      .SummaryPagesShowBranch = Settings.SummaryPagesShowBranch
      .SummaryPagesShowBroker = Settings.SummaryPagesShowBroker
      .SummaryPagesShowBulkFunder = Settings.SummaryPagesShowBulkFunder
      .SummaryPagesShowDealer = Settings.SummaryPagesShowDealer
      .SummaryPagesShowDepartment = Settings.SummaryPagesShowDepartment
      .SummaryPagesShowNotes = Settings.SummaryPagesShowNotes
      .SummaryPagesShowPool = Settings.SummaryPagesShowPool

      ' General.TimeZones
      .TimeZoneList = finBL.Runtime.TimeZones.ToCsvString(True)
      .TimeZoneUse = Settings.TimeZoneUse
      .TimeZoneWindowsDisplayName = Settings.TimeZoneWindowsDisplayName
      .TimeZoneWindowsDisplayNameAvailableList = Settings.TimeZoneWindowsDisplayNameAvailableList

      ' General.UserInterface
      .GridsSortReverseChronological = Settings.GridsSortReverseChronological

      ' --------
      ' Accounts
      ' --------
      .IncludeSettingsAccounts = True

      ' Accounts.NewAccounts
      .AccountDefaultNameFromAllOwnerClients = Settings.AccountDefaultNameFromAllOwnerClients
      .AccountNextId = Settings.AccountNextId
      .AccountUnknownClientId = Settings.AccountUnknownClientId
      If Settings.AddOns.LoansAny Then
        .AccountLoanNextId = Settings.AccountLoanNextId
        .AccountRefinanceIdMethodText = Settings.AccountRefinanceIdMethodText
      End If
      If Settings.AddOns.DepositAccount Then
        .AccountDepositNextId = Settings.AccountDepositNextId
        .AccountReinvestIdMethodText = Settings.AccountReinvestIdMethodText
      End If
      If Settings.AddOns.CurrentAccount Then
        .AccountCurrentNextId = Settings.AccountCurrentNextId
      End If

      ' -------
      ' Clients
      ' -------
      .IncludeSettingsClients = True

      ' Clients.NewClients
      .ClientDefaultAddressee = Settings.ClientDefaultAddressee
      .ClientDefaultSalutation = Settings.ClientDefaultSalutation
      .ClientNextId = Settings.ClientNextId

      ' Clients.Contacts
      .ClientAddressPhysicalContactMethodId = Settings.ClientAddressPhysicalContactMethodId
      .ClientAddressPostalContactMethodId = Settings.ClientAddressPostalContactMethodId
      .ClientEmailContactMethodId = Settings.ClientEmailContactMethodId
      .ClientFacsimileContactMethodId = Settings.ClientFacsimileContactMethodId
      .ClientMobileContactMethodId = Settings.ClientMobileContactMethodId
      .ClientPhoneContactMethodId = Settings.ClientPhoneContactMethodId
      .ClientPhoneWorkContactMethodId = Settings.ClientPhoneWorkContactMethodId

      ' Clients.WebAccess
      .ClientWebLoginLockoutAttempts = Settings.ClientWebLoginLockoutAttempts
      .ClientWebLoginLockoutMinutes = Settings.ClientWebLoginLockoutMinutes
      .ClientWebLoginLockoutTimespan = Settings.ClientWebLoginLockoutTimespan
      .ClientWebPasswordMinLength = Settings.ClientWebPasswordMinLength
      .ClientWebPasswordStrong = Settings.ClientWebPasswordStrong
      .WebAutomationUseClientWebAccess = Settings.WebAutomationUseClientWebAccess
      .WebAutomationUseWebMail = Settings.WebAutomationUseWebMail

      ' ----------------
      ' External Parties
      ' ----------------
      If Settings.AddOns.ExternalParty Then
        .IncludeSettingsExternalParties = True

        ' ExternalParties.General
        .AccountBdmResolveMethod = Settings.AccountBdmResolveMethodText
        .DefaultExternalPartyBrokerClientClientGroupId = Settings.DefaultExternalPartyBrokerClientClientGroupId
        If Settings.AddOns.Securitisation Then
          .DefaultExternalPartyBulkFunderClientClientGroupId = Settings.DefaultExternalPartyBulkFunderClientClientGroupId
        End If
        .DefaultExternalPartyClientClientGroupId = Settings.DefaultExternalPartyClientClientGroupId
        .DefaultExternalPartyClientClientTypeId = Settings.DefaultExternalPartyClientClientTypeId
        .DefaultExternalPartyClientManagerUserId = Settings.DefaultExternalPartyClientManagerUserId
        .DefaultExternalPartyDealerClientClientGroupId = Settings.DefaultExternalPartyDealerClientClientGroupId
        .DefaultExternalPartyInsurerClientClientGroupId = Settings.DefaultExternalPartyInsurerClientClientGroupId
        .ExternalPartyNewClientEmploymentIdDefault = Settings.ExternalPartyNewClientEmploymentIdDefault
        .ExternalPartyNewClientIdDefault = Settings.ExternalPartyNewClientIdDefault
        .ExternalPartyShowRelatedAccountsOnly = Settings.ExternalPartyShowRelatedAccountsOnly
      End If

      ' -----
      ' Users
      ' -----
      .IncludeSettingsUsers = True

      ' Users.General
      .DefaultUserGroupId = Settings.DefaultUserGroupId
      .DefaultUserPolicyId = Settings.DefaultUserPolicyId
      .UserEmailsForceUnique = Settings.UserEmailsForceUnique
      .UserNewWizardValidatorScriptId = Settings.UserNewWizardValidatorScriptId

      ' Edit Information
      .AccountBdmResolveMethodList = finBL.Enums.isefinAccountBdmResolveMethod_GetList().ToCsvString()
      .AccountRefinanceIdMethodList = finBL.Enums.isefinAccountRefinanceIdMethod_GetList().ToCsvString()
      .AccountReinvestIdMethodList = finBL.Enums.isefinAccountRefinanceIdMethod_GetList().ToCsvString()
      .ClientDefaultAddresseeList = finSettings.ClientDefaultAddresseeList
      .ClientDefaultSalutationList = finSettings.ClientDefaultSalutationList
      .CountryCodesList = finBL.SupportedCountries.GetCountryCodesList().ToCsvString()
      .DefaultExternalPartyClientClientTypeIdSqlWhere = finBL.HtmlWidgetUtilities.EncryptSql(finBL.ClientTypes.GetDataViewFilter(False, True))
      .DefaultExternalPartyClientManagerUserSqlWhere = finBL.HtmlWidgetUtilities.EncryptSql(finBL.Users.GetDataViewFilter(True, True, False, False, True, False))
      .ExternalPartyNewClientEmploymentIdDefaultBlankTip = finSettings.ExternalPartyNewClientEmploymentIdDefaultBlankTip
      .ExternalPartyNewClientEmploymentIdDefaultList = finSettings.ExternalPartyNewClientEmploymentIdDefaultList
      .ExternalPartyNewClientIdDefaultBlankTip = finSettings.ExternalPartyNewClientIdDefaultBlankTip
      .ExternalPartyNewClientIdDefaultList = finSettings.ExternalPartyNewClientIdDefaultList
      .SummaryPageStandardBlocksOverrideSqlWhere = finBL.HtmlWidgetUtilities.EncryptSql(finBL.Scripts.GetDataViewFilter(True, isefinScriptType.SummaryPageStandardBlockOverride, False, ""))
      .UserNewWizardValidatorScriptIdSqlWhere = finBL.HtmlWidgetUtilities.EncryptSql(finBL.Scripts.GetDataViewFilter(True, isefinScriptType.WizardValidator, True, "New User"))
    End With
  End If

  ' Response
  If Success Then
    Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(FormInitialisationInfo, response)
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Finish, i.e., Save Settings.
''' &lt;/summary&gt;
''' &lt;param name="parametersJson"&gt;
'''  A JSON formatted record (FormInitialisationInfo) object.
''' &lt;/param&gt;
Private Function Finish(parametersJson As String,
                        requestInfo As finScriptRequestInfo,
                        ByRef returnValue As String) As Boolean

  Dim obj As Object
  Dim Record As FormInitialisationInfo
  Dim Settings As finSettings
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Parse Parameters
  If finBL.Runtime.WebUtilities.DeserialiseJsonStringToObject(parametersJson, GetType(FormInitialisationInfo), obj) Then
    Record = DirectCast(obj, FormInitialisationInfo)
  Else
    Success = False
    finBL.Error.ErrorBegin("Failed to deserialise Global Settings parameters.")
  End If

  ' Validate
  If Success Then
    If Not finBL.CurrentUser.IsAdministrator Then
      Success = False
      finBL.Error.ErrorBegin("You do not have permission to update Global Settings.")
    End If
  End If

  ' Create and Load Settings
  ' NOTE: Global Settings cannot be edited via the read-only finBL.Settings singleton (this trips a "Security violation" guard when marked dirty). Create a dedicated editable instance and Load it, exactly as the desktop frmSettingsGlobal and the User Preferences Widget do.
  If Success Then
    Settings = finBL.CreateSettings()
    Success = Settings.Load()
  End If

  ' Update Settings
  ' NOTE: Do not wrap Settings.Save() in an external Transaction - Save() manages its own Transaction internally and a nested Transaction left open here causes the script host to fail with "uncommitted Database Transaction".
  If Success Then
    With Settings
      ' -------
      ' General
      ' -------
      If Record.IncludeSettingsGeneral Then
        ' General.Database
        .CountryCode = Record.CountryCode
        .PhoneDialDefaultInternationalCode = Record.PhoneDialDefaultInternationalCode
        .PhoneDialDefaultAreaCode = Record.PhoneDialDefaultAreaCode
        .DatabaseOpenMessage = finBL.Runtime.Validation.ValidateString(Record.DatabaseOpenMessage)

        ' General.Formatting
        .ConvertCodesToUpperCase = Record.ConvertCodesToUpperCase
        .DateFormatShortDocuments = Record.DateFormatShortDocuments
        .DateFormatLongDocuments = Record.DateFormatLongDocuments

        ' General.Performance
        .PerformanceShowUnactionedLogCount = Record.PerformanceShowUnactionedLogCount
        .PerformanceShowUnpublishedLogCount = Record.PerformanceShowUnpublishedLogCount
        .PerformanceShowOpenWorkflowCount = Record.PerformanceShowOpenWorkflowCount
        .PerformanceShowIncompleteAccountCount = Record.PerformanceShowIncompleteAccountCount

        ' General.SummaryPages
        .SummaryPageStandardBlocksOverrideScriptId = Record.SummaryPageStandardBlocksOverrideScriptId
        .SummaryPagesShowNotes = Record.SummaryPagesShowNotes
        .SummaryPagesShowBranch = Record.SummaryPagesShowBranch
        .SummaryPagesShowBroker = Record.SummaryPagesShowBroker
        .SummaryPagesShowBulkFunder = Record.SummaryPagesShowBulkFunder
        .SummaryPagesShowDealer = Record.SummaryPagesShowDealer
        .SummaryPagesShowDepartment = Record.SummaryPagesShowDepartment
        .SummaryPagesShowPool = Record.SummaryPagesShowPool
        .SummaryPagesAlwaysShowTimeZoneInformationFromWeb = Record.SummaryPagesAlwaysShowTimeZoneInformationFromWeb

        ' General.TimeZones
        .TimeZoneWindowsDisplayName = Record.TimeZoneWindowsDisplayName
        .TimeZoneUse = Record.TimeZoneUse
        .TimeZoneWindowsDisplayNameAvailableList = Record.TimeZoneWindowsDisplayNameAvailableList

        ' General.UserInterface
        .GridsSortReverseChronological = Record.GridsSortReverseChronological
      End If

      ' --------
      ' Accounts
      ' --------
      If Record.IncludeSettingsAccounts Then
        ' Accounts.NewAccounts
        .AccountNextId = Record.AccountNextId
        .AccountUnknownClientId = Record.AccountUnknownClientId
        .AccountDefaultNameFromAllOwnerClients = Record.AccountDefaultNameFromAllOwnerClients
        If .AddOns.LoansAny Then
          .AccountLoanNextId = Record.AccountLoanNextId
          .AccountRefinanceIdMethodText = Record.AccountRefinanceIdMethodText
        End If
        If .AddOns.DepositAccount Then
          .AccountDepositNextId = Record.AccountDepositNextId
          .AccountReinvestIdMethodText = Record.AccountReinvestIdMethodText
        End If
        If .AddOns.CurrentAccount Then
          .AccountCurrentNextId = Record.AccountCurrentNextId
        End If
      End If

      ' -------
      ' Clients
      ' -------
      If Record.IncludeSettingsClients Then
        ' Clients.NewClients
        .ClientNextId = Record.ClientNextId
        .ClientDefaultSalutation = Record.ClientDefaultSalutation
        .ClientDefaultAddressee = Record.ClientDefaultAddressee

        ' Clients.Contacts
        .ClientPhoneContactMethodId = Record.ClientPhoneContactMethodId
        .ClientPhoneWorkContactMethodId = Record.ClientPhoneWorkContactMethodId
        .ClientMobileContactMethodId = Record.ClientMobileContactMethodId
        .ClientEmailContactMethodId = Record.ClientEmailContactMethodId
        .ClientFacsimileContactMethodId = Record.ClientFacsimileContactMethodId
        .ClientAddressPostalContactMethodId = Record.ClientAddressPostalContactMethodId
        .ClientAddressPhysicalContactMethodId = Record.ClientAddressPhysicalContactMethodId

        ' Clients.WebAccess
        .WebAutomationUseClientWebAccess = Record.WebAutomationUseClientWebAccess
        .WebAutomationUseWebMail = Record.WebAutomationUseWebMail
        .ClientWebLoginLockoutAttempts = Record.ClientWebLoginLockoutAttempts
        .ClientWebLoginLockoutTimespan = Record.ClientWebLoginLockoutTimespan
        .ClientWebLoginLockoutMinutes = Record.ClientWebLoginLockoutMinutes
        .ClientWebPasswordMinLength = Record.ClientWebPasswordMinLength
        .ClientWebPasswordStrong = Record.ClientWebPasswordStrong
      End If

      ' ----------------
      ' External Parties
      ' ----------------
      If Record.IncludeSettingsExternalParties AndAlso .AddOns.ExternalParty Then
        ' ExternalParties.General
        .DefaultExternalPartyClientClientTypeId = Record.DefaultExternalPartyClientClientTypeId
        .DefaultExternalPartyClientManagerUserId = Record.DefaultExternalPartyClientManagerUserId
        .DefaultExternalPartyClientClientGroupId = Record.DefaultExternalPartyClientClientGroupId
        .DefaultExternalPartyBrokerClientClientGroupId = Record.DefaultExternalPartyBrokerClientClientGroupId
        If .AddOns.Securitisation Then
          .DefaultExternalPartyBulkFunderClientClientGroupId = Record.DefaultExternalPartyBulkFunderClientClientGroupId
        End If
        .DefaultExternalPartyDealerClientClientGroupId = Record.DefaultExternalPartyDealerClientClientGroupId
        .DefaultExternalPartyInsurerClientClientGroupId = Record.DefaultExternalPartyInsurerClientClientGroupId
        .ExternalPartyNewClientIdDefault = Record.ExternalPartyNewClientIdDefault
        .ExternalPartyNewClientEmploymentIdDefault = Record.ExternalPartyNewClientEmploymentIdDefault
        .AccountBdmResolveMethod = finBL.Enums.isefinAccountBdmResolveMethod_FromString(Record.AccountBdmResolveMethod)
        .ExternalPartyShowRelatedAccountsOnly = Record.ExternalPartyShowRelatedAccountsOnly
      End If

      ' -----
      ' Users
      ' -----
      If Record.IncludeSettingsUsers Then
        ' Users.General
        .DefaultUserGroupId = Record.DefaultUserGroupId
        .DefaultUserPolicyId = Record.DefaultUserPolicyId
        .UserNewWizardValidatorScriptId = Record.UserNewWizardValidatorScriptId
        .UserEmailsForceUnique = Record.UserEmailsForceUnique
      End If
    End With
  End If

  ' Save
  If Success Then
    Success = Settings.Save()
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Wizard Initialisation Information.
''' &lt;/summary&gt;
''' &lt;remarks&gt;
'''  This object is also used to save the Settings.
''' &lt;/remarks&gt;
Public Class FormInitialisationInfo

  ' Form
  Public PageId As String
  Public [ReadOnly] As Boolean

  ' Configuration
  Public DatabaseName As String
  Public PromptOnSave As Boolean

  ' Add-On flags
  Public AddOnsBranch As Boolean
  Public AddOnsCurrentAccount As Boolean
  Public AddOnsDepositAccount As Boolean
  Public AddOnsExternalParty As Boolean
  Public AddOnsLoanAny As Boolean
  Public AddOnsPool As Boolean
  Public AddOnsSecuritisation As Boolean
  Public AddOnsSecurityRegisterPPSR As Boolean
  Public AddOnsWorkflow As Boolean

  ' -------
  ' General
  ' -------
  Public IncludeSettingsGeneral As Boolean

  ' General.Database
  Public CountryCode As String
  Public DatabaseOpenMessage As String
  Public PhoneDialDefaultAreaCode As String
  Public PhoneDialDefaultInternationalCode As String

  ' General.Formatting
  Public ConvertCodesToUpperCase As Boolean
  Public DateFormatLongDocuments As String
  Public DateFormatShortDocuments As String

  ' General.Performance
  Public PerformanceShowIncompleteAccountCount As Boolean
  Public PerformanceShowOpenWorkflowCount As Boolean
  Public PerformanceShowUnactionedLogCount As Boolean
  Public PerformanceShowUnpublishedLogCount As Boolean

  ' General.SummaryPages
  Public SummaryPageStandardBlocksOverrideScriptId As String
  Public SummaryPagesAlwaysShowTimeZoneInformationFromWeb As Boolean
  Public SummaryPagesShowBranch As Boolean
  Public SummaryPagesShowBroker As Boolean
  Public SummaryPagesShowBulkFunder As Boolean
  Public SummaryPagesShowDealer As Boolean
  Public SummaryPagesShowDepartment As Boolean
  Public SummaryPagesShowNotes As Boolean
  Public SummaryPagesShowPool As Boolean

  ' General.TimeZones
  Public TimeZoneList As String
  Public TimeZoneUse As Boolean
  Public TimeZoneWindowsDisplayName As String
  Public TimeZoneWindowsDisplayNameAvailableList As String

  ' General.UserInterface
  Public GridsSortReverseChronological As Boolean

  ' --------
  ' Accounts
  ' --------
  Public IncludeSettingsAccounts As Boolean

  ' Accounts.NewAccounts
  Public AccountCurrentNextId As String
  Public AccountDefaultNameFromAllOwnerClients As Boolean
  Public AccountDepositNextId As String
  Public AccountLoanNextId As String
  Public AccountNextId As String
  Public AccountRefinanceIdMethodText As String
  Public AccountReinvestIdMethodText As String
  Public AccountUnknownClientId As String

  ' -------
  ' Clients
  ' -------
  Public IncludeSettingsClients As Boolean

  ' Clients.NewClients
  Public ClientDefaultAddressee As String
  Public ClientDefaultSalutation As String
  Public ClientNextId As String

  ' Clients.Contacts
  Public ClientAddressPhysicalContactMethodId As String
  Public ClientAddressPostalContactMethodId As String
  Public ClientEmailContactMethodId As String
  Public ClientFacsimileContactMethodId As String
  Public ClientMobileContactMethodId As String
  Public ClientPhoneContactMethodId As String
  Public ClientPhoneWorkContactMethodId As String

  ' Clients.WebAccess
  Public ClientWebLoginLockoutAttempts As Integer
  Public ClientWebLoginLockoutMinutes As Integer
  Public ClientWebLoginLockoutTimespan As Integer
  Public ClientWebPasswordMinLength As Integer
  Public ClientWebPasswordStrong As Boolean
  Public WebAutomationUseClientWebAccess As Boolean
  Public WebAutomationUseWebMail As Boolean

  ' ----------------
  ' External Parties
  ' ----------------
  Public IncludeSettingsExternalParties As Boolean

  ' ExternalParties.General
  Public AccountBdmResolveMethod As String
  Public DefaultExternalPartyBrokerClientClientGroupId As String
  Public DefaultExternalPartyBulkFunderClientClientGroupId As String
  Public DefaultExternalPartyClientClientGroupId As String
  Public DefaultExternalPartyClientClientTypeId As String
  Public DefaultExternalPartyClientManagerUserId As String
  Public DefaultExternalPartyDealerClientClientGroupId As String
  Public DefaultExternalPartyInsurerClientClientGroupId As String
  Public ExternalPartyNewClientEmploymentIdDefault As String
  Public ExternalPartyNewClientIdDefault As String
  Public ExternalPartyShowRelatedAccountsOnly As Boolean

  ' -----
  ' Users
  ' -----
  Public IncludeSettingsUsers As Boolean

  ' Users.General
  Public DefaultUserGroupId As String
  Public DefaultUserPolicyId As String
  Public UserEmailsForceUnique As Boolean
  Public UserNewWizardValidatorScriptId As String

  ' Edit Information (Lists, BlankTips, SqlWhere)
  Public AccountBdmResolveMethodList As String
  Public AccountRefinanceIdMethodList As String
  Public AccountReinvestIdMethodList As String
  Public ClientDefaultAddresseeList As String
  Public ClientDefaultSalutationList As String
  Public CountryCodesList As String
  Public DefaultExternalPartyClientClientTypeIdSqlWhere As String
  Public DefaultExternalPartyClientManagerUserSqlWhere As String
  Public ExternalPartyNewClientEmploymentIdDefaultBlankTip As String
  Public ExternalPartyNewClientEmploymentIdDefaultList As String
  Public ExternalPartyNewClientIdDefaultBlankTip As String
  Public ExternalPartyNewClientIdDefaultList As String
  Public SummaryPageStandardBlocksOverrideSqlWhere As String
  Public UserNewWizardValidatorScriptIdSqlWhere As String

End Class</Code>
    <Language>VisualBasic</Language>
    <Notes>System-supplied HTML Widget to edit Global Settings.</Notes>
    <PermissionKeyExecute />
    <RunWithoutPrompts>false</RunWithoutPrompts>
    <TemplateText>&lt;div id="frmMain" class="is-widget-content" style="visibility:hidden"&gt;

  &lt;!-- Form Header --&gt;
  &lt;header&gt;
    &lt;!-- Tabs --&gt;
    &lt;div id="tabDetails" class="is-tabs"&gt;
      &lt;ul&gt;
        &lt;!-- General --&gt;
        &lt;li tabId="General_Database"&gt;Database&lt;/li&gt;
        &lt;li tabId="General_Formatting"&gt;Formatting&lt;/li&gt;
        &lt;li tabId="General_Performance"&gt;Performance&lt;/li&gt;
        &lt;li tabId="General_SummaryPages"&gt;Summary Pages&lt;/li&gt;
        &lt;li tabId="General_TimeZones"&gt;Time Zones&lt;/li&gt;
        &lt;li tabId="General_UserInterface"&gt;User Interface&lt;/li&gt;

        &lt;!-- Accounts --&gt;
        &lt;li tabId="Accounts_NewAccounts"&gt;New Accounts&lt;/li&gt;

        &lt;!-- Clients --&gt;
        &lt;li tabId="Clients_NewClients"&gt;New Clients&lt;/li&gt;
        &lt;li tabId="Clients_Contacts"&gt;Contacts&lt;/li&gt;
        &lt;li tabId="Clients_WebAccess"&gt;Web Access&lt;/li&gt;

        &lt;!-- External Parties --&gt;
        &lt;li tabId="ExternalParties_General"&gt;General&lt;/li&gt;

        &lt;!-- Users --&gt;
        &lt;li tabId="Users_General"&gt;General&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  &lt;/header&gt;


  &lt;!-- Pages --&gt;
  &lt;div class="is-widget-form-body"&gt;

    &lt;!--
      -------
      General
      -------
    --&gt;
    &lt;!-- General.Database --&gt;
    &lt;div id="pageGeneral_Database"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblDatabaseName"&gt;Database Name and Country&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtDatabaseName"&gt;Name:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtDatabaseName" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboCountryCode"&gt;Country:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboCountryCode" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblDefaultPhoneCodes"&gt;Default International and Area dialing codes&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtPhoneDialDefaultInternationalCode"&gt;International:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtPhoneDialDefaultInternationalCode" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtPhoneDialDefaultAreaCode"&gt;Area:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtPhoneDialDefaultAreaCode" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblDatabaseOpenMessage"&gt;Message to display upon signing in&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="txtDatabaseOpenMessage" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;

    &lt;!-- General.Formatting --&gt;
    &lt;div id="pageGeneral_Formatting"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblFormattingOptions"&gt;Formatting options&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkConvertCodesToUpperCase" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblDateFormats"&gt;Date formats to use in documents&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDateFormatShortDocuments"&gt;Short Date:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDateFormatShortDocuments" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDateFormatLongDocuments"&gt;Long Date:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDateFormatLongDocuments" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;

    &lt;!-- General.Performance --&gt;
    &lt;div id="pageGeneral_Performance"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblPerformanceOtherOptions"&gt;Other performance-related options&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkPerformanceShowUnactionedLogCount" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkPerformanceShowUnpublishedLogCount" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkPerformanceShowOpenWorkflowCount" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkPerformanceShowIncompleteAccountCount" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;

    &lt;!-- General.SummaryPages --&gt;
    &lt;div id="pageGeneral_SummaryPages"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblSummaryPageOverrider"&gt;Define a Script that can override standard Summary Page blocks&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboSummaryPageStandardBlocksOverrideScriptId"&gt;Script:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboSummaryPageStandardBlocksOverrideScriptId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblSummaryPageOptions"&gt;Summary Page options&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkSummaryPagesShowNotes" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkSummaryPagesShowBranch" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkSummaryPagesShowBroker" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkSummaryPagesShowBulkFunder" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkSummaryPagesShowDealer" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkSummaryPagesShowDepartment" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkSummaryPagesShowPool" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkSummaryPagesAlwaysShowTimeZoneInformationFromWeb" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;

    &lt;!-- General.TimeZones --&gt;
    &lt;div id="pageGeneral_TimeZones"&gt;
      &lt;div style="display:flex; flex-direction:column; padding:4px 0 8px 8px" class="is-dock-fill"&gt;
        &lt;div style="flex-grow:0"&gt;
          &lt;table class="is-form"&gt;
            &lt;colgroup&gt;
              &lt;col style="width:7em" /&gt;
              &lt;col /&gt;
            &lt;/colgroup&gt;

            &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblTimezoneSettings"&gt;Default Time Zone settings for this database&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
            &lt;tr&gt;
              &lt;th&gt;&lt;label for="cboTimeZone"&gt;Time Zone:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input id="cboTimeZone" /&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblTimezoneUse"&gt;Time Zones&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkUseTimeZones" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
          &lt;/table&gt;
        &lt;/div&gt;

        &lt;div style="flex-grow:1; position:relative; margin:4px 0 0 28px;"&gt;
          &lt;input id="chklstAvailableTimeZones" /&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;

    &lt;!-- General.UserInterface --&gt;
    &lt;div id="pageGeneral_UserInterface"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblUserInterfaceGrids"&gt;Display Grid data in Reverse Chronological order?&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkGridsSortReverseChronological" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;


    &lt;!--
      --------
      Accounts
      --------
    --&gt;
    &lt;!-- Accounts.NewAccounts --&gt;
    &lt;div id="pageAccounts_NewAccounts"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:10em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblAccountsNextCode"&gt;Define the Next Code for New Accounts&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtAccountNextId"&gt;General:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtAccountNextId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtAccountLoanNextId"&gt;Loans:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtAccountLoanNextId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtAccountDepositNextId"&gt;Deposits:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtAccountDepositNextId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtAccountCurrentNextId"&gt;Current&amp;nbsp;Accounts:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtAccountCurrentNextId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblAccountCodeGeneration"&gt;Specify how the Code will be generated for Refinanced / Reinvested Accounts&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboAccountRefinanceIdMethod"&gt;Refinanced&amp;nbsp;Loan:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboAccountRefinanceIdMethod" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboAccountReinvestIdMethod"&gt;Reinvested&amp;nbsp;Deposit:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboAccountReinvestIdMethod" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblAccountUnknownClient"&gt;Define the Unknown Client to use in Quotations&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboAccountUnknownClientId"&gt;Unknown&amp;nbsp;Client:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboAccountUnknownClientId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblNewAccountOther"&gt;Other options&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkAccountDefaultNameFromAllOwnerClients" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;


    &lt;!--
      -------
      Clients
      -------
    --&gt;
    &lt;!-- Clients.NewClients --&gt;
    &lt;div id="pageClients_NewClients"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblNewClientDefaults"&gt;Define default values for New Clients&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtClientNextId"&gt;Next&amp;nbsp;Code:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtClientNextId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboClientDefaultSalutation"&gt;Salutation:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboClientDefaultSalutation" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboClientDefaultAddressee"&gt;Addressee:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboClientDefaultAddressee" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;

    &lt;!-- Clients.Contacts --&gt;
    &lt;div id="pageClients_Contacts"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblClientContacts"&gt;Specify defaults for Client Contact Methods&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboClientPhoneContactMethodId"&gt;Phone:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboClientPhoneContactMethodId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboClientPhoneWorkContactMethodId"&gt;Phone&amp;nbsp;(Work):&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboClientPhoneWorkContactMethodId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboClientMobileContactMethodId"&gt;Mobile:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboClientMobileContactMethodId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboClientEmailContactMethodId"&gt;Email:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboClientEmailContactMethodId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboClientFacsimileContactMethodId"&gt;Facsimile:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboClientFacsimileContactMethodId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboClientAddressPostalContactMethodId"&gt;Postal&amp;nbsp;Address:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboClientAddressPostalContactMethodId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboClientAddressPhysicalContactMethodId"&gt;Physical&amp;nbsp;Address:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboClientAddressPhysicalContactMethodId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;

    &lt;!-- Clients.WebAccess --&gt;
    &lt;div id="pageClients_WebAccess"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:8em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblWebAccessGeneral"&gt;General options&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkWebAutomationUseClientWebAccess" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkWebAutomationUseWebMail" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblWebAccessLogin"&gt;Number of login attempts before Clients should be locked out&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numClientWebLoginLockoutAttempts"&gt;Login&amp;nbsp;Attempts:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numClientWebLoginLockoutAttempts" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numClientWebLoginLockoutTimespan"&gt;Timespan&amp;nbsp;(mins):&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numClientWebLoginLockoutTimespan" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numClientWebLoginLockoutMinutes"&gt;Lockout&amp;nbsp;(mins):&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numClientWebLoginLockoutMinutes" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblWebAccessPassword"&gt;Specify details about required password complexity&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numClientWebPasswordMinLength"&gt;Min&amp;nbsp;Length:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numClientWebPasswordMinLength" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkClientWebPasswordStrong" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;


    &lt;!--
      ----------------
      External Parties
      ----------------
    --&gt;
    &lt;!-- ExternalParties.General --&gt;
    &lt;div id="pageExternalParties_General"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:8em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblExternalPartyClientType"&gt;Define the Client Type and Manager for new External Party Clients&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultExternalPartyClientClientTypeId"&gt;Client&amp;nbsp;Type:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultExternalPartyClientClientTypeId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultExternalPartyClientManagerUserId"&gt;Manager:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultExternalPartyClientManagerUserId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblExternalPartyClientGroup"&gt;Define the Client Group for new External Party Clients&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultExternalPartyClientClientGroupId"&gt;General:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultExternalPartyClientClientGroupId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultExternalPartyBrokerClientClientGroupId"&gt;Broker:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultExternalPartyBrokerClientClientGroupId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultExternalPartyBulkFunderClientClientGroupId"&gt;Bulk&amp;nbsp;Funder:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultExternalPartyBulkFunderClientClientGroupId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultExternalPartyDealerClientClientGroupId"&gt;Dealer:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultExternalPartyDealerClientClientGroupId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultExternalPartyInsurerClientClientGroupId"&gt;Insurer:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultExternalPartyInsurerClientClientGroupId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblExternalPartyClientCode"&gt;Specify how Client codes are generated for Clients linked to External Parties&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboExternalPartyNewClientIdDefault"&gt;Client&amp;nbsp;Code:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboExternalPartyNewClientIdDefault" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblExternalPartyEmployeeCode"&gt;Specify how Employee codes are generated&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboExternalPartyNewClientEmploymentIdDefault"&gt;Employee&amp;nbsp;Code:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboExternalPartyNewClientEmploymentIdDefault" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblExternalPartyBDM"&gt;Specify how an Account's Business Development Manager is resolved&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboAccountBdmResolveMethod"&gt;Resolved&amp;nbsp;from:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboAccountBdmResolveMethod" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblExternalPartyOtherOptions"&gt;Other options&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkExternalPartyShowRelatedAccountsOnly" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;


    &lt;!--
      -----
      Users
      -----
    --&gt;
    &lt;!-- Users.General --&gt;
    &lt;div id="pageUsers_General"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblUsersGeneral"&gt;Define defaults for new User records&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultUserGroupId"&gt;User&amp;nbsp;Group:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultUserGroupId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultUserPolicyId"&gt;User&amp;nbsp;Policy:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultUserPolicyId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblUsersWizardValidatorScript"&gt;Define a validator Script for the New User wizard&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboUserNewWizardValidatorScriptId"&gt;Script:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboUserNewWizardValidatorScriptId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblUsersOther"&gt;Specify other User options&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkUserEmailsForceUnique" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;

  &lt;/div&gt;


  &lt;!-- Form Footer --&gt;
  &lt;footer&gt;
    &lt;button id="cmdCancel" class="is-button"&gt;Cancel&lt;/button&gt;
    &lt;button id="cmdFinish" class="is-button ok"&gt;Save&lt;/button&gt;
  &lt;/footer&gt;

&lt;/div&gt;


&lt;script&gt;
// Properties
var mOriginalJson;
var mRecord;
var mSection;

// Controls
var C = {
  // -------
  // General
  // -------
  //   General.Database
  lblDatabaseName: null,
  txtDatabaseName: null,
  cboCountryCode: null,

  lblDefaultPhoneCodes: null,
  txtPhoneDialDefaultInternationalCode: null,
  txtPhoneDialDefaultAreaCode: null,

  lblDatabaseOpenMessage: null,
  txtDatabaseOpenMessage: null,

  //   General.Formatting
  lblFormattingOptions: null,
  chkConvertCodesToUpperCase: null,
  lblDateFormats: null,
  cboDateFormatShortDocuments: null,
  cboDateFormatLongDocuments: null,

  //   General.Performance
  lblPerformanceOtherOptions: null,
  chkPerformanceShowUnactionedLogCount: null,
  chkPerformanceShowUnpublishedLogCount: null,
  chkPerformanceShowOpenWorkflowCount: null,
  chkPerformanceShowIncompleteAccountCount: null,

  //   General.SummaryPages
  lblSummaryPageOverrider: null,
  cboSummaryPageStandardBlocksOverrideScriptId: null,
  lblSummaryPageOptions: null,
  chkSummaryPagesShowNotes: null,
  chkSummaryPagesShowBranch: null,
  chkSummaryPagesShowBroker: null,
  chkSummaryPagesShowBulkFunder: null,
  chkSummaryPagesShowDealer: null,
  chkSummaryPagesShowDepartment: null,
  chkSummaryPagesShowPool: null,
  chkSummaryPagesAlwaysShowTimeZoneInformationFromWeb: null,

  //   General.TimeZones
  lblTimezoneSettings: null,
  cboTimeZone: null,
  lblTimezoneUse: null,
  chkUseTimeZones: null,
  chklstAvailableTimeZones: null,

  //   General.UserInterface
  lblUserInterfaceGrids: null,
  chkGridsSortReverseChronological: null,

  // --------
  // Accounts
  // --------
  //   Accounts.NewAccounts
  lblAccountsNextCode: null,
  txtAccountNextId: null,
  txtAccountLoanNextId: null,
  txtAccountDepositNextId: null,
  txtAccountCurrentNextId: null,
  lblAccountCodeGeneration: null,
  cboAccountRefinanceIdMethod: null,
  cboAccountReinvestIdMethod: null,
  lblAccountUnknownClient: null,
  cboAccountUnknownClientId: null,
  lblNewAccountOther: null,
  chkAccountDefaultNameFromAllOwnerClients: null,

  // -------
  // Clients
  // -------
  //   Clients.NewClients
  lblNewClientDefaults: null,
  txtClientNextId: null,
  cboClientDefaultSalutation: null,
  cboClientDefaultAddressee: null,

  //   Clients.Contacts
  lblClientContacts: null,
  cboClientPhoneContactMethodId: null,
  cboClientPhoneWorkContactMethodId: null,
  cboClientMobileContactMethodId: null,
  cboClientEmailContactMethodId: null,
  cboClientFacsimileContactMethodId: null,
  cboClientAddressPostalContactMethodId: null,
  cboClientAddressPhysicalContactMethodId: null,

  //   Clients.WebAccess
  lblWebAccessGeneral: null,
  chkWebAutomationUseClientWebAccess: null,
  chkWebAutomationUseWebMail: null,
  lblWebAccessLogin: null,
  numClientWebLoginLockoutAttempts: null,
  numClientWebLoginLockoutTimespan: null,
  numClientWebLoginLockoutMinutes: null,
  lblWebAccessPassword: null,
  numClientWebPasswordMinLength: null,
  chkClientWebPasswordStrong: null,

  // ----------------
  // External Parties
  // ----------------
  //   ExternalParties.General
  lblExternalPartyClientType: null,
  cboDefaultExternalPartyClientClientTypeId: null,
  cboDefaultExternalPartyClientManagerUserId: null,
  lblExternalPartyClientGroup: null,
  cboDefaultExternalPartyClientClientGroupId: null,
  cboDefaultExternalPartyBrokerClientClientGroupId: null,
  cboDefaultExternalPartyBulkFunderClientClientGroupId: null,
  cboDefaultExternalPartyDealerClientClientGroupId: null,
  cboDefaultExternalPartyInsurerClientClientGroupId: null,
  lblExternalPartyClientCode: null,
  cboExternalPartyNewClientIdDefault: null,
  lblExternalPartyEmployeeCode: null,
  cboExternalPartyNewClientEmploymentIdDefault: null,
  lblExternalPartyBDM: null,
  cboAccountBdmResolveMethod: null,
  lblExternalPartyOtherOptions: null,
  chkExternalPartyShowRelatedAccountsOnly: null,

  // -----
  // Users
  // -----
  //   Users.General
  lblUsersGeneral: null,
  cboDefaultUserGroupId: null,
  cboDefaultUserPolicyId: null,
  lblUsersWizardValidatorScript: null,
  cboUserNewWizardValidatorScriptId: null,
  lblUsersOther: null,
  chkUserEmailsForceUnique: null
};

// Form
var frmMain;
var tabDetails;

// Buttons
var cmdCancel;
var cmdFinish;

// ==========
// Initialise
// ==========
$(function () {
  // -------
  // General
  // -------
  //   General.Database
  C.lblDatabaseName = widget.UI.Label("lblDatabaseName", {});
  C.txtDatabaseName = widget.UI.TextBox("txtDatabaseName", {
    allowBlank: false,
    maxLength: 50,
  });
  C.cboCountryCode = widget.UI.ComboBox("cboCountryCode", {
    allowBlank: false,
    limitToList: true,
    maxLength: 3,
    width: "5em",
  });

  C.lblDefaultPhoneCodes = widget.UI.Label("lblDefaultPhoneCodes", {});
  C.txtPhoneDialDefaultInternationalCode = widget.UI.TextBox("txtPhoneDialDefaultInternationalCode", {
    maxLength: 5,
  });
  C.txtPhoneDialDefaultAreaCode = widget.UI.TextBox("txtPhoneDialDefaultAreaCode", {
    maxLength: 5,
  });

  C.lblDatabaseOpenMessage = widget.UI.Label("lblDatabaseOpenMessage", {});
  C.txtDatabaseOpenMessage = widget.UI.TextBox("txtDatabaseOpenMessage", {
    allowBlank: true,
    maxLength: 32767,
    multiLine: true,
    rows: 12,
  });

  //   General.Formatting
  C.lblFormattingOptions = widget.UI.Label("lblFormattingOptions", {});
  C.chkConvertCodesToUpperCase = widget.UI.CheckBox("chkConvertCodesToUpperCase", {
    caption: "Convert all Codes to UPPER CASE",
  });

  C.lblDateFormats = widget.UI.Label("lblDateFormats", {});
  C.cboDateFormatShortDocuments = widget.UI.ComboBox("cboDateFormatShortDocuments", {
    allowBlank: true,
    limitToList: false,
    maxLength: 20,
  });
  C.cboDateFormatLongDocuments = widget.UI.ComboBox("cboDateFormatLongDocuments", {
    allowBlank: true,
    limitToList: false,
    maxLength: 20,
  });

  //   General.Performance
  C.lblPerformanceOtherOptions = widget.UI.Label("lblPerformanceOtherOptions", {});
  C.chkPerformanceShowUnactionedLogCount = widget.UI.CheckBox("chkPerformanceShowUnactionedLogCount", {
    caption: "Show Unactioned Log counts?",
  });
  C.chkPerformanceShowUnpublishedLogCount = widget.UI.CheckBox("chkPerformanceShowUnpublishedLogCount", {
    caption: "Show Unpublished Log counts?",
  });
  C.chkPerformanceShowOpenWorkflowCount = widget.UI.CheckBox("chkPerformanceShowOpenWorkflowCount", {
    caption: "Show Open Workflow count?",
  });
  C.chkPerformanceShowIncompleteAccountCount = widget.UI.CheckBox("chkPerformanceShowIncompleteAccountCount", {
    caption: "Show Incomplete Account count?",
  });

  //   General.SummaryPages
  C.lblSummaryPageOverrider = widget.UI.Label("lblSummaryPageOverrider", {});
  C.cboSummaryPageStandardBlocksOverrideScriptId = widget.UI.DBCombo("cboSummaryPageStandardBlocksOverrideScriptId", {
    allowBlank: true,
    limitToList: true,
    maxLength: 20,
    width: widget.UI.FIELD_WIDTH_CODE_20,
  });
  C.lblSummaryPageOptions = widget.UI.Label("lblSummaryPageOptions", {
    tooltipText: "These options can be used by Summary Pages and are used by many built-in Standard Blocks to refine what information is displayed without the need to use Constants.",
  });
  C.chkSummaryPagesShowNotes = widget.UI.CheckBox("chkSummaryPagesShowNotes", {
    caption: "Show Notes?",
  });
  C.chkSummaryPagesShowBranch = widget.UI.CheckBox("chkSummaryPagesShowBranch", {
    caption: "Show Branch?",
  });
  C.chkSummaryPagesShowBroker = widget.UI.CheckBox("chkSummaryPagesShowBroker", {
    caption: "Show Broker?",
  });
  C.chkSummaryPagesShowBulkFunder = widget.UI.CheckBox("chkSummaryPagesShowBulkFunder", {
    caption: "Show Bulk Funder?",
  });
  C.chkSummaryPagesShowDealer = widget.UI.CheckBox("chkSummaryPagesShowDealer", {
    caption: "Show Dealer?",
  });
  C.chkSummaryPagesShowDepartment = widget.UI.CheckBox("chkSummaryPagesShowDepartment", {
    caption: "Show Department?",
  });
  C.chkSummaryPagesShowPool = widget.UI.CheckBox("chkSummaryPagesShowPool", {
    caption: "Show Pool?",
  });
  C.chkSummaryPagesAlwaysShowTimeZoneInformationFromWeb = widget.UI.CheckBox("chkSummaryPagesAlwaysShowTimeZoneInformationFromWeb", {
    caption: "Always show Time Zone information where relevant when generating from a Web Server?",
  });

  //   General.TimeZones
  C.lblTimezoneSettings = widget.UI.Label("lblTimezoneSettings", {});
  C.cboTimeZone = widget.UI.ComboBox("cboTimeZone", {
    allowBlank: false,
    limitToList: true,
    maxLength: 50,
  });
  C.lblTimezoneUse = widget.UI.Label("lblTimezoneUse", {});
  C.chkUseTimeZones = widget.UI.CheckBox("chkUseTimeZones", {
    caption: "Use Time Zones?",

    onChange: chkUseTimeZones_Change,
  });
  C.chklstAvailableTimeZones = widget.UI.CheckList("chklstAvailableTimeZones", {});
  C.chklstAvailableTimeZones.WrapperElement().css({ position: "absolute", top: 0, bottom: 0 });

  //   General.UserInterface
  C.lblUserInterfaceGrids = widget.UI.Label("lblUserInterfaceGrids", {
    tooltipText: "Grids support this setting on a case-by-case basis, e.g., the Account History grid.\n\nThis setting can also be used by HTML Widgets and Summary Pages.",
  });
  C.chkGridsSortReverseChronological = widget.UI.CheckBox("chkGridsSortReverseChronological", {
    caption: "Sort Grids in Reverse Chronological order (where supported)?",
  });

  // --------
  // Accounts
  // --------
  //   Accounts.NewAccounts
  C.lblAccountsNextCode = widget.UI.Label("lblAccountsNextCode", {
    tooltipText: "The next Account code to use when generating an auto-sequence.\n\nIf no code is defined for each of the different types of Account, the 'General' sequence will be used.\n\nEach Entity, Product Type and Account Type can choose to ignore these codes and use its own sequence.",
  });
  C.txtAccountNextId = widget.UI.TextBox("txtAccountNextId", {
    maxLength: 10,
  });
  C.txtAccountLoanNextId = widget.UI.TextBox("txtAccountLoanNextId", {
    maxLength: 10,
  });
  C.txtAccountDepositNextId = widget.UI.TextBox("txtAccountDepositNextId", {
    maxLength: 10,
  });
  C.txtAccountCurrentNextId = widget.UI.TextBox("txtAccountCurrentNextId", {
    maxLength: 10,
  });

  C.lblAccountCodeGeneration = widget.UI.Label("lblAccountCodeGeneration", {});
  C.cboAccountRefinanceIdMethod = widget.UI.ComboBox("cboAccountRefinanceIdMethod", {
    allowBlank: false,
    limitToList: true,
    width: "15em",
  });
  C.cboAccountReinvestIdMethod = widget.UI.ComboBox("cboAccountReinvestIdMethod", {
    allowBlank: false,
    limitToList: true,
    width: "15em",
  });

  C.lblAccountUnknownClient = widget.UI.Label("lblAccountUnknownClient", {});
  C.cboAccountUnknownClientId = widget.UI.DBCombo("cboAccountUnknownClientId", {
    limitToList: true,
    maxLength: 10,
    width: widget.UI.FIELD_WIDTH_CODE_10,
  });

  C.lblNewAccountOther = widget.UI.Label("lblNewAccountOther", {});
  C.chkAccountDefaultNameFromAllOwnerClients = widget.UI.CheckBox("chkAccountDefaultNameFromAllOwnerClients", {
    caption: "Default Account Name from all Owner Clients?",
  });

  // -------
  // Clients
  // -------
  //   Clients.NewClients
  C.lblNewClientDefaults = widget.UI.Label("lblNewClientDefaults", {});
  C.txtClientNextId = widget.UI.TextBox("txtClientNextId", {
    maxLength: 10,
  });
  C.cboClientDefaultSalutation = widget.UI.ComboBox("cboClientDefaultSalutation", {
    maxLength: 50,
  });
  C.cboClientDefaultAddressee = widget.UI.ComboBox("cboClientDefaultAddressee", {
    maxLength: 50,
  });

  //   Clients.Contacts
  C.lblClientContacts = widget.UI.Label("lblClientContacts", {});
  C.cboClientPhoneContactMethodId = widget.UI.DBCombo("cboClientPhoneContactMethodId", {
    allowBlank: true,
    limitToList: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.cboClientPhoneWorkContactMethodId = widget.UI.DBCombo("cboClientPhoneWorkContactMethodId", {
    allowBlank: true,
    limitToList: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.cboClientMobileContactMethodId = widget.UI.DBCombo("cboClientMobileContactMethodId", {
    allowBlank: true,
    limitToList: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.cboClientEmailContactMethodId = widget.UI.DBCombo("cboClientEmailContactMethodId", {
    allowBlank: true,
    limitToList: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.cboClientFacsimileContactMethodId = widget.UI.DBCombo("cboClientFacsimileContactMethodId", {
    allowBlank: true,
    limitToList: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.cboClientAddressPostalContactMethodId = widget.UI.DBCombo("cboClientAddressPostalContactMethodId", {
    allowBlank: true,
    limitToList: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.cboClientAddressPhysicalContactMethodId = widget.UI.DBCombo("cboClientAddressPhysicalContactMethodId", {
    allowBlank: true,
    limitToList: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });

  //   Clients.WebAccess
  C.lblWebAccessGeneral = widget.UI.Label("lblWebAccessGeneral", {
    tooltipText: "Not using Client Web Access will hide items such as the 'Web Access' page on the Clients form.",
  });
  C.chkWebAutomationUseClientWebAccess = widget.UI.CheckBox("chkWebAutomationUseClientWebAccess", {
    caption: "Use Client Web Access?",
  });
  C.chkWebAutomationUseWebMail = widget.UI.CheckBox("chkWebAutomationUseWebMail", {
    caption: "Use Client Web Mail?",
  });

  C.lblWebAccessLogin = widget.UI.Label("lblWebAccessLogin", {});
  C.numClientWebLoginLockoutAttempts = widget.UI.NumberBox("numClientWebLoginLockoutAttempts", {
    decimals: 0,
    minValue: 1,
    maxValue: 10,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.numClientWebLoginLockoutTimespan = widget.UI.NumberBox("numClientWebLoginLockoutTimespan", {
    decimals: 0,
    minValue: 1,
    maxValue: 1440,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.numClientWebLoginLockoutMinutes = widget.UI.NumberBox("numClientWebLoginLockoutMinutes", {
    decimals: 0,
    minValue: 0,
    maxValue: 1440,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });

  C.lblWebAccessPassword = widget.UI.Label("lblWebAccessPassword", {
    tooltipText: "A strong password must contain both upper and lower case letters and numbers and cannot contain the User Id.",
  });
  C.numClientWebPasswordMinLength = widget.UI.NumberBox("numClientWebPasswordMinLength", {
    allowBlank: false,
    decimals: 0,
    minValue: 6,
    maxValue: 50,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.chkClientWebPasswordStrong = widget.UI.CheckBox("chkClientWebPasswordStrong", {
    caption: "Force strong passwords?",
  });

  // ----------------
  // External Parties
  // ----------------
  //   ExternalParties.General
  C.lblExternalPartyClientType = widget.UI.Label("lblExternalPartyClientType", {});
  C.cboDefaultExternalPartyClientClientTypeId = widget.UI.DBCombo("cboDefaultExternalPartyClientClientTypeId", {
    allowBlank: false,
    limitToList: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.cboDefaultExternalPartyClientManagerUserId = widget.UI.DBCombo("cboDefaultExternalPartyClientManagerUserId", {
    maxLength: 20,
    width: widget.UI.FIELD_WIDTH_CODE_20,
  });

  C.lblExternalPartyClientGroup = widget.UI.Label("lblExternalPartyClientGroup", {
    tooltipText: "The 'General' Client Group will be used if no Client Group is specified for the specific External Party types.",
  });
  C.cboDefaultExternalPartyClientClientGroupId = widget.UI.DBCombo("cboDefaultExternalPartyClientClientGroupId", {
    allowBlank: false,
    limitToList: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.cboDefaultExternalPartyBrokerClientClientGroupId = widget.UI.DBCombo("cboDefaultExternalPartyBrokerClientClientGroupId", {
    limitToList: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.cboDefaultExternalPartyBulkFunderClientClientGroupId = widget.UI.DBCombo("cboDefaultExternalPartyBulkFunderClientClientGroupId", {
    limitToList: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.cboDefaultExternalPartyDealerClientClientGroupId = widget.UI.DBCombo("cboDefaultExternalPartyDealerClientClientGroupId", {
    limitToList: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.cboDefaultExternalPartyInsurerClientClientGroupId = widget.UI.DBCombo("cboDefaultExternalPartyInsurerClientClientGroupId", {
    limitToList: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });

  C.lblExternalPartyClientCode = widget.UI.Label("lblExternalPartyClientCode", {
    tooltipText: "The tag '[Id]' will be replaced with the External Party code.",
  });
  C.cboExternalPartyNewClientIdDefault = widget.UI.ComboBox("cboExternalPartyNewClientIdDefault", {
    limitToList: true,
    width: widget.UI.FIELD_WIDTH_CODE_10,
  });

  C.lblExternalPartyEmployeeCode = widget.UI.Label("lblExternalPartyEmployeeCode", {});
  C.cboExternalPartyNewClientEmploymentIdDefault = widget.UI.ComboBox("cboExternalPartyNewClientEmploymentIdDefault", {
    limitToList: true,
    width: "32em",
  });

  C.lblExternalPartyBDM = widget.UI.Label("lblExternalPartyBDM", {});
  C.cboAccountBdmResolveMethod = widget.UI.ComboBox("cboAccountBdmResolveMethod", {
    allowBlank: false,
    limitToList: true,
    width: widget.UI.FIELD_WIDTH_CODE_15,
  });

  C.lblExternalPartyOtherOptions = widget.UI.Label("lblExternalPartyOtherOptions", {});
  C.chkExternalPartyShowRelatedAccountsOnly = widget.UI.CheckBox("chkExternalPartyShowRelatedAccountsOnly", {
    caption: "Show only related Accounts when selecting Disbursement, Commission and Securitisation Accounts?",
  });

  // -----
  // Users
  // -----
  //   Users.General
  C.lblUsersGeneral = widget.UI.Label("lblUsersGeneral", {});
  C.cboDefaultUserGroupId = widget.UI.DBCombo("cboDefaultUserGroupId", {
    allowBlank: false,
    limitToList: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.cboDefaultUserPolicyId = widget.UI.DBCombo("cboDefaultUserPolicyId", {
    allowBlank: false,
    limitToList: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });

  C.lblUsersWizardValidatorScript = widget.UI.Label("lblUsersWizardValidatorScript", {});
  C.cboUserNewWizardValidatorScriptId = widget.UI.DBCombo("cboUserNewWizardValidatorScriptId", {
    limitToList: true,
    maxLength: 20,
    width: widget.UI.FIELD_WIDTH_CODE_20,
  });

  C.lblUsersOther = widget.UI.Label("lblUsersOther", {});
  C.chkUserEmailsForceUnique = widget.UI.CheckBox("chkUserEmailsForceUnique", {
    caption: "Ensure User's Email addresses are unique when adding or updating a User?",
  });

  // Date Format Lists
  switch (widget.DayMonthYearOrder ? widget.DayMonthYearOrder() : "DMY") {
    case "MDY":
      C.cboDateFormatShortDocuments.ListFromCsvString("MM/d/yyyy,MMddyy,MM/dd/yy,ddMMMyy");
      C.cboDateFormatShortDocuments.BlankTip("MM/d/yyyy");
      C.cboDateFormatLongDocuments.ListFromCsvString("MMMM d yyyy,MMddyyyy,MM/dd/yyyy,dd MMM yyyy");
      C.cboDateFormatLongDocuments.BlankTip("MMMM d yyyy");
      break;
    case "YMD":
      C.cboDateFormatShortDocuments.ListFromCsvString("yyyy/MM/d,yyMMdd,yy/MM/dd,ddMMMyy");
      C.cboDateFormatShortDocuments.BlankTip("yyyy/MM/d");
      C.cboDateFormatLongDocuments.ListFromCsvString("yyyy MMMM d,yyyyMMdd,yyyy/MM/dd,dd MMM yyyy");
      C.cboDateFormatLongDocuments.BlankTip("yyyy MMMM d");
      break;
    default:
      C.cboDateFormatShortDocuments.ListFromCsvString("d/MM/yyyy,ddMMyy,dd/MM/yy,ddMMMyy");
      C.cboDateFormatShortDocuments.BlankTip("d/MM/yyyy");
      C.cboDateFormatLongDocuments.ListFromCsvString("d MMMM yyyy,ddMMyyyy,dd/MM/yyyy,dd MMM yyyy");
      C.cboDateFormatLongDocuments.BlankTip("d MMMM yyyy");
      break;
  }

  // Create Widget form
  frmMain = new widget.UI.Form("frmMain", { visible: false });

  // Create Tabs
  tabDetails = new widget.UI.Tabs("tabDetails", {
    style: "normal",
    onSelectedTabChanged: tabDetails_Refresh
  });

  // Handle resize
  $(window).resize(Form_Resize);

  // Disable Close Button (this causes the 'FormClose' notification action to be invoked instead)
  widget.DisableCloseButton();
  widget.ActionNotificationHandle(Widget_NotificationHandler);

  // Handle Wizard Buttons
  cmdCancel = $("#cmdCancel");
  cmdFinish = $("#cmdFinish");
  cmdCancel.click(tabDetails_Cancel);
  cmdFinish.click(Form_ExecuteAction_Finish);

  // Reset
  Form_Reset();
});

// ==========
// Reset Form
// ==========
function Form_Reset() {
  Form_Resize();
  Record_Load();
}

// ===========
// Load Record
// ===========
function Record_Load() {
  // Initialise
  mRecord = null;

  // Hide content
  frmMain.Visible(false);

  // Block UI
  widget.UI.Block("Initialising, please wait...");

  // Load Initialisation details
  widget.GetString("GetInitialisationInfo", {},
    Record_Load_Done,
    function (message) {
      widget.UI.MsgBoxAlert("fail: " + message);
      Fields_Load();
    }
  );
}

function Record_Load_Done(data) {
  mRecord = JSON.parse(data);

  // Tabs filtered by section (e.g., only General_* visible if section is General)
  if (mRecord &amp;&amp; mRecord.PageId) {
    tabDetails.SelectedTabId(mRecord.PageId);
    var n = mRecord.PageId.indexOf("_");
    mSection = (n &gt;= 0) ? mRecord.PageId.substr(0, n) : mRecord.PageId;
    for (var i = 0; i &lt; tabDetails.TabCount(); i++) {
      var tab = tabDetails.GetTabByIndex(i);
      tabDetails.TabVisible(tab.tabId, tab.tabId.substr(0, mSection.length + 1) == mSection + "_");
    }
  }
  else {
    mSection = "General";
    tabDetails.SelectedTabId("General_Database");
  }

  // Configuration and Licensing - hide rows for inactive Add-Ons
  if (!mRecord.AddOnsCurrentAccount) C.txtAccountCurrentNextId.VisibleRow(false);
  if (!mRecord.AddOnsLoanAny) {
    C.txtAccountLoanNextId.VisibleRow(false);
    C.cboAccountRefinanceIdMethod.VisibleRow(false);
  }
  if (!mRecord.AddOnsDepositAccount) {
    C.txtAccountDepositNextId.VisibleRow(false);
    C.cboAccountReinvestIdMethod.VisibleRow(false);
  }
  if (mRecord.AddOnsLoanAny &amp;&amp; mRecord.AddOnsDepositAccount) {
    // Default label
  }
  else if (mRecord.AddOnsLoanAny) {
    C.lblAccountCodeGeneration.Text("Specify how the Code will be generated for Refinanced Accounts");
  }
  else if (mRecord.AddOnsDepositAccount) {
    C.lblAccountCodeGeneration.Text("Specify how the Code will be generated for Reinvested Accounts");
  }
  if (!mRecord.AddOnsWorkflow) C.chkPerformanceShowOpenWorkflowCount.VisibleRow(false);
  if (!mRecord.AddOnsBranch) C.chkSummaryPagesShowBranch.VisibleRow(false);
  if (!mRecord.AddOnsExternalParty) {
    C.chkSummaryPagesShowBroker.VisibleRow(false);
    C.chkSummaryPagesShowDealer.VisibleRow(false);
  }
  if (!mRecord.AddOnsSecuritisation) {
    C.chkSummaryPagesShowBulkFunder.VisibleRow(false);
    C.lblExternalPartyOtherOptions.VisibleRow(false);
    C.chkExternalPartyShowRelatedAccountsOnly.VisibleRow(false);
  }
  if (!mRecord.AddOnsPool) C.chkSummaryPagesShowPool.VisibleRow(false);

  // Load Fields
  Fields_Load();

  // Save Fields (so values are in correct format for mOriginalJson)
  Fields_Save();

  // Save original JSON for Form_IsDirty
  mOriginalJson = JSON.stringify(mRecord);
}

// ===========
// Load Fields
// ===========
function Fields_Load() {
  if (mRecord) {
    // -------
    // General
    // -------
    if (mRecord.IncludeSettingsGeneral) {
      // General.Database
      C.txtDatabaseName.Text(mRecord.DatabaseName);
      C.cboCountryCode.Text(mRecord.CountryCode);
      C.txtPhoneDialDefaultInternationalCode.Text(mRecord.PhoneDialDefaultInternationalCode);
      C.txtPhoneDialDefaultAreaCode.Text(mRecord.PhoneDialDefaultAreaCode);
      C.txtDatabaseOpenMessage.Text(mRecord.DatabaseOpenMessage);

      // General.Formatting
      C.chkConvertCodesToUpperCase.Value(mRecord.ConvertCodesToUpperCase);
      C.cboDateFormatShortDocuments.Text(mRecord.DateFormatShortDocuments);
      C.cboDateFormatLongDocuments.Text(mRecord.DateFormatLongDocuments);

      // General.Performance
      C.chkPerformanceShowUnactionedLogCount.Value(mRecord.PerformanceShowUnactionedLogCount);
      C.chkPerformanceShowUnpublishedLogCount.Value(mRecord.PerformanceShowUnpublishedLogCount);
      C.chkPerformanceShowOpenWorkflowCount.Value(mRecord.PerformanceShowOpenWorkflowCount);
      C.chkPerformanceShowIncompleteAccountCount.Value(mRecord.PerformanceShowIncompleteAccountCount);

      // General.SummaryPages
      C.cboSummaryPageStandardBlocksOverrideScriptId.Text(mRecord.SummaryPageStandardBlocksOverrideScriptId);
      C.chkSummaryPagesShowNotes.Value(mRecord.SummaryPagesShowNotes);
      C.chkSummaryPagesShowBranch.Value(mRecord.SummaryPagesShowBranch);
      C.chkSummaryPagesShowBroker.Value(mRecord.SummaryPagesShowBroker);
      C.chkSummaryPagesShowBulkFunder.Value(mRecord.SummaryPagesShowBulkFunder);
      C.chkSummaryPagesShowDealer.Value(mRecord.SummaryPagesShowDealer);
      C.chkSummaryPagesShowDepartment.Value(mRecord.SummaryPagesShowDepartment);
      C.chkSummaryPagesShowPool.Value(mRecord.SummaryPagesShowPool);
      C.chkSummaryPagesAlwaysShowTimeZoneInformationFromWeb.Value(mRecord.SummaryPagesAlwaysShowTimeZoneInformationFromWeb);

      // General.TimeZones
      C.cboTimeZone.Text(mRecord.TimeZoneWindowsDisplayName);
      C.chkUseTimeZones.Value(mRecord.TimeZoneUse);
      C.chklstAvailableTimeZones.Text(mRecord.TimeZoneWindowsDisplayNameAvailableList);

      // General.UserInterface
      C.chkGridsSortReverseChronological.Value(mRecord.GridsSortReverseChronological);
    }

    // --------
    // Accounts
    // --------
    if (mRecord.IncludeSettingsAccounts) {
      C.txtAccountNextId.Text(mRecord.AccountNextId);
      if (mRecord.AddOnsCurrentAccount) C.txtAccountCurrentNextId.Text(mRecord.AccountCurrentNextId);
      if (mRecord.AddOnsLoanAny) {
        C.txtAccountLoanNextId.Text(mRecord.AccountLoanNextId);
        C.cboAccountRefinanceIdMethod.Text(mRecord.AccountRefinanceIdMethodText);
      }
      if (mRecord.AddOnsDepositAccount) {
        C.cboAccountReinvestIdMethod.Text(mRecord.AccountReinvestIdMethodText);
        C.txtAccountDepositNextId.Text(mRecord.AccountDepositNextId);
      }
      C.cboAccountUnknownClientId.Text(mRecord.AccountUnknownClientId);
      C.chkAccountDefaultNameFromAllOwnerClients.Value(mRecord.AccountDefaultNameFromAllOwnerClients);
    }

    // -------
    // Clients
    // -------
    if (mRecord.IncludeSettingsClients) {
      C.txtClientNextId.Text(mRecord.ClientNextId);
      C.cboClientDefaultSalutation.Text(mRecord.ClientDefaultSalutation);
      C.cboClientDefaultAddressee.Text(mRecord.ClientDefaultAddressee);

      C.cboClientPhoneContactMethodId.Text(mRecord.ClientPhoneContactMethodId);
      C.cboClientPhoneWorkContactMethodId.Text(mRecord.ClientPhoneWorkContactMethodId);
      C.cboClientMobileContactMethodId.Text(mRecord.ClientMobileContactMethodId);
      C.cboClientEmailContactMethodId.Text(mRecord.ClientEmailContactMethodId);
      C.cboClientFacsimileContactMethodId.Text(mRecord.ClientFacsimileContactMethodId);
      C.cboClientAddressPostalContactMethodId.Text(mRecord.ClientAddressPostalContactMethodId);
      C.cboClientAddressPhysicalContactMethodId.Text(mRecord.ClientAddressPhysicalContactMethodId);

      C.chkWebAutomationUseClientWebAccess.Value(mRecord.WebAutomationUseClientWebAccess);
      C.chkWebAutomationUseWebMail.Value(mRecord.WebAutomationUseWebMail);
      C.numClientWebLoginLockoutAttempts.Value(mRecord.ClientWebLoginLockoutAttempts);
      C.numClientWebLoginLockoutTimespan.Value(mRecord.ClientWebLoginLockoutTimespan);
      C.numClientWebLoginLockoutMinutes.Value(mRecord.ClientWebLoginLockoutMinutes);
      C.numClientWebPasswordMinLength.Value(mRecord.ClientWebPasswordMinLength);
      C.chkClientWebPasswordStrong.Value(mRecord.ClientWebPasswordStrong);
    }

    // ----------------
    // External Parties
    // ----------------
    if (mRecord.IncludeSettingsExternalParties) {
      C.cboDefaultExternalPartyClientClientTypeId.Text(mRecord.DefaultExternalPartyClientClientTypeId);
      C.cboDefaultExternalPartyClientManagerUserId.Text(mRecord.DefaultExternalPartyClientManagerUserId);
      C.cboDefaultExternalPartyClientClientGroupId.Text(mRecord.DefaultExternalPartyClientClientGroupId);
      C.cboDefaultExternalPartyBrokerClientClientGroupId.Text(mRecord.DefaultExternalPartyBrokerClientClientGroupId);
      if (mRecord.AddOnsSecuritisation) C.cboDefaultExternalPartyBulkFunderClientClientGroupId.Text(mRecord.DefaultExternalPartyBulkFunderClientClientGroupId);
      C.cboDefaultExternalPartyDealerClientClientGroupId.Text(mRecord.DefaultExternalPartyDealerClientClientGroupId);
      C.cboDefaultExternalPartyInsurerClientClientGroupId.Text(mRecord.DefaultExternalPartyInsurerClientClientGroupId);
      C.cboExternalPartyNewClientIdDefault.Text(mRecord.ExternalPartyNewClientIdDefault);
      C.cboExternalPartyNewClientEmploymentIdDefault.Text(mRecord.ExternalPartyNewClientEmploymentIdDefault);
      C.cboAccountBdmResolveMethod.Text(mRecord.AccountBdmResolveMethod);
      C.chkExternalPartyShowRelatedAccountsOnly.Value(mRecord.ExternalPartyShowRelatedAccountsOnly);
    }

    // -----
    // Users
    // -----
    if (mRecord.IncludeSettingsUsers) {
      C.cboDefaultUserGroupId.Text(mRecord.DefaultUserGroupId);
      C.cboDefaultUserPolicyId.Text(mRecord.DefaultUserPolicyId);
      C.cboUserNewWizardValidatorScriptId.Text(mRecord.UserNewWizardValidatorScriptId);
      C.chkUserEmailsForceUnique.Value(mRecord.UserEmailsForceUnique);
    }
  }

  // Unblock UI
  widget.UI.Unblock();

  // Update fields
  Fields_Update();

  // Refresh Tab
  tabDetails_Refresh();
  tabDetails_Resize();
}

// ===========
// Save Fields
// ===========
function Fields_Save() {
  if (!mRecord) return;

  if (mRecord.IncludeSettingsGeneral) {
    mRecord.DatabaseName = C.txtDatabaseName.Text();
    mRecord.CountryCode = C.cboCountryCode.Text();
    mRecord.PhoneDialDefaultInternationalCode = C.txtPhoneDialDefaultInternationalCode.Text();
    mRecord.PhoneDialDefaultAreaCode = C.txtPhoneDialDefaultAreaCode.Text();
    mRecord.DatabaseOpenMessage = C.txtDatabaseOpenMessage.Text();

    mRecord.ConvertCodesToUpperCase = C.chkConvertCodesToUpperCase.Value();
    mRecord.DateFormatShortDocuments = C.cboDateFormatShortDocuments.Text();
    mRecord.DateFormatLongDocuments = C.cboDateFormatLongDocuments.Text();

    mRecord.PerformanceShowUnactionedLogCount = C.chkPerformanceShowUnactionedLogCount.Value();
    mRecord.PerformanceShowUnpublishedLogCount = C.chkPerformanceShowUnpublishedLogCount.Value();
    mRecord.PerformanceShowOpenWorkflowCount = C.chkPerformanceShowOpenWorkflowCount.Value();
    mRecord.PerformanceShowIncompleteAccountCount = C.chkPerformanceShowIncompleteAccountCount.Value();

    mRecord.SummaryPageStandardBlocksOverrideScriptId = C.cboSummaryPageStandardBlocksOverrideScriptId.Text();
    mRecord.SummaryPagesShowNotes = C.chkSummaryPagesShowNotes.Value();
    mRecord.SummaryPagesShowBranch = C.chkSummaryPagesShowBranch.Value();
    mRecord.SummaryPagesShowBroker = C.chkSummaryPagesShowBroker.Value();
    mRecord.SummaryPagesShowBulkFunder = C.chkSummaryPagesShowBulkFunder.Value();
    mRecord.SummaryPagesShowDealer = C.chkSummaryPagesShowDealer.Value();
    mRecord.SummaryPagesShowDepartment = C.chkSummaryPagesShowDepartment.Value();
    mRecord.SummaryPagesShowPool = C.chkSummaryPagesShowPool.Value();
    mRecord.SummaryPagesAlwaysShowTimeZoneInformationFromWeb = C.chkSummaryPagesAlwaysShowTimeZoneInformationFromWeb.Value();

    mRecord.TimeZoneWindowsDisplayName = C.cboTimeZone.Text();
    mRecord.TimeZoneUse = C.chkUseTimeZones.Value();
    mRecord.TimeZoneWindowsDisplayNameAvailableList = C.chklstAvailableTimeZones.Text();

    mRecord.GridsSortReverseChronological = C.chkGridsSortReverseChronological.Value();
  }

  if (mRecord.IncludeSettingsAccounts) {
    mRecord.AccountNextId = C.txtAccountNextId.Text();
    mRecord.AccountLoanNextId = C.txtAccountLoanNextId.Text();
    mRecord.AccountDepositNextId = C.txtAccountDepositNextId.Text();
    mRecord.AccountCurrentNextId = C.txtAccountCurrentNextId.Text();
    mRecord.AccountRefinanceIdMethodText = C.cboAccountRefinanceIdMethod.Text();
    mRecord.AccountReinvestIdMethodText = C.cboAccountReinvestIdMethod.Text();
    mRecord.AccountUnknownClientId = C.cboAccountUnknownClientId.Text();
    mRecord.AccountDefaultNameFromAllOwnerClients = C.chkAccountDefaultNameFromAllOwnerClients.Value();
  }

  if (mRecord.IncludeSettingsClients) {
    mRecord.ClientNextId = C.txtClientNextId.Text();
    mRecord.ClientDefaultSalutation = C.cboClientDefaultSalutation.Text();
    mRecord.ClientDefaultAddressee = C.cboClientDefaultAddressee.Text();

    mRecord.ClientPhoneContactMethodId = C.cboClientPhoneContactMethodId.Text();
    mRecord.ClientPhoneWorkContactMethodId = C.cboClientPhoneWorkContactMethodId.Text();
    mRecord.ClientMobileContactMethodId = C.cboClientMobileContactMethodId.Text();
    mRecord.ClientEmailContactMethodId = C.cboClientEmailContactMethodId.Text();
    mRecord.ClientFacsimileContactMethodId = C.cboClientFacsimileContactMethodId.Text();
    mRecord.ClientAddressPostalContactMethodId = C.cboClientAddressPostalContactMethodId.Text();
    mRecord.ClientAddressPhysicalContactMethodId = C.cboClientAddressPhysicalContactMethodId.Text();

    mRecord.WebAutomationUseClientWebAccess = C.chkWebAutomationUseClientWebAccess.Value();
    mRecord.WebAutomationUseWebMail = C.chkWebAutomationUseWebMail.Value();
    mRecord.ClientWebLoginLockoutAttempts = C.numClientWebLoginLockoutAttempts.Value();
    mRecord.ClientWebLoginLockoutTimespan = C.numClientWebLoginLockoutTimespan.Value();
    mRecord.ClientWebLoginLockoutMinutes = C.numClientWebLoginLockoutMinutes.Value();
    mRecord.ClientWebPasswordMinLength = C.numClientWebPasswordMinLength.Value();
    mRecord.ClientWebPasswordStrong = C.chkClientWebPasswordStrong.Value();
  }

  if (mRecord.IncludeSettingsExternalParties) {
    mRecord.DefaultExternalPartyClientClientTypeId = C.cboDefaultExternalPartyClientClientTypeId.Text();
    mRecord.DefaultExternalPartyClientManagerUserId = C.cboDefaultExternalPartyClientManagerUserId.Text();
    mRecord.DefaultExternalPartyClientClientGroupId = C.cboDefaultExternalPartyClientClientGroupId.Text();
    mRecord.DefaultExternalPartyBrokerClientClientGroupId = C.cboDefaultExternalPartyBrokerClientClientGroupId.Text();
    mRecord.DefaultExternalPartyBulkFunderClientClientGroupId = C.cboDefaultExternalPartyBulkFunderClientClientGroupId.Text();
    mRecord.DefaultExternalPartyDealerClientClientGroupId = C.cboDefaultExternalPartyDealerClientClientGroupId.Text();
    mRecord.DefaultExternalPartyInsurerClientClientGroupId = C.cboDefaultExternalPartyInsurerClientClientGroupId.Text();
    mRecord.ExternalPartyNewClientIdDefault = C.cboExternalPartyNewClientIdDefault.Text();
    mRecord.ExternalPartyNewClientEmploymentIdDefault = C.cboExternalPartyNewClientEmploymentIdDefault.Text();
    mRecord.AccountBdmResolveMethod = C.cboAccountBdmResolveMethod.Text();
    mRecord.ExternalPartyShowRelatedAccountsOnly = C.chkExternalPartyShowRelatedAccountsOnly.Value();
  }

  if (mRecord.IncludeSettingsUsers) {
    mRecord.DefaultUserGroupId = C.cboDefaultUserGroupId.Text();
    mRecord.DefaultUserPolicyId = C.cboDefaultUserPolicyId.Text();
    mRecord.UserNewWizardValidatorScriptId = C.cboUserNewWizardValidatorScriptId.Text();
    mRecord.UserEmailsForceUnique = C.chkUserEmailsForceUnique.Value();
  }
}

// =============
// Update Fields
// =============
function Fields_Update() {
  // Heading
  if (mRecord) {
    var section = mSection;
    switch (section) {
      case "ExternalParties":
        section = "External Parties";
        break;
    }
    widget.SetHeading("&lt;HTML&gt;&lt;b&gt;" + section + ":&lt;/b&gt; Global Settings");
  }

  // Other change handlers
  if (mRecord) {
    chkUseTimeZones_Change(null, null);
  }

  // Lists
  if (mRecord) {
    if (mRecord.IncludeSettingsGeneral) {
      C.cboCountryCode.ListFromCsvString(mRecord.CountryCodesList);
      C.cboSummaryPageStandardBlocksOverrideScriptId.RefreshFromStandardRange("Scripts", mRecord.SummaryPageStandardBlocksOverrideSqlWhere);
      C.cboTimeZone.ListFromCsvString(mRecord.TimeZoneList);
      C.chklstAvailableTimeZones.ListFromCsvString(mRecord.TimeZoneList);
    }

    if (mRecord.IncludeSettingsAccounts) {
      C.cboAccountRefinanceIdMethod.ListFromCsvString(mRecord.AccountRefinanceIdMethodList);
      C.cboAccountReinvestIdMethod.ListFromCsvString(mRecord.AccountReinvestIdMethodList);
      C.cboAccountUnknownClientId.RefreshFromStandardRange("Clients");
    }

    if (mRecord.IncludeSettingsClients) {
      C.cboClientDefaultSalutation.ListFromCsvString(mRecord.ClientDefaultSalutationList);
      C.cboClientDefaultAddressee.ListFromCsvString(mRecord.ClientDefaultAddresseeList);

      C.cboClientPhoneContactMethodId.RefreshFromStandardRange("ContactMethods");
      C.cboClientPhoneWorkContactMethodId.RefreshFromStandardRange("ContactMethods");
      C.cboClientMobileContactMethodId.RefreshFromStandardRange("ContactMethods");
      C.cboClientEmailContactMethodId.RefreshFromStandardRange("ContactMethods");
      C.cboClientFacsimileContactMethodId.RefreshFromStandardRange("ContactMethods");
      C.cboClientAddressPostalContactMethodId.RefreshFromStandardRange("ContactMethods");
      C.cboClientAddressPhysicalContactMethodId.RefreshFromStandardRange("ContactMethods");
    }

    if (mRecord.IncludeSettingsExternalParties) {
      C.cboDefaultExternalPartyClientClientTypeId.RefreshFromStandardRange("ClientTypes", mRecord.DefaultExternalPartyClientClientTypeIdSqlWhere);
      C.cboDefaultExternalPartyClientManagerUserId.RefreshFromStandardRange("Users", mRecord.DefaultExternalPartyClientManagerUserSqlWhere);
      C.cboDefaultExternalPartyClientClientGroupId.RefreshFromStandardRange("ClientGroups");
      C.cboDefaultExternalPartyBrokerClientClientGroupId.RefreshFromStandardRange("ClientGroups");
      if (mRecord.AddOnsSecuritisation) {
        C.cboDefaultExternalPartyBulkFunderClientClientGroupId.RefreshFromStandardRange("ClientGroups");
      }
      else {
        C.cboDefaultExternalPartyBulkFunderClientClientGroupId.VisibleRow(false);
      }
      C.cboDefaultExternalPartyDealerClientClientGroupId.RefreshFromStandardRange("ClientGroups");
      C.cboDefaultExternalPartyInsurerClientClientGroupId.RefreshFromStandardRange("ClientGroups");

      C.cboExternalPartyNewClientIdDefault.BlankTip(mRecord.ExternalPartyNewClientIdDefaultBlankTip);
      C.cboExternalPartyNewClientIdDefault.ListFromCsvString(mRecord.ExternalPartyNewClientIdDefaultList);

      C.cboExternalPartyNewClientEmploymentIdDefault.BlankTip(mRecord.ExternalPartyNewClientEmploymentIdDefaultBlankTip);
      C.cboExternalPartyNewClientEmploymentIdDefault.ListFromCsvString(mRecord.ExternalPartyNewClientEmploymentIdDefaultList);

      C.cboAccountBdmResolveMethod.ListFromCsvString(mRecord.AccountBdmResolveMethodList);
    }

    if (mRecord.IncludeSettingsUsers) {
      C.cboDefaultUserGroupId.RefreshFromStandardRange("UserGroups");
      C.cboDefaultUserPolicyId.RefreshFromStandardRange("UserPolicies");
      C.cboUserNewWizardValidatorScriptId.RefreshFromStandardRange("Scripts", mRecord.UserNewWizardValidatorScriptIdSqlWhere);
    }
  }

  // Read-Only?
  if (mRecord &amp;&amp; mRecord.ReadOnly) {
    cmdFinish.prop("disabled", true);
    frmMain.FormReadOnly(C, true);
  }

  // Show content
  frmMain.Visible(mRecord != null);

  // Resize Tab
  tabDetails_Resize();
}

// ===========
// Resize Form
// ===========
function Form_Resize() {
  tabDetails_Resize();
}

// ========
// Is Dirty
// ========
function Form_IsDirty() {
  if (mRecord) {
    Fields_Save();
    return mOriginalJson != JSON.stringify(mRecord);
  }
  return false;
}

// ==============
// Wizard Buttons
// ==============
function tabDetails_Cancel() {
  if (Form_IsDirty()) {
    widget.UI.MsgBoxConfirm("Are you sure you want to close this form without saving your changes?", { heading: "Close Form" }, tabDetails_Cancel_Finalise);
  }
  else {
    tabDetails_Cancel_Finalise();
  }
}

function tabDetails_Cancel_Finalise() {
  if (widget.CanClose()) {
    widget.Close();
  }
  else {
    widget.Reset();
  }
}

// ======================
// chkUseTimeZones_Change
// ======================
function chkUseTimeZones_Change(sender, e) {
  if (e) e.ChangeHandled = true;
  if (C.chkUseTimeZones &amp;&amp; C.chklstAvailableTimeZones) {
    C.chklstAvailableTimeZones.ReadOnly(!C.chkUseTimeZones.Value());
  }
}

// ==========
// Resize Tab
// ==========
function tabDetails_Resize() {
  switch (tabDetails.SelectedTabId()) {
    case "General_Database":
      C.txtDatabaseName.WidthResizeFromParent();
      C.txtPhoneDialDefaultInternationalCode.WidthResizeFromParent();
      C.txtPhoneDialDefaultAreaCode.WidthResizeFromParent();
      break;

    case "General_Formatting":
      C.cboDateFormatShortDocuments.WidthResizeFromParent();
      C.cboDateFormatLongDocuments.WidthResizeFromParent();
      break;

    case "General_TimeZones":
      C.cboTimeZone.WidthResizeFromParent();
      C.chklstAvailableTimeZones.WidthResizeFromParent();
      break;

    case "Accounts_NewAccounts":
      C.txtAccountNextId.WidthResizeFromParent();
      C.txtAccountLoanNextId.WidthResizeFromParent();
      C.txtAccountDepositNextId.WidthResizeFromParent();
      C.txtAccountCurrentNextId.WidthResizeFromParent();
      C.cboAccountUnknownClientId.WidthResizeFromParent();
      break;

    case "Clients_NewClients":
      C.txtClientNextId.WidthResizeFromParent();
      C.cboClientDefaultSalutation.WidthResizeFromParent();
      C.cboClientDefaultAddressee.WidthResizeFromParent();
      break;
  }
}

// ===========
// Refresh Tab
// ===========
function tabDetails_Refresh() {
  tabDetails_Resize();
  if (tabDetails.FocusFirst) tabDetails.FocusFirst();
}

// =============
// Finish Action
// =============
function Form_ExecuteAction_Finish() {
  // Validate
  if (!tabDetails.Validate()) return;

  if (mRecord.PromptOnSave) {
    widget.UI.MsgBoxConfirm("WARNING: Saving Global Settings may cause finPOWER Connect Cloud to become briefly unresponsive for all Users whilst the new settings take effect.\n\nDo you want to continue?",
                            { heading: "Save Global Settings" },
                            Form_ExecuteAction_FinishPost);
  }
  else {
    Form_ExecuteAction_FinishPost();
  }
}

function Form_ExecuteAction_FinishPost() {
  widget.UI.Block("Saving, please wait...");

  Fields_Save();
  var params = JSON.parse(JSON.stringify(mRecord));

  widget.GetString("Finish", params,
    function (data) {
      widget.Close();
      widget.RefreshParent();
    },
    function (data) {
      widget.UI.MsgBoxAlert(data);
      widget.UI.Unblock();
    }
  );
}

// ====================
// Notification Handler
// ====================
function Widget_NotificationHandler(actionId, data) {
  switch (actionId) {
    case "FormClose":
      tabDetails_Cancel();
      break;
  }
}
&lt;/script&gt;</TemplateText>
    <TemplateTextBookmarks />
    <TimeoutSeconds>60</TimeoutSeconds>
    <UniqueId>FINGSWID-W2026-A</UniqueId>
    <AllowRefresh>true</AllowRefresh>
    <Caption>Global Settings</Caption>
    <HtmlWidgetMaxHeight>2048</HtmlWidgetMaxHeight>
    <HtmlWidgetMaxWidth>1024</HtmlWidgetMaxWidth>
    <HtmlWidgetNeverApplyStyling>false</HtmlWidgetNeverApplyStyling>
    <HtmlWidgetResourceChartsApex>false</HtmlWidgetResourceChartsApex>
    <HtmlWidgetResourceCssSummaryPage2>false</HtmlWidgetResourceCssSummaryPage2>
    <HtmlWidgetResourceCssWidget>true</HtmlWidgetResourceCssWidget>
    <HtmlWidgetResourceJQuery>true</HtmlWidgetResourceJQuery>
    <HtmlWidgetResourceJQueryVersion />
    <HtmlWidgetSpecialEventGetFolderCount>false</HtmlWidgetSpecialEventGetFolderCount>
    <Icon>Settings_Global</Icon>
    <RestrictedOriginsListEnabled>false</RestrictedOriginsListEnabled>
    <RunAsAdministrator>false</RunAsAdministrator>
    <WebServiceName />
    <WebServiceAllowAnonymous>false</WebServiceAllowAnonymous>
    <WebServiceSendDebugInformation>false</WebServiceSendDebugInformation>
    <ShowInMenu>None</ShowInMenu>
    <ParametersType>Custom</ParametersType>
    <Parameters>
      <ISParameterDefs version="1.00">
        <Parameters>
          <Parameter name="PageId" type="List">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <Mandatory>false</Mandatory>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value />
            <Visible>true</Visible>
            <List>General_Database,General_Formatting,General_Performance,General_SummaryPages,General_TimeZones,General_UserInterface,Accounts_NewAccounts,Clients_NewClients,Clients_Contacts,Clients_WebAccess,ExternalParties_General,Users_General</List>
            <LimitToList>false</LimitToList>
            <MaxLength>0</MaxLength>
            <Rows>1</Rows>
          </Parameter>
          <Parameter name="ReadOnly" type="Boolean">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value>False</Value>
            <Visible>true</Visible>
          </Parameter>
        </Parameters>
      </ISParameterDefs>
    </Parameters>
  </finScript>
