function form_OnLoad() {
    if (Xrm.Page.ui.getFormType() != 1) { loadLOBForm(); }

    if (Xrm.Page.getAttribute("DNS_isassist_bool") != null) {
        Xrm.Page.getAttribute("DNS_isassist_bool").setSubmitMode("never");
    }

    if (Xrm.Page.getAttribute("DNS_dayssincelastcontact_text") != null) {
        Xrm.Page.getAttribute("DNS_dayssincelastcontact_text").setSubmitMode("always");
    }
}

function firstname_OnChange() { refresh.firstname_OnChange(); }

function lastname_OnChange() { refresh.lastname_OnChange(); }

function dob_OnChange() { refresh.dob_OnChange(); }

function ssn_OnChange() { refresh.ssn_OnChange(); }

function edipi_OnChange() { refresh.edipi_OnChange(); }

function gender_OnChange() { refresh.gender_OnChange(); }

function daytimePhone_OnChange() { refresh.daytimePhone_OnChange(); }

function type_OnChange(context) {
    Xrm.Page.getAttribute("DNS_areaintersectionid").setValue(null);
    Xrm.Page.getAttribute("DNS_subareaintersectionid").setValue(null);
    Xrm.Page.getAttribute("DNS_resolutionintersectionid").setValue(null);
    Xrm.Page.getAttribute("DNS_casenotetemplateid").setValue(null);
    Xrm.Page.getAttribute("DNS_subareaintersectionid").setRequiredLevel("none");
    Xrm.Page.getAttribute("DNS_casenotetemplateid").setRequiredLevel("none");
    Xrm.Page.getAttribute("DNS_assist_casenotetemplateid").setValue(null);
    N52.Clientside.ExecuteFormulas(context, 'yDn');
}

function area_OnChange(context) {
    Xrm.Page.getAttribute("DNS_subareaintersectionid").setValue(null);
    Xrm.Page.getAttribute("DNS_casenotetemplateid").setValue(null);
    Xrm.Page.getAttribute("DNS_subareaintersectionid").setRequiredLevel("none");
    Xrm.Page.getAttribute("DNS_casenotetemplateid").setRequiredLevel("none");
    Xrm.Page.getAttribute("DNS_assist_casenotetemplateid").setValue(null);
    Xrm.Page.data.entity.save();

    N52.Clientside.ExecuteFormulas(context, 'OYa');
}

function resolution_OnChange() {
    Xrm.Page.data.entity.save();
}

function caseNoteTemplate_OnChange(context) {
    Xrm.Page.data.entity.save();
    N52.Clientside.ExecuteFormulas(context, 'GV7');
}

function loadWebParts() {
    unattendedSearchFromRelatedRecord("bah_veteranid", loadAssociations, loadESRWebParts);
}

function loadAssociations(icn) {
    displayWebPart(icn, 'IFRAME_associations', 'esr_associations_endpoint');
}

function loadESRWebParts(icn) {
    //pass icn, folder path and list of control names/resource names to the loadEsrResources function
    loadEsrResources(icn, '/webresources/DNS_/ESRParts', 'WebResource_enrollment|enrollment.htm,WebResource_esreligibility|eligibility.htm,WebResource_demographics|demographics.htm');
}
