// Creado: Félix Ricardo Oliva Alonso, 12/10/2016. Función paar agregar nuevo css
// Modificado: Jorge Antonio Mendoza Salazar, 07/12/2016. Agregar y modificar validaciones
// Modificado: Jorge Antonio Mendoza Salazar, 23/12/2016. Modificar validaciones



$(document).ready(function(){





  ///////////////////////////////////////////////////////////////////////
  //                     ADMINISTRAR ACCESOS DEL FE
  ///////////////////////////////////////////////////////////////////////
  //*********************************************************************
  //                        AGREGAR NUEVO ACCESO
  //*********************************************************************
  $(function(){
    $("#btn_guardar_aacc2").on("click",function(){
      $("#admin_accesos2").validate({
        rules:
        {
          modulo_aacc2:
          {required: true},

          nombre_aacc2:
          {required: true, maxlength: 250},

          ubicacion_aacc2:
          {required: true, maxlength: 250},

          descripcion_aacc2:
          {required: true, maxlength: 4000}
        },
        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 ACCESO
  //*********************************************************************
  $(function(){
    $("#btn_guardar_aacc3").on("click",function(){
      $("#admin_accesos3").validate({
        rules:
        {
          modulo_aacc3:
          {required: true},

          nombre_aacc3:
          {required: true, maxlength: 250},

          ubicacion_aacc3:
          {required: true, maxlength: 250},

          descripcion_aacc3:
          {required: true, maxlength: 4000}
        },
        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 NUEVO MODULO
  //*********************************************************************
  $(function(){
    $("#btn_guardar_n_aacc2").on("click",function(){
      $("#agregar_modulo_aacc2").validate({
        rules:
        {
          nuevo_modulo_aacc2:
          {required: true, minlength: 8, maxlength: 250},

          des_modulo_aacc2:
          {required: true, maxlength: 4000}
        },
        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" );
        },
        errorPlacement: function(error, element){},
      });
    });
  });

  //**********************************************
  //               adminConsultorios
  //**********************************************
  $(function(){
    $("#btn_guardar_adcon2").on("click",function(){
      $("#admin_consultorios2").validate({
        rules:
        {
          consultorio_adcon2:
          {required: true,
          maxlength: 8}
        },
        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",
      });
    });
  });
  $(function(){
    $("#btn_guardar_adcon3").on("click",function(){
      $("#admin_consultorios3").validate({
        rules:
        {
          consultorio_adcon3:
          {required: true,
          maxlength: 8}
        },
        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",
      });
    });
  });


  //**********************************************
  //               adminModulos
  //**********************************************
  $(function(){
    $("#btn_guardar_admod2").on("click",function(){
      $("#admin_modulos_a2").validate({
        rules:
        {
          nmodulo_admod2:
          {required: true,
          maxlength: 8}
        },
        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",
      });
    });
  });
  $(function(){
    $("#btn_guardar_admod3").on("click",function(){
      $("#admin_modulos_a3").validate({
        rules:
        {
          nmodulo_admod3:
          {required: true,
          maxlength: 8}
        },
        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",
      });
    });
  });


  //**********************************************
  //                adminPerfiles
  //**********************************************
  $(function(){
    $("#btn_guardar_ap2").on("click",function(){
      $("#admin_perfiles2").validate({
        rules:
        {
          centro_salud_ap2:
          {required: true},

          perfil_ap2:
          {required: true, maxlength: 250},

          actividades_ap2:
          {required: true, maxlength: 4000}
        },
        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",
      });
    });
  });
  $(function(){
    $("#btn_guardar_ap3").on("click",function(){
      $("#admin_perfiles3").validate({
        rules:
        {
          centro_salud_ap3:
          {required: true},

          perfil_ap3:
          {required: true,
          maxlength: 250},

          actividades_ap3:
          {required: true,
          maxlength: 4000}
        },
        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",
      });
    });
  });
  $(function(){
    $("#btn_guardar_ap4").on("click",function(){
      $("#admin_perfiles4").validate({
        rules:
        {
          centro_salud_ap4:
          {required: true},

          perfil_ap4:
          {required: true, maxlength: 250},

          actividades_ap4:
          {required: true, maxlength: 4000}
        },
        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",
      });
    });
  });

  ///////////////////////////////////////////////////////////////////////
  //                      ADMINISTRAR ESTILOS CSS
  ///////////////////////////////////////////////////////////////////////
  //*********************************************************************
  //                        AGREGAR NUEVO ESTILO
  //*********************************************************************
  $(function(){
    $("#btn_guardar_cae2").on("click",function(){
      $("#css_agregar_cae2").validate({
        rules:
        {
          
          // url:
          // {required: true, maxlength: 200},

          titulo:
          {required: true, maxlength: 200},

          descripcion:
          {required: true, maxlength: 4000}
        },
        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 ESTILO
  //*********************************************************************
  $(function(){
    $("#btn_guardar_cae3").on("click",function(){
      $("#css_agregar_cae3").validate({
        rules:
        {
          url_2:
          {required: true, maxlength: 200},

          titulo_2:
          {required: true, maxlength: 200},

          descripcion_2:
          {required: true, maxlength: 4000}
        },
        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",
      });
    });
  });

  ///////////////////////////////////////////////////////////////////////
  //            ADMINISTRAR CUENTAS DE ADMINISTRADORES DE CS
  ///////////////////////////////////////////////////////////////////////
  //*********************************************************************
  //                        AGREGAR NUEVA CUENTA
  //*********************************************************************
  $(function(){
    $("#btn_guardar_ac2").on("click",function(){
      $("#admin_cuentas2").validate({
        rules:
        {
          centro_s:
          {required: true},

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

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

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

          nivel_e:
          {required: true},

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

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

          clave_ac2:
          {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 CUENTA
  //*********************************************************************
  $(function(){
    $("#btn_guardar_ac3").on("click",function(){
      $("#admin_cuentas3").validate({
        rules:
        {
          nombre_ac3:
          {required: true, maxlength: 50},

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

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

          nivel_e_ac3:
          {required: true},

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

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

          clave_ac3:
          {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",
      });
    });
  });
});
