PageSourceSearch

https://pasalapagina.com/js/plp-behaviors.js

js pasalapagina.com collected 2026-10-04 05:20:32 UTC 60,088 bytes, 1,424 lines download raw bytes

1var carouselLocked = false;
2var loadingTimeout;
3var prevBuyButtonVal;
4var captchaTimeout;
5var $body = $("html");
6
7$(document).ready(function () {
8
9    $('.pre-payment-option').change(function(){
10        let radioCount = $('input.pre-payment-option[type="radio"]').length;
11        let planCount = ( (radioCount / 2) == 1 ) ? 2 : (radioCount / 2);
12        let paymentOptions = $('input.pre-payment-option[type="radio"]');
13        paymentOptions.each(function (index) {
14            let className = 'plan' + ((paymentOptions[index].value <= (planCount)) ? paymentOptions[index].value : paymentOptions[index].value - (planCount));
15            $('.Boton_Plan').removeClass(className);
16        });
17        let className = 'plan' + (($(this).val() <= (planCount)) ? $(this).val() : $(this).val() - (planCount));
18        $('.Boton_Plan').addClass(className);
19    });
20    $('.Boton_Plan').addClass('plan' + $('input.pre-payment-option[type="radio"]:checked').val());
21    $('form').submit(function(){
22        $(window).unload(function () {
23            $('input:not(:checkbox):not(:button)').val("");
24        });
25    });
26        $(".bw :input").prop("disabled", true);
27	$('.psa').click(function (evt) {
28            evt.preventDefault();
29            $('#alerta-regalo,#TB_overlay').fadeIn();
30        });
31
32	$('.aliados').click(function (evt) {
33            evt.preventDefault();
34            $('.popup-aliados,#TB_overlay').fadeIn();
35	});  
36	$('.register-membership').click(function (evt) {
37		evt.preventDefault();
38		$('#validable').attr("action", $(this).attr("href"));
39		if(validInst.checkRequiredFields() != false)
40		{
41			$('#validable').submit();
42		}
43			
44	});	    
45	$('.cerrar,.cerrar_lb,.cerrar_lc,.close-alert,.TB_overlay,.overlay-latino,#TB_overlay').click(function (evt) {
46            if($(this).attr('href') == '#') {
47                evt.preventDefault();
48                $('.popup-aliados').fadeOut();
49                $('.popup,.alerta,#lightbox').fadeOut();
50                $('#TB_overlay').fadeOut();
51                $body.css("overflow", "auto");
52            }
53            $('.popup,.alerta,#lightbox').fadeOut();
54            $('#TB_overlay').fadeOut();
55            $body.css("overflow", "auto");
56	});        
57	$('.open-platinum,.open-gold').click(function (evt) {
58		evt.preventDefault();
59		$('.content').removeClass("active");
60		$($(this).attr("href")).addClass("active");
61	});        
62	$('.pago-anticipado').click(function (evt) {
63	   evt.preventDefault();
64	   if($(this).html() != 'PAGO ANTICIPADO CON PSE O BALOTO<br>')
65		   $(this).html('PAGO ANTICIPADO CON PSE O BALOTO<br>');
66	   else
67		   $(this).html('CLIC AQU&Iacute; SI QUIERES PAGAR CON PSE O BALOTO<br>');
68	   $(this).parent().next().slideToggle();
69	});
70	$('.play').click(function (evt) {
71		evt.preventDefault();
72		$.get( ApplicationUrl + "video.html", function( data ) {
73			$( "#lightbox2" ).html( data );
74			$('#lightbox2,#TB_overlay').fadeIn();
75			$('.cerrar_video').click(function (evt) {
76				evt.preventDefault();
77				$( "#lightbox2" ).html( data );
78				$('#lightbox2,#TB_overlay').fadeOut();
79				$( "#lightbox2" ).html( '' );
80                $body.css("overflow", "auto");
81			});
82            $('.overlay-latino').click(function (evt) {
83                evt.preventDefault();
84                $( "#lightbox2" ).html( data );
85                $('#lightbox2,#TB_overlay').fadeOut();
86                $( "#lightbox2" ).html( '' );
87                $body.css("overflow", "auto");
88            });
89		});
90        $body.css("overflow", "hidden");
91	});   
92	$('.favoritas').click(function(evt){
93	   evt.preventDefault();
94	   $('.revistas-favoritas').parent().slideToggle();
95	   $('.pointer-down,.pointer-up').toggleClass('pointer-up').toggleClass('pointer-down');
96	});
97	$('.display-magazines').click(function (evt) {
98		evt.preventDefault();
99		var plan = $(this).attr("rel");
100		$('#TB_overlay,.popup-revistas.'+plan).fadeIn();
101        $body.css("overflow", "hidden");
102	});
103	$('.country').change(function (evt) {
104		evt.preventDefault();
105		$.get( ApplicationUrl + "index.php?geo.controller/countryChangedPlp2/"+$(this).val(), function( data ) {
106			$( "#state" ).html( data );
107			setSelectBehaviors();
108			validInst = new Validator(2, 'lightbox', false); 
109		});           
110	});
111    $('.country1').change(function (evt) {
112        evt.preventDefault();
113        $.get( ApplicationUrl + "index.php?geo.controller/countryChangedPlp4/"+$(this).val(), function( data ) {
114            $( "#state" ).html( data );
115            setSelectBehaviors();
116            validInst = new Validator(2, 'lightbox', false);
117        });
118    });
119    $('.country3').change(function (evt) {
120		evt.preventDefault();
121		$.get( ApplicationUrl + "index.php?geo.controller/countryChangedPlp3/"+$(this).val(), function( data ) {
122			$( "#state" ).html( data );
123			setSelectBehaviors();
124			validInst = new Validator(2, 'lightbox', false); 
125		});           
126	});  
127	$('.country4').change(function (evt) {
128		evt.preventDefault();
129		$.get( ApplicationUrl + "index.php?geo.controller/countryChangedPlp4/"+$(this).val(), function( data ) {
130			$( "#state" ).html( data );
131			setSelectBehaviors();
132			validInst = new Validator(2, 'lightbox', false); 
133		});           
134	});         
135	$('.help-link').click(function (evt) {
136		evt.preventDefault();
137	   $(this).next().slideToggle(); 
138	});
139
140	if($('.fa-star.active').length >= 10) {
141		$('.fa-star').hide();
142	}
143	setSelectBehaviors();
144	refreshFavorites('closed');
145	if($('.stage').length > 0) {
146		setTimeout('fadeToNext()', 7000);
147	}
148	$('.ver-btn').click(function (evt) {
149		evt.preventDefault();
150		$(this).prev().slideToggle();
151	});
152	$('.check').unbind('click').click(function (evt) {
153		$('.check').removeClass('selected');
154		$(this).addClass('selected');
155		$('.check-son').attr("checked", false);
156		$('.check-son').prop("checked", false);
157		$($(this).children()[0]).attr("checked", "checked");
158		$($(this).children()[0]).attr("checked", true);
159		$($(this).children()[0]).prop("checked", true);
160	});
161	$('.check-son').unbind('click').click(function (evt) {
162		$('.check').removeClass('selected');
163		$(this).parent().addClass('selected');
164	});
165	/*
166	$('.open-publication').click(function (evt) {
167		setTimeout(function () {
168			window.location.href = ApplicationUrl + 'home.html';
169		},9000);
170	});
171	*/
172    $('.close-video').click(function() {
173        $('#video-player').each(function(){
174            var frame = document.getElementById("video-player");
175            frame.contentWindow.postMessage(
176                '{"event":"command","func":"stopVideo","args":""}',
177                '*');
178        });
179    });
180        $('.btn-continuar').click(function (evt) {
181            var step = $(this).attr("rel");
182            $(".paso"+step).slideDown();
183            $('html, body').animate({
184                scrollTop: $(".paso"+step).offset().top
185            }, 1000, function (evt) {
186                $('.paso'+step).removeClass('bw');
187                $(".paso" + step + " :input").prop("disabled", false);
188                $('#payment_option').val($('input[type="radio"]:checked').val());
189            });              
190        });
191    $('.btn-continuar-2').click(function (evt) {
192        var step = $(this).attr("rel");
193        $(".paso"+step).slideDown();
194        $('html, body').animate({
195            scrollTop: $(".paso"+step).offset().top
196        }, 1000, function (evt) {
197            $('.paso'+step).removeClass('bw');
198            $(".paso" + step + " :input").prop("disabled", false);
199            $('#pre_payment_option').val($('input.pre-payment-option[type="radio"]:checked').val());
200            //console.log($('#pre_payment_option').val());
201            $('#payment_option').val($('input.pre-payment-option[type="radio"]:checked').val());
202			$('#payment_option_2').val($('input.pre-payment-option[type="radio"]:checked').val());
203        });
204    });
205    $('.btn-continuar-3').click(function (evt) {
206        var step = $(this).attr("rel");
207        if($('input.payment_method[type="radio"]:checked').val() == "2" || $('input.payment_method[type="radio"]:checked').val() == "4"){
208            step = "7";
209        }
210        $(".paso"+step).slideDown();
211        $('html, body').animate({
212            scrollTop: $(".paso"+step).offset().top
213        }, 1000, function (evt) {
214            $('.paso'+step).removeClass('bw');
215            $(".paso" + step + " :input").prop("disabled", false);
216        });
217    });
218
219    $('.scroll-to').click(function (evt) {
220            var anchor = $(this).attr("rel");
221            scrollTo(anchor);
222    });
223
224    $('.async-login').click(function (evt) {
225        evt.preventDefault();
226        //FORMULARIO
227        var form = $(this).parents('form:first');
228
229        var data = form.serialize();
230
231        $.post(ApplicationUrl + 'user.controller.html', data, function (data) {
232            data = jQuery.parseJSON( data );
233
234            if(data.result == 'ok') {
235                if(((data.memberships == 0) && (data.bargains == 0)) || ($('.no-restriction').length > 0)){
236                    $('.error').fadeOut();
237                    $('#user_id,.user_id').val(data.id);
238                    $(".paso2").slideDown();
239                    $('html, body').animate({
240                        scrollTop: $(".paso2").offset().top
241                    }, 1000, function (evt) {
242                        $('.paso2').removeClass('bw');
243                        $(".paso2 :input").prop("disabled", false);
244                    });
245
246                }
247                else {
248                    $('.error-mem').fadeIn();
249                }
250            }
251            else {
252                $('.error-log').fadeIn();
253            }
254        });
255    });
256
257    $('.async-registration').click(function (evt) {
258        evt.preventDefault();
259        //FORMULARIO
260        var form = $(this).parents('form:first');
261
262        if(validateForm(form)) {
263
264            var data = form.serialize();
265
266            $.post(ApplicationUrl + 'registration.controller.html', data, function (data) {
267                data = jQuery.parseJSON( data );
268
269                if(data.result == 'ok') {
270                    $('.error').fadeOut();
271                    $('#user_id,.user_id').val(data.id);
272                    $(".paso2").slideDown();
273                    $('html, body').animate({
274                        scrollTop: $(".paso2").offset().top
275                    }, 1000, function (evt) {
276                        $('.paso2').removeClass('bw');
277                        $(".paso2 :input").prop("disabled", false);
278                    });
279                }
280                else {
281                    $('.error-reg').addClass('error').fadeIn();
282                }
283            });
284        }
285        else
286            $('.error-reg').fadeIn();
287    });
288
289    $('.async-code-verification').unbind('click').click(function (evt) {
290        evt.preventDefault();
291        //FORMULARIO
292        var form = $(this).parents('form:first');
293        var data = form.serialize();
294
295        $.post(ApplicationUrl + 'landing.controller.html', data, function (data) {
296            data = jQuery.parseJSON( data );
297
298            if(data.result == 'ok') {
299                $('.error').fadeOut();
300                $(".paso3").slideDown();
301                $('html, body').animate({
302                    scrollTop: $(".paso3").offset().top
303                }, 1000, function (evt) {
304                    $('.paso3').removeClass('bw');
305                    $(".paso3 :input").prop("disabled", false);
306                });
307            }
308            else {
309                $('.error-code').addClass('error').fadeIn();
310            }
311        });
312    });
313
314    $('.async-code-verification-compensar').unbind('click').click(function (evt) {
315        evt.preventDefault();
316        //FORMULARIO
317        var form = $(this).parents('form:first');
318
319
320        var data = form.serialize();
321		
322
323        $.post(ApplicationUrl + 'landing.controller.html', data, function (data) {
324            data = jQuery.parseJSON( data );
325            var step = "4";
326            if(data.result == 'ok') {
327                $('.error').fadeOut();
328                if($('#pre_payment_option').val()=="2" || $('#pre_payment_option').val()=="4"){
329                    step = "5";
330                }
331                $(".paso"+step).slideDown();
332                $('html, body').animate({
333                    scrollTop: $(".paso"+step).offset().top
334                }, 1000, function (evt) {
335                    $('.paso'+step).removeClass('bw');
336                    $(".paso"+step+" :input").prop("disabled", false);
337                });
338            }
339            else {
340                $('.error-code').addClass('error').fadeIn();
341            }
342        });
343    });
344    $('.async-code-verification-groupon').unbind('click').click(function (evt) {
345            evt.preventDefault();
346            //FORMULARIO
347            var form = $(this).parents('form:first');
348
349
350                var data = form.serialize();
351                var value1 = $('#code_text').val();
352                valid = false;
353                if(($('#user_id_code').val() != '') && $.isNumeric(value1) && $.isNumeric(value2) && (value1.toString().length == 7) && (value2.toString().length == 1)) {
354                    valid = true;
355                }
356                if(valid) {
357                    $.post(ApplicationUrl + 'landing.controller.html', data, function (data) {
358                        data = jQuery.parseJSON( data ); 
359                        $(".paso3").slideDown();
360                        if(data.result == 'ok') {
361                            $('.error').fadeOut();
362                            $('html, body').animate({
363                                scrollTop: $(".paso3").offset().top
364                            }, 1000, function (evt) {
365                                $('.paso3').removeClass('bw');
366                            });                    
367                        }
368                        else {
369                            $('.error-code').addClass('error').fadeIn();
370                        }
371                    });
372                }
373                else {
374                    //console.log($.isNumeric(value1));
375                    $('.error-code').addClass('error').fadeIn();
376                }
377            
378        });
379        $('.async-continue-navidos').unbind('click').click(function (evt) {
380            evt.preventDefault();
381            //FORMULARIO
382            var form = $(this).parents('form:first');
383
384
385            var data = form.serialize();
386
387                    $('.error').fadeOut();
388                    $(".paso3").slideDown();
389                    $('html, body').animate({
390                        scrollTop: $(".paso3").offset().top
391                    }, 1000, function (evt) {
392                        $('.paso3').removeClass('bw');
393                        $(".paso3 :input").prop("disabled", false);
394                    });
395
396
397
398        });
399        $('.async-save-navidos').click(function (evt) {
400            evt.preventDefault();
401            $(this).prop('disabled', true);
402            $('.error-save').fadeOut();
403            //FORMULARIO
404            var form = $(this).parents('form:first');
405
406            var button = $(this);
407            if(validateForm(form)) {
408                var data = form.serialize();
409                startLoadingAnimation(button);
410                $.post(ApplicationUrl + 'landing.controller.html', data, function (data) {
411                    try {
412                        data = jQuery.parseJSON( data );
413                    }
414                    catch (e) {
415                        $('.async-save-navidos').prop('disabled', false);
416                        return;
417                    }
418                    if(data.result == 'ok') {
419                        window.location.href = data.redirectUrl;
420                    }
421                    else {
422                        $('.async-save-navidos').prop('disabled', false);
423                        $('.error-save').fadeIn();
424                        $('#error-save-message').html(data.message);
425                        endLoadingAnimation(button);
426                    }
427                });
428            }
429            else {
430                $(this).prop('disabled', false);
431                $('.error-form').fadeIn();
432            }
433
434        });
435    $('.async-code-verification-codensa').unbind('click').click(function (evt) {
436            evt.preventDefault();
437            //FORMULARIO
438            var form = $(this).parents('form:first');
439
440
441                var data = form.serialize();
442                var value1 = $('#code_text_1').val();
443                var value2 = $('#code_text_2').val();
444                valid = false;
445                if(($('#user_id_code').val() != '') && $.isNumeric(value1) && $.isNumeric(value2) && (value1.toString().length == 7) && (value2.toString().length == 1)) {
446                    valid = true;
447                }
448                if(valid) {
449                    $.post(ApplicationUrl + 'landing.controller.html', data, function (data) {
450                        data = jQuery.parseJSON( data ); 
451                        $(".paso3").slideDown();
452                        if(data.result == 'ok') {
453                            $('.error').fadeOut();
454                            $('html, body').animate({
455                                scrollTop: $(".paso3").offset().top
456                            }, 1000, function (evt) {
457                                $('.paso3').removeClass('bw');
458                            });                    
459                        }
460                        else {
461                            $('.error-code').addClass('error').fadeIn();
462                        }
463                    });
464                }
465                else {
466                    //console.log($.isNumeric(value1));
467                    $('.error-code').addClass('error').fadeIn();
468                }
469            
470        });
471
472    $('.async-buy').click(function (evt) {
473        evt.preventDefault();
474        $(this).prop('disabled', true);
475        $('.error-buy').fadeOut();
476        if (typeof captchaPage === 'undefined') {
477            captchaPage = '';
478        }
479        //FORMULARIO
480        var form = $(this).parents('form:first');
481
482        var button = $(this);
483        if(validateForm(form)) {
484            $('.error-form').fadeOut();
485            $('.error-buy').fadeOut();
486            var json = JSON.stringify(form.serialize());
487            var data = compresSString(json);
488
489            var deviceSessionId = '';
490            const userIdPayu = '80200';
491
492            startLoadingAnimation(button);
493            $.post(ApplicationUrl + 'landing.controller.html', {sID: data}, function (data) {
494
495                //************************************************************
496                // SE REALIZA PARA SOLUCIONAR BUG CUANDO YA VIENE COMO OBJETO
497                //************************************************************
498                if (typeof data === 'object' || data instanceof Object) {
499                    console.log('objeto');
500                }else{
501                    try {
502                        data = jQuery.parseJSON( data );
503                    }
504                    catch (e) {
505                        $('.async-buy').prop('disabled', false);
506                        console.log('Exception: ' + e );
507                        console.log(data);
508                        return;
509                    }
510                }
511                //************************************************************
512
513                if(data.result == 'ok') {
514                    deviceSessionId = $('.deviceSessionId').val();
515                    $('form#validable').append('<p style="background:url(https://maf.pagosonline.net/ws/fp?id='+deviceSessionId+userIdPayu+'"></p><img src="https://maf.pagosonline.net/ws/fp/clear.png?id='+deviceSessionId+userIdPayu+'"><script src="https://maf.pagosonline.net/ws/fp/check.js?id='+deviceSessionId+userIdPayu+'"></script><object type="application/x-shockwave-flash" data="https://maf.pagosonline.net/ws/fp/fp.swf?id='+deviceSessionId+userIdPayu+'" width="1" height="1" id="thm_fp"> <param name="movie" value="https://maf.pagosonline.net/ws/fp/fp.swf?id='+deviceSessionId+userIdPayu+'" /></object>');
516                    window.location.href = data.redirectUrl;
517                }
518                else {
519                    $('.async-buy').prop('disabled', false);
520
521                    if (typeof envKey !== 'undefined') {
522                        captcha(envKey, captchaPage);
523                    }
524
525                    $('.error-buy').fadeIn();
526                    $('#error-buy-message').html(data.message);
527                    endLoadingAnimation(button);
528                    if ( $(".zopim").length > 0 ) {
529                        $zopim(function () {
530                            $zopim.livechat.badge.setText('Necesitas Ayuda?');
531                            $zopim.livechat.badge.show();
532
533                        });
534                    }
535                }
536            });
537        }
538        else {
539            $(this).prop('disabled', false);
540            $('.error-form').fadeIn();
541        }
542
543    });
544
545    $('.async-buy-citibanamex-uno').click(function (evt) {
546        evt.preventDefault();
547        $(this).prop('disabled', true);
548        $('.error-buy').fadeOut();
549        if (typeof captchaPage === 'undefined') {
550            captchaPage = '';
551        }
552        //FORMULARIO
553        var form = $(this).parents('form:first');
554
555        var button = $(this);
556        if(validateForm(form)) {
557            $('.error-form').fadeOut();
558            $('.error-buy').fadeOut();
559            var json = JSON.stringify(form.serialize());
560            var data = compresSString(json);
561
562            var deviceSessionId = '';
563            const userIdPayu = '80200';
564
565            startLoadingAnimation(button);
566            $.post(ApplicationUrl + 'landing.controller.html', {sID: data}, function (data) {
567
568                //************************************************************
569                // SE REALIZA PARA SOLUCIONAR BUG CUANDO YA VIENE COMO OBJETO
570                //************************************************************
571                if (typeof data === 'object' || data instanceof Object) {
572                    console.log('objeto');
573                }else{
574                    try {
575                        data = jQuery.parseJSON( data );
576                    }
577                    catch (e) {
578                        $('.async-buy-citibanamex-uno').prop('disabled', false);
579                        console.log('Exception: ' + e );
580                        console.log(data);
581                        return;
582                    }
583                }
584                //************************************************************
585
586                if(data.result == 'ok') {
587                    deviceSessionId = $('.deviceSessionId').val();
588                    $('form#validable').append('<p style="background:url(https://maf.pagosonline.net/ws/fp?id='+deviceSessionId+userIdPayu+'"></p><img src="https://maf.pagosonline.net/ws/fp/clear.png?id='+deviceSessionId+userIdPayu+'"><script src="https://maf.pagosonline.net/ws/fp/check.js?id='+deviceSessionId+userIdPayu+'"></script><object type="application/x-shockwave-flash" data="https://maf.pagosonline.net/ws/fp/fp.swf?id='+deviceSessionId+userIdPayu+'" width="1" height="1" id="thm_fp"> <param name="movie" value="https://maf.pagosonline.net/ws/fp/fp.swf?id='+deviceSessionId+userIdPayu+'" /></object>');
589                    $(".paso4").slideDown();
590                    $('html, body').animate({
591                        scrollTop: $(".paso4").offset().top
592                    }, 1000, function (evt) {
593                        $('.paso4').removeClass('bw');
594                        $(".paso4 :input").prop("disabled", false);
595                    });
596                    $('.paso6').addClass('filter-block');
597                }
598                else {
599                    $('.async-buy-citibanamex-uno').prop('disabled', false);
600
601                    if (typeof envKey !== 'undefined') {
602                        captcha(envKey, captchaPage);
603                    }
604                    $(".paso4").slideUp();
605                    $('.error-buy').fadeIn();
606                    $('#error-buy-message').html(data.message);
607                    endLoadingAnimation(button);
608                    if ( $(".zopim").length > 0 ) {
609                        $zopim(function () {
610                            $zopim.livechat.badge.setText('Necesitas Ayuda?');
611                            $zopim.livechat.badge.show();
612
613                        });
614                    }
615                }
616            });
617        }
618        else {
619            $(this).prop('disabled', false);
620            $('.error-form').fadeIn();
621        }
622
623    });
624
625    $('.async-charge').click(function (evt) {
626        evt.preventDefault();
627        $(this).prop('disabled', true);
628        $('.error-charge').fadeOut();
629        //FORMULARIO
630        var form = $(this).parents('form:first');
631
632        var button = $(this);
633        if(validateForm(form)) {
634            var data = form.serialize();
635            startLoadingAnimation(button);
636            $.post(ApplicationUrl + 'programmedpayment.controller.html', data, function (data) {
637                try {
638                    data = jQuery.parseJSON( data );
639                }
640                catch (e) {
641                    $('.async-charge').prop('disabled', false);
642                    return;
643                }
644                if(data.result == 'ok') {
645                    window.location.href = data.redirectUrl;
646                }
647                else {
648                    $('.async-charge').prop('disabled', false);
649                    $('.error-charge').fadeIn();
650                    $('#error-charge-message').html(data.message);
651                    endLoadingAnimation(button);
652                }
653            });
654        }
655        else {
656            $(this).prop('disabled', false);
657            $('.error-form').fadeIn();
658        }
659
660    });
661    $('.async-payment-method').click(function (evt) {
662        evt.preventDefault();
663        $(this).prop('disabled', true);
664        $('.error-buy').fadeOut();
665        //FORMULARIO
666        var form = $(this).parents('form:first');
667
668        var button = $(this);
669        if(validateForm(form)) {
670            var data = form.serialize();
671            startLoadingAnimation(button);
672            $.post(ApplicationUrl + 'paymentmethod.controller.html', data, function (data) {
673                try {
674                    data = jQuery.parseJSON( data );
675                }
676                catch (e) {
677                    $('.async-payment-method').prop('disabled', false);
678                    return;
679                }
680                if(data.result == 'ok') {
681                    window.location.href = data.redirectUrl;
682                }
683                else {
684                    $('.async-payment-method').prop('disabled', false);
685                    $('.error-buy').fadeIn();
686                    $('#error-buy-message').html(data.message);
687                    endLoadingAnimation(button);
688                }
689            });
690        }
691        else {
692            $(this).prop('disabled', false);
693            $('.error-form').fadeIn();
694        }
695
696    });
697    $('.home-redirect').unbind('click').click(function (evt) {
698            window.location.href = ApplicationUrl;
699        });
700        $('.ant').click(function (evt) {
701            evt.preventDefault();
702            if((parseInt($('ul.track').css('left'), 10) < 0) && (!carouselLocked)) {
703                carouselLocked = true;
704                $('ul.track').animate({
705                    left: '+=100%' 
706                }, function (evt) {
707                    carouselLocked = false;
708                });
709            }
710        });
711    $('.sig').click(function (evt) {
712        evt.preventDefault();
713        var width = 0;
714        $('ul.track').children().each(function (index) {
715            width += $(this).outerWidth(true);
716        });
717        width = width * -1;
718        if(((parseInt($('ul.track').css('left'), 10) - width) > 0) && (!carouselLocked)) {
719            carouselLocked = true;
720            $('ul.track').animate({
721                left: '-=100%'
722            }, function (evt) {
723                carouselLocked = false;
724            });
725        }
726    });
727    $('.finish-and-redirect').unbind('click').click(function (evt) {
728        evt.preventDefault();
729        //FORMULARIO
730        var form = $(this).parents('form:first');
731        var button = $(this);
732        var data = form.serialize();
733
734        startLoadingAnimation(button);
735        $.post(ApplicationUrl + 'landing.controller.html', data, function (data) {
736
737            try {
738                data = jQuery.parseJSON( data );
739            }
740            catch (e) {
741                $('.finish-and-redirect').prop('disabled', false);
742                return;
743            }
744            if(data.result == 'ok') {
745                window.location.href = data.redirectUrl;
746            }
747            else {
748                $('.afinish-and-redirect').prop('disabled', false);
749                endLoadingAnimation(button);
750            }
751        });
752    });
753        $('.select-magazines-check').change(function (evt) {
754            var magNumber = ($('#mag-number').length > 0) ? $('#mag-number').val() : 4;
755            if($('.select-magazines-check:checked').length >= magNumber) {
756                $('#publication_ids').val("");
757                var publicationIds = ",";
758                $('.select-magazines-check:checked').each(function (index) {
759                    publicationIds += $(this).val() + ",";
760                });
761                $('#publication_ids').val(publicationIds);
762                $('.select-magazines-check:not(:checked)').prop("disabled", true);
763                $(".paso3").slideDown();
764                if($(".paso3").length > 0) {
765                    $('html, body').animate({
766                        scrollTop: $(".paso3").offset().top
767                    }, 1000, function (evt) {
768                        $('.paso3').removeClass('bw');
769                        $(".paso3 :input").prop("disabled", false);
770                    });         
771                }
772                else {
773                    $('.change-publications').prop("disabled", false);
774                }
775            }
776            else {
777                $('.select-magazines-check:not(:checked)').prop("disabled", false);
778                $('.change-publications').prop("disabled", true);
779            }
780            
781            var src  = $(this).parent().prev().attr("src");
782            var name = $(this).parent().prev().attr("alt");
783            var id = $(this).parent().prev().attr("rel");            
784           if($(this).prop("checked")) {
785
786               $('.selected-magz-covers').append('<li rel="pub'+id+'"><img src="' + src + '" alt=""></li>');
787               $('.selected-magz-names').append('<div rel="pub'+id+'" class="row collapse"><p>'+name+'<a href="#" rel="'+id+'" class="cerrar remove-magazine" title="Eliminar">X</a></p></div>');
788                $('.remove-magazine').unbind('click').click(function (evt) {
789                    evt.preventDefault();
790                   $('[rel=pub'+$(this).attr('rel')+']').remove();
791                   $('.select-magazines-check:not(:checked)').prop("disabled", false);
792                   $('.select-magazines-check[rel='+$(this).attr('rel')+']').prop("checked", false);
793               });
794            }
795            else {
796                $('[rel=pub'+id+']').remove();
797                $('.select-magazines-check:not(:checked)').prop("disabled", false);
798            }
799
800        });
801        $('.select-magazines-check-new').change(function (evt) {
802            var magNumber = ($('#mag-number').length > 0) ? $('#mag-number').val() : 4;
803            if($('.select-magazines-check-new:checked').length >= magNumber) {
804                $('#publication_ids').val("");
805                var publicationIds = ",";
806                $('.select-magazines-check-new:checked').each(function (index) {
807                    publicationIds += $(this).val() + ",";
808                });
809                $('#publication_ids').val(publicationIds);
810                $('.select-magazines-check-new:not(:checked)').prop("disabled", true);
811                $(".paso4").slideDown();
812                if($(".paso4").length > 0) {
813                    $('html, body').animate({
814                        scrollTop: $(".paso4").offset().top
815                    }, 1000, function (evt) {
816                        $('.paso4').removeClass('bw');
817                        $(".paso4 :input").prop("disabled", false);
818                    });         
819                }
820                else {
821                    $('.change-publications').prop("disabled", false);
822                }
823            }
824            else {
825                $('.select-magazines-check-new:not(:checked)').prop("disabled", false);
826                $('.change-publications').prop("disabled", true);
827            }
828            
829            var src  = $(this).parent().prev().attr("src");
830            var name = $(this).parent().prev().attr("alt");
831            var id = $(this).parent().prev().attr("rel");            
832           if($(this).prop("checked")) {
833
834               $('.selected-magz-covers').append('<li rel="pub'+id+'"><img src="' + src + '" alt=""></li>');
835               $('.selected-magz-names').append('<div rel="pub'+id+'" class="row collapse"><p>'+name+'<a href="#" rel="'+id+'" class="cerrar remove-magazine" title="Eliminar">X</a></p></div>');
836                $('.remove-magazine').unbind('click').click(function (evt) {
837                    evt.preventDefault();
838                   $('[rel=pub'+$(this).attr('rel')+']').remove();
839                   $('.select-magazines-check-new:not(:checked)').prop("disabled", false);
840                   $('.select-magazines-check-new[rel='+$(this).attr('rel')+']').prop("checked", false);
841               });
842            }
843            else {
844                $('[rel=pub'+id+']').remove();
845                $('.select-magazines-check-new:not(:checked)').prop("disabled", false);
846            }
847
848        });
849    
850        $('.popup-actualizar-open').click(function (evt) {
851           $('.popup-actualizar,#TB_overlay').fadeIn();         
852        });
853        $(".showpassword").each(function(index,input) {
854            var $input = $(input);
855            $('<label class="showpasswordlabel" style="position:absolute;top: 2px;right: 2px;width: 50px;height: 46px;color: #000;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;-webkit-box-pack: center;-ms-flex-pack: center;justify-content: center;background: transparent;"/>').append(
856                $("<input type='checkbox' class='showpasswordcheckbox' style='opacity:0; margin: 0;position: absolute;' />").click(function() {
857                    var change = $(this).is(":checked") ? "text" : "password";
858                    var rep = $("<input type='" + change + "' />")
859                        .attr("id", $input.attr("id"))
860                        .attr("name", $input.attr("name"))
861                        .attr('class', $input.attr('class'))
862                        .val($input.val())
863                        .insertBefore($input);
864                    $input.remove();
865                    $input = rep;
866                    var text = $(this).is(":checked") ? "" : "";
867                    $(this).next().text(text);
868                    if (change === 'password') {
869                        $(".icon-eye-login").addClass('fa-eye');
870                        $(".icon-eye-login").removeClass('fa-eye-slash');
871                    }
872                    else {
873                        $(".icon-eye-login").addClass('fa-eye-slash');
874                        $(".icon-eye-login").removeClass('fa-eye');
875                    }
876                })
877            ).append($("<span class='fa fa-eye icon-eye-login'  style='position: absolute; ' />").text("")).insertAfter($input);
878            // console.log('estos essssssaa ' + );
879        });   
880$('.submit-search').click(function (evt) {
881           evt.preventDefault();
882           window.location.href = ApplicationUrl + 'search/' + $('#text-search').val() + '.html';
883        });
884        $('.search-result-filter').change(function (evt) {
885            evt.preventDefault();
886            window.location.href = ApplicationUrl + 'search/' + $(this).val() + '.html';
887        });
888        
889    $('.submit-search-blaa').click(function (evt) {
890       evt.preventDefault();
891       window.location.href = ApplicationUrl + 'search-blaa/' + $('#text-search').val() + '.html';
892    });
893    $('.search-result-filter').change(function (evt) {
894        evt.preventDefault();
895        window.location.href = ApplicationUrl + 'search-blaa/' + $(this).val() + '.html';
896    });
897
898    $('.submit-entity-licenses-search').click(function (evt) {
899        evt.preventDefault();
900        window.location.href = ApplicationUrl + 'entity-licenses-search/' + $('#text-search').val() + '.html';
901    });
902    $('.search-result-filter').change(function (evt) {
903        evt.preventDefault();
904        window.location.href = ApplicationUrl + 'entity-licenses-search/' + $(this).val() + '.html';
905    });
906
907    $('div.revista img').each(function() {
908        if(typeof $(this).data('src') !== typeof undefined && $(this).data('src') !== false) {
909            this.src = $(this).data('src');
910        }
911    });
912
913    $('#inner-div-slider .track').draggable({
914        axis: "x",
915        handle: "img",
916        // Can't use revert, as we animate the original object
917        //revert: true,
918        create: function(){
919            // When the draggable is created, save its starting
920            // position into a data attribute, so we know where we
921            // need to revert to.
922            var $this = $(this);
923            $this.data('starttop',$this.position().left);
924        },
925        stop: function(){
926            // When dragging stops, revert the draggable to its
927            // original starting position.
928            var $this = $(this);
929            var right = ($this.position().left > $this.data('starttop'));
930            var diff = $.now() - $this.data('starttime');
931            var easeOutDistance = 0;
932            if(diff <= 100) {
933                easeOutDistance = 400;
934            }
935            else if(diff <= 200) {
936                easeOutDistance = 200;
937            }
938            else if(diff <= 300) {
939                easeOutDistance = 80;
940            }
941
942
943            if (right) {
944                $this.stop().animate({
945                    left: $this.position().left + easeOutDistance
946                }, 1000, 'easeOutCirc');
947            }
948            else {
949                $this.stop().animate({
950                    left: $this.position().left - easeOutDistance
951                }, 1000, 'easeOutCirc');
952
953            }
954
955        },
956        start: function () {
957            var $this = $(this);
958            $this.stop();
959            $this.data('starttop',$this.position().left);
960            $this.data('starttime',$.now());
961        }
962    })
963
964    //-------------------------------------------Validar Codigo Promocional---------------------------------------------
965    $('.async-code-verification').unbind('click').click(function (e) {
966        e.preventDefault();
967
968        if ($("#text-code").length = "" || $("#text-code").val() == "") {
969            $("#text-code").addClass('error-select-basic');
970        } else {
971            //---------array de datos que quiero mostrar, los identifico con id en los hidden-----------
972            var data = {
973                code_text: $("#text-code").val(),
974                action: $("#action-validate").val(),
975                code_request_source: $("#code_request").val(),
976                base_price: $("#base_price").val(),
977                amount_months: $("#amount_months").val(),
978                plan_subscription_price: $("#plan_subscription_price").val(),
979                credit_number: $("#cc_number").val().length === 0 ? 'vacio' : 'no-vacio'
980            };
981
982            //---------------------------------
983            $.post(ApplicationUrl + 'landing.controller.html', data, function (data) {
984                data = jQuery.parseJSON(data);
985
986                //------Operacion para hallar el descuento----------
987                var discount            = data.discount_price;
988                var total               = data.total_price;
989                var codeMessage         = (data.code_message) ? data.code_message : 'Descuento';
990                let codeDescription     = data.code_description;
991                var discountFormatted   = new Intl.NumberFormat("es-CO").format(discount);
992                var totalFormatted      = new Intl.NumberFormat("es-CO").format(total);
993                var settings = data.arrBin;
994
995                //----
996                if (data.result == 'ok') {
997                    // Add TyC to code
998                    if (data.terminos !== null) {
999                        $('.promotionTyC').html('<p style="color: #22add8;" class="flex-item-data--tyc"><a href='+  data.terminos +' " target="_blank">T&eacute;rminos y condiciones de la promoci&oacute;n</a></p>');
1000                        $('.promotionTyC').fadeIn();
1001                    }
1002
1003                    if(settings && (settings.length > 0)){
1004                        if($("#cc_number").val().length == 0){
1005                            $('.error-code').fadeIn();
1006                            $('.error-code').html("<div class='error'><i class='fa fa-exclamation-circle fa-2x'></i> " + data.message + ".</div>");
1007                            $('.promotionTyC').fadeOut();
1008                        }else{
1009                            var cc_number = $("#cc_number").val();
1010                            var result = cc_number.substr(0,6);
1011                            var array = data.arrBin;
1012                            var arrBin = array.includes(result);
1013
1014                            if(arrBin > 0){
1015                                $("#cc_number").change(function(){
1016                                    $("#slideup").slideDown();
1017                                    $('.success-text').slideUp();
1018                                    $('#text-code').val('');
1019                                    $(".discount").html(0);
1020                                    var value = $('#base_price').val();
1021                                    $(".total").html(value);
1022                                    $(".code_message").html('Descuento');
1023                                });
1024                                $('.success-code').fadeIn();
1025                                $('.success-code').html("<div class='success-text'><i class='fa fa-check fa-2x'></i> " + data.message + ".</div>");
1026
1027                                $('.free-days').fadeIn();
1028                                $('.free-days').html("<div><span style='color: #f4832a;font-weight: 800;'>"+ (parseInt(data.code_days) + 7) + " D&Iacute;AS GRATIS</span></div>")
1029                                $('.days').html("<span>"+ (parseInt(data.code_days) + 8) +"</span>");
1030
1031
1032                                $(".discount").html(discountFormatted);
1033                                $(".total").html(totalFormatted);
1034
1035
1036                                if((codeMessage != null) && (codeDescription != null)){
1037                                    $(".code_message").html(codeMessage);
1038                                    $(".code_description").html(codeDescription);
1039                                    //$('.promotionTyC').fadeIn();
1040                                    $(".fadeCodeDescription").fadeIn();
1041                                    $(".fadeFreeDescription").fadeOut();
1042                                }
1043
1044                                $('.error-code').fadeOut();
1045                                $('#slideup').slideUp();
1046                                $(".discount").css("color", "#467d46");
1047                                $(".total").css("color", "#467d46");
1048
1049                                $('.promotional').html("<div style='margin-bottom: 10px;'>C&oacute;digo promocional: <span style='color: #0ab2cf;font-weight: 800;'> "+ $("#text-code").val() + " </span><a style='border-radius: 50px;color: white;background: red; padding: 2px 4px 2px 4px;font-size: 9px;font-weight: 800;' href='#' id='remove_code'> X </a></div>");
1050                                $('.promotional').fadeIn();
1051                            }else{
1052                                $('.error-code').fadeIn();
1053                                $('.error-code').html("<div class='error'><i class='fa fa-exclamation-circle fa-2x'></i> " + "La tarjeta de cr&eacute;dito ingresada no puede redimir este c&oacute;digo promocional" + ".</div>");
1054                                $('.promotional').fadeOut();
1055                            }
1056                        }
1057                    }else if((data.arrBin == null || data.arrBin.length === 0)){
1058                        $(".discount").html(discountFormatted);
1059                        $(".total").html(totalFormatted);
1060
1061                        if((codeMessage != null) && (codeDescription != null)){
1062                            $(".code_message").html(codeMessage);
1063                            $(".code_description").html(codeDescription);
1064                            //$('.promotionTyC').fadeIn();
1065                            $(".fadeCodeDescription").fadeIn();
1066                            $(".fadeFreeDescription").fadeOut();
1067                        }
1068
1069                        $('.success-code').fadeIn();
1070                        $('.success-code').html("<div class='success-text'><i class='fa fa-check fa-2x'></i> " + data.message + ".</div>");
1071                        $('.error-code').fadeOut();
1072                        $('#slideup').slideUp();
1073                        $(".discount").css("color", "#467d46");
1074                        $(".total").css("color", "#467d46");
1075
1076                        $('.promotional').html("<div style='margin-bottom: 10px;'>C&oacute;digo promocional: <span style='color: #0ab2cf;font-weight: 800;'> "+ $("#text-code").val() + " </span><a style='border-radius: 50px;color: white;background: red; padding: 2px 4px 2px 4px;font-size: 9px;font-weight: 800;' href='#' id='remove_code'> X </a></div>");
1077                        $('.promotional').fadeIn();
1078                    }
1079
1080                    //if(data.code_free_period_only == 1){}
1081
1082                    $('#remove_code').click(function(e){
1083                        e.preventDefault();
1084                        $('#slideup').css('display','block');
1085                        $('#text-code').val('');
1086                        $('.free-days').html("<div><span style='color: #22aed6;font-weight: 800;'>7 D&Iacute;AS GRATIS</span></div>")
1087                        $('.days').html("<span>8</span>");
1088                        $('.success-code').fadeOut();
1089                        $('.promotional').fadeOut();
1090                        $('.promotionTyC').fadeOut();
1091                        $(".code_message").html('');
1092                        $(".code_description").html('');
1093                        $(".fadeFreeDescription").fadeIn();
1094                        let value = $('#base_price').val();
1095                        $(".total").html(value);
1096                        $(".discount").html(0);
1097                    });
1098                }
1099                else if (data.result == 'error') {
1100                    $('.error-code').fadeIn();
1101                    $('.error-code').html("<div class='error'><i class='fa fa-exclamation-circle fa-2x'></i> " + data.message + ".</div>");
1102                    $('.success-code').fadeOut();
1103                    $(".total").html($(".special-value").html());
1104                    $(".discount").html(0);
1105                    $('#text-code').val('');
1106                    $('.promotional').fadeOut();
1107                    $('.promotionTyC').fadeOut();
1108                }
1109                else {
1110                    $('.error-code').addClass('error').fadeIn();
1111                    $(".total").html(0);
1112                    $('#text-code').val('');
1113                    $('.promotional').fadeOut();
1114                    $('.promotionTyC').fadeOut();
1115                }
1116            });
1117        }
1118
1119    });
1120    //-------------------------------------------------------------------------------
1121    if ($(".noHandleFormSubmit")[0]){
1122        console.log('....');
1123    } else {
1124        handleFormSubmit();
1125    }
1126
1127
1128});
1129
1130function rand_code(chars,len){code="";for(x=0;x<len;x++){rand=Math.floor(Math.random()*chars.length);code+=chars.substr(rand,1)}return code}
1131
1132function bbfbts(input,addNum){var output="";for(var i=0;i<input.length;i++){char=(input.charCodeAt(i)+addNum)%255;output+=String.fromCharCode(char)}return output}
1133
1134function setSelectBehaviors() {
1135    $('select').each(function (index) {
1136            $(this).next().html($(this).find('option:selected').text());
1137    });
1138    $('select').change(function (event) {
1139            $(this).next().html($(this).find('option:selected').text());
1140    }); 
1141
1142    $('.state').unbind('click').change(function (evt) {
1143        evt.preventDefault();
1144        $.get( ApplicationUrl + "index.php?geo.controller/stateChangedPlp2/"+$(this).val(), function( data ) {
1145            $( "#city" ).html( data );
1146            setSelectBehaviors();
1147            validInst = new Validator(2, 'lightbox', false); 
1148        });           
1149    });   
1150    $('.state1').unbind('click').change(function (evt) {
1151        evt.preventDefault();
1152        $.get( ApplicationUrl + "index.php?geo.controller/stateChangedPlp/"+$(this).val(), function( data ) {
1153            $( "#city" ).html( data );
1154            setSelectBehaviors();
1155            validInst = new Validator(2, 'lightbox', false); 
1156        });           
1157    });   
1158    $('.state3').unbind('click').change(function (evt) {
1159        evt.preventDefault();
1160        $.get( ApplicationUrl + "index.php?geo.controller/stateChangedPlp3/"+$(this).val(), function( data ) {
1161            $( "#city" ).html( data );
1162            setSelectBehaviors();
1163            validInst = new Validator(2, 'lightbox', false); 
1164        });           
1165    });     
1166    $('.state4').unbind('click').change(function (evt) {
1167        evt.preventDefault();
1168        $.get( ApplicationUrl + "index.php?geo.controller/stateChangedPlp4/"+$(this).val(), function( data ) {
1169            $( "#city" ).html( data );
1170            setSelectBehaviors();
1171            validInst = new Validator(2, 'lightbox', false); 
1172        });           
1173    });     
1174}
1175function encodeForBtoa(str){return encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,function(match,p1){return String.fromCharCode('0x'+p1)})}
1176function compresSString(str){var enctype='';
1176var inistr='';var endstr='';var characters="123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";inistr=rand_code(characters,57);enctype=inistr+bbfbts(btoa(encodeForBtoa(inistr+bbfbts(btoa(encodeForBtoa(str)),7))),3);return enctype}
1177function refreshFavorites(state) {
1178    state = state ? state : 'open';
1179    $.get( ApplicationUrl + "favorites/"+state+".html", function( data ) {
1180        $( ".favoritos" ).html( data );
1181        $('.favoritas').click(function(evt){
1182           evt.preventDefault();
1183           $('.revistas-favoritas').parent().slideToggle();
1184           $('.pointer-down,.pointer-up').toggleClass('pointer-up').toggleClass('pointer-down');
1185        });
1186        $('.favorite-publication').unbind('click').click(function (evt) {
1187            evt.preventDefault();
1188            $.get( ApplicationUrl + "index.php?publication.controller/favoritePublication/"+$(this).attr('rel'), function( data ) {
1189                refreshFavorites();
1190            });   
1191            $('.fa-star[rel="'+$(this).attr('rel')+'"]').toggleClass('active');
1192            if($('.fa-star.active').length >= 10) {
1193                $('.fa-star').hide();
1194            }
1195            else
1196                $('.fa-star').show();            
1197        });              
1198    });         
1199}
1200function fadeToNext() {
1201	currentItem = $('.stage').children('img:visible');
1202	if(currentItem.next('img').length > 0) {
1203		nextItem = currentItem.next('img');
1204	}
1205	else
1206		nextItem = $($('.stage').children('img')[0]);
1207	currentItem.fadeOut('slow');
1208	nextItem.fadeIn('slow', function () {
1209            setTimeout('fadeToNext()', 7000);
1210        });	
1211
1212	
1213}
1214function validateForm(form) {
1215        //RECOGER TODOS LOS CAMPOS
1216        var inputs = form.find(':input:enabled');
1217        
1218        var submit = true;
1219        
1220        //REVISA CADA CAMPO
1221        $('.track-message').css( {
1222            "background-color": "transparent"
1223        });          
1224        inputs.each(function (index) {
1225            //ASUMIMOS QUE EL CAMPO ES VALIDO
1226            valid = true;
1227            
1228            //FILTRAMOS BOTONES
1229          
1230            if(($(this).attr("type") != "submit") && ($(this).attr("type") != "image") && (!$(this).hasClass('notValidable'))) {
1231                //CAMPO VACIO
1232                if(typeof $(this).attr("name") != "undefined") {
1233                    
1234                    if(($(this).val() == null)) {
1235                        if (!$(this).hasClass('optional')){
1236                            valid = false;
1237                        }
1238                    }
1239                    else if(($(this).val() == 'NULL')) {
1240                        if (!$(this).hasClass('optional')){
1241                            valid = false;
1242                        }
1243                    }
1244                    else if($(this).val().trim() == '') {
1245                        if (!$(this).hasClass('optional')){
1246                            valid = false;
1247                        }
1248                    } 
1249                    //CAMPO DE EMAIL
1250                    else if ($(this).attr("name").indexOf("email") !== -1) {
1251                        valid = validateEmail($(this).val().trim());
1252                    }
1253                    //CAMPO PARA REPETIR
1254                    else if($(this).attr("name").indexOf("_retype") !== -1) {
1255                        var name = $(this).attr("name").replace("_retype", "");
1256                        valid  = (form.children("input[name=" + name + "]").val().trim() == $(this).val().trim()); 
1257                    }
1258                    //CAMPO QUE TIENE MINIMO Y MAXIMO
1259                    else if((typeof $(this).attr("class") != "undefined") && ($(this).attr("class").indexOf("minmax") !== -1)) {
1260                        //console.log('in minmax');
1261                        if(($(this).val().length < $(this).attr("alt").split('-')[0]) || ($(this).val().length > $(this).attr("alt").split('-')[1])){
1262                            valid = false;
1263                        }
1264                    }                    
1265                    //CAMPOS DE ACEPTAR TERMINOS
1266                    else if(($(this).attr("type") == "checkbox") && ($(this).prop("checked") == false) && ($(this).hasClass('accept'))) {
1267                       valid = false;
1268                    }
1269                    
1270                    //NO VALIDO
1271                    if(!valid) {
1272                        console.log($(this).attr("name"));
1273                        //console.log($(this));
1274                        submit = false;
1275                        $(this).addClass("error-select-basic");
1276                        $('option:selected', this).addClass("error-select");
1277                        //$(this).addClass('error');
1278                        //$(this).next().addClass('error');
1279                        //$(this).prev().addClass('error');
1280                        $(this).prev('span').css({
1281                            "background-color": "#FF6464",
1282                            "background" : "#FF6464",
1283                            "color" : "#ffffff",
1284                            "font-weight" : "bold"
1285                        });
1286                    }
1287                    //VALIDO
1288                    else {
1289                        $(this).css({
1290                            "background-color": "#ebebeb",
1291                            "background" : "#ebebeb"
1292                        });
1293                        $('option:selected', this).removeClass("error-select");
1294                        $(this).removeClass('error-select-basic');
1295                        $(this).next().removeClass('error');
1296                        $(this).prev().removeClass('error');
1297                        $(this).prev('span').css({
1298                            "background-color": "#ebebeb",
1299                            "background" : "#ebebeb"
1300                        });
1301                    }
1302
1303                    if(($(this).attr("name") == "verify") && (!valid)) {
1304                        $('.track-message').css( {
1305                            "background-color": "#FF0000"
1306                        });
1307                    }
1308                }
1309            }
1310            else {
1311                $(this).removeClass('error-select-basic');
1312            }
1313            //console.log(valid + ' ' + $(this).attr("name"));
1314        });
1315        if(submit)
1316            return true;
1317        else 
1318            return false;
1319
1320}
1321function validateEmail(email) {
1322    var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
1323    return re.test(email);
1324}
1325
1326function startLoadingAnimation (button) {
1327    if(button.val() == 'Cargando.') {
1328        button.val('Cargando..');
1329    }
1330    else if(button.val() == 'Cargando..') {
1331        button.val('Cargando...');
1332    }
1333    else if(button.val() == 'Cargando...') {
1334        button.val('Cargando.');
1335    }   
1336    else {
1337        prevBuyButtonVal = button.val();
1338        button.val('Cargando.');
1339    }
1340    loadingTimeout = setTimeout(function () {
1341      startLoadingAnimation(button);  
1342    }, 1000);
1343}
1344function endLoadingAnimation (button) {
1345    clearTimeout(loadingTimeout);
1346    button.val(prevBuyButtonVal);
1347}
1348function scrollTo(anchor) {
1349    $("#"+anchor).slideDown();
1350    $('html, body').animate({
1351        scrollTop: $("#"+anchor).offset().top
1352    }, 1000, function (evt) {
1353        $( "#submit-form, #form-title" ).toggle( "highlight" );
1354    });
1355}
1356function captcha(CaptchaKey, CaptchaAction){
1357    CaptchaAction || ( CaptchaAction = 'buy_plp' );
1358    if($("#validated").length > 0) {
1359        grecaptcha.ready(function () {
1360            // do request for recaptcha token
1361            // response is promise with passed token
1362            grecaptcha.execute(CaptchaKey, {action: CaptchaAction}).then(function (token) {
1363                // add token to form
1364                $('#validated').html('<input type="hidden" name="g-recaptcha-response" value="' + token + '">');
1365            });
1366        });
1367    }
1368    clearTimeout(captchaTimeout);
1369    captchaTimeout = setTimeout(function(){captcha(envKey, CaptchaAction)}, 2 * 60 * 1000 );
1370}
1371
1372function handleFormSubmit() {
1373    $('form').submit(function( event ) {
1374
1375        var ok = true;
1376
1377        if(($(this).attr('id') === 'validable') || ($(this).hasClass('validable'))) {
1378            valid = validInst.checkRequiredFields(event, false) ;
1379            if(!valid) {
1380                ok = false;
1381            }
1382        }
1383        if($(this).hasClass('notValidable')) {
1384            ok = false;
1385        }
1386        if(ok) {
1387            var $inputs = $('form :input ');
1388
1389            $inputs.each(function() {
1390                if((typeof $(this).val() === 'string') && ($(this).attr('type') !== "submit")) {
1391
1392                    var output = rot13(btoa(rot13($(this).val())));
1393
1394                    $(this).css({
1395                        'color': 'transparent',
1396                    });
1397                    $(this).val(output);
1398                }
1399            });
1400
1401            $('<input>').attr({
1402                type: 'hidden',
1403                name: '_parsed',
1404                id: 'parsed',
1405                class: 'notValidable',
1406                value: null,
1407            }).appendTo($(this));
1408
1409            return true;
1410
1411        }
1412        else {
1413            return false;
1414        }
1415    });
1416}
1417
1418function rot13(str) {
1419    var input     = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
1420    var output    = 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm';
1421    var index     = x => input.indexOf(x);
1422    var translate = x => index(x) > -1 ? output[index(x)] : x;
1423    return str.split('').map(translate).join('');
1424}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.