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 Taux is valid */
var commissions = $j('#commissions').val();

});

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

/* calculer le total */
$j('#total_ht, #commissions, #total_ttc, #frais_pta, #net_payer').change(function(){
var totalht = parseFloat($j('#total_ht').val()) || 0;
var commission = parseFloat($j('#commissions').val()) || 0;
var totalttc = parseFloat($j('#total_ttc').val()) || 0;
var fraispta = parseFloat($j('#frais_pta').val()) || 0;
var netpayer = parseFloat($j('#net_payer').val()) || 0;

var totalttc2 = totalht * commission / 100 + totalht;

var totalttc3 = totalttc2 + fraispta;

$j('#net_payer').val(totalttc3);
$j('#total_ttc').val(totalttc2);
});

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


})