// Creado: Félix Ricardo Oliva Alonso, 29/09/2016. Función para agregar nuevo css
// Modificado: Jorge Antonio Mendoza Salazar, 16/11/2016. Agregar validaciones
// Modificado: Jorge Antonio Mendoza Salazar, 02/12/2016. Agregar y modificar validaciones
// Modificado: Jorge Antonio Mendoza Salazar, 07/12/2016. Modificar validaciones
// Modificado: Jorge Antonio Mendoza Salazar, 23/12/2016. Agregar y modificar validaciones

///////////////////////////////////////////////////////////////////////
//                   ADMINISTRAR CUENTAS DE USUARIO
///////////////////////////////////////////////////////////////////////
$(document).ready(function(){

  //*********************************************************************
  //                AGREGAR UNA NUEVA CUENTA DE USUARIO
  //*********************************************************************
  $(function(){
    $("#btn_guardar_usuario").on("click",function(){
      $("#agregar_cuenta").validate({
        rules:
        {
          curp:
          {required: true, maxlength: 18},

          nombre:
          {required: true, maxlength: 50},

          apellido_p:
          {required: true, maxlength: 50},

          lugar_n:
          {required: true, maxlength: 50},

          sexo:
          {required: true, maxlength: 20},

          fecha_n:
          {required: true, maxlength: 10},

          rfc:
          {required: true, maxlength: 13},

          nacionalidad:
          {required: true, maxlength: 50},

          especialidad:
          {required: true, maxlength: 50},

          universidad:
          {required: true, maxlength: 100},

          nivel_est1:
          {required: true, maxlength: 100},

          cedula_p1:
          {required: true, maxlength: 20},

          n_empleado:
          {required: true, maxlength: 30}
        },
        highlight: function(element) {
            $(element).css( "border-color", "#dd4939" );
            $(element).css( "background-color",  "rgba(221, 73, 57, 0.05)" );

        },
        unhighlight: function(element) {
            $(element).css( "border-color", "rgb(172, 172, 172)" );
            $(element).css( "background-color", "#ffffff" );
        },
        errorElement: "div",
      });
    });
  });

  //*********************************************************************
  //                      EDITAR CUENTA DE USUARIO
  //*********************************************************************
  $(function(){
    $("#btn_actualizar_usuario").on("click",function(){
      $("#editar_cuenta").validate({
        rules: {
          curp:
          {required: true, maxlength: 18},

          nombre:
          {required: true, maxlength: 50},

          apellido_p:
          {required: true, maxlength: 50},

          lugar_n:
          {required: true, maxlength: 50},

          sexo:
          {required: true, maxlength: 20},

          fecha_n:
          {required: true, maxlength: 10},

          rfc:
          {required: true, maxlength: 13},

          nacionalidad:
          {required: true, maxlength: 50},

          especialidad:
          {required: true, maxlength: 50},

          universidad:
          {required: true, maxlength: 100},

          nivel_est1:
          {required: true, maxlength: 100},

          cedula_p1:
          {required: true, maxlength: 20},

          n_empleado:
          {required: true, maxlength: 30}
        },
        highlight: function(element) {
            $(element).css( "border-color", "#dd4939" );
            $(element).css( "background-color",  "rgba(221, 73, 57, 0.05)" );

        },
        unhighlight: function(element) {
            $(element).css( "border-color", "rgb(172, 172, 172)" );
            $(element).css( "background-color", "#ffffff" );
        },
        errorElement: "div",
      });
    });
  });

  //*********************************************************************
  //                            AGREGAR CLAVE
  //*********************************************************************
  $(function(){
    $("#btn_guardar_clave").on("click",function(){
      $("#agregar_clave").validate({
        rules:
        {
          usuario_acu:
          {required: true, maxlength: 50},

          clave_acu:
          {required: true, maxlength: 32}
        },
        highlight: function(element) {
          $(element).css( "border-color", "#dd4939" );
          $(element).css( "background-color",  "rgba(221, 73, 57, 0.05)" );
        },
        unhighlight: function(element) {
          $(element).css( "border-color", "rgb(172, 172, 172)" );
          $(element).css( "background-color", "#ffffff" );
        },
        errorElement: "div",
      });
    });
  });

  //*********************************************************************
  //                             EDITAR CLAVE
  //*********************************************************************
  $(function(){
    $("#btn_actualizar_clave").on("click",function(){
      $("#editar_clave").validate({
        rules:
        {
          usuario_acu2:
          {required: true, maxlength: 50},

          clave_acu2:
          {required: true, maxlength: 32}
        },
        highlight: function(element) {
          $(element).css( "border-color", "#dd4939" );
          $(element).css( "background-color",  "rgba(221, 73, 57, 0.05)" );
        },
        unhighlight: function(element) {
          $(element).css( "border-color", "rgb(172, 172, 172)" );
          $(element).css( "background-color", "#ffffff" );
        },
        errorElement: "div",
      });
    });
  });
});
