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(){
$j('#update, #insert').click(function(){
/* Make sure commission is valid */
var commission = $j('#commission').val();

});

/* Set montant a payer to read-only */
$j('#net_compagnie').prop('readonly', true);

/* calculer le total */
$j('#montant, #commission_agence').change(function(){
var montantAchat = parseFloat($j('#montant').val()) || 0;
var commission = parseFloat($j('#commission_agence').val()) || 0;

var montantPayer = montantAchat * commission / 100 + montantAchat;
$j('#net_compagnie').val(montantPayer);
});
/* calculate total price on opening the detail view form*/
$j('#montant').change();

})