function show_error(field, msg) {
    modal_window({
        message: '<div class="alert alert-danger">' + msg + '</div>',
        title: 'Error in ' + field,
        close: function () {
            $j('#' + field).focus();
            $j('#' + field).parents('.form-group').addClass('has-error');
        }
    });

    return false;
}

$j(function () {
    /* set to read only*/
    $j('#caisse').prop('readonly', true);

    /* calcul du champs montant_ttc */
    $j('#recette, #depense').change(function () {
        var recette = parseFloat($j('#recette').val()) || 0;
        var depense = parseFloat($j('#depense').val()) || 0;

        var caisse = recette - depense;
        $j('#caisse').val(caisse);
    });

    /* calculate total price on opening the detail view form*/
    $j('#recette').change();

})
