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

    loadWebParts();
}

function type_OnChange()
{
	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");
}

function area_OnChange(context)
{
	Xrm.Page.data.entity.save();
	Xrm.Page.getAttribute("DNS_subareaintersectionid").setValue(null);
	Xrm.Page.getAttribute("DNS_casenotetemplateid").setValue(null);
	Xrm.Page.getAttribute("DNS_subareaintersectionid").setRequiredLevel("none");
	N52.Clientside.ExecuteFormulas(context, 'Q5i'); 
}

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

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

function loadWebParts() {
    unattendedSearchFromRelatedRecord("customerid", 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_esrenrollment|enrollment.htm,WebResource_esreligibility|eligibility.htm,WebResource_esrdemographics|demographics.htm');
}

