PageSourceSearch

https://umag.edu.mx/home/components/com_baforms/assets/js/ba-form.js

js umag.edu.mx collected 2026-09-24 13:36:10 UTC 98,377 bytes, 2,454 lines download raw bytes

1/**
2* @package   BaForms
3* @author    Balbooa http://www.balbooa.com/
4* @copyright Copyright @ Balbooa
5* @license   http://www.gnu.org/licenses/gpl.html GNU/GPL
6*/
7
8var ba_jQuery = jQuery,
9    mapStyles = {
10    'standart' : [],
11    'silver' : [
12        {
13            "elementType": "geometry",
14            "stylers": [{
15                "color": "#f5f5f5"
16            }]
17        },
18        {
19            "elementType": "labels.icon",
20            "stylers": [{
21                "visibility": "off"
22            }]
23        },
24        {
25            "elementType": "labels.text.fill",
26            "stylers": [{
27                "color": "#616161"
28            }]
29        },
30        {
31            "elementType": "labels.text.stroke",
32            "stylers": [{
33                "color": "#f5f5f5"
34            }]
35        },
36        {
37            "featureType": "administrative.land_parcel",
38            "elementType": "labels.text.fill",
39            "stylers": [{
40                "color": "#bdbdbd"
41            }]
42        },
43        {
44            "featureType": "poi",
45            "elementType": "geometry",
46            "stylers": [{
47                "color": "#eeeeee"
48            }]
49        },
50        {
51            "featureType": "poi",
52            "elementType": "labels.text.fill",
53            "stylers": [{
54                "color": "#757575"
55            }]
56        },
57        {
58            "featureType": "poi.park",
59            "elementType": "geometry",
60            "stylers": [{
61                "color": "#e5e5e5"
62            }]
63        },
64        {
65            "featureType": "poi.park",
66            "elementType": "labels.text.fill",
67            "stylers": [{
68                "color": "#9e9e9e"
69            }]
70        },
71        {
72            "featureType": "road",
73            "elementType": "geometry",
74            "stylers": [{
75                "color": "#ffffff"
76            }]
77        },
78        {
79            "featureType": "road.arterial",
80            "elementType": "labels.text.fill",
81            "stylers": [{
82                "color": "#757575"
83            }]
84        },
85        {
86            "featureType": "road.highway",
87            "elementType": "geometry",
88            "stylers": [{
89                "color": "#dadada"
90            }]
91        },
92        {
93            "featureType": "road.highway",
94            "elementType": "labels.text.fill",
95            "stylers": [{
96                "color": "#616161"
97            }]
98        },
99        {
100            "featureType": "road.local",
101            "elementType": "labels.text.fill",
102            "stylers": [{
103                "color": "#9e9e9e"
104            }]
105        },
106        {
107            "featureType": "transit.line",
108            "elementType": "geometry",
109            "stylers": [{
110                "color": "#e5e5e5"
111            }]
112        },
113        {
114            "featureType": "transit.station",
115            "elementType": "geometry",
116            "stylers": [{
117                "color": "#eeeeee"
118            }]
119        },
120        {
121            "featureType": "water",
122            "elementType": "geometry",
123            "stylers": [{
124                "color": "#c9c9c9"
125            }]
126        },
127        {
128            "featureType": "water",
129            "elementType": "labels.text.fill",
130            "stylers": [{
131                "color": "#9e9e9e"
132            }]
133        }
134    ],
135    'retro' : [
136        {
137            "elementType": "geometry",
138            "stylers": [{
139                "color": "#ebe3cd"
140            }]
141        },
142        {
143            "elementType": "labels.text.fill",
144            "stylers": [{
145                "color": "#523735"
146            }]
147        },
148        {
149            "elementType": "labels.text.stroke",
150            "stylers": [{
151                "color": "#f5f1e6"
152            }]
153        },
154        {
155            "featureType": "administrative",
156            "elementType": "geometry.stroke",
157            "stylers": [{
158                "color": "#c9b2a6"
159            }]
160        },
161        {
162            "featureType": "administrative.land_parcel",
163            "elementType": "geometry.stroke",
164            "stylers": [{
165                "color": "#dcd2be"
166            }]
167        },
168        {
169            "featureType": "administrative.land_parcel",
170            "elementType": "labels.text.fill",
171            "stylers": [{
172                "color": "#ae9e90"
173            }]
174        },
175        {
176            "featureType": "landscape.natural",
177            "elementType": "geometry",
178            "stylers": [{
179                "color": "#dfd2ae"
180            }]
181        },
182        {
183            "featureType": "poi",
184            "elementType": "geometry",
185            "stylers": [{
186                "color": "#dfd2ae"
187            }]
188        },
189        {
190            "featureType": "poi",
191            "elementType": "labels.text.fill",
192            "stylers": [{
193                "color": "#93817c"
194            }]
195        },
196        {
197            "featureType": "poi.park",
198            "elementType": "geometry.fill",
199            "stylers": [{
200                "color": "#a5b076"
201            }]
202        },
203        {
204            "featureType": "poi.park",
205            "elementType": "labels.text.fill",
206            "stylers": [{
207                "color": "#447530"
208            }]
209        },
210        {
211            "featureType": "road",
212            "elementType": "geometry",
213            "stylers": [{
214                "color": "#f5f1e6"
215            }]
216        },
217        {
218            "featureType": "road.arterial",
219            "elementType": "geometry",
220            "stylers": [{
221                "color": "#fdfcf8"
222            }]
223        },
224        {
225            "featureType": "road.highway",
226            "elementType": "geometry",
227            "stylers": [{
228                "color": "#f8c967"
229            }]
230        },
231        {
232            "featureType": "road.highway",
233            "elementType": "geometry.stroke",
234            "stylers": [{
235                "color": "#e9bc62"
236            }]
237        },
238        {
239            "featureType": "road.highway.controlled_access",
240            "elementType": "geometry",
241            "stylers": [{
242                "color": "#e98d58"
243            }]
244        },
245        {
246            "featureType": "road.highway.controlled_access",
247            "elementType": "geometry.stroke",
248            "stylers": [{
249                "color": "#db8555"
250            }]
251        },
252        {
253            "featureType": "road.local",
254            "elementType": "labels.text.fill",
255            "stylers": [{
256                "color": "#806b63"
257            }]
258        },
259        {
260            "featureType": "transit.line",
261            "elementType": "geometry",
262            "stylers": [{
263                "color": "#dfd2ae"
264            }]
265        },
266        {
267            "featureType": "transit.line",
268            "elementType": "labels.text.fill",
269            "stylers": [{
270                "color": "#8f7d77"
271            }]
272        },
273        {
274            "featureType": "transit.line",
275            "elementType": "labels.text.stroke",
276            "stylers": [{
277                "color": "#ebe3cd"
278            }]
279        },
280        {
281            "featureType": "transit.station",
282            "elementType": "geometry",
283            "stylers": [{
284                "color": "#dfd2ae"
285            }]
286        },
287        {
288            "featureType": "water",
289            "elementType": "geometry.fill",
290            "stylers": [{
291                "color": "#b9d3c2"
292            }]
293        },
294        {
295            "featureType": "water",
296            "elementType": "labels.text.fill",
297            "stylers": [{
298                "color": "#92998d"
299            }]
300        }
301    ],
302    'dark' : [
303        {
304            "elementType": "geometry",
305            "stylers": [{
306                "color": "#212121"
307            }]
308        },
309        {
310            "elementType": "labels.icon",
311            "stylers": [{
312                "visibility": "off"
313            }]
314        },
315        {
316            "elementType": "labels.text.fill",
317            "stylers": [{
318                "color": "#757575"
319            }]
320        },
321        {
322            "elementType": "labels.text.stroke",
323            "stylers": [{
324                "color": "#212121"
325            }]
326        },
327        {
328            "featureType": "administrative",
329            "elementType": "geometry",
330            "stylers": [{
331                "color": "#757575"
332            }]
333        },
334        {
335            "featureType": "administrative.country",
336            "elementType": "labels.text.fill",
337            "stylers": [{
338                "color": "#9e9e9e"
339            }]
340        },
341        {
342            "featureType": "administrative.land_parcel",
343            "stylers": [{
344                "visibility": "off"
345            }]
346        },
347        {
348            "featureType": "administrative.locality",
349            "elementType": "labels.text.fill",
350            "stylers": [{
351                "color": "#bdbdbd"
352            }]
353        },
354        {
355            "featureType": "poi",
356            "elementType": "labels.text.fill",
357            "stylers": [{
358                "color": "#757575"
359            }]
360        },
361        {
362            "featureType": "poi.park",
363            "elementType": "geometry",
364            "stylers": [{
365                "color": "#181818"
366            }]
367        },
368        {
369            "featureType": "poi.park",
370            "elementType": "labels.text.fill",
371            "stylers": [{
372                "color": "#616161"
373            }]
374        },
375        {
376            "featureType": "poi.park",
377            "elementType": "labels.text.stroke",
378            "stylers": [{
379                "color": "#1b1b1b"
380            }]
381        },
382        {
383            "featureType": "road",
384            "elementType": "geometry.fill",
385            "stylers": [{
386                "color": "#2c2c2c"
387            }]
388        },
389        {
390            "featureType": "road",
391            "elementType": "labels.text.fill",
392            "stylers": [{
393                "color": "#8a8a8a"
394            }]
395        },
396        {
397            "featureType": "road.arterial",
398            "elementType": "geometry",
399            "stylers": [{
400                "color": "#373737"
401            }]
402        },
403        {
404            "featureType": "road.highway",
405            "elementType": "geometry",
406            "stylers": [{
407                "color": "#3c3c3c"
408            }]
409        },
410        {
411            "featureType": "road.highway.controlled_access",
412            "elementType": "geometry",
413            "stylers": [{
414                "color": "#4e4e4e"
415            }]
416        },
417        {
418            "featureType": "road.local",
419            "elementType": "labels.text.fill",
420            "stylers": [{
421                "color": "#616161"
422            }]
423        },
424        {
425            "featureType": "transit",
426            "elementType": "labels.text.fill",
427            "stylers": [{
428                "color": "#757575"
429            }]
430        },
431        {
432            "featureType": "water",
433            "elementType": "geometry",
434            "stylers": [{
435                "color": "#000000"
436            }]
437        },
438        {
439            "featureType": "water",
440            "elementType": "labels.text.fill",
441            "stylers": [{
442                "color": "#3d3d3d"
443            }]
444        }
445    ],
446    'night' : [
447        {
448            "elementType": "geometry",
449            "stylers": [{
450                "color": "#242f3e"
451            }]
452        },
453        {
454            "elementType": "labels.text.fill",
455            "stylers": [{
456                "color": "#746855"
457            }]
458        },
459        {
460            "elementType": "labels.text.stroke",
461            "stylers": [{
462                "color": "#242f3e"
463            }]
464        },
465        {
466            "featureType": "administrative.locality",
467            "elementType": "labels.text.fill",
468            "stylers": [{
469                "color": "#d59563"
470            }]
471        },
472        {
473            "featureType": "poi",
474            "elementType": "labels.text.fill",
475            "stylers": [{
476                "color": "#d59563"
477            }]
478        },
479        {
480            "featureType": "poi.park",
481            "elementType": "geometry",
482            "stylers": [{
483                "color": "#263c3f"
484            }]
485        },
486        {
487            "featureType": "poi.park",
488            "elementType": "labels.text.fill",
489            "stylers": [{
490                "color": "#6b9a76"
491            }]
492        },
493        {
494            "featureType": "road",
495            "elementType": "geometry",
496            "stylers": [{
497                "color": "#38414e"
498            }]
499        },
500        {
501            "featureType": "road",
502            "elementType": "geometry.stroke",
503            "stylers": [{
504                "color": "#212a37"
505            }]
506        },
507        {
508            "featureType": "road",
509            "elementType": "labels.text.fill",
510            "stylers": [{
511                "color": "#9ca5b3"
512            }]
513        },
514        {
515            "featureType": "road.highway",
516            "elementType": "geometry",
517            "stylers": [{
518                "color": "#746855"
519            }]
520        },
521        {
522            "featureType": "road.highway",
523            "elementType": "geometry.stroke",
524            "stylers": [{
525                "color": "#1f2835"
526            }]
527        },
528        {
529            "featureType": "road.highway",
530            "elementType": "labels.text.fill",
531            "stylers": [{
532                "color": "#f3d19c"
533            }]
534        },
535        {
536            "featureType": "transit",
537            "elementType": "geometry",
538            "stylers": [{
539                "color": "#2f3948"
540            }]
541        },
542        {
543            "featureType": "transit.station",
544            "elementType": "labels.text.fill",
545            "stylers": [{
546                "color": "#d59563"
547            }]
548        },
549        {
550            "featureType": "water",
551            "elementType": "geometry",
552            "stylers": [{
553                "color": "#17263c"
554            }]
555        },
556        {
557            "featureType": "water",
558            "elementType": "labels.text.fill",
559            "stylers": [{
560                "color": "#515c6d"
561            }]
562        },
563        {
564            "featureType": "water",
565            "elementType": "labels.text.stroke",
566            "stylers": [{
567                "color": "#17263c"
568            }]
569        }
570    ],
571    'aubergine' : [
572        {
573            "elementType": "geometry",
574            "stylers": [{
575                "color": "#1d2c4d"
576            }]
577        },
578        {
579            "elementType": "labels.text.fill",
580            "stylers": [{
581                "color": "#8ec3b9"
582            }]
583        },
584        {
585            "elementType": "labels.text.stroke",
586            "stylers": [{
587                "color": "#1a3646"
588            }]
589        },
590        {
591            "featureType": "administrative.country",
592            "elementType": "geometry.stroke",
593            "stylers": [{
594                "color": "#4b6878"
595            }]
596        },
597        {
598            "featureType": "administrative.land_parcel",
599            "elementType": "labels.text.fill",
600            "stylers": [{
601                "color": "#64779e"
602            }]
603        },
604        {
605            "featureType": "administrative.province",
606            "elementType": "geometry.stroke",
607            "stylers": [{
608                "color": "#4b6878"
609            }]
610        },
611        {
612            "featureType": "landscape.man_made",
613            "elementType": "geometry.stroke",
614            "stylers": [{
615                "color": "#334e87"
616            }]
617        },
618        {
619            "featureType": "landscape.natural",
620            "elementType": "geometry",
621            "stylers": [{
622                "color": "#023e58"
623            }]
624        },
625        {
626            "featureType": "poi",
627            "elementType": "geometry",
628            "stylers": [{
629                "color": "#283d6a"
630            }]
631        },
632        {
633            "featureType": "poi",
634            "elementType": "labels.text.fill",
635            "stylers": [{
636                "color": "#6f9ba5"
637            }]
638        },
639        {
640            "featureType": "poi",
641            "elementType": "labels.text.stroke",
642            "stylers": [{
643                "color": "#1d2c4d"
644            }]
645        },
646        {
647            "featureType": "poi.park",
648            "elementType": "geometry.fill",
649            "stylers": [{
650                "color": "#023e58"
651            }]
652        },
653        {
654            "featureType": "poi.park",
655            "elementType": "labels.text.fill",
656            "stylers": [{
657                "color": "#3C7680"
658            }]
659        },
660        {
661            "featureType": "road",
662            "elementType": "geometry",
663            "stylers": [{
664                "color": "#304a7d"
665            }]
666        },
667        {
668            "featureType": "road",
669            "elementType": "labels.text.fill",
670            "stylers": [{
671                "color": "#98a5be"
672            }]
673        },
674        {
675            "featureType": "road",
676            "elementType": "labels.text.stroke",
677            "stylers": [{
678                "color": "#1d2c4d"
679            }]
680        },
681        {
682            "featureType": "road.highway",
683            "elementType": "geometry",
684            "stylers": [{
685                "color": "#2c6675"
686            }]
687        },
688        {
689            "featureType": "road.highway",
690            "elementType": "geometry.stroke",
691            "stylers": [{
692                "color": "#255763"
693            }]
694        },
695        {
696            "featureType": "road.highway",
697            "elementType": "labels.text.fill",
698            "stylers": [{
699                "color": "#b0d5ce"
700            }]
701        },
702        {
703            "featureType": "road.highway",
704            "elementType": "labels.text.stroke",
705            "stylers": [{
706                "color": "#023e58"
707            }]
708        },
709        {
710            "featureType": "transit",
711            "elementType": "labels.text.fill",
712            "stylers": [{
713                "color": "#98a5be"
714            }]
715        },
716        {
717            "featureType": "transit",
718            "elementType": "labels.text.stroke",
719            "stylers": [{
720                "color": "#1d2c4d"
721            }]
722        },
723        {
724            "featureType": "transit.line",
725            "elementType": "geometry.fill",
726            "stylers": [{
727                "color": "#283d6a"
728            }]
729        },
730        {
731            "featureType": "transit.station",
732            "elementType": "geometry",
733            "stylers": [{
734                "color": "#3a4762"
735            }]
736        },
737        {
738            "featureType": "water",
739            "elementType": "geometry",
740            "stylers": [{
741                "color": "#0e1626"
742            }]
743        },
744        {
745            "featureType": "water",
746            "elementType": "labels.text.fill",
747            "stylers": [{
748                "color": "#4e6d70"
749            }]
750        }
751    ]
752};
753
754document.addEventListener('DOMContentLoaded', function(){
755    ba_jQuery('.com-baforms').each(function(){
756        var baForm = ba_jQuery(this),
757            saveModal = baForm.find('.save-and-continue-modal'),
758            messageModal = ba_jQuery(this).find('.message-modal'),
759            form = baForm.find('form'),
760            files,
761            popupModal = baForm.find('.ba-modal.popup-form'),
762            iframe,
763            theme = baForm.find('.theme-color').val(),
764            baTotal = baForm.find('.ba-total-price'),
765            cart = baForm.find('.baforms-cart'),
766            symbol = baForm.find('.cart-currency').val(),
767            symbolPos = baForm.find('.cart-position').val(),
768            saveContinue = baForm.find('.save-and-continue').val(),
769            stripe;
770
771        baForm.find('.ba-input-image').closest('.tool').addClass('ba-image-input');
772
773        baForm.find('.ba-maxlength').each(function(){
774            var $this = jQuery(this),
775                input = $this.parent().find('input[type=text], textarea');
776            input.on('input', function(){
777                var length = this.value.replace(new RegExp('\n', 'g'), 'br').length,
778                    str = length+'/'+this.maxLength;
779                $this.text(str)
780                if (length >= this.maxLength) {
781                    $this.addClass('ba-maxlength-alert');
782                } else {
783                    $this.removeClass('ba-maxlength-alert');
784                }
785            })
786        });
787
788        baForm.find('.ba-tooltip').parent().on('mouseenter', function(){
789            var coord = this.getBoundingClientRect(),
790                top = coord.top,
791                left = coord.left;
792            left = left + (coord.right - coord.left) / 2;
793            jQuery(this).find('.ba-tooltip').css({
794                'top' : top+'px',
795                'left' : left+'px'
796            })
797        });
798
799        baForm.find('.ba-chekInline span.ba-input-image').on('click', function(){
800            var checkbox = jQuery(this).find('input');
801            if (!checkbox.prop('checked')) {
802                checkbox.prop('checked', true);
803                jQuery(this).css('border', '2px solid '+theme);
804            } else {
805                checkbox.prop('checked', false);
806                jQuery(this).css('border', '');
807            }
808            checkbox.trigger('change');
809        });
810        baForm.find('.ba-radioInline > span.ba-input-image').on('click', function(){
811            var checkbox = jQuery(this).find('input');
812            if (!checkbox.prop('checked')) {
813                checkbox.prop('checked', true);
814                checkbox.trigger('change');
815                jQuery(this).css('border', '2px solid '+theme);
816            }
817        });
818        baForm.find('.ba-radioInline.ba-image-input > span input').on('change', function(){
819            jQuery(this).closest('.tool').find('> span.ba-input-image').css('border', '');
820        })
821
822        baForm.find('input[data-type="calculation"]').on('keyup', function(){
823            if (baTotal.length == 0) {
824                return;
825            }
826            var price = ba_jQuery(this).val() * 1,
827                name = ba_jQuery(this).attr('name'),
828                total = baTotal.find('.ba-price').text()*1,
829                label = '';
830            if (ba_jQuery(this).closest('.tool').find('> label').length > 0){
831                label = ba_jQuery(this).closest('.tool').find('> label > span')[0].innerText;
832                label = label.replace(' *', '');
833            }
834            if (isNaN(price)) {
835                ba_jQuery(this).addClass('ba-alert');
836                if (prices[name]) {
837                    var quantity = 1
838                    if (cart.length > 0) {
839                        if (cart.find('.product-cell[data-id="'+name+'"]').length > 0) {
840                            quantity = Math.round(cart.find('.product-cell[data-id="'+name+'"] .quantity input').val());
841                            cart.find('.product-cell[data-id="'+name+'"]').remove();
842                        }
843                    }
844                    total = total - prices[name]  * quantity;
845                    prices[name] = 0;
846                    total = Math.round10(total, -2);
847                    baTotal.find('.ba-price').text(total);
848                    baTotal.find('input[name="ba_total"]').val(total);
849                }                
850                return false;
851            }
852            ba_jQuery(this).removeClass('ba-alert');
853            if (price > 999999999) {
854                price = 999999999;
855                jQuery(this).val(price)
856            }
857            if (!label) {
858                label = ba_jQuery(this).attr('placeholder');
859            }
860            if (prices[name]) {
861                var quantity = 1
862                if (cart.length > 0) {
863                    quantity = Math.round(cart.find('.product-cell[data-id="'+name+'"] .quantity input').val());
864                    cart.find('.product-cell[data-id="'+name+'"]').remove();
865                }
866                total = total - prices[name]  * quantity;
867            }
868            var value;
869            if (symbolPos == 'before') {
870                value = symbol+price;
871            } else {
872                value = price+symbol
873            }
874            addToCart(label, value, name, price);
875            if (price == 0) {
876                cart.find('.product-cell[data-id="'+name+'"]').remove();
877            }
878            cart.find('.product-cell[data-id="'+name+'"] .remove-item i').on('click', function(){
879                
880            });
881            prices[name] = price * 1;
882            total = total + price * 1;
883            total = Math.round10(total, -2);
884            baTotal.find('.ba-price').text(total);
885            baTotal.find('input[name="ba_total"]').val(total);
886        });
887
888        baForm.find('input').on('keydown', function(event){
889            if (event.keyCode == 13) {
890                event.preventDefault();
891                event.stopPropagation();
892            }
893        });
894
895        baForm.find('.ba-address').each(function(){
896            var input = jQuery(this).find('input[type="text"]'),
897                autocomplete = new google.maps.places.Autocomplete(input[0]);
898        });
899
900        function conditionShow()
901        {
902            baForm.find('.ba-dropdown > select, .ba-dropdown > .container-icon select').on('change', function(){
903                var parent = jQuery(this).closest('.ba-dropdown'),
904                    height = 20;                
905                if (parent.find('> .condition-area').length == 0) {
906                    return;
907                }
908                jQuery(this).find('option').each(function(ind, el){
909                    if (jQuery(this).prop('selected')) {
910                        var h,
911                            flag = false;
912                        if (ind > 0) {
913                            ind = ind - 1;
914                            flag = true;
915                        }
916                        parent.parentsUntil('.ba-row').each(function(){
917                            this.style.height = '';
918                        });
919                        if (parent.find('> .condition-area.selected').length > 0) {
920                            parent.find('> .condition-area.selected').addClass('close-condition');
921                            height = parent.find('.close-condition').height();
922                            parent.find(' > [data-condition="'+ind+'"]').height(height);
923                            parent.find('> .condition-area').removeClass('selected');
924                            parent.find('> .condition-area .condition-area').removeClass('selected');
925                        } else {
926                            parent.find(' > [data-condition="'+ind+'"]').height(0);
927                        }
928                        if (flag && parent.find(' > [data-condition="'+ind+'"]').length > 0) {
929                            parent.find(' > [data-condition="'+ind+'"]').addClass('selected');
930                            parent.find(' > [data-condition="'+ind+'"]')[0].style.height = '';
931                            h = parent.find(' > [data-condition="'+ind+'"]').height();
932                            parent.find(' > [data-condition="'+ind+'"]').animate({
933                                'height' : h * 1 + 3
934                            }, 600, function(){
935                                parent.find('.close-condition').removeClass('close-condition');
936                                var top = parent.find(' > [data-condition="'+ind+'"]').position().top;
937                                parent.find(' > [data-condition="'+ind+'"]').css('top', top+'px');
938                                parent.closest('.ba-form')[0].style.height = '';
939                                height = parent.closest('.ba-form').height();
940                                parent.closest('.ba-form').height(height);
941                            })
942                            parent.closest('.ba-form')[0].style.height = '';
943                        }
944                        if (!flag || parent.find(' > [data-condition="'+ind+'"]').length == 0) {
945                            parent.css('margin-bottom', height+'px');
946                            parent.animate({
947                                'margin-bottom' : 20
948                            }, 600, function(){
949                                parent.find('.close-condition').removeClass('close-condition');
950                                parent.closest('.ba-form')[0].style.height = '';
951                                height = parent.closest('.ba-form').height();
952                                parent.closest('.ba-form').height(height);
953                            });
954                            parent.closest('.ba-form')[0].style.height = '';
955                        }
956                        var item = parent.find('> .condition-area');
957                        clearCondition(item);
958                        return false;
959                    }
960                });
961                refreshMap();
962            });
963            baForm.find('.ba-radioInline > span input, .ba-radioMultiple > span input').on('change', function(){
964                var parent = jQuery(this).closest('.tool'),
965                    height = 20,
966                    $this = this;
967                if (parent.find('> .condition-area').length == 0) {
968                    return;
969                }
970                parent.find(' > span input').each(function(ind){
971                    if (this == $this) {
972                        var conditionArea = parent.find(' > [data-condition="'+ind+'"]'),
973                        	h,
974                        	conditions = parent.find('> .condition-area.selected');
975                        parent.parentsUntil('.ba-row').each(function(){
976                            this.style.height = '';
977                        });
978                        conditionArea.addClass('selected');
979                        h = conditionArea.height();
980                        if (conditions.length > 0) {
981                            conditions.addClass('close-condition');
982                            height = parent.find('.close-condition').height();
983                            conditionArea.height(height);
984                            conditions.removeClass('selected');
985                            parent.find('> .condition-area .condition-area').removeClass('selected');
986                        } else {
987                            conditionArea.height(0);
988                        }
989                        conditionArea.animate({
990                            'height' : h * 1 + 3
991                        }, 600, function(){
992                            parent.find('.close-condition').removeClass('close-condition');
993                            var top = conditionArea.position().top;
994                            conditionArea.css('top', top+'px');
995                            parent.closest('.ba-form')[0].style.height = '';
996                            height = parent.closest('.ba-form').height();
997                            parent.closest('.ba-form').height(height);
998                        })
999                        parent.closest('.ba-form')[0].style.height = '';
1000                        if (conditionArea.length == 0) {
1001                            parent.css('margin-bottom', height+'px');
1002                            parent.animate({
1003                                'margin-bottom' : 20
1004                            }, 600, function(){
1005                                parent.find('.close-condition').removeClass('close-condition');
1006                                parent.closest('.ba-form')[0].style.height = '';
1007                                height = parent.closest('.ba-form').height();
1008                                parent.closest('.ba-form').height(height);
1009                            })
1010                        }
1011                        var item = parent.find('> .condition-area');
1012                        clearCondition(item);
1013                        return false;
1014                    }
1015                });
1016                refreshMap();
1017            });
1018        }
1019
1020        function clearCondition(item)
1021        {
1022            var total = baTotal.find('input[name="ba_total"]').val(),
1023                totalPrice = 0;
1024            item.find('span.ba-input-image').css('border', '');
1025            item.find('.ba-alert').removeClass('ba-alert');
1026            item.find('input').each(function(){
1027                var type = ba_jQuery(this).attr('type');
1028                if (type == 'radio' || type == 'checkbox') {
1029                    if (ba_jQuery(this).prop('checked') && ba_jQuery(this).attr('data-price')) {
1030                        var quantity = 1,
1031                            name = this.name;
1032                        if (cart.find('.product-cell[data-id="'+name+'"]').length > 0) {
1033                            quantity = cart.find('.product-cell[data-id="'+name+'"] .quantity input').val();
1034                        }
1035                        totalPrice += ba_jQuery(this).attr('data-price') * quantity;
1036                        cart.find('.product-cell[data-id="'+name+'"]').find('.remove-item i.zmdi').trigger('click');
1037                        if (prices[name]) {
1038                            delete(prices[name]);
1039                        }
1040                    }
1041                    ba_jQuery(this).prop('checked', false);
1042                }
1043                if (type == 'email') {
1044                    ba_jQuery(this).val('');
1045                }
1046                if (ba_jQuery(this).parent().hasClass('ba-textInput') || ba_jQuery(this).parent().parent().hasClass('ba-textInput')) {
1047                    if (this.dataset.type == 'calculation') {
1048                    	var quantity = 1,
1049                    		price = this.value,
1050                            name = this.name;
1051                        if (!isNaN(price)) {
1052                        	if (cart.find('.product-cell[data-id="'+name+'"]').length > 0) {
1053	                            quantity = cart.find('.product-cell[data-id="'+name+'"] .quantity input').val();
1054	                        }
1055	                        totalPrice += price * quantity;
1056	                        cart.find('.product-cell[data-id="'+name+'"]').find('.remove-item i.zmdi').trigger('click');
1057	                        if (prices[name]) {
1058	                            delete(prices[name]);
1059	                        }
1060                        }
1061                    }
1062                    ba_jQuery(this).val('');
1063                }
1064            });
1065            item.find('textarea').each(function () {
1066                ba_jQuery(this).val('');
1067            });
1068            item.find('select').each(function(){
1069                ba_jQuery(this).find('option').each(function(){
1070                    if (ba_jQuery(this).prop('selected') && ba_jQuery(this).attr('data-price')) {
1071                        var quantity = 1,
1072                            name = jQuery(this).parent()[0].name.replace('[]', '');
1073                        if (cart.find('.product-cell[data-id="'+name+'"]').length > 0) {
1074                            quantity = cart.find('.product-cell[data-id="'+name+'"] .quantity input').val();
1075                        }
1076                        totalPrice += ba_jQuery(this).attr('data-price') * quantity;
1077                        cart.find('.product-cell[data-id="'+name+'"]').find('.remove-item i.zmdi').trigger('click');
1078                        if (prices[name]) {
1079                            delete(prices[name]);
1080                        }
1081                    }
1082                    ba_jQuery(this).removeAttr('selected');
1083                });
1084            });
1085            total = total - totalPrice;
1086            baTotal.find('input[name="ba_total"]').val(total);
1087            baTotal.find('.ba-price').text(total);
1088        }
1089        
1090        function refreshMap()
1091        {
1092            ba_jQuery('.ba-map.tool').each(function(){
1093                var options = ba_jQuery(this).parent().find('.ba-options').val(),
1094                    zoom = true,
1095                    draggable = true,
1096                    image;
1097                options = options.replace('-_-', "'");
1098                options = options.split(';');
1099                if (options[8] == 0) {
1100                    zoom = false;
1101                }
1102                if (options[9] == 0) {
1103                    draggable = false;
1104                }
1105                if (!options[10]) {
1106                    options[10] = 'standart';
1107                }
1108                if (options[0] != '') {
1109                    options[0] = options[0].replace(new RegExp('\\n', 'g'), '\\n');
1110                    var option = JSON.parse(options[0]);
1111                    if (typeof(option.center) == 'string') {
1112                        option.center = option.center.split(',');
1113                        option.center = {
1114                            lat : option.center[0]*1,
1115                            lng : option.center[1]*1
1116                        }
1117                    }
1118                    if (options[6] == 1) {
1119                        option.scrollwheel = zoom;
1120                        option.navigationControl = true;
1121                        option.mapTypeControl = true;
1122                        option.scaleControl = true;
1123                        option.draggable = draggable;
1124                        option.zoomControl = true;
1125                        option.disableDefaultUI = false;
1126                        option.disableDoubleClickZoom = false;
1127                    }
1128                } else {
1129                    if (options[6] == 0) {
1130                        option = {
1131                            center : {
1132                                lat : 42.345573,
1133                                lng : -71.098326
1134                            },
1135                            zoom: 14,
1136                            scrollwheel: zoom,
1137                            navigationControl: false,
1138                            mapTypeControl: false,
1139                            scaleControl: false,
1140                            draggable: draggable,
1141                            zoomControl: false,
1142                            disableDefaultUI: true,
1143                            disableDoubleClickZoom: true,
1144                        }
1145                    } else {
1146                        option = {
1147                            center : {
1148                                lat : 42.345573,
1149                                lng : -71.098326
1150                            },
1151                            zoom: 14,
1152                            scrollwheel: zoom,
1153                            navigationControl: true,
1154                            mapTypeControl: true,
1155                            scaleControl: true,
1156                            draggable: draggable,
1157                            zoomControl: true,
1158                            disableDefaultUI: false,
1159                            disableDoubleClickZoom: false,
1160                        }
1161                    }
1162                }
1163                if (options[7] != '') {
1164                    image = ba_jQuery('.admin-dirrectory').val()+options[7];
1165                } else {
1166                    image = options[7];
1167                }
1168                var content = options[2],
1169                    flag = options[5],
1170                    map = new google.maps.Map(jQuery(this)[0], option),
1171                    marker = '';
1172                map.setOptions({styles: mapStyles[options[10]]});
1173                if (options[1] != '') {
1174                    options[1] = options[1].replace(new RegExp('\\n', 'g'),'\\n');
1175                    var mark = JSON.parse(options[1]);
1176                    var keys = [];
1177                    for (var key in mark) {
1178                        keys.push(key);
1179                    }
1180                    marker = new google.maps.Marker({
1181                        position: {
1182                            lat : mark[keys[0]]*1,
1183                            lng : mark[keys[1]]*1
1184                        },
1185                        map: map,
1186                        icon : image
1187                    });
1188                    if (content != '') {
1189                        content = content.replace(new RegExp('---', 'g'), ';')
1190                        var infowindow = new google.maps.InfoWindow({
1191                            content : content
1192                        });
1193                        if (flag == 1) {
1194                            infowindow.open(map, marker);
1195                        }
1196                        marker.addListener('click', function(event){
1197                            infowindow.open(map, marker);
1198                        });
1199                    }
1200                }
1201            });
1202        }
1203        
1204        function prepareUpload(event)
1205        {
1206            ba_jQuery(this).parent().find('.upl-error').val('');
1207            ba_jQuery(this).removeClass('ba-alert');
1208            files = event.target.files;
1209            if (files.length != 0) {
1210                var size = ba_jQuery(this).parent().find('.upl-size').val(),
1211                    types = ba_jQuery(this).parent().find('.upl-type').val(),
1212                    len = files.length,
1213                    tLen;
1214                types = types.split(',');
1215                size = 1048576 * size;
1216                tLen = types.length;
1217                for (var i = 0; i < len; i++) {
1218                    if (files[i].size < size) {
1219                        var type = files[i].name.split('.'),
1220                            flag = true;
1221                        type = type[type.length-1].toLowerCase();
1222                        for (var j = 0; j < tLen; j++) {
1223                            if (type != ba_jQuery.trim(types[j].toLowerCase())) {
1224                                flag = false;
1225                            } else {
1226                                flag = true;
1227                                break;
1228                            }
1229                        }
1230                        if (!flag) {
1231                            ba_jQuery(this).addClass('ba-alert');
1232                            ba_jQuery(this).parent().find('.upl-error').val('error');
1233                            break;
1234                        }
1235                    }  else {
1236                        ba_jQuery(this).addClass('ba-alert');
1237                        ba_jQuery(this).parent().find('.upl-error').val('error');
1238                        break;
1239                    }
1240                }
1241            } else {
1242                if (ba_jQuery(this).prop('required')) {
1243                    ba_jQuery(this).parent().find('.upl-error').val('error');
1244                    ba_jQuery(this).addClass('ba-alert');
1245                } else {
1246                    ba_jQuery(this).parent().find('.upl-error').val('');
1247                    ba_jQuery(this).removeClass('ba-alert');
1248                }                
1249            }
1250        }
1251
1252        function checkAlert(item)
1253        {
1254            item.find('.tool').each(function() {
1255                var tool = ba_jQuery(this),
1256                    condArea = jQuery(this).closest('.condition-area');
1257                if (condArea.length > 0 && !condArea.hasClass('selected')) {
1258                    return;
1259                }
1260                if (tool.hasClass('ba-email')) {
1261                    var reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/,
1262                        value = tool.find('input[type="email"]').first().val();
1263                    if(!reg.test(value)) {
1264                        tool.find('input[type="email"]').first().addClass('ba-alert');
1265                    } else {
1266                        tool.find('input[type="email"]').first().removeClass('ba-alert');
1267                    }
1268                } else if (tool.hasClass('ba-terms-conditions')) {
1269                    if (tool.find('> span input').prop('checked')) {
1270                        tool.removeClass('ba-alert');
1271                    } else {
1272                        tool.addClass('ba-alert');
1273                    }
1274                } else if (tool.hasClass('confirm-email')) {
1275                    var reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/,
1276                        value = tool.find('input[type="email"]').val(),
1277                        email = tool.parent().find('input[type="email"]').first().val();
1278                    if (reg.test(value) && value && value == email) {
1279                        tool.find('input[type="email"]').first().removeClass('ba-alert');
1280                    } else {
1281                        tool.find('input[type="email"]').first().addClass('ba-alert');
1282                    }
1283                } else if (tool.hasClass('ba-upload')) {
1284                    var item = tool.find('.ba-upload')
1285                        required = item.prop('required'),
1286                        value = item.val();
1287                    if (tool.find('.upl-error').val() == 'error' || (required && item[0].files.length == 0)) {
1288                        item.addClass('ba-alert');
1289                    } else {
1290                        item.removeClass('ba-alert');
1291                    }
1292                } else if (tool.hasClass('ba-textarea')) {
1293                    var required = tool.find('textarea').prop('required'),
1294                        value = tool.find('textarea').val();
1295                    if (required) {
1296                        if(ba_jQuery.trim(value) == '') {
1297                            tool.find('textarea').addClass('ba-alert');
1298                        } else {
1299                            tool.find('textarea').removeClass('ba-alert');
1300                        }
1301                    }
1302                } else if (tool.hasClass('ba-textInput')) {
1303                    var required = tool.find('input[type="text"]').prop('required'),
1304                        type = tool.find('input[type="text"]').attr('data-type'),
1305                        value = tool.find('input[type="text"]').val();
1306                    if (required) {
1307                        if(ba_jQuery.trim(value) == '') {
1308                            tool.find('input[type="text"]').addClass('ba-alert');
1309                        } else {
1310                            if (type == 'number' || type == 'calculation') {
1311                                if (ba_jQuery.isNumeric(value)) {
1312                                    tool.find('input[type="text"]').removeClass('ba-alert');
1313                                } else {
1314                                    tool.find('input[type="text"]').addClass('ba-alert');
1315                                }
1316                            } else {
1317                                tool.find('input[type="text"]').removeClass('ba-alert');
1318                            }
1319                        }
1320                    }
1321                } else if (tool.hasClass('ba-chekInline') || tool.hasClass('ba-checkMultiple')) {
1322                    var checkFlag = false;
1323                    if (tool.find('.required').length == 0) {
1324                        return;
1325                    }
1326                    tool.find('.required input[type="checkbox"]').each(function(){
1327                        if (ba_jQuery(this).prop('checked')) {
1328                            checkFlag = true;
1329                            return false;
1330                        }
1331                    });
1332                    if(!checkFlag) {
1333                        tool.addClass('ba-alert');
1334                    } else {
1335                        tool.removeClass('ba-alert');
1336                    }
1337                } else if (tool.hasClass('ba-radioInline') || tool.hasClass('ba-radioMultiple')) {
1338                    var checkFlag = false,
1339                        required = tool.find(' > span input[type="radio"]').first().prop('required');
1340                    if (required) {
1341                        tool.find(' > span input[type="radio"]').each(function(){
1342                            if (ba_jQuery(this).prop('checked')) {
1343                                checkFlag = true;
1344                                return false;
1345                            }
1346                        });
1347                        if(!checkFlag) {
1348                            tool.addClass('ba-alert');
1349                        } else {
1350                            tool.removeClass('ba-alert');
1351                        }
1352                    }                    
1353                } else if (tool.hasClass('ba-dropdown') || tool.hasClass('ba-selectMultiple')) {
1354                    var select = tool.find('> select'),
1355                        checkFlag = false,
1356                        required;
1357                    if (select.length == 0) {
1358                        select = tool.find('> .container-icon select');
1359                    }
1360                    required = select.prop('required');
1361                    if (required) {
1362                        select.find('option').each(function(){
1363                            if (ba_jQuery(this).prop('selected') && ba_jQuery(this).val()) {
1364                                checkFlag = true;
1365                                return false;
1366                            }
1367                        });
1368                        if(!checkFlag) {
1369                            select.addClass('ba-alert');
1370                        } else {
1371                            select.removeClass('ba-alert');
1372                        }
1373                    }
1374                } else if (tool.hasClass('ba-address')) {
1375                    var required = tool.find('input[type="text"]').prop('required'),
1376                        value = tool.find('input[type="text"]').val();
1377                    if (required) {
1378                        if(ba_jQuery.trim(value) == '') {
1379                            tool.find('input[type="text"]').addClass('ba-alert');
1380                        } else {
1381                            tool.find('input[type="text"]').removeClass('ba-alert');
1382                        }
1383                    }
1384                } else if (tool.hasClass('ba-date')) {
1385                    var required = tool.hasClass('required'),
1386                        value = tool.find('input[type="text"]').val();
1387                    if (required) {
1388                        if(ba_jQuery.trim(value) == '') {
1389                            tool.find('input[type="text"]').addClass('ba-alert');
1390                        } else {
1391                            tool.find('input[type="text"]').removeClass('ba-alert');
1392                        }
1393                    }
1394                }
1395            });
1396            if (item.find('.ba-captcha input[type="text"]').length != 0) {
1397                var captcha = item.find('.ba-captcha input[type="text"]').val();
1398                if (captcha == '') {
1399                    item.find('.ba-captcha input[type="text"]').addClass('ba-alert');
1400                } else {
1401                    item.find('.ba-captcha input[type="text"]').removeClass('ba-alert');
1402                }
1403            }
1404        }
1405        
1406        function sendMessage(event) 
1407        {
1408            checkAlert(form);
1409            if (form.find('.ba-alert').length > 0) {
1410                event.stopPropagation();
1411                event.preventDefault();
1412                var alert = form.find('.ba-alert').first();
1413                if (!alert.hasClass('tool')) {
1414                    alert = alert.closest('.tool');
1415                }
1416                var position = alert.offset().top
1417                ba_jQuery('html, body').animate({
1418                    scrollTop: position - 150
1419                }, 'slow');
1420            } else {
1421                var task = jQuery(this).find('[name="task"]').val();
1422                if (cart.length > 0) {
1423                    var obj = {},
1424                        str = new Array(),
1425                        quantity = cart.find('.product-cell').first().find('.quantity').text();
1426                    cart.find('.product-cell').each(function(){
1427                        var id = jQuery(this).attr('data-id');
1428                        if (id) {
1429                            obj.id = id.replace('[]', '');
1430                            obj.product = jQuery(this).attr('data-product');
1431                            obj.quantity = Math.round(jQuery(this).find('.quantity input').val());
1432                            var label = obj.product,
1433                                array = label.split(' - ');
1434                            array[array.length - 1] = jQuery(this).find('div.total').text().trim();
1435                            label = array.join(' - ');
1436                            obj.str = label;
1437                            str.push(JSON.stringify(obj));
1438                        }
1439                    });
1440                    str = str.join(';');
1441                    jQuery(this).find('.forms-cart').val(str);
1442                }
1443                jQuery(this).find('input[name="page_url"]').val(window.location.href);
1444                jQuery(this).find('input[name="page_title"]').val(jQuery('title')[0].innerText.trim());
1445                if (task != 'form.save') {
1446                    var cloneForm = this.cloneNode(true),
1447                        cloneTask = jQuery(cloneForm).find('[name="task"]').remove(),
1448                        formData = new FormData(cloneForm),
1449                        url = jQuery('.admin-dirrectory').val()+"index.php?option=com_baforms&task=form.checkCaptcha",
1450                        XHR = new XMLHttpRequest(),
1451                        responseText = '';
1452                    XHR.onreadystatechange = function(e) {
1453                        if (XHR.readyState == 4) {
1454                            responseText = XHR.responseText;
1455                        }
1456                    }
1457                    XHR.open("POST", url, false);
1458                    XHR.send(formData);
1459                    if (!responseText) {
1460                        return false;
1461                    }
1462                }
1463                if (task == 'form.save' || task == 'form.mollie') {
1464                    jQuery(this).removeClass('ba-payment');
1465                    ba_jQuery(this).attr('target', 'form-target');
1466                } else if (task == 'form.stripe') {
1467                    jQuery(this).addClass('ba-payment');
1468                    ba_jQuery(this).attr('target', 'form-target');
1469                    iframe = ba_jQuery('<iframe/>', {
1470                        name:'form-target',
1471                        id:'form-target'
1472                    });
1473                    ba_jQuery('#form-target').remove();
1474                    iframe.appendTo(ba_jQuery('body'));
1475                    ba_jQuery(iframe).attr('style', 'display:none');
1476                    var api_key = form.find('[value="form.stripe"]').attr('data-api-key'),
1477                        image = form.find('[value="form.stripe"]').attr('data-image'),
1478                        total = baTotal.find('.ba-price').text() * 100,
1479                        name = form.find('[value="form.stripe"]').attr('data-name'),
1480                        description = form.find('[value="form.stripe"]').attr('data-description');
1481                    total = Math.round10(total, -2);
1482                    if (!stripe) {
1483                        stripe = StripeCheckout.configure({
1484                            key: api_key,
1485                            image: image,
1486                            name: name,
1487                            description: description,
1488                            locale: 'auto',
1489                            currency: form.find('.currency-code').val(),
1490                            token: function(token) {
1491                                form.append('<input type="hidden" name="stripeTokenId" value="'+token.id+'" />');
1492                                HTMLFormElement.prototype.submit.call(form[0]);
1493                                jQuery.ajax({
1494                                    type:"POST",
1495                                    dataType:'text',
1496                                    url:"?option=com_baforms&task=form.stripeCharges&tmpl=component",
1497                                    data : {
1498                                        ba_token : JSON.stringify(token),
1499                                        form_id : form.find('[name="form_id"]').val(),
1500                                        total : total,
1501                                        currency : form.find('.currency-code').val().toLowerCase()
1502                                    },
1503                                    success: function(msg){
1504                                        clearFields();
1505                                    }
1506                                });
1507                            }
1508                        });
1509                    }
1510                    stripe.open({
1511                        amount: total
1512                    });
1513                    return false;
1514                } else {
1515                    jQuery(this).addClass('ba-payment');
1516                    ba_jQuery(this).removeAttr('target');
1517                }
1518                if (!jQuery(this).hasClass('ba-payment')) {
1519                    iframe = ba_jQuery('<iframe/>', {
1520                        name:'form-target',
1521                        id:'form-target'
1522                    });
1523                    ba_jQuery('#form-target').remove();
1524                    iframe.appendTo(ba_jQuery('body'));
1525                    ba_jQuery(iframe).attr('style', 'display:none');
1526                    var item = ba_jQuery(this),
1527                        dir = ba_jQuery('.admin-dirrectory').val();
1528                    messageModal.ba_modal();
1529                    messageModal.parent().show();
1530                    messageModal.find('.message').html('<img src="'+dir+'components/com_baforms/assets/images/reload.svg">');    
1531                }
1532            }
1533        }
1534
1535        function clearFields()
1536        {
1537            form.find('span.ba-input-image').css('border', '');
1538            form.find('input').each(function(){
1539                var type = ba_jQuery(this).attr('type');
1540                if (type == 'radio' || type == 'checkbox') {
1541                    ba_jQuery(this).prop('checked', false);
1542                }
1543                if (type == 'email') {
1544                    ba_jQuery(this).val('');
1545                }
1546                if (ba_jQuery(this).closest('.tool').hasClass('ba-textInput') ||
1547                    ba_jQuery(this).closest('.tool').hasClass('ba-address') ||
1548                    jQuery(this).closest('.tool').hasClass('ba-upload')) {
1549                    ba_jQuery(this).val('');
1550                }
1551            });
1552            baTotal.find('input[name="ba_total"]').val('0');
1553            baTotal.find('.ba-price').text('0');
1554            prices = [];
1555            form.find('textarea').each(function () {
1556                ba_jQuery(this).val('');
1557            });
1558            cart.find('.product-cell').not('.ba-cart-headline').remove();
1559            form.find('select').each(function(){
1560                ba_jQuery(this).find('option').each(function(){
1561                    ba_jQuery(this).removeAttr('selected');
1562                });
1563            });
1564            form.find('.condition-area').removeClass('selected');
1565            form.find('.ba-form')[0].style.height = ''
1566            var redirect =  form.find('.redirect').val();
1567            if (redirect != '') {
1568                setTimeout(function(){
1569                    var redirect =  form.find('.redirect').val();
1570                    window.location = redirect;
1571                }, 2000);
1572            }
1573        }
1574        
1575        function listenMessage(event) {
1576            if (typeof(event.data) == 'object' && event.data.type == 'baform') {
1577                var payment = form.find('[name="task"]').val();
1578                if (payment == 'form.mollie') {
1579                    var message = event.data;
1580                    if (event.data.msg.indexOf('http') == -1) {
1581                        setTimeout(function(){
1582                            messageModal.find('.message img').addClass('reload-hide');
1583                            setTimeout(function(){
1584                                messageModal.find('.message').html('<div class="message-text">
1584'+event.data.msg+'</div>');
1585                            }, 500);
1586                        }, 1500);
1587                    } else {
1588                        location.href = event.data.msg;
1589                    }
1590                    return false;
1591                }
1592                window.removeEventListener("message", listenMessage, false);
1593                form.find('.ba-captcha').find('input[type="text"]').val('');
1594                var mesage = ba_jQuery(iframe).contents().find('#form-sys-mesage').val();
1595                setTimeout(function(){
1596                    messageModal.find('.message img').addClass('reload-hide');
1597                    setTimeout(function(){
1598                        messageModal.find('.message').html('<div class="message-text">'+mesage+'</div>');
1599                    }, 500);
1600                }, 1500);
1601                var success = form.find('.sent-massage').val();
1602                if (popupModal.length > 0) {
1603                    form.closest('.popup-form').ba_modal('hide');
1604                    form.closest('modal-scrollable').hide();
1605                }
1606                if (success == mesage) {
1607                    clearFields();
1608                }
1609            }
1610        }
1611        
1612        messageModal.on('show', function(){
1613            window.addEventListener("message", listenMessage, false);
1614        });
1615        messageModal.on('hide', function(){
1616            window.removeEventListener("message", listenMessage, false);
1617            messageModal.parent().addClass('hide-animation');
1618            setTimeout(function(){
1619                messageModal.parent().removeClass('hide-animation');
1620            }, 500);
1621        });
1622
1623        var now = new Date();
1624        now = new Date(now.getFullYear(), now.getMonth(), now.getDate()).valueOf();
1625
1626        baForm.find('.tool.ba-date').each(function(){
1627            var text = ba_jQuery(this).find('input[type="text"]').attr('id'),
1628                flag = false;
1629            if (ba_jQuery(this).hasClass('disable-previous-date')) {
1630                flag = true;
1631            }
1632            Calendar.setup({
1633                inputField: text,
1634                ifFormat: "%d %B %Y",
1635                align: "Tl",
1636                singleClick: true,
1637                firstDay: 0,
1638                disableFunc: function(date){
1639                    if (flag) {
1640                        var date = new Date(date);
1641                        date = new Date(date.getFullYear(), date.getMonth(), date.getDate()).valueOf()
1642                        if (now > date) {
1643                            return true;
1644                        } else {
1645                            return false;
1646                        }
1647                    } else {
1648                        return false;
1649                    }
1650                },
1651            });
1652        });
1653        
1654        baForm.find('.ba-textInput input').on('keyup', function(){
1655            var type = ba_jQuery(this).attr('data-type'),
1656                value = ba_jQuery(this).val();
1657            if (type == 'number') {
1658                if (ba_jQuery.isNumeric(value)) {
1659                    ba_jQuery(this).removeClass('ba-alert');
1660                } else {
1661                    ba_jQuery(this).addClass('ba-alert');
1662                }
1663            }
1664        });
1665
1666        if (baForm.find('.ba-form .btn-next').length > 0) {
1667            baForm.find('.ba-submit-cell').hide();
1668        }
1669        
1670        baForm.find('.ba-form .btn-next').on('click', function() {
1671            setTimeout(refreshMap, 100)
1672            var parent = ba_jQuery(this).parent().parent(),
1673                id = parent.attr('class'),
1674                formParent = form.find('.ba-form');
1675                n = id.substr(5),
1676                position = formParent.offset().top;
1677            checkAlert(parent);
1678            if (parent.find('.ba-alert').length == 0) {
1679                var height = formParent.height(),
1680                    nextParent = formParent.find('.page-'+(++n)),
1681                    title = formParent.find(' > .ba-row');
1682                if (title.length > 0) {
1683                    title = title.height();
1684                }
1685                if (nextParent.find('.btn-next').length == 0) {
1686                    formParent.find('.ba-submit-cell').show();
1687                }
1688                nextParent.find('.condition-area.selected').css('height', '');
1689                formParent.height(height);
1690                parent.hide();
1691                nextParent.show();
1692                height = nextParent.height();
1693                height += formParent.find('.ba-form-footer').height();
1694                if (typeof(title) == 'number') {
1695                    height += title;
1696                }
1697                parent.closest('.ba-form').height(height);
1698            } else {
1699                var alert = parent.find('.ba-alert').first();
1700                if (!alert.hasClass('tool')) {
1701                    alert = alert.closest('.tool');
1702                }
1703                position = alert.offset().top - 150;
1704            }
1705            ba_jQuery('html, body').animate({
1706                scrollTop: position
1707            }, 'slow');
1708        });
1709        
1710        baForm.find('.tool input[type="text"], .tool textarea').on('blur', function(){
1711            if (ba_jQuery(this).hasClass('ba-alert')) {
1712                var value = ba_jQuery(this).val(),
1713                    type = ba_jQuery(this).attr('data-type');
1714                if (ba_jQuery.trim(value) != '') {
1715                    if (type == 'number') {
1716                        if (ba_jQuery.isNumeric(value)) {
1717                            ba_jQuery(this).removeClass('ba-alert');
1718                        }
1719                    } else if (type == 'calculation') {
1720
1721                    } else {
1722                        ba_jQuery(this).removeClass('ba-alert');
1723                    }
1724                }
1725            }
1726        });
1727        
1728        baForm.find('.tool input[type="email"]').on('blur', function(){
1729            if (ba_jQuery(this).hasClass('ba-alert')) {
1730                var reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/,
1731                    value = ba_jQuery(this).val();
1732                if(reg.test(value)) {
1733                    ba_jQuery(this).removeClass('ba-alert');
1734                }                
1735            }
1736        });
1737        
1738        baForm.find('.tool select').on('change', function(){
1739            if (ba_jQuery(this).hasClass('ba-alert')) {
1740                var value = ba_jQuery(this).val();
1741                if (ba_jQuery.trim(value) != '') {
1742                    ba_jQuery(this).removeClass('ba-alert');
1743                }
1744            }
1745        });
1746        
1747        baForm.find('.tool input[type="checkbox"], .tool input[type="radio"]').on('change', function(){
1748            ba_jQuery(this).closest('.tool').removeClass('ba-alert');
1749        });
1750        
1751        baForm.find('.ba-form .btn-prev').on('click', function(){
1752            setTimeout(refreshMap, 50)
1753            var parent = ba_jQuery(this).parent().parent(),
1754                id = parent.attr('class'),
1755                n = id.substr(5),
1756                formParent = form.find('.ba-form');
1757                height = formParent.height(),
1758                nextParent = parent.parent().find('.page-'+(--n)),
1759                title = formParent.find(' > .ba-row');
1760            formParent.find('.ba-submit-cell').hide();
1761            if (title.length > 0) {
1762                title = title.height();
1763            }
1764            formParent.height(height);
1765            parent.hide();
1766            nextParent.show();
1767            height = nextParent.height();
1768            height += formParent.find('.ba-form-footer').height();
1769            if (typeof(title) == 'number') {
1770                height += title;
1771            }
1772            parent.closest('.ba-form').height(height);
1773            var position = formParent.offset().top;
1774            ba_jQuery('html, body').animate({
1775                scrollTop: position
1776            }, 'slow');
1777        });
1778        
1779        refreshMap();
1780        conditionShow();
1781
1782        function decimalAdjust(type, value, exp)
1783        {
1784            if (typeof exp === 'undefined' || +exp === 0) {
1785                return Math[type](value);
1786            }
1787            value = +value;
1788            exp = +exp;
1789            if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) {
1790                return NaN;
1791            }
1792            value = value.toString().split('e');
1793            value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp)));
1794            value = value.toString().split('e');
1795            return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp));
1796        }
1797
1798        if (!Math.round10) {
1799            Math.round10 = function(value, exp) {
1800                return decimalAdjust('round', value, exp);
1801            };
1802        }
1803        
1804        var prices = new Array();
1805        baForm.find('input[type="radio"][data-price]').each(function(){
1806            baForm.find('input[name="'+this.name+'"]:not([data-price])').attr('data-price', 0);
1807        });
1808        baForm.find('input[data-price]').on('change', function(event){
1809            var price = jQuery(this).attr('data-price') * 1,
1810                name = jQuery(this).attr('name'),
1811                total = baTotal.find('.ba-price').text() * 1,
1812                label = jQuery(this).val(),
1813                array = label.split(' - '),
1814                coast = '';
1815            if (price) {
1816                coast = array[array.length - 1];
1817                label = label.replace(' - '+coast, '');
1818            }
1819            if (jQuery(this).attr('type') == 'radio') {
1820                if (!prices[name]) {
1821                    if (coast) {
1822                        prices[name] = price;
1823                        addToCart(label, coast, name, price);
1824                    }
1825                    var radio = jQuery(this).closest('div').find('input[name="'+name+'"]').not('[data-price]');
1826                    radio.off('click.ba_total')
1827                    radio.one('click.ba_total', function(){
1828                        var name = jQuery(this).attr('name'),
1829                            total = baTotal.find('.ba-price').text()*1
1830                        if (cart.length > 0) {
1831                            var quantity = Math.round(cart.find('.product-cell[data-id="'+name+'"] .quantity input').val());
1832                            total = total - prices[name]  * quantity;
1833                        } else {
1834                            total = total - prices[name] * 1;
1835                        }
1836                        prices[name] = 0;
1837                        total = Math.round10(total, -2);
1838                        var pieces = String(total).split('.');
1839                        if (!pieces[1]) {
1840                            pieces[1] = '00';
1841                        } else if (pieces[1].length == 1) {
1842                            pieces[1] += '0';
1843                        }
1844                        pieces = pieces.join('.');
1845                        baTotal.find('.ba-price').text(pieces);
1846                        baTotal.find('input[name="ba_total"]').val(total);
1847                    });
1848                } else {
1849                    if (cart.length > 0) {
1850                        var quantity = Math.round(cart.find('.product-cell[data-id="'+name+'"] .quantity input').val());
1851                        total = total - prices[name]  * quantity;
1852                    } else {
1853                        total = total - prices[name] * 1;
1854                    }
1855                    cart.find('.product-cell[data-id="'+name+'"]').remove();
1856                    if (coast) {
1857                        addToCart(label, coast, name, price);
1858                    }
1859                    prices[name] = price;
1860                }
1861                total = total + price;
1862            } else {
1863                if (jQuery(this).prop('checked')) {
1864                    addToCart(label, coast, name, price);
1865                    total = total + price;
1866                } else {
1867                    var str = '.product-cell[data-id="'+name+'"][data-product="';
1868                    str += jQuery(event.currentTarget).val()+'"]';
1869                    if (cart.length > 0) {
1870                        var quantity = Math.round(cart.find(str).find('.quantity input').val());
1871                        total = total - price * quantity;
1872                    } else {
1873                        total = total - price * 1;
1874                    }
1875                    cart.find(str).remove();
1876                }
1877            }
1878            total = Math.round10(total, -2);
1879            var pieces = String(total).split('.');
1880            if (!pieces[1]) {
1881                pieces[1] = '00';
1882            } else if (pieces[1].length == 1) {
1883                pieces[1] += '0';
1884            }
1885            pieces = pieces.join('.');
1886            baTotal.find('.ba-price').text(pieces);
1887            baTotal.find('input[name="ba_total"]').val(total);
1888        });
1889        
1890        baForm.find('.tool select').on('change', function(){
1891            if (jQuery(this).find('[data-price]').length > 0) {
1892                var value = jQuery(this).val(),
1893                    option = jQuery(this).find('option[value="'+value+'"]'),
1894                    price = option.attr('data-price')*1,
1895                    name = jQuery(this).attr('name'),
1896                    total = baTotal.find('.ba-price').text() * 1;
1897                if (isNaN(price)) {
1898                    price = 0;
1899                }
1900                if (jQuery(this).attr('multiple')) {
1901                    if (!prices[name]) {
1902                        prices[name] = new Array();
1903                    } else {
1904                        for (var i = 0; i < prices[name].length; i++) {
1905                            var str = '.product-cell[data-id="'+name+'"]';
1906                            str += '[data-product="'+prices[name][i].value+'"]'
1907                            if (cart.length > 0) {
1908                                var quantity = Math.round(cart.find(str).find('.quantity input').val());
1909                                total = total - prices[name][i].price  * quantity;
1910                            } else {
1911                                total = total - prices[name][i].price * 1;
1912                            }
1913                            cart.find(str).first().remove();
1914                        }
1915                        prices[name] = [];
1916                    }
1917                    if (jQuery(this).val()) {
1918                        for (var i = 0; i < value.length; i++) {
1919                            var label = value[i],
1920                                array = label.split(' - '),
1921                                coast = '';
1922                            option = jQuery(this).find('option[value="'+value[i]+'"]');
1923                            price = option.attr('data-price')*1;
1924                            if (price) {
1925                                coast = array[array.length - 1];
1926                                label = label.replace(' - '+coast, '');
1927                            }
1928                            if (!isNaN(price)) {
1929                                addToCart(label, coast, name, price);
1930                                var obj = {
1931                                    price : price,
1932                                    value : value[i]
1933                                }
1934                                prices[name].push(obj);
1935                                total  = total + price;
1936                            }                            
1937                        }
1938                    }
1939                } else {
1940                    var label = jQuery(this).val(),
1941                        array = label.split(' - '),
1942                        coast = '';
1943                    if (price) {
1944                        coast = array[array.length - 1];
1945                        label = label.replace(' - '+coast, '');
1946                    }
1947                    if (!prices[name]) {
1948                        if (coast) {
1949                            prices[name] = price;
1950                            addToCart(label, coast, name, price);
1951                        }
1952                    } else {
1953                        if (cart.length > 0) {
1954                            var quantity = Math.round(cart.find('.product-cell[data-id="'+name+'"] .quantity input').val());
1955                            total = total - prices[name]  * quantity;
1956                        } else {
1957                            total = total - prices[name] * 1;
1958              
1958          }
1959                        prices[name] = price;
1960                        cart.find('.product-cell[data-id="'+name+'"]').remove();
1961                        if (coast) {
1962                            addToCart(label, coast, name, price);
1963                        }
1964                    }
1965                    total = total + price;
1966                }
1967                total = Math.round10(total, -2);
1968                var pieces = String(total).split('.');
1969                if (!pieces[1]) {
1970                    pieces[1] = '00';
1971                } else if (pieces[1].length == 1) {
1972                    pieces[1] += '0';
1973                }
1974                pieces = pieces.join('.');
1975                baTotal.find('.ba-price').text(pieces);
1976                baTotal.find('input[name="ba_total"]').val(total);
1977            }
1978        });
1979
1980
1981
1982        if (!form.parent().hasClass('ba-modal-body')) {
1983            form.find('.tool select').each(function(){
1984                var $this = ba_jQuery(this);
1985                if ($this.val()) {
1986                    $this.trigger('change');
1987                }
1988            });
1989            form.find('input[checked]').trigger('change');
1990            form.find('input[checked]').each(function(){
1991            	if (jQuery(this).closest('span').hasClass('ba-input-image')) {
1992	            	jQuery(this).closest('span').css('border', '2px solid '+theme);
1993	            }
1994            });
1995        }
1996        
1997        baForm.find('.popup-btn').on('click', function(event){
1998            event.preventDefault();
1999            ba_jQuery('body').addClass('ba-forms-modal');
2000            popupModal.ba_modal();
2001            popupModal.on('hide', function(){
2002                var scrollable = popupModal.parent();
2003                ba_jQuery('body').removeClass('ba-forms-modal');
2004                scrollable.addClass('hide-animation');
2005                setTimeout(function(){
2006                    scrollable.removeClass('hide-animation');
2007                }, 500);
2008            });
2009            setTimeout(function(){
2010                form.find('.tool select').trigger('change');
2011                form.find('input[checked]').trigger('change');
2012            }, 600);
2013            popupModal.parent().show();
2014            setTimeout(refreshMap, 300);
2015        });
2016        
2017        baForm.find('.tool').find('input[type=file]').on('change', prepareUpload);
2018        
2019        baForm.find('.ba-form').parent().on('submit', sendMessage);
2020        if (baForm.find('.popup-btn').length > 0) {
2021            if (baForm.find('.popup-btn')[0].localName == 'a') {
2022                var id = baForm.find('[name="form_id"]').val();
2023                jQuery('.baform-replace').each(function(){
2024                    if (jQuery.trim(jQuery(this).text()) == '[forms ID='+id+']') {
2025                        jQuery(this).replaceWith(baForm.find('.popup-btn')[0])
2026                        return false;
2027                    }
2028                })
2029            }
2030        }
2031
2032        baForm.find('.ba-modal-close').on('click', function(event){
2033            event.preventDefault();
2034            ba_jQuery(this).parent().ba_modal('hide');
2035        });
2036        baForm.find('.ba-lightbox-image img').on('click.lightbox', function(){
2037            jQuery('.ba-image-backdrop').remove();
2038            var div = document.createElement('div'),
2039                width = this.width,
2040                height = this.height,
2041                backdrop = document.createElement('div'),
2042                offset = jQuery(this).offset(),
2043                imgHeight = this.naturalHeight,
2044                modalTop,
2045                imgWidth = this.naturalWidth,
2046                modal = jQuery(div),
2047                target = jQuery(window).height()-100,
2048                flag = true,
2049                img = document.createElement('img'),
2050                left,
2051                wWidth = jQuery(window).width()*1,
2052                wHeigth = jQuery(window).height()*1,
2053                bg = jQuery(this).attr('data-lightbox');
2054            img.src = this.src;
2055            div.className = 'ba-image-modal';
2056            div.style.top = offset.top * 1 - jQuery(window).scrollTop() * 1+'px';
2057            div.style.left = offset.left+'px';
2058            div.style.width = width+'px';
2059            div.appendChild(img);
2060            img.style.width = width+'px';
2061            img.style.height = height+'px';
2062            backdrop.className = 'ba-image-backdrop';
2063            backdrop.style.backgroundColor = bg;
2064            jQuery(backdrop).on('click', function(){
2065                jQuery(this).addClass('image-lightbox-out');
2066                modal.animate({
2067                    'width' : width,
2068                    'height' : height,
2069                    'left' : offset.left,
2070                    'top' : offset.top * 1 - jQuery(window).scrollTop() * 1
2071                }, '500', function(){
2072                    jQuery('.ba-image-backdrop').remove();
2073                });
2074                modal.find('img').animate({
2075                    'width' : width,
2076                    'height' : height,
2077                    'left' : offset.left,
2078                    'top' : offset.top * 1 - jQuery(window).scrollTop() * 1
2079                }, '500');
2080            });
2081            jQuery('body').append(div);
2082            modal.wrap(backdrop);
2083            if (wWidth > 1024) {
2084                if (imgWidth * 1 < wWidth && imgHeight * 1 < wHeigth) {
2085                
2086                } else {
2087                    if (imgWidth > imgHeight) {
2088                        var percent = target/imgWidth;
2089                        flag = false;
2090                    } else {
2091                        var percent = target/imgHeight;
2092                        flag = true;
2093                    }
2094                    imgWidth = imgWidth * percent;
2095                    imgHeight = imgHeight * percent;
2096                    if (imgWidth > wWidth) {
2097                        imgWidth = imgWidth * percent;
2098                        imgHeight = imgHeight * percent;
2099                    }
2100                    if (!flag) {
2101                        var percent = imgWidth / imgHeight;
2102                        imgHeight = target;
2103                        imgWidth = imgHeight * percent;
2104                        if (wWidth - 100 < imgWidth) {
2105                            imgWidth = wHeigth - 100;
2106                            imgHeight = imgWidth / percent;
2107                        }
2108                    }
2109                }
2110            } else {
2111                var percent = imgWidth / imgHeight;
2112                if (percent >= 1) {
2113                    imgWidth = wWidth * 0.90;
2114                    imgHeight = imgWidth / percent;
2115                    if (wHeigth - imgHeight < wHeigth * 0.1) {
2116                        imgHeight = wHeigth * 0.90;
2117                        imgWidth = imgHeight * percent;
2118                    }
2119                } else {
2120                    imgHeight = wHeigth * 0.90;
2121                    imgWidth = imgHeight * percent;
2122                    if (wWidth -imgWidth < wWidth * 0.1) {
2123                        imgWidth = wWidth * 0.90;
2124                        imgHeight = imgWidth / percent;
2125                    }
2126                }
2127            }
2128            modalTop = (wHeigth - imgHeight)/2;
2129            left = (wWidth - imgWidth)/2;
2130            modal.animate({
2131                'width' : Math.round(imgWidth),
2132                'height' : Math.round(imgHeight),
2133                'left' : Math.round(left),
2134                'top' : Math.round(modalTop)
2135            }, '500');
2136            modal.find('img').animate({
2137                'width' : Math.round(imgWidth),
2138                'height' : Math.round(imgHeight),
2139                'left' : Math.round(left),
2140                'top' : Math.round(modalTop)
2141            }, '500');
2142        });
2143            
2144        function addToCart(product, price, id, cost)
2145        {
2146            if (cart.length > 0) {
2147                var str = '<div class="product-cell" data-id="'+id;
2148                str += '" data-product="'+product+' - '+price;
2149                str += '"><div class="product">';
2150                str += product+'</div><div class="price">';
2151                var pieces = String(cost).split('.');
2152                if (!pieces[1]) {
2153                    pieces[1] = '00';
2154                } else if (pieces[1].length == 1) {
2155                    pieces[1] += '0';
2156                }
2157                pieces = pieces.join('.');
2158                if (symbolPos == 'before') {
2159                    pieces = symbol + pieces;
2160                } else {
2161                    pieces = pieces + symbol;
2162                }
2163                str += pieces+'</div><div class="quantity"><input type="number" ';
2164                str += 'value="1" min="1" step="1" data-cost="'+cost;
2165                str += '"></div><div class="total">'+pieces;
2166                str += '</div><div class="remove-item"><i class="zmdi zmdi';
2167                str += '-close"></i></div></div>';
2168                cart.append(str);
2169                cart.find('.remove-item i.zmdi').off('click');
2170                cart.find('.remove-item i.zmdi').on('click', removeCart);
2171                cart.find('.quantity input').off('click keyup blur').on('click keyup', function(){
2172                    var value = jQuery(this).val(),
2173                        price = jQuery(this).attr('data-cost'),
2174                        cost;
2175                    if (value < 1) {
2176                        value = 1;
2177                    }
2178                    value = Math.round(value);
2179                    cost = value * price;
2180                    cost = Math.round10(cost, -2);
2181                    var pieces = String(cost).split('.');
2182                    if (!pieces[1]) {
2183                        pieces[1] = '00';
2184                    } else if (pieces[1].length == 1) {
2185                        pieces[1] += '0';
2186                    }
2187                    cost = pieces.join('.');
2188                    if (symbolPos == 'before') {
2189                        cost = symbol + cost;
2190                    } else {
2191                        cost = cost + symbol;
2192                    }
2193                    var total = baTotal.find('.ba-price').text()*1,
2194                        currentPrice = jQuery(this).closest('.product-cell').find('.total').text();
2195                    currentPrice = currentPrice.replace(symbol, '');
2196                    total = total - currentPrice;
2197                    total = total + price * value;
2198                    total = Math.round10(total, -2);
2199                    pieces = String(total).split('.');
2200                    if (!pieces[1]) {
2201                        pieces[1] = '00';
2202                    } else if (pieces[1].length == 1) {
2203                        pieces[1] += '0';
2204                    }
2205                    pieces = pieces.join('.');
2206                    baTotal.find('.ba-price').text(pieces);
2207                    baTotal.find('input[name="ba_total"]').val(total);
2208                    jQuery(this).closest('.product-cell').find('.total').text(cost);
2209                }).on('blur', function(){
2210                    if (this.value < 1) {
2211                        this.value = 1;
2212                    }
2213                });
2214                cart.closest('.ba-form')[0].style.height = '';
2215            }
2216        }
2217
2218        function removeCart()
2219        {
2220            var item = jQuery(this).closest('.product-cell'),
2221                id = item.attr('data-id'),
2222                value = item.attr('data-product'),
2223                element = jQuery('[name="'+id+'"]'),
2224                price = item.find('.total').text();
2225            if (element.attr('type') == 'checkbox') {
2226                jQuery('[name="'+id+'"][value="'+value+'"]').prop('checked', false).trigger('change');
2227                jQuery('[name="'+id+'"][value="'+value+'"]').closest('span').css('border', '');
2228            } else if (element.attr('type') == 'radio') {
2229                var total = baTotal.find('.ba-price').text()*1,
2230                    quantity = Math.round(cart.find('.product-cell[data-id="'+id+'"] .quantity input').val());
2231                total = total - prices[id]  * quantity;
2232                delete(prices[id]);
2233                total = Math.round10(total, -2);
2234                baTotal.find('.ba-price').text(total);
2235                baTotal.find('input[name="ba_total"]').val(total);
2236                item.remove();
2237                var input = jQuery('[name="'+id+'"][value="'+value+'"]');
2238                input.prop('checked', false).closest('span').css('border', '');
2239                if (input.closest('.tool').find('> .condition-area').length > 0) {
2240                    input.closest('.tool').find('> .condition-area.selected').removeClass('selected');
2241                    clearCondition(input.closest('.tool').find('> .condition-area'));
2242                }
2243            } else {
2244                element.find('option[value="'+value+'"]').removeAttr('selected');
2245                if (!element.attr('multiple')) {
2246                    element.find('option').first().attr('selected', true);
2247                }
2248                element.trigger('change');
2249            }
2250            element.closest('.ba-form')[0].style.height = '';
2251        }
2252
2253        if (saveContinue == 1) {
2254            baForm.find('.get-save-continue').on('click', function(event){
2255                event.preventDefault();
2256                var obj = {};
2257                form.find('input[type="text"][name], textarea[name], input[type="email"][name]').each(function(){
2258                    var name = this.name,
2259                        value = this.value;
2260                    value = jQuery.trim(value);
2261                    obj[name] = value;
2262                });
2263                form.find('input[type="radio"][name]').each(function(){
2264                    if (jQuery(this).prop('checked')) {
2265                        var name = this.name,
2266                            value = this.value;
2267                        value = jQuery.trim(value);
2268                        obj[name] = value;
2269                    }
2270                });
2271                form.find('input[type="checkbox"][name]').each(function(i){
2272                    var name = this.name,
2273                        key,
2274                        value;
2275                    if (!obj[name]) {
2276                        obj[name] = {};
2277                    }
2278                    if (jQuery(this).prop('checked')) {
2279                        value = this.value;
2280                        value = jQuery.trim(value);
2281                        obj[name][i] = value;
2282                    }
2283                });
2284                form.find('select[name]').each(function(){
2285                    var name = this.name,
2286                        key,
2287                        value;
2288                    if (!obj[name]) {
2289                        obj[name] = {};
2290                    }
2291                    jQuery(this).find('option').each(function(i){
2292                        if (jQuery(this).prop('selected')) {
2293                            value = this.value;
2294                            value = jQuery.trim(value);
2295                            obj[name][i] = value;
2296                        }
2297                    });
2298                });
2299                if (form.find('.ba-terms-conditions.tool').length > 0) {
2300                    var key = 0;
2301                    if (jQuery('.ba-terms-conditions.tool input').prop('checked')) {
2302                        key = 1;
2303                    }
2304                    obj.terms = key;
2305                }
2306                form.find('.ba-slider-values').each(function(){
2307                    var name = this.name,
2308                        value = this.value;
2309                    obj[name] = value;
2310                });
2311                obj = JSON.stringify(obj);
2312                var token = saveModal.find('.save-popup-token').val(),
2313                    url = window.location.href,
2314                    message = saveModal.find('.save-popup-message').val(),
2315                    link = '<p class="ba-token" ',
2316                    pos;
2317                if (url.indexOf('?') > 0) {
2318                    if ((pos = token.indexOf('bf_token=')) > 0) {
2319                        url = url.substr(0, pos);
2320                        url += 'bf_token='+token;
2321                    } else {
2322                        url += '&bf_token='+token;
2323                    }
2324                } else {
2325                    url += '?bf_token='+token;
2326                }
2327                link += '>
2327'+url+'</p>';
2328                message = message.replace('[ba-form-token-link]', link);
2329                saveModal.find('.save-message').html(message);
2330                saveModal.ba_modal();
2331                saveModal.parent().show();
2332                jQuery.ajax({
2333                    type:"POST",
2334                    dataType:'text',
2335                    url:"?option=com_baforms&task=form.getToken&tmpl=component",
2336                    data : {
2337                        data : obj,
2338                        ba_token : token
2339                    },
2340                    success: function(msg){
2341                    }
2342                });
2343            });
2344            saveModal.on('hide', function(){
2345                saveModal.parent().addClass('hide-animation');
2346                setTimeout(function(){
2347                    saveModal.parent().removeClass('hide-animation');
2348                }, 500);
2349            });
2350            baForm.find('.send-save').on('click', function(event){
2351                event.preventDefault();
2352                var $this = jQuery(this),
2353                	wrapper = $this.closest('.save-email-wrapper'),
2354                	container = $this.closest('.ba-modal-body'),
2355                    link = container.find('.ba-token').text(),
2356                    email = container.find('.save-email').val(),
2357                    obj = {},
2358                    reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/;
2359                if(!reg.test(email)) {
2360                    container.find('.save-email').addClass('ba-alert');
2361                } else {
2362                	if ($this.attr('data-disable')) {
2363                		return false;
2364                	}
2365                	$this.attr('data-disable', true);
2366                	wrapper.addClass('save-animation-in');
2367                	setTimeout(function(){
2368                		wrapper.removeClass('save-animation-in').addClass('save-animation-out');
2369                		setTimeout(function(){
2370                			wrapper.removeClass('save-animation-out');
2371                			$this.removeAttr('data-disable');
2372                		}, 2000);
2373                	}, 2000);
2374                    container.find('.save-email').removeClass('ba-alert');
2375                    jQuery.ajax({
2376                        type : "POST",
2377                        dataType : 'text',
2378                        url : "?option=com_baforms&task=form.saveContinue&tmpl=component",
2379                        data : {
2380                            ba_link : link,
2381                            ba_email : email,
2382                            form_id : form.find('[name="form_id"]').val()
2383                        },
2384                        success: function(msg){
2385                            
2386                        }
2387                    });
2388                }
2389            });
2390            var obj = form.find('.ba-token-data').val();
2391            if (obj) {
2392                obj = JSON.parse(obj);
2393                baForm.find('.tool input[name], .tool textarea[name], .tool select[name]').each(function(){
2394                    if (this.localName == 'textarea' || this.type == 'text' || this.type == 'email') {
2395                        this.value = obj[this.name];
2396                        jQuery(this).trigger('change').trigger('keyup').trigger('input');
2397                    } else if (this.type == 'radio') {
2398                        if (this.value.trim() == obj[this.name]) {
2399                            jQuery(this).prop('checked', true).trigger('change').trigger('click').trigger('input');
2400                        }
2401                    } else if (this.type == 'checkbox') {
2402                        var name = this.name;
2403                        if (obj[name]) {
2404                            for (key in obj[name]) {
2405                                if (this.value.trim() == obj[name][key]) {
2406                                    jQuery(this).prop('checked', true);
2407                                    break;
2408                                }
2409                            }
2410                        }
2411                    } else if (this.localName == 'select') {
2412                        var name = this.name;
2413                        if (obj[name]) {
2414                            jQuery(this).find('option').each(function(){
2415                                for (key in obj[name]) {
2416                                    if (this.value.trim() == obj[name][key]) {
2417                                        jQuery(this).attr('selected', true);
2418                                        break;
2419                                    }
2420                                }
2421                            });
2422                            jQuery(this).trigger('change').trigger('click').trigger('input');
2423                        }
2424                    }
2425                });
2426                if (jQuery('.ba-terms-conditions.tool').length > 0) {
2427                    var key = obj.terms;
2428                    if (key == 1) {
2429                        jQuery('.ba-terms-conditions.tool input').prop('checked', true);
2430                    }
2431                }
2432            }
2433        }
2434
2435        baForm.find('.ba-slider').each(function(){
2436            var options = ba_jQuery(this).parent().find('.ba-options').val(),
2437                values = new Array(),
2438                input = jQuery(this).closest('.tool').find('.ba-slider-values')[0],
2439                name = input.name;
2440            options = options.split(';');
2441            values.push(options[2]);
2442            values.push(options[3]);
2443            if (saveContinue == 1 && obj && obj[name]) {
2444                values = obj[name].split(' — ');
2445            }
2446            ba_jQuery(this).slider({
2447                min: options[2],
2448                max: options[3],
2449                step: options[4],
2450                value: [values[0], values[1]]
2451            });
2452        });
2453    });
2454});

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.