﻿/**************************************************************************************************************/
/***                                                                                                        ***/
/***  Name: toggleTriggerType                                                                               ***/
/***                                                                                                        ***/
/// <summary>
/// Toggles which trigger fieldsets are shown based on trigger type.
/// </summary>
/***                                                                                                        ***/
/**************************************************************************************************************/

function toggleTriggerType(strDropDownClientId)
{
    /**********************************************************************************************************/
    /***  Get the fieldsets and the drop down                                                               ***/
    /**********************************************************************************************************/

    var divNumAbsences = $get('divNumAbsences');
    var divAbsenceLength = $get('divAbsenceLength');
    var divNumShifts = $get('divNumShifts');
    var divCondCode = $get('divCondCode');
    var divBradford = $get('divBradford');
    var divOther = $get('divOther');
    var ddlType = $get(strDropDownClientId);
    
    /**********************************************************************************************************/
    /***  Get the trigger type                                                                              ***/
    /**********************************************************************************************************/
    
    var strType = ddlType.options[ddlType.selectedIndex].value;
    
    /**********************************************************************************************************/
    /***  Turn fieldsets on and off depending on the type                                                   ***/
    /**********************************************************************************************************/

    if (strType == "Number_of_Absences") {
        divNumAbsences.style.display = '';
        divAbsenceLength.style.display = 'none';
        divNumShifts.style.display = 'none';
        divCondCode.style.display = 'none';
        divBradford.style.display = 'none';
        divOther.style.display = 'none';
    }
    else if (strType == "Absence_Length") {
        divNumAbsences.style.display = 'none';
        divAbsenceLength.style.display = '';
        divNumShifts.style.display = 'none';
        divCondCode.style.display = 'none';
        divBradford.style.display = 'none';
        divOther.style.display = 'none';
    }
    else if (strType == "Combined_Absence_Length") {
        divNumAbsences.style.display = 'none';
        divAbsenceLength.style.display = 'none';
        divNumShifts.style.display = '';
        divCondCode.style.display = 'none';
        divBradford.style.display = 'none';
        divOther.style.display = 'none';
    }
    else if (strType == "Bradford_Score") {
        divNumAbsences.style.display = 'none';
        divAbsenceLength.style.display = 'none';
        divNumShifts.style.display = 'none';
        divCondCode.style.display = 'none';
        divBradford.style.display = '';
        divOther.style.display = 'none';
    }
    else if (strType == "Condition_Code") {
        divNumAbsences.style.display = 'none';
        divAbsenceLength.style.display = 'none';
        divNumShifts.style.display = 'none';
        divCondCode.style.display = '';
        divBradford.style.display = 'none';
        divOther.style.display = 'none';
    }
    else if (strType == "Other") {
        divNumAbsences.style.display = 'none';
        divAbsenceLength.style.display = 'none';
        divNumShifts.style.display = 'none';
        divCondCode.style.display = 'none';
        divBradford.style.display = 'none';
        divOther.style.display = '';
    }
}

/**************************************************************************************************************/
/***                                                                                                        ***/
/***  Name: showHideCaseTypes                                                                               ***/
/***                                                                                                        ***/
/// <summary>
/// Shows/hides the case types when Case Management is turned on and off.
/// </summary>
/***                                                                                                        ***/
/**************************************************************************************************************/

function showHideCaseTypes(cbCaseManId, divCaseTypesId, ulCaseTypesId)
{
    /**********************************************************************************************************/
    /***  Get the controls                                                                                  ***/
    /**********************************************************************************************************/
    
    var cbCaseMan = $get(cbCaseManId);
    var divCaseTypes = $get(divCaseTypesId);
    var ulCaseTypes = $get(ulCaseTypesId);
    
    /**********************************************************************************************************/
    /***  Show/hide the controls, depending on the check box state                                          ***/
    /**********************************************************************************************************/
    
    if (cbCaseMan.checked == true)
    {
        divCaseTypes.style.display = '';
        ulCaseTypes.style.display = '';
    }
    else
    {
        divCaseTypes.style.display = 'none';
        ulCaseTypes.style.display = 'none';
    }
}

/**************************************************************************************************************/
/***                                                                                                        ***/
/***  Name: showHideCaseAppointmentTypes                                                                    ***/
/***                                                                                                        ***/
/// <summary>
/// Shows/hides the case appointment types when Case Management is turned on and off.
/// </summary>
/***                                                                                                        ***/
/**************************************************************************************************************/

function showHideCaseAppointmentTypes(cbCaseManId, divCaseAppointmentTypesId, ulCaseAppointmentTypesId) 
{
    /**********************************************************************************************************/
    /***  Get the controls                                                                                  ***/
    /**********************************************************************************************************/

    var cbCaseMan = $get(cbCaseManId);
    var divCaseAppointmentTypes = $get(divCaseAppointmentTypesId);
    var ulCaseAppointmentTypes = $get(ulCaseAppointmentTypesId);

    /**********************************************************************************************************/
    /***  Show/hide the controls, depending on the check box state                                          ***/
    /**********************************************************************************************************/

    if (cbCaseMan.checked == true) {
        divCaseAppointmentTypes.style.display = '';
        ulCaseAppointmentTypes.style.display = '';
    }
    else {
        divCaseAppointmentTypes.style.display = 'none';
        ulCaseAppointmentTypes.style.display = 'none';
    }
}

/**************************************************************************************************************/
/***                                                                                                        ***/
/***  Name: showHideCaseOutcomes                                                                            ***/
/***                                                                                                        ***/
/// <summary>
/// Shows/hides the case outcomes when Case Management is turned on and off.
/// </summary>
/***                                                                                                        ***/
/**************************************************************************************************************/

function showHideCaseOutcomes(cbCaseManId, divCaseOutcomesId, ulCaseOutcomesId)
{
    /**********************************************************************************************************/
    /***  Get the controls                                                                                  ***/
    /**********************************************************************************************************/
    
    var cbCaseMan = $get(cbCaseManId);
    var divCaseOutcomes = $get(divCaseOutcomesId);
    var ulCaseOutcomes = $get(ulCaseOutcomesId);
    
    /**********************************************************************************************************/
    /***  Show/hide the controls, depending on the check box state                                          ***/
    /**********************************************************************************************************/
    
    if (cbCaseMan.checked == true)
    {
        divCaseOutcomes.style.display = '';
        ulCaseOutcomes.style.display = '';
    }
    else
    {
        divCaseOutcomes.style.display = 'none';
        ulCaseOutcomes.style.display = 'none';
    }
}

/**************************************************************************************************************/
/***                                                                                                        ***/
/***  Name: showHideInterventionDropDown                                                                    ***/
/***                                                                                                        ***/
/// <summary>
/// Shows/hides the li the intervention drop down is in, depending on the action selected.
/// </summary>
/***                                                                                                        ***/
/**************************************************************************************************************/

function showHideInterventionDropDown(ddlTriggerActionId,
    liIntGroupId,
    liInterventionId,
    liInterventionStatusId,
    strActionToMatch)
{
    /**********************************************************************************************************/
    /***  Get the controls                                                                                  ***/
    /**********************************************************************************************************/
    
    var ddlTriggerAction = $get(ddlTriggerActionId);
    var liIntGroup = $get(liIntGroupId);
    var liIntervention = $get(liInterventionId);
    var liInterventionStatus = $get(liInterventionStatusId);
    
    /**********************************************************************************************************/
    /***  Get the selected action                                                                           ***/
    /**********************************************************************************************************/
   
    var strSelectedAction = ddlTriggerAction.options[ddlTriggerAction.selectedIndex].value;
    
    /**********************************************************************************************************/
    /***  Turn the intervention li on or off depending on if it matches                                     ***/
    /**********************************************************************************************************/
    
    if (strSelectedAction == strActionToMatch)
    {
        liIntGroup.style.display = '';
        liIntervention.style.display = '';
        liInterventionStatus.style.display = '';
    }
    else
    {
        liIntGroup.style.display = 'none';
        liIntervention.style.display = 'none';
        liInterventionStatus.style.display = 'none';
    }
}

/**************************************************************************************************************/
/***                                                                                                        ***/
/***  Name: changePreviousSla                                                                               ***/
/***                                                                                                        ***/
/// <summary>
/// Shows/hides the LIs for trigger actions and previous SLAs.
/// </summary>
/***                                                                                                        ***/
/**************************************************************************************************************/

function changePreviousSla(rblPrevSlaId,
    ddlTriggerActionId,
    liActionId,
    liIntGroupId,
    liInterventionId,
    liInterventionStatusId,
    liSlasId,
    strActionToMatch)
{
    /**********************************************************************************************************/
    /***  Get the controls                                                                                  ***/
    /**********************************************************************************************************/
    
    var rblPrevSla = $get(rblPrevSlaId);
    var liAction = $get(liActionId);
    var liIntGroup = $get(liIntGroupId);
    var liIntervention = $get(liInterventionId);
    var liInterventionStatus = $get(liInterventionStatusId);
    var liSlas = $get(liSlasId);
    
    /**********************************************************************************************************/
    /***  If it's Actions, turn the SLA li off (and vice versa)                                             ***/
    /**********************************************************************************************************/
    
    if (rblPrevSla.childNodes[0].checked == true)
    {
        liAction.style.display = '';
        liSlas.style.display = 'none';
        
        /******************************************************************************************************/
        /***  We also need to turn the intervention li on, if necessary                                     ***/
        /******************************************************************************************************/
        
        showHideInterventionDropDown(ddlTriggerActionId,
            liIntGroupId,
            liInterventionId,
            liInterventionStatusId,
            strActionToMatch);
    }
    else
    {
        liAction.style.display = 'none';
        liIntGroup.style.display = 'none';
        liIntervention.style.display = 'none';
        liInterventionStatus.style.display = 'none';
        liSlas.style.display = '';
    }
}