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;
}

/* Set to read-only */
//$j('#validite, #age').prop('readonly', true);
$j('#age').prop('readonly', true);


// file: hooks/TABLENAME-dv.js
new AppGiniField("expire_le").toDatepicker();
new AppGiniField("delivre_le").toDatepicker();
new AppGiniField("date_en").toDatepicker();
new AppGiniField("date_naissance").toDatepicker();

// automatic sizing
new AppGiniFields(["passport", "delivre_le", "expire_le"]).inline("Passeport");

// Hide/Show fields depending on conditions
/*
$j('#type_client-container').on('change', function(e){
  if(e.added.text == "PARTICULIER") {
    $j('#raison_sociale').parents('.form-group').hide();
    $j('#personne_contact').parents('.form-group').hide();
    $j('#ninea').parents('.form-group').hide();
    $j('#rc').parents('.form-group').hide();
    $j('#email_pc').parents('.form-group').hide();
    $j('#phone_pc').parents('.form-group').hide();
  }
})

$j('#type_client-container').on('change', function(e){
  if(e.added.text == "EN COMPTE") {
    $j('#raison_sociale').parents('.form-group').hide();
    $j('#personne_contact').parents('.form-group').hide();
    $j('#ninea').parents('.form-group').hide();
    $j('#rc').parents('.form-group').hide();
    $j('#email_pc').parents('.form-group').hide();
    $j('#phone_pc').parents('.form-group').hide();
  }
})

$j('#type_client-container').on('change', function(e){
  if(e.added.text == "ENTREPRISE") {
    $j('#prenom').parents('.form-group').hide();
    $j('#nom').parents('.form-group').hide();
    $j('#cin').parents('.form-group').hide();
    $j('#date_naissance').parents('.form-group').hide();
    $j('#age').parents('.form-group').hide();
  }
})
*/

