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 net à payer field to read only*/
$j('#net_payer').prop('readonly', true);

/* calcul du champs net à payer */
$j('#revenus, #mois, #valeur, #net_payer').change(function(){
	var revenu = parseFloat($j('#revenus').val()) || 0;
	var moiss = parseFloat($j('#mois').val()) || 0;
	var valeurs = parseFloat($j('#valeur').val()) || 0;
	var netPayer = parseFloat($j('#net_payer').val()) || 0;
	
	var totalPrice = (revenu / moiss) * valeurs;
	$j('#net_payer').val(totalPrice);
});

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

})