function loadTypeForm() {

    var OUTBOUNDFORMID = "25b9d714-badd-47d5-8b6f-30612a2bcba2";
    var CALLBACKFORMID = "2e74a092-f59a-412c-ae16-7f115538ffed";
    var DEFAULTFORMID = "a91390a5-99bb-4d10-9eee-3a5c87f841f1";
    var EEDOUTBOUNDFORMID = "5dfb326a-5cca-4288-b851-7b904cc5b655";
    var HDFORMID = "3d7a347a-7b70-4bd5-9d75-d66d92815fa4";

    if (Xrm.Page.ui.getFormType() != 1) {
        var formId = DEFAULTFORMID;
        var currentFormName = Xrm.Page.ui.formSelector.getCurrentItem().getLabel();

        if (Xrm.Page.getAttribute("vhacrm_type_code") != null) {
            var type = Xrm.Page.getAttribute("vhacrm_type_code").getText();

            if (currentFormName != type) {
                switch (type) {
                    case "HRC Outbound":
                        if (Xrm.Page.ui.formSelector.items.get(OUTBOUNDFORMID) != null) {
                            formId = OUTBOUNDFORMID;
                        }
                        break;
                    case "HD Callback":
                        if (Xrm.Page.ui.formSelector.items.get(CALLBACKFORMID) != null) {
                            formId = CALLBACKFORMID;
                        }
                        break;
                     case "EED Outbound":
                        if (Xrm.Page.ui.formSelector.items.get(EEDOUTBOUNDFORMID) != null) {
                            formId = EEDOUTBOUNDFORMID;
                        }
                        break;
                    case "HD Phone Call":
                        if (Xrm.Page.ui.formSelector.items.get(HDFORMID) != null) {
                            formId = HDFORMID;
                        }
                        break;
                    default:
                        formId = DEFAULTFORMID;
                        break;
                }

                if (Xrm.Page.ui.formSelector.items.get(formId) != null) {
                    Xrm.Page.ui.formSelector.items.get(formId).navigate();
                }
            }
        }
    }
}

function preventAutoSave(context) {
    var eventArgs = context.getEventArgs();

    if (eventArgs.getSaveMode() == 70) {
        eventArgs.preventDefault();
    }
}
