(function ($){ $.fn.keyValue=function(expOarr,maxLength){ try{ var $this=$(this); if(maxLength) $this.attr("maxlength",maxLength); $this.keypress(function(event){ try{ var key = event.which; if(key==0||event.charCode==0)return true; if(key==8||event.charCode==8)return true; if(maxLength && this.value.length==maxLength)return false; if(typeof expOarr ==='object'&& expOarr.length!=undefined){ for(var i=0;(exp=expOarr[i++]);) if(key==((typeof exp=="number")? exp : exp.charCodeAt(0))) return true; return false; } return expOarr.test(String.fromCharCode(key)); }catch(e){ alert(e.message); } }); }catch(e){ alert(e.message); } return $this; } })(jQuery); function showLightboxAdvertencia() { document.getElementById('aparece-lightboxAdvertencia').style.display='block'; document.getElementById('desaparece-lightboxAdvertencia').style.display='block'; } function hideLightboxAdvertencia() { document.getElementById('aparece-lightboxAdvertencia').style.display='none'; document.getElementById('desaparece-lightboxAdvertencia').style.display='none'; } function showLightboxNoCompleto() { document.getElementById('aparece-lightboxNoCompleto').style.display='block'; document.getElementById('desaparece-lightboxNoCompleto').style.display='block'; } function hideLightboxNoCompleto() { document.getElementById('aparece-lightboxNoCompleto').style.display='none'; document.getElementById('desaparece-lightboxNoCompleto').style.display='none'; } function showLightboxBloqueo() { document.getElementById('aparece-lightboxBloqueo').style.display='block'; document.getElementById('desaparece-lightboxBloqueo').style.display='block'; } function hideLightboxBloqueo() { document.getElementById('aparece-lightboxBloqueo').style.display='none'; document.getElementById('desaparece-lightboxBloqueo').style.display='none'; } // isMail: devuelve verdadero si value es una direccion de correo valida function isMail(value) { try { var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; return re.test(value); } catch(e) { return false; } } $(document).ready(function() { $("#form-nuevologin-n-documento").on('focus', function(){ if($("#form-nuevologin-tipo-documento").val()==0) { $("#form-nuevologin-n-documento").attr('readonly', 'readonly'); $("#form-nuevologin-clave").attr('readonly', 'readonly'); $(".obligatorio-tipo-documento").show(); }else{ $("#form-nuevologin-n-documento").attr('readonly', false); $("#form-nuevologin-clave").attr('readonly', false); $(".obligatorio-tipo-documento").hide(); } }); $("#form-nuevologin-clave").on('focus', function(){ if($("#form-nuevologin-tipo-documento").val()==0) { $("#form-nuevologin-n-documento").attr('readonly', 'readonly'); $("#form-nuevologin-clave").attr('readonly', 'readonly'); $(".obligatorio-tipo-documento").show(); }else{ $("#form-nuevologin-n-documento").attr('readonly', false); $("#form-nuevologin-clave").attr('readonly', false); $(".obligatorio-tipo-documento").hide(); } }); $("#form-nuevologin-tipo-documento").on('change', function(){ if($("#form-nuevologin-tipo-documento").val()!='0') { $(".obligatorio-tipo-documento").hide(); } }); linkInterno = 0; $('.solo-numeros').keyValue(/[0-9]/); $(".solo-texto").keyValue(/[a-z,'ñ',A-Z,'Ñ',' ','á-ú','Á-Ú']/); //detecta si disposito es mobile isMobile = { Android: function() { return navigator.userAgent.match(/Android/i); }, BlackBerry: function() { return navigator.userAgent.match(/BlackBerry/i); }, iOS: function() { return navigator.userAgent.match(/iPhone|iPad|iPod/i); }, Opera: function() { return navigator.userAgent.match(/Opera Mini/i); }, Windows: function() { return navigator.userAgent.match(/IEMobile/i); }, any: function() { return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows()); } }; //custom select $(".fondo-select").chosen({ disable_search: true, no_results_text: "Oops, nothing found!", width: "100%" }); //abrir ventana login nuevo $(function() { var button = $('#loginButton'); var box = $('.login-nuevo'); var form = $('#loginForm'); var capa = $('#contenedor'); button.removeAttr('href'); button.mouseup(function(login) { if(getBienvenidoCookie()!='1' && !$('#loginButton').hasClass('active')){ modalBienvenida(); }else{ box.toggle(); button.toggleClass('active'); capa.toggle(); } }); form.mouseup(function() { return false; }); $(this).mouseup(function(login) { if(!($(login.target).parent('#loginButton').length > 0) && $(login.target).attr('class')!='cont-login' && $(login.target).attr('class')!='texto') { button.removeClass('active'); box.hide(); capa.hide(); } }); }); $('select[name$="form-nuevologin-tipo-documento"] option:eq(0)').prop('selected', true); //cambia maximo caracteres numero documento segun opcion tipo documento $('select[name$="form-nuevologin-tipo-documento"]').change(function() { if( $(this).val() == '0') { $('input[name$="form-nuevologin-n-documento"]').attr({maxlength:"0", placeholder:"Número de Documento"}).val(''); $('input[name$="form-nuevologin-n-documento"]').unbind('keypress'); $('input[name$="form-nuevologin-n-documento"]').keypress(function(key) { if((key.charCode <= 48 && key.charCode >= 57) || (key.charCode <= 65 || key.charCode >= 90) || (key.charCode <= 97 || key.charCode >= 122)) return true; }); } if( $(this).val() == 'CE') { $('input[name$="form-nuevologin-n-documento"]').removeAttr('disabled').attr({maxlength:"9", placeholder:"Ingrese CE"}).val(''); $('input[name$="form-nuevologin-n-documento"]').unbind('keypress'); $('input[name$="form-nuevologin-n-documento"]').keypress(function(key) { if((key.charCode <= 48 && key.charCode >= 57) || (key.charCode <= 65 || key.charCode >= 90) || (key.charCode <= 97 || key.charCode >= 122)) return true; }); } if( $(this).val() == 'CIP') { $('input[name$="form-nuevologin-n-documento"]').removeAttr('disabled').attr({maxlength:"9", placeholder:"Ingrese CIP"}).val(''); $('input[name$="form-nuevologin-n-documento"]').unbind('keypress'); $('input[name$="form-nuevologin-n-documento"]').keypress(function(key) { if((key.charCode <= 48 && key.charCode >= 57) || (key.charCode <= 65 || key.charCode >= 90) || (key.charCode <= 97 || key.charCode >= 122)) return true; }); } if( $(this).val() == 'DNI') { $('input[name$="form-nuevologin-n-documento"]').removeAttr('disabled').attr({maxlength:"8", placeholder:"Ingrese DNI"}).val(''); $('input[name$="form-nuevologin-n-documento"]').unbind('keypress'); $('input[name$="form-nuevologin-n-documento"]').keypress(function(key) { if((key.charCode < 48 || key.charCode > 57)) return false; }); } if( $(this).val() == 'PAS') { $('input[name$="form-nuevologin-n-documento"]').removeAttr('disabled').attr({maxlength:"16", placeholder:"Ingrese PAS"}).val(''); $('input[name$="form-nuevologin-n-documento"]').unbind('keypress'); $('input[name$="form-nuevologin-n-documento"]').keypress(function(key) { if((key.charCode <= 48 && key.charCode >= 57) || (key.charCode <= 65 || key.charCode >= 90) || (key.charCode <= 97 || key.charCode >= 122)) return true; }); } }); $(".login-nuevo form").submit(function( event ) { if($('select[name$="form-nuevologin-tipo-documento"]').val()=='0') { $(this).parent().find('.chosen-container').addClass('obligatorio'); $('.obligatorio-tipo-documento').show('slow'); $(this).parent().find('.chosen-container').click(function() { $(this).parent().find('.chosen-container').removeClass('obligatorio'); $('.obligatorio-tipo-documento').hide('slow'); $('.obligatorio-numero-documento').hide('slow'); $('.obligatorio-password').hide('slow'); $('.obligatorio-captcha').hide('slow'); }); return false; } if( $('select[name$="form-nuevologin-tipo-documento"]').val() == 'CE' && $('input[name$="form-nuevologin-n-documento"]').val().length < 9) { $('input[name$="form-nuevologin-n-documento"]').attr('placeholder','Ingresa CE válido').addClass('obligatorio').focus(); $('.obligatorio-numero-documento').html('Ingresar 9 caracteres alfa-numéricos.'); $('.obligatorio-numero-documento').show('slow'); $('input[name$="form-nuevologin-n-documento"]').keypress(function() { $('input[name$="form-nuevologin-n-documento"]').removeClass('obligatorio'); $('.obligatorio-numero-documento').hide('slow'); $('.obligatorio-password').hide('slow'); $('.obligatorio-captcha').hide('slow'); }); return false; } if( $('select[name$="form-nuevologin-tipo-documento"]').val() == 'CIP' && $('input[name$="form-nuevologin-n-documento"]').val().length < 9) { $('input[name$="form-nuevologin-n-documento"]').attr('placeholder','Ingresa CIP válido').addClass('obligatorio').focus(); $('.obligatorio-numero-documento').html('Ingresar 9 caracteres alfa-numéricos.'); $('.obligatorio-numero-documento').show('slow'); $('input[name$="form-nuevologin-n-documento"]').keypress(function() { $('input[name$="form-nuevologin-n-documento"]').removeClass('obligatorio'); $('.obligatorio-numero-documento').hide('slow'); $('.obligatorio-password').hide('slow'); $('.obligatorio-captcha').hide('slow'); }); return false; } if( $('select[name$="form-nuevologin-tipo-documento"]').val() == 'DNI' && $('input[name$="form-nuevologin-n-documento"]').val().length < 8) { $('input[name$="form-nuevologin-n-documento"]').attr('placeholder','Ingresa DNI válido').addClass('obligatorio').focus(); $('.obligatorio-numero-documento').html('Ingresar 8 caracteres numéricos.'); $('.obligatorio-numero-documento').show('slow'); $('input[name$="form-nuevologin-n-documento"]').keypress(function() { $('input[name$="form-nuevologin-n-documento"]').removeClass('obligatorio'); $('.obligatorio-numero-documento').hide('slow'); $('.obligatorio-password').hide('slow'); $('.obligatorio-captcha').hide('slow'); }); return false; } if( $('select[name$="form-nuevologin-tipo-documento"]').val() == 'PAS' && $('input[name$="form-nuevologin-n-documento"]').val().length < 16) { $('input[name$="form-nuevologin-n-documento"]').attr('placeholder','Ingresa PAS válido').addClass('obligatorio').focus(); $('.obligatorio-numero-documento').html('Ingresar 16 caracteres alfa-numéricos.'); $('.obligatorio-numero-documento').show('slow'); $('input[name$="form-nuevologin-n-documento"]').keypress(function() { $('input[name$="form-nuevologin-n-documento"]').removeClass('obligatorio'); $('.obligatorio-numero-documento').hide('slow'); $('.obligatorio-password').hide('slow'); $('.obligatorio-captcha').hide('slow'); }); return false; } if($('input[name$="form-nuevologin-clave"]').val().length == '') { $('input[name$="form-nuevologin-clave"]').attr('placeholder','Ingrese su clave').addClass('obligatorio').focus(); $('.obligatorio-password').show('slow'); $('input[name$="form-nuevologin-clave"]').keypress(function() { $('input[name$="form-nuevologin-clave"]').removeClass('obligatorio'); $('.obligatorio-password').hide('slow'); $('.obligatorio-captcha').hide('slow'); }); return false; } if($('#g-recaptcha-response').val()==''){ $('.obligatorio-captcha').show('slow'); return false; } }); }); function openLoginForm(){ $('#loginButton').toggleClass('active'); $('.login-nuevo').toggle(); $('#contenedor').toggle(); } //Muestra y permite cerrar alertas de intentos fallidos y bloqueo de cuenta function advertencia() { $('#aparece-lightboxAdvertencia, #desaparece-lightboxAdvertencia').fadeIn(250); } $('#aparece-lightboxAdvertencia a').click(function() { $('#aparece-lightboxAdvertencia, #desaparece-lightboxAdvertencia').fadeOut(200); openLoginForm(); }); function cuentaBloqueada() { $('#aparece-lightboxBloqueo, #desaparece-lightboxNoCompleto').fadeIn(250); } $('#aparece-lightboxBloqueo a').click(function() { $('#aparece-lightboxBloqueo, #desaparece-lightboxNoCompleto').fadeOut(200); openLoginForm(); }); function registroTerminado(){ $('#desaparece-lightboxRegistroTerminado, #aparece-lightboxRegistroTerminado').fadeIn(200); } $('#aparece-lightboxRegistroTerminado a').click(function(){ $('#desaparece-lightboxRegistroTerminado, #aparece-lightboxRegistroTerminado').fadeOut(200); openLoginForm(); }); function tokenInvalido(){ $('#desaparece-lightboxTokenInvalido, #aparece-lightboxTokenInvalido').fadeIn(200); } $('#aparece-lightboxTokenInvalido a').click(function(){ $('#desaparece-lightboxTokenInvalido, #aparece-lightboxTokenInvalido').fadeOut(200); }); function correoEnviado(){ $('#desaparece-lightboxCorreoEnviado, #aparece-lightboxCorreoEnviado').fadeIn(200); } $('#aparece-lightboxCorreoEnviado a').click(function(){ $('#desaparece-lightboxCorreoEnviado, #aparece-lightboxCorreoEnviado').fadeOut(200); }); function modalBienvenida(){ $('#modalBienvenida-bg, #modalBienvenida').fadeIn(200); } $('#modalBienvenida a').click(function(){ if($('#noMostrarMensajeDenuevo').is(':checked')){ setBienvenidoCookie(); } $('#modalBienvenida-bg, #modalBienvenida').fadeOut(200); }); function setBienvenidoCookie() { document.cookie = "BienvenidoWebUnica=1; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/"; } function getBienvenidoCookie() { var c_name = "BienvenidoWebUnica"; if (document.cookie.length > 0) { c_start = document.cookie.indexOf(c_name + "="); if (c_start != -1) { c_start = c_start + c_name.length + 1; c_end = document.cookie.indexOf(";", c_start); if (c_end == -1) { c_end = document.cookie.length; } return unescape(document.cookie.substring(c_start, c_end)); } } return ""; }