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 montant ttc field to read only*/
$j('#balance').prop('readonly', true);

/* calcul du champs montant_ttc */
$j('#credits, #debits, #balance').change(function(){
	var credit = parseFloat($j('#credits').val()) || 0;
	var debit = parseFloat($j('#debits').val()) || 0;
	
	var restant = debit - credit;
	$j('#balance').val(restant);
});

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

})