function initDialogBox()
{
    var headID = document.getElementsByTagName("head")[0];
    var cssNode = document.createElement('link');
    cssNode.type = 'text/css';
    cssNode.rel = 'stylesheet';
    cssNode.href = '/css/dialog_box.css';
    headID.appendChild(cssNode);

    var headID = document.getElementsByTagName("head")[0];
    var newScript = document.createElement('script');
    newScript.type = 'text/javascript';
    newScript.src = '/js/dialog_box.js';
    headID.appendChild(newScript);
}

function showCancellationFeeBox(invoice_id, condition)
{
    var cancel = new LertButton(translate('dialog_cancellation_button_action'), function() {});
    var with_fee = new LertButton(translate('dialog_cancellation_button_with_fee'), function() {
        window.location.href = '/accounting/check_invoices?action=cancel_invoice&fee=1&invoice_id='+invoice_id;
    });
    var without_fee = new LertButton(translate('dialog_cancellation_button_without_fee'), function() {
        window.location.href = '/accounting/check_invoices?action=cancel_invoice&invoice_id='+invoice_id;
    });

    if (condition == true)
    {
        var message = translate('dialog_cancellation_text_payment');
    }
    else
    {
        var message = translate('dialog_cancellation_text');
    }
    var exampleLert = new Lert(
        message,
        [without_fee,with_fee,cancel],
        {
            defaultButton:cancel,
            icon:'/images/dialog-warning.png'
        });
    exampleLert.display();
}

function showCancellationFeeBookingBox(invoice_id, condition)
{
    var cancel = new LertButton(translate('dialog_cancellation_button_action'), function() {});
    var with_fee = new LertButton(translate('dialog_cancellation_button_with_fee'), function() {
        $('_cancel_invoice_with_fee').value = 1;

        // Simulate submit button
        var sim_button = document.createElement("input");
        sim_button.setAttribute('id','save');
        sim_button.setAttribute('type', 'hidden');
        sim_button.setAttribute('value', 'Save');
        sim_button.setAttribute('name', '__lsm_actionbuttons[save]');
        document.forms["fm_booking_edit"].appendChild(sim_button);
        document.forms["fm_booking_edit"].submit();
    });
    var without_fee = new LertButton(translate('dialog_cancellation_button_without_fee'), function() {
        cancel_box_shown = true;
        $('_cancel_invoice_with_fee').value = 0;

        // Simulate submit button
        var sim_button = document.createElement("input");
        sim_button.setAttribute('id','save');
        sim_button.setAttribute('type', 'hidden');
        sim_button.setAttribute('value', 'Save');
        sim_button.setAttribute('name', '__lsm_actionbuttons[save]');
        document.forms["fm_booking_edit"].appendChild(sim_button);
        document.forms["fm_booking_edit"].submit();
    });

    if (condition == true)
    {
        var message = translate('dialog_cancellation_text_payment');
    }
    else
    {
        var message = translate('dialog_cancellation_text');
    }
    var exampleLert = new Lert(
        message,
        [without_fee,with_fee,cancel],
        {
            defaultButton:cancel,
            icon:'/images/dialog-warning.png'
        });
    exampleLert.display();
}

