﻿/**************************************************************************************************************/
/***                                                                                                        ***/
/***  Name: confirmAbsenceClose                                                                             ***/
/***                                                                                                        ***/
/// <summary>
/// Confirms the closure of an absence.
/// </summary>
/***                                                                                                        ***/
/**************************************************************************************************************/

function confirmAbsenceClose()
{
    if (confirm("Are you sure you want to save any changes made to this absence and then close it?") == true)
    {
        return true;
    }
    else
    {
        return false;
    }
}

/**************************************************************************************************************/
/***                                                                                                        ***/
/***  Name: confirmResendRtw                                                                                ***/
/***                                                                                                        ***/
/// <summary>
/// Confirms the resending of a RTW email.
/// </summary>
/***                                                                                                        ***/
/**************************************************************************************************************/

function confirmResendRtw()
{
    if (confirm("Are you sure you want to resend the RTW email for this absence?") == true)
    {
        return true;
    }
    else
    {
        return false;
    }
}

/**************************************************************************************************************/
/***                                                                                                        ***/
/***  Name: confirmResendSelfCert                                                                           ***/
/***                                                                                                        ***/
/// <summary>
/// Confirms the resending of a Self Cert email.
/// </summary>
/***                                                                                                        ***/
/**************************************************************************************************************/

function confirmResendSelfCert()
{
    if (confirm("Are you sure you want to resend the Self Cert email for this absence?") == true)
    {
        return true;
    }
    else
    {
        return false;
    }
}

/**************************************************************************************************************/
/***                                                                                                        ***/
/***  Name: confirmAbsenceReopen                                                                            ***/
/***                                                                                                        ***/
/// <summary>
/// Confirms the reopening of an absence.
/// </summary>
/***                                                                                                        ***/
/**************************************************************************************************************/

function confirmAbsenceReopen()
{
    if (confirm("Are you sure you want to reopen this absence?") == true)
    {
        return true;
    }
    else
    {
        return false;
    }
}

/**************************************************************************************************************/
/***                                                                                                        ***/
/***  Name: confirmCloseSelfCert                                                                            ***/
/***                                                                                                        ***/
/// <summary>
/// Confirms the action of closing a self-cert
/// </summary>
/***                                                                                                        ***/
/**************************************************************************************************************/

function confirmCloseSelfCert()
{
    if (confirm("Are you sure you want to close this self-cert using the current data in the system?") == true)
    {
        return true;
    }
    else
    {
        return false;
    }
}

/**************************************************************************************************************/
/***                                                                                                        ***/
/***  Name: confirmCloseRTW                                                                                 ***/
/***                                                                                                        ***/
/// <summary>
/// Confirms the action of closing a RTW
/// </summary>
/***                                                                                                        ***/
/**************************************************************************************************************/

function confirmCloseRTW()
{
    if (confirm("Are you sure you want to close this RTW using the current data in the system?") == true)
    {
        return true;
    }
    else
    {
        return false;
    }
}


/**************************************************************************************************************/
/***                                                                                                        ***/
/***  Name: confirmAbsenceDelete                                                                            ***/
/***                                                                                                        ***/
/// <summary>
/// Confirms the deletion of an absence.
/// </summary>
/***                                                                                                        ***/
/**************************************************************************************************************/

function confirmAbsenceDelete()
{
    if (confirm("If you delete this absence it will no longer appear in the system, on reports, or be used " +
        "in calculating Bradford Scores. Are you sure you want to delete this absence?") == true)
    {
        return true;
    }
    else
    {
        return false;
    }
}

/**************************************************************************************************************/
/***                                                                                                        ***/
/***  Name: confirmShiftReset                                                                               ***/
/***                                                                                                        ***/
/// <summary>
/// Confirms the resetting of shifts
/// </summary>
/***                                                                                                        ***/
/**************************************************************************************************************/

function confirmShiftReset() {
    if (confirm("Are you sure you want to reset the shifts for this absence?") == true) {
        return true;
    }
    else {
        return false;
    }
}

/**************************************************************************************************************/
/***                                                                                                        ***/
/***  Name: switchAbsenceEditPanel                                                                          ***/
/***                                                                                                        ***/
/// <summary>
/// On the absence edit screen - flips between the different panels
/// </summary>
/***                                                                                                        ***/
/**************************************************************************************************************/

function switchAbsenceEditPanel(divToShowId, divHide1Id, divHide2Id, divHide3Id,
    butSelectedId, butNormal1Id, butNormal2Id, butNormal3Id,
    hiddenId)
{
    var divShow = document.getElementById(divToShowId);
    var divHide1 = document.getElementById(divHide1Id);
    var divHide2 = document.getElementById(divHide2Id);
    var divHide3 = document.getElementById(divHide3Id);
    
    divShow.style.display = '';
    divHide1.style.display = 'none';
    divHide2.style.display = 'none';
    divHide3.style.display = 'none';
    
    var butSelected = document.getElementById(butSelectedId);
    var butNormal1 = document.getElementById(butNormal1Id);
    var butNormal2 = document.getElementById(butNormal2Id);
    var butNormal3 = document.getElementById(butNormal3Id);
    
    butSelected.className = 'PanelButtonSelected';
    butNormal1.className = 'PanelButton';
    butNormal2.className = 'PanelButton';
    butNormal3.className = 'PanelButton';
    
    var hidden = document.getElementById(hiddenId);
    hidden.value = divToShowId;
}

/**************************************************************************************************************/
/***                                                                                                        ***/
/***  Name: switchAbsenceAddPanel                                                                           ***/
/***                                                                                                        ***/
/// <summary>
/// Flips between three different panels
/// </summary>
/***                                                                                                        ***/
/**************************************************************************************************************/

function switchAbsenceAddPanel(divToShowId, divHide1Id, divHide2Id,
    butSelectedId, butNormal1Id, butNormal2Id,
    butPrevId, butNextId, showPrev, showNext,
    hiddenId)
{
    var divShow = document.getElementById(divToShowId);
    var divHide1 = document.getElementById(divHide1Id);
    var divHide2 = document.getElementById(divHide2Id);
    
    divShow.style.display = '';
    divHide1.style.display = 'none';
    divHide2.style.display = 'none';
    
    var butSelected = document.getElementById(butSelectedId);
    var butNormal1 = document.getElementById(butNormal1Id);
    var butNormal2 = document.getElementById(butNormal2Id);
    
    butSelected.className = 'PanelButtonSelected';
    butNormal1.className = 'PanelButton';
    butNormal2.className = 'PanelButton';
    
    var butPrev = $get(butPrevId);
    var butNext = $get(butNextId);
    
    if  (showPrev == 'True')
    {
        butPrev.style.display = '';
    }
    else
    {
        butPrev.style.display = 'none';
    }
    
    if  (showNext == 'True')
    {
        butNext.style.display = '';
    }
    else
    {
        butNext.style.display = 'none';
    }

    var hidden = document.getElementById(hiddenId);
    hidden.value = divToShowId;
}

/**************************************************************************************************************/
/***                                                                                                        ***/
/***  Name: checkExpectedEndDate                                                                            ***/
/***                                                                                                        ***/
/// <summary>
/// Checks if the expected end date has been edited...
/// </summary>
/***                                                                                                        ***/
/**************************************************************************************************************/

function checkExpectedEndDate(dateClientId, strCurrentExpectedEnd, strDateType) {

    var date = $get(dateClientId);

    if (date && date.children && date.children.length > 0) {
        
        var dateText = date.children[0];

        if (dateText.value == strCurrentExpectedEnd) {
            return confirm('You have not changed the ' + strDateType + ' of the absence, are you sure this is correct?');
        }       
    }

    return true;
}
