PageSourceSearch

https://luk-opttorg.ru/d/3000/t/v6683/images/scripts/main2.js?v=8&r=1791334465

js luk-opttorg.ru collected 2026-10-07 00:54:49 UTC 67,138 bytes, 2,255 lines download raw bytes

1$('.shop2-cart-preview').eq(0).removeClass('new-year-bask');
2
3
4shop2.queue.filter= function(){
5	
6			var wrap = $('.shop2-filter'),
7			result = $('.result');
8
9			shop2.filter.init();
10
11			shop2.on('afterGetSearchMatches', function (d, status) {
12
13				if (d.data.total_found === 0) {
14
15					result.addClass('no-result');
16				} else {
17					result.removeClass('no-result');
18				}
19
20				if (shop2.checkbox) {
21					$('.filter-result').html(d.data.total_found);
22					result.addClass('hide');
23				} else {
24					$('#filter-result').html(d.data.total_found);
25					result.removeClass('hide');
26				}
27				
28				shop2.checkbox = false;
29				
30			});
31
32			wrap.find('.param-val').on('click', function(e) {
33				$('.how-many-checkbox').remove();
34				var $this = $(this),
35					name = $this.data('name'),
36					value = $this.data('value');
37
38				e.preventDefault();
39
40				$this.toggleClass('active-val');
41				shop2.filter.toggle(name, value);
42				shop2.filter.count();
43			});
44			var search_list_params = $('.youre-searching ul'), secondClassName='secondSelect';
45			wrap.find('select').on('change', function() {
46				$('.how-many-checkbox').remove();
47				var $this = $(this),
48					name = this.name,
49					value = $this.val(),
50					text = $this.find(':selected').text(),clName = secondClassName;
51					
52				if (name == 's[folder_id]') clName = "firstSelect";
53
54				shop2.filter.add(name, value);
55				shop2.filter.count();
56				
57				if (search_list_params.find('li.'+clName).length > 0){
58					search_list_params.find('li.'+clName).remove();
59					
60				}
61				var li = $('<li></li>').text(text).addClass(clName);
62				
63				if (clName == 'firstSelect'){
64					search_list_params.prepend(li);
65				} else {
66					search_list_params.append(li);
67				}
68			});
69			if($('select[name=s\\[luke_sizes\\]]:visible')){
70				if(search_list_params.find('li.'+secondClassName).length==0)
71				search_list_params.append($('<li/>', {"text": $('select[name=s\\[luke_sizes\\]]:visible option:selected').text(), "class": secondClassName}));
72			}
73			wrap.find('input:checkbox').on('change', function() {
74				$('.how-many-checkbox').remove();
75				var $this = $(this),
76					name = this.name,
77					value = $this.val(),
78					text = $this.parents('label').text(),
79					ul = $('.youre-searching ul');
80				
81				$this.parents('label').prepend('<div class="how-many-checkbox result"><span class="filter-result"></span></div>');
82				if (!$this.prop('checked')) $('.how-many-checkbox').remove();
83				shop2.checkbox = true;
84				shop2.filter.add(name, value);
85				shop2.filter.count();
86				
87				if (ul.find('li:contains('+text+')').length > 0){
88					ul.find('li:contains('+text+')').remove();
89				} else {
90					ul.append('<li>'+text+'</li>');
91				}
92				
93			});
94
95			wrap.find('input:text').keyup(function() {
96				$('.how-many-checkbox').remove();
97				var $this = $(this),
98					name = $this.attr('name');
99
100				$.s3throttle('filter: ' + name, function() {
101					var value = $this.val();
102
103					shop2.filter.add(name, value);
104					shop2.filter.count();
105				}, 500);
106			});
107
108			wrap.find('.shop2-filter-go').on('click', function(e) {
109				$('.how-many-checkbox').remove();
110				e.preventDefault();
111				shop2.filter.go();
112			});
113			
114			if (wrap.length > 0){
115				var isMaster = wrap.find('input[name="s[is_master]"]');
116				shop2.filter.add(isMaster.attr('name'), isMaster.val());
117			}
118	}
119
120
121$(function() {
122	var isTest = /test=1/.test(location.href);
123	
124	/**
125	 * В детальной товара подгружает таблицу с модификациями
126	 * @author [email protected]
127	 */
128	  if( $('#size_table').length) { // && getParameterByName('sdem')
129	  	isTest = true;
130	  	var test = isTest ? '&no_table=1' : '';
131	  	$.ajax({
132	    	url: '?ajx=1&ajax_table=1&jx=1&sdem=1' + test,
133	    	data: {},
134	    	dataType: "html",
135	    	type: "get",
136	    	success: function(res){
137	    		$('.table-preloader').remove();
138	      		var table = $("#size_table", $(res)).html();
139	      		$('#size_table').append(table);
140     			if(getParameterByName("old")!=1){deleteEmptyColumns();
141				$('.size-main-row').scroll(function(){
142					$('.pr-popup').fadeOut('fast').removeClass('opened');
143				});
144     			}
145     			
146				$('.size-main-row .pr:not(.nav)').mouseenter(function(event){
147					
148					var elemIndex = $(this).index() - 1;
149				
150					$('.first-line .sz:not(.empty)').eq(elemIndex).addClass('js-hover');
151					$('.last-line .sz:not(.empty)').eq(elemIndex).addClass('js-hover');
152					$('.size-main-row .white-row.clearfix').find("[data-id]:nth-child(" + (elemIndex + 2) + ")").addClass('js-hovered')
153					
154					$(this).closest('.white-row').addClass('active').find('.pr.nav').addClass('js-hover');
155				
156				});
157				
158				$('.size-main-row .pr:not(.nav)').mouseleave(function(event) {
159					$('.white-row').removeClass('active');
160					$('.sz, .pr').removeClass('js-hover');
161					$('.size-main-row .white-row.clearfix').find("[data-id]").removeClass('js-hovered')
162				});
163	      		
164	    	}//success
165	  	});	  	
166	  }
167	
168	/**
169     * загружает отзывы на главной
170     * 
171     * @author kirill.sadovnikov [email protected]
172     * @date        2016-04-27
173     * @anotherdate 2016-04-27T16:03:37+0300
174     */
175	if(location.pathname === "/"){
176		$.get("/otzyvy?ajx=1").done(function(data){
177			var obj = $.parseJSON(data);
178			var reviewsDiv = $('div').find('.spec-n-reviews_reviews');
179			
180			obj.forEach(function(v,k){
181				if (k > 2) return;
182				
183				var post_body = v.post_body.replace(/&amp;quot;/gi, '"').replace(/&quot;/gi, '"');
184				var post_name = v.post_name.replace(/&amp;quot;/gi, '"').replace(/&quot;/gi, '"');
185				var div = $('<div>', {'class' : 'review-block'})
186					.append($('<div>', {'class': 'text' , 'text': post_body}))
187					.append(
188						$('<div>', {'class': 'person'})
189							.append($('<span>', {'class': 'name', 'text': post_name}))
190							/*.append($('<span>', {'class': 'company', 'text': v.post_company}))*/
191					);
192		
193				reviewsDiv.append(div);
194			})
195		});
196	}
197	
198	$('[name="s[folder_id]"]').change(function(){
199		var id = $(this).val();
200		
201		if (id == "1259401") {
202			$('.search-tile-select').show().addClass('search-selects-block');
203		} else {
204			$('.search-tile-select').hide().removeClass('search-selects-block');
205			$('.youre-searching .secondSelect').remove();
206			$('.search-size-block').show();
207			$('.search-tile-block').hide();
208		}
209	});
210	
211	$('.search-tile-select').change(function(){
212		var id = $(this).find('.selected').index();
213
214		if (id === 0){
215			$('.search-size-block').show();
216			$('.search-tile-block').hide();
217		} else {
218			$('.search-size-block').hide();
219			$('.search-tile-block').show();
220		}
221	});
222	
223	
224	
225	
226	$('[name="payment_id"]').change(function(){
227		if($('[name="payment_id"]:checked').val()=="-23"){
228			$('.label-icons').show();
229		}else{
230			$('.label-icons').hide();
231		}
232	})
233	
234	
235	$('.star-rating label').on('click', function(e) {
236		$('[name="rating"]').val($(this).prev().val());
237		$(this).prev().prop('checked', true);
238	});
239	
240	
241});
242
243
244$(document).ready(function() {
245	
246	
247
248	
249	var IsMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
250	
251	function setCookie(name, value, props) {
252		props = props || {};
253		var exp = props.expires;
254		if (typeof exp == "number" && exp) {
255			var d = new Date();
256			d.setTime(d.getTime() + exp*1000);
257			exp = props.expires = d;
258		}
259		if(exp && exp.toUTCString) { props.expires = exp.toUTCString() }
260	
261		value = encodeURIComponent(value);
262		var updatedCookie = name + "=" + value;
263		for(var propName in props){
264			updatedCookie += "; " + propName;
265			var propValue = props[propName];
266			if(propValue !== true){ updatedCookie += "=" + propValue; }
267		}
268		document.cookie = updatedCookie;
269	}
270	
271	
272	if (IsMobile) {
273		
274	    $('.header-menu_item.catalog').on('click', function(e) {
275	    	e.preventDefault();
276	    	
277	    	if ( $(this).hasClass('active') ) {
278		        $(this).removeClass('active');
279		        $('.menu-catalog-popup').removeClass('active');
280	    	} else {
281		        $(this).addClass('active');
282		        $('.menu-catalog-popup').addClass('active');
283	    	}
284	    });
285		
286	    // Каталог - выпадающее меню
287	    $('.menu-catalog-popup').on('click', function() {
288	    	
289	    	if ( $(this).hasClass('active') ) {
290		        $(this).removeClass('active');
291		        $('.header-menu_item.catalog').removeClass('active');
292	    	} else {
293		        $(this).addClass('active');
294		        $('.header-menu_item.catalog').addClass('active');
295	    	}
296	    });
297	    
298	} else {
299
300	    $('.header-menu_item.catalog').hover(function() {
301	        $(this).addClass('active');
302	        $('.menu-catalog-popup').addClass('active');
303	        $('.my_shadow_wrap').addClass('active');
304	    }, function() {
305	        setTimeout(function () {
306	        	
307	        	/*$(this).removeClass('active');
308		        $('.menu-catalog-popup').removeClass('active');*/
309	        	
310	        },2000);
311	    });
312		
313	    // Каталог - выпадающее меню
314	    $('.menu-catalog-popup').hover(function() {
315	        $(this).addClass('active');
316	        $('.header-menu_item.catalog').addClass('active');
317	    }, function() {
318	    	setTimeout(function () {
319	    		
320		        /*$(this).removeClass('active');
321		        $('.header-menu_item.catalog').removeClass('active');*/
322	    	
323	    		
324	    	},2000);
325 	    });
326 	    
327 	    $(".menu-catalog-popup .menu-catalog-popup-close").click(function(){
328 	    	$('.header-menu .menu-catalog-popup').removeClass('active');
329 	    	$('.header-menu_item.catalog').removeClass('active');
330 	    });
331	}
332	
333	
334	// <!-- жесткая упаковка
335	function number_format( number, decimals, dec_point, thousands_sep ) {	// Format a number with grouped thousands
336		// 
337		// +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
338		// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
339		// +	 bugfix by: Michael White (http://crestidg.com)
340	
341		var i, j, kw, kd, km;
342	
343		// input sanitation & defaults
344		if( isNaN(decimals = Math.abs(decimals)) ){
345			decimals = 2;
346		}
347		if( dec_point == undefined ){
348			dec_point = ",";
349		}
350		if( thousands_sep == undefined ){
351			thousands_sep = ".";
352		}
353	
354		i = parseInt(number = (+number || 0).toFixed(decimals)) + "";
355	
356		if( (j = i.length) > 3 ){
357			j = j % 3;
358		} else{
359			j = 0;
360		}
361	
362		km = (j ? i.substr(0, j) + thousands_sep : "");
363		kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep);
364		//kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).slice(2) : "");
365		kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : "");
366	
367	
368		return km + kw + kd;
369	}
370	
371	var pricePack = 0;
372	if ($('.hard-pack').length) {
373		$.ajax({
374			url: '/katalog/product/zhestkaya-upakovka?pack=1',
375			success: function (data) {
376				pricePack = parseFloat($.trim(data));
377			}
378		});
379	}
380	
381	//console.log(pricePack);
382	
383	$('.hard-pack').on('change', function() {
384	
385		if (!pricePack) return;
386		//var pricePack = 500;
387		
388		if ($(this).val() == 'Да') {
389			
390			var hash = $('#hard-pack-block').data('hash');
391			
392			$.ajax({
393				url: '/katalog?mode=cart&action=del&kind_id=7142201',
394				async: false,
395				success: function (d) {
396					$.ajax({
397						url: '/my/s3/api/shop2/?cmd=cartAddItem',
398						type: 'post',
399						data: {
400							hash: hash,
401							ver_id: shop2.verId,
402							kind_id: 7142201,
403							amount: 1
404						},
405						success: function (d) {
406							$('.hard-pack-sum').text(pricePack + ' руб.');
407							$('.hard-pack-sum').closest('div.bot').show();
408							
409							var total = parseInt( $('.order-total-price').text().replace(/\s+/g, ''));
410							total += pricePack;
411							
412							total = number_format(total, 0, ' ', ' ');
413							$('.luke-im-your-father-sum .order-total-price').text(total);
414							
415							/*
416							var delivery_price = parseInt( $( "input[name=delivery_id]:checked" ).attr('data-cost') );
417							var delivery_total_sum = delivery_price + 450;
418							
419							var inner_del_price= number_format(delivery_total_sum, 0, ' ', ' ');
420							$('.delivery-total-sum').text(inner_del_price + " руб.");
421							
422							
423							var total = parseInt( $('.price-subtotal').text().replace(/\s+/g, ''));
424							total += 450;
425							
426							total = number_format(total, 0, ' ', ' ');
427							$('.luke-im-your-father-sum .order-total-price').text(total);
428							*/
429						}
430					});		
431				}
432			});
433			
434		} else if ($(this).val() == 'Нет') {
435			$.ajax({
436				url: '/katalog?mode=cart&action=del&kind_id=7142201',
437				async: false,
438				success: function (d) {
439					$('.hard-pack-sum').text(0 + ' руб.');
440					$('.hard-pack-sum').closest('div.bot').hide();
441					
442					var total = parseInt( $('.order-total-price').text().replace(/\s+/g, ''));
443					total -= pricePack;
444					
445					total = number_format(total, 0, ' ', ' ');
446					$('.luke-im-your-father-sum .order-total-price').text(total);
447					
448					/*
449					var delivery_price = parseInt( $( "input[name=delivery_id]:checked" ).attr('data-cost') );
450					var delivery_total_sum = delivery_price - 450;
451					
452					var inner_del_price= number_format(delivery_total_sum, 0, ' ', ' ');
453					$('.delivery-total-sum').text(inner_del_price + " руб.");
454					*/
455				}
456			});
457		}
458	});
459	// жесткая упаковка -->
460	
461	
462	
463	// фильтра в категории
464	$('.shop2-filter-submit').on('click', function () {
465		/*
466		var folderId = $('[name="s\[folder_id\]"]').val();
467	
468		if (!folderId) {
469			//$('[name="s\[folder_id\]"]').val($('[name="s\[folder_id\]"]').data('current'));
470			//console.log($('[name="s\[folder_id\]"]').val());
471		}
472		*/
473		
474		$('form.shop2-filter').submit();
475	});
476	
477
478    // Главная. Слайдер - мы производим ревизионные люки
479    $(".we-create_slider").owlCarousel({
480        items: 1,
481        loop: true,
482        nav: true,
483        navText: '',
484        pagination: false,
485        autoplay: true,
486        autoplayTimeout: 5000,
487        autoplayHoverPause: true,
488        responsive: {
489        	390: {
490        		items:2
491        	},
492        	560: {
493        		items:3
494        	},
495        	768: {
496        		items:5
497        	}
498        }
499    });
500
501    // Главная. Слайдер возле Хитов продаж
502    $(".hits-n-sliders_slider").owlCarousel({
503        loop: true,
504        dots: true,
505        nav: false,
506        paginationSpeed: 400,
507        items: 1,
508        autoplay: true,
509        autoplayTimeout: 4000,
510        autoplayHoverPause: true
511    });
512
513    // Главная. Слайдер - специальные предложения
514    $(".spec-n-reviews_slider").owlCarousel({
515        loop: true,
516        items: 1,
517        nav: true,
518        navText: '',
519        dots: false,
520        autoplay: true,
521        autoplayTimeout: 3000,
522        autoplayHoverPause: true,
523        responsive: {
524        	0: {
525        		items: 1	
526        	},
527        	480: {
528        		items:2
529        	},
530        	768: {
531        		items:3	
532        	},
533        	922: {
534        		items:4	
535        	},
536        	980: {
537        		items:5
538        	}
539        }
540    });
541    
542    // Слайдер - Недавно просмотренные товары
543    
544    if ( $(".recently-in-slider > div").length > 1 ) {
545    	if($('.no-mods').length){
546		    $(".recently-in-slider").owlCarousel({
547		        loop: true,
548		        items: 1,
549		        nav: true,
550		        navText: '',
551		        dots: false,
552		        autoplay: true,
553		        autoplayTimeout: 3000,
554		        autoplayHoverPause: true,
555		        responsive: {
556		        	522: {
557		        		items:2
558		        	},
559		        	640: {
560		        		items:3
561		        	},
562		        	978: {
563		        		items:4
564		        	}
565		        }
566		    });
567    	}else{
568		    $(".recently-in-slider").owlCarousel({
569		        loop: true,
570		        items: 1,
571		        nav: true,
572		        navText: '',
573		        dots: false,
574		        autoplay: false,
575		        autoplayTimeout: 3000,
576		        autoplayHoverPause: true,
577		        responsive: {
578		        	522: {
579		        		items:2
580		        	},
581		        	640: {
582		        		items:3
583		        	},
584		        	978: {
585		        		items:4
586		        	}
587		        }
588		    });
589    	}
590    }
591
592    // Главная. Слайдер - наши люки на объектах
593    $(".our-lukes_slider").owlCarousel({
594        loop: true,
595        items: 1,
596        nav: true,
597        navText: '',
598        dots: false,
599        autoplay: true,
600        autoplayTimeout: 6000,
601        autoplayHoverPause: true,
602        responsive: {
603        	480: {
604        		items:2
605        	},
606        	642: {
607        		items:3
608        	}
609        }
610    });
611
612    // Главная. Колонки в футере
613    $(function() {
614        $('.footer-main_block.menu ul').autocolumnlist({
615            columns: 2,
616            classname: 'col',
617            min: 8
618        });
619    });
620
621    // Главная. Список городов
622    $(function() {
623    	if (!IsMobile) {
624	        $('.cities-list').autocolumnlist({
625	            columns: 5,
626	            classname: 'col',
627	            min: 20
628	        });
629		} else {
630	        $('.cities-list').autocolumnlist({
631	            columns: 2,
632	            classname: 'col',
633	            min: 20
634	        });
635		}
636    });
637
638    // Главная. Слайдер - информация в красном блоке
639    /*$('.we-create_slider .top-slide').hover(
640        function() {
641            $(this).find('.red-box').fadeIn(100);
642        },
643        function() {
644            $(this).find('.red-box').fadeOut(100);
645        }
646    );*/
647
648    // Главная. Кнопка вверх
649    $(document).scroll(function() {
650        var scrTop = $(this).scrollTop();
651        if (scrTop > 650) {
652            $('.arrow-up-section').fadeIn(200);
653        } else {
654            $('.arrow-up-section').fadeOut(200);
655        }
656    });
657
658    $('.arrow-up').click(function(e) {
659        e.preventDefault();
660        $('html, body').animate({
661            scrollTop: 0
662        }, 300);
663    });
664
665    // Стилизация инпутов
666    $(function() {
667        $('select, input[type=checkbox], input[type=radio]:not(.usertype)').styler();
668        $('.star-rating input').styler('destroy');
669    });
670
671    // Каталог. Кнопка - использовать дополнительные параметры
672    if ($('.add-link').length) {
673    	if ($('.more-options input').length || $('.more-options select').length) {
674	    	$('.add-link').click(function(event) {
675		        event.preventDefault();
676		        $(this).parent('.add-options').next('.more-options').slideToggle('fast');
677		        $(this).toggleClass('active');
678		
679		        $(this).parent('.add-options').prev('.more-button-block').toggleClass('dif-bot');
680		    });
681    	}
682    	else {
683    		// Нет дополнительных параметров для поиска
684    		$('.add-link').remove();
685    	}
686    }
687    
688    
689    if ( $('.mobile-header').length == 0 ) {
690
691	    // Внутренние. Слайдер - спецпредложение.
692	    $(".special-offer_block.slider").owlCarousel({
693	        loop: true,
694	        items: 1,
695	        nav: true,
696	        navText: '',
697	        dots: false,
698	        autoplay: true,
699	        autoplayTimeout: 4000,
700	        autoplayHoverPause: true
701	    });
702    	
703    }
704
705    // Вопросительный знак. Всплывашка
706    $('.q-popup').not('.q-popup.top__menu').click(function() {
707    	
708    	if ($(this).hasClass('mobile-ver')) {
709    		
710    		if ($(this).hasClass('active')) {
711    			$(this).removeClass('active');
712    		} else {
713    			$('.q-popup').removeClass('active');
714    			$(this).addClass('active');
715    		}
716    		
717    	} else {
718    		
719        	$(this).toggleClass('active');
720	        $('.q-popup-info').fadeOut('fast');
721	        $(this).find('.q-popup-info').fadeToggle('fast');
722	        
723		    // Закрытие по клику вне всплывашки
724		    $(document).on('click touch', function(event) {
725		        if (!$(event.target).parents().addBack().is('.q-popup')) {
726		            $('.q-popup-info').hide().parent('.q-popup').removeClass('active');
727		        }
728		    });
729		    // При клике на всплывашку не будет срабатывать предыдущее действие
730		    $('.q-popup-info').on('click touch', function(event) {
731		        event.stopPropagation();
732		    });
733    	}
734    });
735
736    // Каталог. Колонки внутри всплывашки
737    $(function() {
738        $('.catalog-block .additional-list').autocolumnlist({
739            columns: 2,
740            classname: 'col',
741            min: 7
742        });
743    });
744
745    // Каталог. Ширина всплывашки
746    $('.additional-info').each(function() {
747        var colWidth = $(this).outerWidth();
748        var colLength = $(this).find('li').length;
749        if (colLength > 7) {
750            colWidth *= 2;
751            $(this).width(colWidth - 20);
752        }
753    });
754
755    // Каталог. Всплывашка
756    // Открыть
757    $('.catalog-block .show-all').click(function(event) {
758        event.preventDefault();
759        $('.additional-info.active').fadeOut('fast').removeClass('active');
760        $(this).parents('.info').next('.additional-info').fadeToggle('fast').toggleClass('active');;
761    });
762
763    // Закрытие по крестику
764    $('.catalog-block .additional-info_close').click(function(event) {
765        event.preventDefault();
766        $(this).parents('.additional-info').fadeOut('fast').removeClass('active');
767    });
768
769    // Закрытие по клику вне всплывашки
770    $(document).on('click touch', function(event) {
771        if (!$(event.target).parents().addBack().is('.catalog-block .show-all')) {
772            $('.additional-info').hide();
773        }
774    });
775
776    // При клике на "показать все" не будет срабатывать предыдущее действие
777    $('.additional-info').on('click touch', function(event) {
778        event.stopPropagation();
779    });
780
781    // Карточка. Развернуть фильтр
782    $('.toggle-filter').click(function() {
783        var searchHeight = $(this).parent('.luke-search.card').height();
784
785        if (!$(this).parents('.luke-search-out').hasClass('active')) {
786
787            $(this).text('свернуть фильтр');
788            $(this).parents('.luke-search-out').addClass('active');
789
790            $(this).parents('.luke-search-out').animate({
791                height: searchHeight + 60
792            }, 200, function() {
793                $(this).css('height', 'auto');
794            });
795        } else {
796
797            $(this).text('развернуть фильтр');
798            $(this).parents('.luke-search-out').removeClass('active');
799
800            $(this).parents('.luke-search-out').animate({
801                height: 85
802            }, 200);
803        }
804
805    });
806
807    // Карточка. Основной слайдер и его пейджер
808    
809    function cardPagerOwl () {
810    	var cItems = $(".card-pager").data('items');
811    	if (!cItems) cItems = 3;
812    	$(".card-pager").owlCarousel({
813	        items: cItems,
814	        nav: true,
815	        navText: '',
816	        dots: false,
817	        itemClass: 'pager-slide',
818	        activeClass: 'slide',
819	        onInitialized: callback,
820	        responsive: {
821	        	480: {
822	        		items:cItems
823	        	}
824	        }
825	    });
826	    
827	    var owl_dot = $(".card-pager").find('.owl-dot').length;
828	    var owl_nav = $(".card-pager").find('.owl-nav');
829	    
830	    if(owl_dot < 4) {
831	    	owl_nav.css("display", "none");
832	    }
833    }
834    
835    if( $(".card-pager").length ) {
836    	cardPagerOwl();
837    	console.log(1)
838    }
839    
840    setTimeout(function(){
841    	if ( !$('.card-pager.owl-carousel').length ) {
842    		cardPagerOwl();
843    	}
844    }, 1000);
845    
846    setTimeout(function(){
847    	if ( !$('.card-pager.owl-carousel').length ) {
848    		cardPagerOwl();
849    	}
850    }, 5000);
851    
852
853    function callback(event) {
854        $(".card-slider").owlCarousel({
855            items: 1,
856            nav: true,
857            navText: '',
858            dotsContainer: '.card-pager .owl-stage-outer .owl-stage'
859        });
860    };
861
862    // Картчока. Положение стрелки главного слайдера
863    if ($('.card-slider-section .card-sales').height() >= 170) {
864        $('.card-slider .owl-next').css('right', '128px');
865    }
866
867    // Инициализация Лайтгалереи
868    $(".lightgallery").lightGallery({
869        selector: '.light-item'
870    });
871    
872    $(".our-lukes_slider").lightGallery({
873        selector: '.light-item'
874    });
875
876    // Табы
877    $('.tab-nav_li').click(function() {
878        $(this).addClass('active').siblings().removeClass('active');
879        dataLi = $(this).data('index');
880        $(this).parent('.tab-nav').next('.tab-cont')
881            .find('.tab-cont_div[data-index="' + dataLi + '"]')
882            .addClass('active').slideDown('fast')
883            .siblings('').removeClass('active').removeClass('visible').slideUp('fast');
884    });
885
886    // Карточка. Высота колонок в таблице размеров-цен
887    var rowHei = $('.size-main-row').height();
888    $('.height-row').each(function() {
889        $(this).height(rowHei);
890    })
891
892    // Карточка. Подсветка рядов в таблице размеров-цен
893    $('.size-main-row .pr').click(function() {
894        var prData = $(this).data('index');
895        $('.grey-row').each(function() {
896            $(this).find('.sz[data-index="' + prData + '"]')
897                .addClass('active').siblings().removeClass('active');
898        })
899        $('.pr.nav.active').each(function() {
900            $(this).removeClass('active');
901        });
902        $(this).siblings('.nav').addClass('active');
903    });
904
905    // Карточка. Всплывающее окошко в таблице размеров-цен
906    //$('.size-main-row .pr').click(function() {
907    $(document).on( 'click', '.size-main-row .pr', function(e){
908        /*$('.size-main-row .pr-popup.opened').fadeOut('fast').removeClass('opened');
909        var prPos = $(this).position().top;
910        var prPosLeft = $(this).position().left;
911        var prWindowPos = $(this).offset().top - $(window).scrollTop();
912        var windowSize = $(window).height();*/
913        
914        $('body .pr-popup').remove();
915        
916        
917
918        var $self  = $(this);
919        var $popUp = $(this).find('.pr-popup');
920        var id     = $self.data('id');
921		if($popUp.length == 0) $popUp = $('.pr-popup[data-id="' + id + '"]');
922		if(!id){
923			return;
924		}
925		var show = function($popUp){
926			if($popUp.length && $('.pr-popup[data-id="' + id + '"]').length==0) {
927	          $popUp
928	            .appendTo($('body'))
929	            .attr('data-id', id);
930	            
931	        } else {
932	          //$popUp = $('.pr-popup[data-id="' + id + '"]');
933	        }
934	
935	        $('.pr-popup').hide();
936	
937			var ofset_left = $('.size-main-row .pr:first').offset().left;
938			
939			// Чтобы при прокрутке не сбивалось положение
940			// Определяем что есть прокрутка
941			// Используем размер прокрутки у родителя и отступ, все по модулю так как нужны положительные значения
942			if (ofset_left < $('.size-main-row').offset().left) {
943				ofset_left = Math.abs( $('.size-main-row').scrollLeft() + ofset_left);
944			}
945	
946	        $popUp.fadeIn().css({
947	          top  : $self.offset().top,
948	          left : ofset_left
949	        });
950	        
951	
952	       $popUp.find('.angle').css('left', $self.position().left);	
953		}
954
955		if($popUp.length==0) {
956			$.get('/katalog/product/' + id + '?ajx=1&ajax_table_one=1', function(d){
957				var d = $(d);
958				show(d);
959			})
960		} else {
961			show($popUp);
962		}
963		
964        
965
966        // Положение всплывашки и "уголка"" в зависимости от положения ячейки
967        /*if (windowSize / 2 > prWindowPos) {
968            $(this).find('.pr-popup').css({ 'top': prPos + 41, 'bottom': 'auto' })
969                .fadeIn('fast').addClass('opened');
970            $(this).find('.pr-popup .angle').addClass('top').css('left', prPosLeft + 5);
971        } else {
972            $(this).find('.pr-popup').css({ 'bottom': rowHei - prPos, 'top': 'auto' })
973                .fadeIn('fast').addClass('opened');
974            $(this).find('.pr-popup .angle').removeClass('top').css('left', prPosLeft + 5);
975        }*/
976    });
977
978    // Карточка. Закрыть всплывашку
979    //$('.close').click(function() {
980    $(document).on( 'click', '.close', function(){
981    	$('.pr-popup').fadeOut('fast').removeClass('opened');
982	});
983	
984    $(document).on( 'click', '.buy-one-cl-in-popup', function(event){
985		// $(".header-info_block .buy-one-cl-prod").next('.main-popup').fadeIn('fast');
986		// var prod_razm = $(this).parents(".shop2-product").find(".popup-title .go-card-parm").text();
987		
988		// $(".main-popup .title .pop-subtitle .main-popup-product-sp").text(prod_razm);
989		
990		// var url = $(".header-info_block .buy-one-cl-prod").data('url');
991		// var inner = $(".header-info_block .buy-one-cl-prod").next().find('.inner-form');
992		
993		// var h1_prod = $(this).parents(".shop2-product").find(".popup-title").text();
994		
995		// inner.includeForm(url, function(){
996		// 	$(".main-popup .phone_mask").mask("+7 (999) 999-9999");
997		// 	$(".main-popup .inpt-prodname").val(h1_prod);
998		// });
999		$(".buy-one-cl-prod").click();	
1000		$(".buy-one-cl-prod").next().show();
1001	});
1002	
1003	$(document).on( 'click', '.main-popup-product', function(event){
1004		event.stopPropagation();	
1005	});
1006
1007    // Закрытие по клику вне всплывашки
1008    $(document).on('click touchstart', function(event) {
1009        if (!$(event.target).parents().addBack().is('.size-main-row .pr') && !$(event.target).closest('.pr-popup').length) {
1010            $('.pr-popup').fadeOut('fast').removeClass('opened');
1011        }
1012    });
1013
1014    // При клике на всплывашку не будет срабатывать предыдущее действие
1015    //$('.pr-popup').on('click touch', function(event) {
1016    $(document).on( 'click touch', '.pr-popup', function(event){
1017        event.stopPropagation();
1018    });
1019
1020    // Карточка - слайдер "Рекомендуем также следующие модели"
1021    $(".rec-slider").owlCarousel({
1022        items: 1,
1023        loop: true,
1024        nav: true,
1025        navText: '',
1026        pagination: true,
1027        autoplay: true,
1028        margin:20,
1029        responsive: {
1030        	522: {
1031        		items:2
1032        	},
1033        	640: {
1034        		items:2
1035        	},
1036        	978: {
1037        		items:2
1038        	}
1039        }
1040    });
1041    
1042    if($('.modif').length){
1043    	$('.all_sizes').show()
1044    	$('.all_sizes span').on('click', function(){
1045			$('html, body').animate({ scrollTop: $('.modif').offset().top }, 500);	
1046		})
1047    }
1048    
1049    if($('.main-card_sizes').length){
1050    	$('.all_sizes').show()
1051    	$('.all_sizes span').on('click', function(){
1052			$('html, body').animate({ scrollTop: $('.main-card_sizes').offset().top }, 500);	
1053		})
1054    }
1055    
1056	
1057	
1058	
1059    // Карточка. Всплывашка с цветами
1060    //$('.choose-color').hover(function() {
1061    
1062    $(document).on( 'mouseover', '.choose-color', function(){
1063        $(this).find('.color-popup').fadeIn('fast');
1064        $(this).find('.chosen-color-block').fadeIn('fast');
1065    });
1066    
1067    $(document).on( 'mouseleave', '.choose-color', function(){
1068        $(this).find('.color-popup').fadeOut('fast');
1069        $(this).find('.chosen-color-block').fadeOut('fast');    	
1070    });    
1071    
1072 
1073    // Карточка. Закрыть всплывашку с цветами
1074    $('.color-popup .close').click(function() {
1075        $(this).parent('.color-popup').fadeOut('fast');
1076        $(this).parent('.color-popup').siblings('.chosen-color-block').fadeOut('fast');
1077    });
1078
1079    // Выбор цвета
1080    //$('.color-item').click(function(event) {
1081    $(document).on( 'click', '.color-item', function(event){
1082        event.preventDefault();
1083        
1084        var colorBlock = $(this).parents('.color-popup').siblings('.chosen-color-block');
1085        if (colorBlock.find('.color-sqr').length == 0){
1086        	colorBlock.html('');
1087        	colorBlock.append('<span>Выбран цвет</span><div class="color-sqr"></div>');
1088        }
1089        
1090        var color = $(this).find('.color-sqr').css('background-color');
1091        var colorName = $(this).find('.color-name').text();
1092        $(this).addClass('chosen').siblings().removeClass('chosen');
1093        $(this).parents('.color-popup').siblings('.chosen-color-block')
1094            .find('.color-sqr').css('background-color', color);
1095        $(this).parents('.color-popup').siblings('.chosen-color-block')
1096            .find('span').text('Выбран цвет ' + colorName);
1097        $(this).show();
1098    });
1099
1100    // Личный кабинет. Выпадашка с товарами
1101    $('.history-item.goods .goods').click(function(event) {
1102        event.preventDefault();
1103        $(this).toggleClass('opened');
1104        $(this).next('.goods-popup').fadeToggle('fast');
1105    });
1106    // Закрытие по клику вне всплывашки
1107    $(document).on('click touch', function(event) {
1108        if (!$(event.target).parents().addBack().is('.history-item.goods .goods')) {
1109            $('.goods-popup').fadeOut('fast').prev('.goods').removeClass('opened');
1110        }
1111    });
1112    // При клике на всплывашку не будет срабатывать предыдущее действие
1113    //$('.goods-popup').on('click touch', function(event) {
1114    $(document).on( 'click', '.goods-popup', function(event){
1115        event.stopPropagation();
1116    });
1117
1118    // Основные всплывашки
1119    $('.open-popup').click(function(event) {
1120        event.preventDefault();
1121       	
1122        $('.black-bg').fadeIn('fast');
1123        
1124        if ( $(this).hasClass('mobile-ver') ) {
1125        	$('.header-info_block.adress .main-popup').fadeToggle('fast');
1126        } else {
1127        	var wr = $(this).next('.main-popup');
1128        	wr.fadeToggle('fast');
1129
1130        	if(wr.find('form').length==0 && wr.find('[data-ppp]').length){
1131        		wr.find('[data-ppp]').includeForm($(this).data('url'));		
1132        	} else {
1133        		console.log('data-ppp not found for inc form');
1134        	}
1135        }
1136    });
1137    $('.main-popup .close-button').click(function(event) {
1138        event.preventDefault();
1139        $('.black-bg').fadeOut('fast');
1140        $(this).closest('.main-popup').fadeOut('fast')
1141    })
1142    $(document).on('click','.main-popup .cls-btn',function(event) {
1143        event.preventDefault();
1144        $(this).closest('.main-popup').fadeOut('fast')
1145    })
1146    
1147    $('.office-change').click(function(event){
1148    	var id = $(this).attr('data-id');
1149    	setCookie('office', id);
1150        $('.black-bg').fadeOut('fast');
1151        $(this).parents('.main-popup').fadeOut('fast');
1152        location.reload();
1153    })
1154    $('.black-bg').click(function() {
1155        $(this).fadeOut('fast');
1156        $('.main-popup').fadeOut('fast')
1157    })
1158
1159    // Карточка - всплывашка Изготовление люка по индивидуальным заказам
1160    $(/*.two-buttons.card*/' .make-luke').click(function(event) {
1161        event.preventDefault();
1162        $(this).next('.make-luke-popup').fadeIn('fast');
1163        $('html').removeClass('ov_hide');
1164        $('.main-content').removeClass('view');
1165    });
1166    $('.make-luke-popup .close-button').click(function(event) {
1167        event.preventDefault();
1168        
1169        $(this).closest('.make-luke-popup').fadeOut('fast');
1170       	$('html').removeClass('ov_hide');
1171        $('.main-content').removeClass('view');
1172    });
1173    // Закрытие по клику вне всплывашки
1174    $(document).on('click touch', function(e) {
1175        if (!$(e.target).hasClass('zvonok') && !$(e.target).parents().addBack().is('.make-luke-popup, .recall-popup')) {
1176            $('.make-luke-popup').fadeOut('fast');
1177            $('html').removeClass('ov_hide');
1178	        $('.main-content').removeClass('view');
1179        }
1180    });
1181    // При клике на всплывашку не будет срабатывать предыдущее действие
1182    $(/*.two-buttons.card*/ '.make-luke').on('click touch', function(event) {
1183        event.stopPropagation();
1184    });
1185
1186});
1187
1188$(function(){
1189	var phoneMask = $(".phone_mask");
1190	var deliveryType = $('.delivery-type.option-label');
1191	var deliveryInputs = $('.option-details.delivery-inputs');
1192	var cardSales = $('.card-sales');
1193	var callPopup = $('.call-popup');
1194	var writePopup = $('.write-popup');
1195	var cartSizes = $('.main-card_sizes');
1196	var shopBtn = $('.shop2-btn');
1197	var compareElement = $('.to-comparsion');
1198	
1199	function recount(form){
1200		shop2.cart.update(form);
1201	}
1202	
1203	function phoneMaskInit(){
1204		$(".phone_mask").mask("+7 (999) 999-9999");
1205	}
1206	
1207	function checkboxSubscribe(){
1208		$('input[name="subscribed"]').change(function(){
1209			var status = $(this).prop('checked');
1210			if (status){
1211				$(this).val(1);
1212			} else {
1213				$(this).val(0);
1214			}
1215		})
1216	}
1217	
1218	function getCaptcha(form){
1219		var form = form;
1220		$.getScript("//captcha.megagroup.ru/static/captcha.js?2", function(){
1221					var params={"inputSession":"_cs"};
1222					
1223					mgCaptcha.draw = function (url, container, params, nodraw) {
1224						var key = "mcp"+Math.round(Math.random()*10000);
1225						if(!params) params = {"inputSession": "mgcaptcha-sid"};
1226						else {
1227							if(!params["inputSession"]) params["inputSession"] = "mgcaptcha-sid";
1228						}
1229						mgCaptcha.stack[ key ] = {};
1230						mgCaptcha.stack[ key ]["url"] = url;
1231						mgCaptcha.stack[ key ]["params"] = params;
1232						mgCaptcha.stack[ key ]["up"] = mgCaptcha.update(key);
1233						if(container) {
1234							container.html(mgCaptcha.getHtml(key, params));
1235						}
1236						mgCaptcha.fetch(key, false, nodraw);
1237						return key;
1238					}
1239					
1240	                if (/MSIE (\d+\.\d+);/.test(navigator.userAgent) && (new Number(RegExp.$1) <= 8.0 )) {
1241	                        widgets.addOnloadEvent(function() {
1242	                    try{ 
1243	                    	mgCaptcha.draw("/my/s3/captcha/get.php", form.find('.s3_captcha_content'), params) 
1244	                    } catch(e){ }});
1245	                } else {
1246	                    try{ 
1247	                    	mgCaptcha.draw("/my/s3/captcha/get.php",form.find('.s3_captcha_content'),params) 
1248	                    }catch(e){
1249	                    }                            				
1250	                }
1251				});
1252	}
1253	
1254	/**
1255    * phone mask initialize
1256    */
1257    if (phoneMask.length > 0){
1258	    phoneMaskInit();
1259	}
1260	
1261	/**
1262	 * show delivery options
1263	 */
1264	if (deliveryType.length > 0){
1265		deliveryType.on('click', function(){
1266			deliveryInputs.hide();
1267			$(this).next().show(300);
1268		});
1269	}
1270	
1271	/**
1272	 * If page has sales
1273	 */
1274	 if (cardSales.length > 0){
1275	 		$('.card-sales a').each(function(k,v){
1276	 			if ($(v).attr('href') != ""){
1277					var href = $(v).attr('href') + "?ajx=1";
1278					$.get(href, function(data){
1279						$(v).text($(data).text());
1280					});
1281	 			}
1282			})
1283	}
1284	 
1285	if (location.pathname == '/katalog/cart'){
1286		function recountCart(){
1287			recount($(this).closest('form'));
1288		}
1289		
1290		$('#shop2-cart input').on('change', function(){
1291			recountCart();
1292		});
1293		
1294		/*$('#shop2-cart .amount-plus,.amount-minus').on('click', function(){
1295			recountCart();
1296		});*/
1297	}
1298	
1299	function initializeEventListeners(form){
1300		var form = form || $('#orderForm');
1301		
1302		phoneMaskInit();
1303		checkboxSubscribe();
1304		if($("#recaptcha").length==0){
1305			getCaptcha(form);	
1306		}
1307		
1308	}
1309	
1310	$('.register-data').load('?usertype=retail #orderForm', function(){
1311		var form = $('#orderForm'); 
1312		initializeEventListeners(form);
1313		createRecaptcha();
1314	});
1315	
1316	if (location.pathname == '/user/register'){
1317		$('.usertype').on('click', function(){
1318			$('.register-data').html('');
1319			var link = $(this).attr('data-link');
1320			$('.register-data').load('?usertype=' + link + ' #orderForm', function(){
1321				var form = $('#orderForm'); 
1322				initializeEventListeners(form);
1323				createRecaptcha();
1324			});
1325		});
1326	}
1327	
1328	$(document).on('click', '#orderForm .button', function(){
1329		$('#orderForm').find('[required]').each(function(k,v){
1330			if ($(v).val() == '') {
1331				$(v).addClass('error');
1332			}
1333		});
1334	});
1335	
1336	//include forms
1337	if (callPopup.length > 0 && writePopup.length > 0){
1338		//$('.call-popup').includeForm('/obratnyy-zvonok?jx=1');
1339		//$('.write-popup').includeForm('/napishite-nam?jx=1');
1340	}
1341	
1342
1343	//init's for popup product	
1344	if (cartSizes.length > 0){
1345		$('.shop2-product-btn').on('click', function(e) {
1346		    var $this = $(this),
1347		        $form = $this.closest('form'),
1348		        form = $form.get(0),
1349		        adds = $form.find('.additional-cart-params'),
1350		        len = adds.length,
1351		        i, el,
1352		        a4 = form.amount.value,
1353		        kind_id = form.kind_id.value;
1354		
1355		    e.preventDefault();
1356		    
1357		    //console.log("dd");
1358		    $('#shop2-cart-preview').css("background-color","#30ab2b");
1359		
1360		    if (len) {
1361		        a4 = {
1362		            amount: a4
1363		        };
1364		
1365		        for (i = 0; i < len; i += 1) {
1366		            el = adds[i];
1367		            if (el.value) {
1368		                a4[el.name] = el.value;
1369		            }
1370		        }
1371		    }
1372		
1373		    shop2.cart.add(kind_id, a4, function(d) {
1374		
1375		        var count = $(d.data).find('.goods-amount').text().match(/(^[\d]*)/gi);
1376		       
1377		        console.log($(d.data).html());
1378		        $('#shop2-cart-preview').replaceWith(d.data);
1379		        $('.widget.in-basket span').text('(' + count + ')');
1380		
1381		        if (d.errstr) {
1382		            shop2.msg(d.errstr, $this);
1383		        } else {
1384		            shop2.msg(window._s3Lang.JS_ADDED, $this);
1385		        }
1386		
1387		        if (d.panel) {
1388		            $('#shop2-panel').replaceWith(d.panel);
1389		        }
1390		    });
1391		
1392		});
1393		$('.amount-plus').on('click', function() {
1394		
1395		    var $this = $(this),
1396		        text = $this.siblings('input:text'),
1397		        value = text.getVal();
1398		
1399		    if (value) {
1400		        value = value[0];
1401		    }
1402		
1403		    value += shop2.options.amountDefaultInc;
1404		    value = value.toFixed(5) - 0;
1405		
1406		    text.val(value);
1407		    text.trigger('keyup');
1408		});
1409		$('.amount-minus').on('click', function() {
1410		    var $this = $(this),
1411		        text = $this.siblings('input:text'),
1412		        value = text.getVal();
1413		
1414		    if (value) {
1415		        value = value[0];
1416		    }
1417		    value -= shop2.options.amountDefaultInc;
1418		    value = value.toFixed(5) - 0;
1419		
1420		    if (value <= shop2.options.amountDefaultValue) {
1421		        value = shop2.options.amountDefaultValue;
1422		    }
1423		
1424		    text.val(value);
1425		    text.trigger('keyup');
1426		});
1427	}
1428	
1429	//show recount button in card
1430	if (shopBtn.length > 0) {
1431		$(shopBtn).on('click', function(){
1432			$('.recount-btn').show();
1433		});
1434	}
1435	
1436	
1437	if($('.card-video').length>0){
1438		$('.card-video').each(function(){
1439			var href=$(this).attr("href");
1440			
1441			href = href.replace('https://www.youtube.com', 'https://youtube.com');
1442			href = href.replace('watch?v=', 'embed/');
1443			href = href.replace('&feature=youtu.be', '');
1444			$(this).attr("href", href);
1445			
1446			if(href.indexOf("https://youtu.be")>=0){
1447				var new_href=href.replace("https://youtu.be/","https://youtube.com/embed/");
1448				$(this).attr("href",new_href);
1449			}
1450		});
1451		
1452		setTimeout(function() {
1453			$(".card-video").fancybox({
1454				openEffect	: 'none',
1455				closeEffect	: 'none'
1456			});
1457		}, 500);
1458		
1459	}
1460	
1461	
1462	
1463	//compare products
1464	//if ($('.to-comparsion').length > 0){
1465		//compareElement.on('click', function(){
1466		$(document).on( 'click', '.to-comparsion', function(){
1467			console.log(444);
1468			var $this = $(this),kind_id = $this.data('kind');
1469			if($this.hasClass('added')) {
1470				return false;
1471			}
1472			shop2.compare.add(kind_id, function(response){ 
1473				var count = response.count; 
1474				$('.compare_count0').data('count',count);
1475				$this.addClass('added');
1476				$('.widget.comparison span').text('('+count+')');
1477			});
1478		});
1479//	}
1480	$('.compare_count0').on('click', function(e){
1481		
1482		if(!$(this).data('count')) {
1483			e.preventDefault();
1484			shop2.msg('Добавьте товары в сравнение', $('.comparison-msg'));}
1485	});
1486	$('.recall.zvonok').on('click', function(e){
1487		e.preventDefault();
1488        
1489        $(this).next('.make-luke-popup').fadeIn('fast');
1490        $(this).parents('.wrapper').find('.phones .main-popup').fadeIn('fast');
1491  console.log('recall');  
1492		var url = $(this).data('url');
1493		$('.make-zvokok-inner:last').includeForm(url, function(d){
1494			phoneMaskInit();
1495		});
1496	});
1497	
1498	$('.make-lukes-not-found').on('click', function(){
1499		
1500        var url = $(this).data('url');
1501		$('.make-luke-not-found-inner').includeForm(url, function(){
1502				phoneMaskInit();
1503				
1504				var textAreaContent = '';
1505
1506				$('.shop2-filter :selected').each(function(k,v){
1507				var text = $(v).text();
1508				    if(text != ""){
1509				        textAreaContent += text + "\n";
1510				    }
1511				});
1512				
1513				$('.shop2-filter :checked').each(function(k,v){
1514				    var text = $(v).parents('label').text();
1515				    if(text != ""){
1516				        textAreaContent += text + "\n";
1517				    }
1518				});
1519				
1520
1521				$('.make-luke-not-found-inner').find('textarea').text(textAreaContent);
1522			});
1523			return false;
1524	});
1525	
1526	if ($('.subscribe-includeForm').length > 0){
1527		//$('.subscribe-includeForm').includeForm('/podpisatsya?jx=1');
1528		$('.subscribe-includeForm').includeForm('/ne-mozhete-vybrat-tovar?jx=1');
1529	}
1530	
1531	
1532	$('.recall-popup').on('click', function(e){
1533		e.preventDefault();
1534		$('html').addClass('ov_hide');
1535		$('.main-content').addClass('view');
1536        $('.make-luke-popup, .main-popup').hide();
1537        $(this).next('.make-luke-popup').fadeIn('fast');
1538
1539		var url = $(this).data('url');
1540		var inner = $(this).next().find('.inner-form'), sep = '&';
1541		if(!/\?/.test(url)){
1542			sep = '?';
1543		}
1544		if(!/jx=/.test(url)){
1545			url = url + sep + 'jx=1';
1546		}
1547		inner.includeForm(url, function(){
1548			phoneMaskInit();
1549		});
1550	});
1551	
1552	$('.measurement:not(.recall-popup)').on('click', function(e){
1553		e.preventDefault();
1554		$(this).next('.make-luke-popup').fadeIn('fast');
1555		
1556		var url = $(this).data('url');
1557		var inner = $(this).next().find('.inner-form');
1558		
1559		inner.includeForm(url, function(){
1560			phoneMaskInit();
1561		});
1562	});
1563	
1564	$(".to-comparsion-wr").click(function(){
1565		$(this).find("span").show();
1566			setTimeout(function(){
1567				$(".to-comparsion-wr span").hide();
1568			}, 2000);
1569	});
1570	
1571	$(".one-click-butt").click(function(){
1572		
1573		$(".buy-one-cl-prod").click();	
1574		$(".buy-one-cl-prod").next().show();
1575	});
1576	
1577	$('.buy-one-cl-prod:not(.recall-popup)').on('click', function(e){
1578		e.preventDefault();
1579		$(this).next('.main-popup').fadeIn('fast');
1580		
1581		var url = $(this).data('url');
1582		var inner = $(this).next().find('.inner-form');
1583		
1584		var prodlink = $(".product_link").val(),
1585			prod_kind_id = $(".product_kind_id").text();
1586		
1587		var prodname = $(".product_name").val() + ' ' + prod_kind_id;
1588		
1589		var h1_prod = $("h1.product_h1").text();
1590		
1591		inner.includeForm(url, function(){
1592			phoneMaskInit();
1593			$(".inp-tovarlink").val(prodlink);
1594			$(".inp-tovarname").val(prodname);
1595			//$(".main-popup .inpt-prodname").val(h1_prod);
1596			$(".main-popup .inpt-prodname").val(prodname);
1597		});
1598	});
1599	///////////
1600	function buyOneClick(){
1601		$(".buy_by_one_click").click(function(e){
1602			$(".popup").show();
1603			$(".buy-by-one-click").click();	
1604			$(".buy-by-one-click").next().show();
1605		});
1606	}
1607	
1608	buyOneClick();
1609	setTimeout(function(){
1610		$('.size-main-row .pr').on('click', function(){
1611			setTimeout(buyOneClick, 1500);
1612		});
1613	}, 1000);
1614	
1615	
1616	$('.buy-by-one-click:not(.recall-popup)').on('click', function(e){
1617		e.preventDefault();
1618		$(this).next('.main-popup').fadeIn('fast');
1619		
1620		var url = $(this).data('url');
1621		var inner = $(this).next().find('.inner-form');
1622		
1623		//var prodlink = $(".product_link").val();
1624		var prodname = $(".product_name").val();
1625		if ($('.shop2-product').hasClass("popup_prod")) {
1626			var h1_prod = $(".pr-popup .popup-title a.go-card").text();
1627		}
1628		else {
1629			var h1_prod = $("h1.product_h1").text();
1630		}
1631		
1632		inner.includeForm(url, function(){
1633			phoneMaskInit();
1634			//$(".inp-tovarlink").val(prodlink);
1635			//$(".inp-tovarname").val(prodname);
1636			$(".main-popup .inp-productname").val(h1_prod).attr('readonly', 'readonly');
1637			$("input.inp-count").val($('.shop2-product-amount input[type="text"]').val());
1638			$("input.inp-priceperunit").val($('.price_main').text());
1639		});
1640		setTimeout(function(){
1641			$('.checkbox-delivery').on('click', function(){
1642				if ($('.checkbox-delivery').find('input[type="checkbox"]:checked')) {
1643					$('.field-address').fadeIn();
1644				}
1645				else {
1646					$('.field-address').fadeOut();
1647				}
1648			});
1649		},1500);
1650	});
1651
1652	/////////////
1653	if ($('.usertype-radio-block').length > 0){
1654		$('[type="radio"]').styler('destroy');
1655	}
1656	
1657	//initialize search for tile
1658	if(typeof shop2!="undefined"){
1659		shop2.on('afterGetFolderCustomFields', function(d) { 
1660			//console.log(d);
1661		})
1662	}
1663	
1664	if($('.our-lukes_slider img.highslide-image').length){
1665		hs.align = 'center';
1666	hs.transitions = ['expand', 'crossfade'];
1667	hs.outlineType = 'rounded-white';
1668	hs.fadeInOut = true;
1669	hs.dimmingOpacity = 0.8;
1670						hs.addSlideshow({
1671			interval: 5000,
1672			repeat: false,
1673			useControls: true,
1674			fixedControls: 'fit',
1675			overlayOptions: {
1676				opacity: .75,
1677				position: 'bottom center',
1678				hideOnMouseOut: true
1679			}
1680		});
1681	}
1682	
1683	//delete empty rows from table
1684	if ($('.size-table').length>0){
1685		var count = $('.grey-row:first').find('.sz').length;
1686		for(var i=0; i<count; i++){
1687			if ($('.pr[data-index="'+i+'"]:parent').length == 0){
1688				$('.sz[data-index="'+i+'"],.pr[data-index="'+i+'"]').remove();
1689			}
1690		}
1691		
1692		
1693	}
1694});
1695
1696$(function() {
1697
1698    $('.mkad-km-count').keyup(function() {
1699    	recalcMkadDost();
1700    	calcDeliveryTotalSum();
1701	});
1702	
1703	// Стоимость доставки
1704	$('.delivery-option').click(function() {
1705		calcDeliveryTotalSum();
1706		// При клике на не самовывоз
1707		var otype = $(this).attr('data-type');
1708		
1709		if(otype != 801) {
1710			$('.show-del-cont-note').hide();	
1711		}
1712	});
1713	/*
1714	$('.delivery-counter .amount-minus, .delivery-counter .amount-plus').click(function(){
1715		recalcMkadDost();
1716	});
1717	*/
1718	if( $('.delivery-option').length ) {
1719		recalcMkadDost();
1720		calcDeliveryTotalSum();
1721	}
1722	
1723	$('.cont-to-show').click(function(e){
1724		e.preventDefault();
1725		var cont_to_show = $(this).attr('data-cont-to-show');
1726		$('.show-del-cont-note').hide();
1727		$('.'+cont_to_show).show();
1728		
1729	});
1730	
1731	// valid register
1732    $('.jx-validate-form-order').on('submit', function (e) {
1733
1734        var has_error = false,
1735            has_email_error = false,
1736            $email = $(this).find('.email_valid'),
1737            $form = $(this);
1738        if ( $form.data('went') === true && !$form.find('[name=jx]').length ) {
1739            return true;
1740        }
1741
1742        e.preventDefault();
1743
1744        $form.find('[data-req=1]').each(function () {
1745            if ( !$.trim( $(this).val() ) ) {
1746                has_error = true;
1747                $(this).addClass('error');
1748            }
1749        });
1750        
1751        if ($form.find('[data-checkboxreq=3]:visible').length) {
1752        	var isset_checked = false;
1753        	$form.find('[data-checkboxreq=3]:visible').each(function () {
1754	            if ($(this).prop('checked')) {
1755	            	isset_checked = true;
1756	            }
1757	        });
1758	        
1759	        if (!isset_checked) {
1760	        	has_error = true;
1761	        	$form.find('[data-checkboxreq=3]:visible').addClass('error');
1762	        }
1763	        
1764        }
1765        
1766
1767        if ( !has_error && $email.val() ) {
1768            if ( !isEmail( $email.val() ) ) {
1769                has_email_error = true;
1770                $email.addClass('error');
1771            }
1772        }
1773
1774        $form.find('[data-req-email]').each(function () {
1775            if ( $.trim( $(this).val() ) && !isEmail($.trim( $(this).val() )) ) {
1776                has_email_error = true;
1777                $(this).addClass('error');
1778            }
1779        });
1780
1781        // setTimeout(function () {
1782        //     $('.error').removeClass('error');
1783        // }, 2000);
1784
1785        if ( has_error ) {
1786            $.notify("Заполните обязательные поля", "error");
1787            return false;
1788        }
1789
1790        if(has_email_error) {
1791            $.notify("Введите корректный email", "error");
1792            return false;
1793        }
1794
1795        if( $('#agree')[0] && !$('#agree').is(':checked') ) {
1796			//$.notify("", "error");
1797			//return false;
1798        }
1799
1800        $('.one-click-btn').attr("disabled", true);
1801
1802        $form.data('went', true);
1803        $(this).submit();
1804
1805    });
1806    //validate code	
1807	
1808    
1809	function isEmail(email) {
1810	  var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
1811	  return regex.test(email);
1812	}
1813	
1814	function recalcMkadDost() {
1815		var price = $('.mkad-km-price').text();
1816		var count = $('.mkad-km-count').val();
1817		
1818		if(count && price) {
1819			var price = parseInt( price.replace(/\s+/g, '') );
1820			var count = parseInt( count.replace(/\s+/g, '') );		
1821			$('.mkad-price-total').text( number_format(price*count, 0, ' ', ' ') );
1822		}
1823	}
1824	
1825	// При смене доставки производит необходимые расчеты
1826	function calcDeliveryTotalSum() {
1827		
1828		
1829		
1830		var delivery_price = parseInt( $( "input[name=delivery_id]:checked" ).attr('data-cost') );
1831		var delivery_type = $( "input[name=delivery_id]:checked" ).val();
1832		
1833		
1834		if(delivery_type==3801){
1835			$("input[name='fio_surname'],input[name='fio_patronymic']").attr('data-req', '1');
1836			$(".transport_req").show();
1837		}else{
1838			$("input[name='fio_surname'],input[name='fio_patronymic']").removeAttr('data-req');
1839			$(".transport_req").hide();
1840		}
1841		
1842		$('.cart-form_delivery').find('[data-req]').each(function () {
1843            $(this).attr('data-req', '0');
1844        });
1845        
1846		$('.delivery-option-'+delivery_type).find('[data-req]').each(function () {
1847            $(this).attr('data-req', '1');
1848        });        
1849        
1850
1851		var mkad_price = 0;		
1852		// Если за МКАД
1853		if(delivery_type == 1201) {
1854			var mkad_price = parseInt( $('.mkad-price-total').text().replace(/\s+/g, '') );
1855		}
1856		
1857		//alert(delivery_type);
1858		
1859		var price_subtotal = parseInt( $('.price-subtotal').text().replace(/\s+/g, '') );
1860		var delivery_total_sum = delivery_price+mkad_price;
1861		
1862		var inner_del_price= number_format(delivery_total_sum, 0, ' ', ' ') ;
1863		if(inner_del_price==0){
1864			inner_del_price="бесплатно";
1865			$('.delivery-total-sum').text( inner_del_price);
1866		}else{
1867			$('.delivery-total-sum').text( inner_del_price+" руб." );
1868		}
1869		
1870		
1871		
1872		$('.order-total-price').text( number_format(price_subtotal+parseInt(delivery_total_sum), 0, ' ', ' ') );
1873	}
1874	
1875	function number_format( number, decimals, dec_point, thousands_sep ) {	// Format a number with grouped thousands
1876		// 
1877		// +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
1878		// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
1879		// +	 bugfix by: Michael White (http://crestidg.com)
1880	
1881		var i, j, kw, kd, km;
1882	
1883		// input sanitation & defaults
1884		if( isNaN(decimals = Math.abs(decimals)) ){
1885			decimals = 2;
1886		}
1887		if( dec_point == undefined ){
1888			dec_point = ",";
1889		}
1890		if( thousands_sep == undefined ){
1891			thousands_sep = ".";
1892		}
1893	
1894		i = parseInt(number = (+number || 0).toFixed(decimals)) + "";
1895	
1896		if( (j = i.length) > 3 ){
1897			j = j % 3;
1898		} else{
1899			j = 0;
1900		}
1901	
1902		km = (j ? i.substr(0, j) + thousands_sep : "");
1903		kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep);
1904		//kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).slice(2) : "");
1905		kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : "");
1906	
1907	
1908		return km + kw + kd;
1909	}
1910	
1911
1912	
1913});
1914
1915	function getParameterByName(name, url) {
1916	    if (!url) {
1917	      url = window.location.href;
1918	    }
1919	    name = name.replace(/[\[\]]/g, "\\$&");
1920	    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
1921	        results = regex.exec(url);
1922	    if (!results) return null;
1923	    if (!results[2]) return '';
1924	 return decodeURIComponent(results[2].replace(/\+/g, " "));
1925}
1926
1927
1928	function deleteEmptyColumns(){
1929		
1930		var tmp_mas = new Array();
1931		$('.size-main-row .white-row .pr').each(function(index) {
1932		    var elem = $(this);
1933		    var data_index = elem.data("index");
1934		    if(!tmp_mas[data_index]){tmp_mas[data_index]  =new Array(); }
1935		    tmp_mas[data_index].push(elem.text());
1936		
1937		})
1938		
1939		for(var i = 0; i < tmp_mas.length; i++) {
1940		    
1941		
1942		
1943		    if(tmp_mas[i].every(checkEmpty)) {
1944		        $('.size-main-row .pr[data-index="' + i + '"],.size-main-row .sz[data-index="' + i + '"]').css({"background":"red"}).remove();
1945		    } else {
1946		        console.log("false");
1947		    }
1948		}
1949		
1950		function checkEmpty(elem) {
1951		
1952		    return elem == "";
1953		
1954		}
1955	}
1956	
1957	
1958	
1959var createRecaptcha = 	function() {
1960		if($("#recaptcha").length>0){
1961		grecaptcha.render("recaptcha", {sitekey: "6LeU0SgUAAAAAIIBuYvtSf65-xqdL7ulhtHmvzHw", theme: "light"});
1962		}
1963	
1964}
1965
1966
1967	
1968	
1969$(document).ready(function() {
1970		$(".scrl-reviews").click(function(){
1971			$('html, body').animate({
1972                scrollTop: $(".product-comment-wr").offset().top
1973            }, 2000);
1974            
1975            return false;
1976		});
1977	
1978		
1979	
1980		$('.slide-tabs .tab-slide1').click(function(){
1981			$('.spec-n-reviews_specs').css({"opacity" : "1", "z-index" : "1"});
1982			$('.leaders-slider').css({"opacity" : "0", "z-index" : "-1000"});
1983			$(this).css({"color":"#9f1922","border-bottom":"1px dashed #9f1922"});
1984			$('.slide-tabs .tab-slide2').css({"color":"#000","border-bottom":"none"});
1985		});
1986		$('.slide-tabs .tab-slide2').click(function(){
1987			$('.spec-n-reviews_specs').css({"opacity" : "0", "z-index" : "-1000"});
1988			$('.leaders-slider').css({"opacity" : "1", "z-index" : "1"});
1989			$(this).css({"color":"#9f1922","border-bottom":"1px dashed #9f1922"});
1990			$('.slide-tabs .tab-slide1').css({"color":"#000","border-bottom":"none"});
1991		});
1992		
1993		
1994		if($('.leaders-slider .leader-slider-bit').length) $.get('/katalog/search?s[vyvodit_na_glavnoj]=1&ajx=1&hits=1&s[products_per_page]=10', function(data){
1995          			$('.leaders-slider .leader-slider-bit').append(data);
1996	          			$('.search-slider-wr').owlCarousel({
1997					        loop: true,
1998					        items: 1,
1999					        nav: true,
2000					        navText: '',
2001					        dots: false,
2002					        autoplay: true,
2003					        autoplayTimeout: 3000,
2004					        autoplayHoverPause: true,
2005					        responsive: {
2006					        	0: {
2007					        		items: 1	
2008					        	},
2009					        	480: {
2010					        		items:2
2011					        	},
2012					        	768: {
2013					        		items:3	
2014					        	},
2015					        	922: {
2016					        		items:4	
2017					        	},
2018					        	980: {
2019					        		items:5
2020					        	}
2021					        }
2022					    });
2023          		})
2024		$( ".size-main-row .white-row.clearfix > [data-id]" ).hover(
2025		  function() {
2026		  	$('.grey-row.first-line.clearfix').find('>div').eq($( this ).index()).addClass('hvr');
2027		  }, function() {
2028		    $('.grey-row.first-line.clearfix').find('>div').eq($( this ).index()).removeClass('hvr')
2029		  }
2030		);
2031		
2032		
2033		if($('.camera-v:not(.l)').length){
2034			$('.camera-v:not(.l)').each(function(){
2035				
2036				console.log($(this).data('url'))
2037				var y = "https://youtu.be/D284sqAlaX0".split('/');
2038				if(y[y.length-1] && (y = y[y.length-1])){
2039					$(this).find('img').attr('src','https://img.youtube.com/vi/'+y+'/0.jpg')
2040					$(this).removeClass('light-item').attr('href','https://youtube.com/embed/' + y)
2041					$(this).fancybox({
2042		openEffect	: 'none',
2043		closeEffect	: 'none'
2044	})
2045				}
2046			})	
2047		};
2048		if ($('.js_video_slider .video').length > 3) {
2049			console.log('o')
2050	        function sl_video(){
2051	        	$(".js_video_slider").owlCarousel({
2052			        items:1,
2053			        loop:true,
2054			        autoplay: false,
2055			        autoplayTimeout: 3000,
2056			        nav: true,
2057			        navText: '',
2058			        margin:10,
2059			        video:true,
2060			        lazyLoad:true,
2061			        center:true,
2062			        responsive:{
2063			            480:{
2064			                items:2
2065			            },
2066			            600:{
2067			                items:1
2068			        	}
2069			    	}
2070				});
2071	        }
2072	        sl_video()
2073	        $('.tab-nav__video').on('click', function(){
2074	        	setTimeout(function(){
2075	        		sl_video()
2076	        		$('document').trigger('resize')
2077	        	},100)	
2078	        })
2079		}
2080		else{
2081			$(".js_video_slider").owlCarousel({
2082				loop:false,
2083				items:1,
2084				autoplay: false,
2085		        autoplayTimeout: 3000,
2086		        nav: false,
2087		        dots: false,
2088		        navText: '',
2089		        margin:10,
2090		        video:true,
2091		        lazyLoad:true,
2092		        center:true,
2093		        responsive:{
2094		            480:{
2095		                items:2
2096		            },
2097		            600:{
2098		                items:1
2099		        	}
2100		    	}
2101			});
2102		}
2103		
2104
2105// $(document).ready(function() {
2106// 	$('.name').mousemove(function(event) { // элемент при наведении на который показывается картинка
2107// 	// Расчет координат курсора
2108// 	var pos = $(this).offset();
2109// 	var pageX = event.pageX;
2110// 	var pageY = event.pageY;
2111// 	var x = pageX - pos.left + 10;
2112// 	var y = pageY - pos.top + 10;
2113
2114// 	$(this).children('.image').css({ // картинка
2115// 		'display' : 'block',
2116// 		'left' : x + 'px',
2117// 		'top' : y + 'px'});
2118// 	});
2119
2120// 	$('.name').mouseout(function() {
2121// 		$(this).children('.image').hide();
2122// 	});
2123// });
2124	$(function(){
2125        var heads=[];
2126        
2127        $(".mob-adapt .t_row:first-child .t_head--td").each(function(){
2128          heads.push($(this).text());
2129        })
2130
2131        $(".mob-adapt .t_row").each(function(){
2132          if ($(this).index()>0){
2133            $(this).find('.t_row--td').each(function(){
2134              $(this).html('<div class="subber_title">'+heads[$(this).index()]+'</div><div class="value">'+$(this).html()+'</div>');
2135            });
2136          }
2137        })
2138    
2139	    $('ul.left-menu > li.has-child > span.arrow').on('click', function(){
2140			$(this).siblings('ul').slideToggle();
2141			$(this).parent('li.has-child').toggleClass('opened');
2142			$(this).parent('li.has-child').siblings('li').removeClass('opened').children('ul.level-2').slideUp();
2143		});
2144		
2145		var url = document.URL;
2146		var chpu = url.replace('https://luk-opttorg.ru', '');
2147		var chpu = chpu.replace('?left_side=1','');
2148		console.log(chpu);
2149		$('ul.left-menu li a[href="' + chpu + '"]').each(function(){
2150			$(this).addClass('active').parents('li.has-child').addClass('opened');
2151			$(this).parent('li').addClass('active');
2152		});
2153        
2154        $('ul.left-menu ul.level-2 li.folders-title.rolled').on('click', function(){
2155			$(this).toggleClass('opened');
2156			$(this).next().slideToggle();
2157		});
2158    });
2159    
2160    $('.luke-search .title').on('click', function(){
2161		$(this).parents('.luke-search').toggleClass('opened');
2162	});
2163});
2164
2165
2166try {
2167	(function($){
2168		$(function(){
2169			var $btn_sort = $('.sort_product .select-title');
2170			
2171			$btn_sort.click(function(){
2172				var $this = $(this),
2173					$select = $this.next();
2174				
2175				$select.addClass('active');	
2176			});
2177			
2178			$(document).click(function(e){
2179				var $select = $('.sort_product');
2180				
2181				if ($select.length && !$select.is(e.target) && $select.has(e.target).length === 0) {
2182					console.log(!$select.is(e.target));
2183					$select.find('.popup-body-select').removeClass('active');	
2184				};
2185			});
2186			
2187			
2188		});
2189	})(jQuery);
2190} catch (e) {
2191	console.log(e.message());
2192}
2193
2194
2195
2196$(function(){
2197	// В фильтре клик по кнопке поиска по id - переводим на страницу.
2198	$(".show_by_id a").on("click", function(e){
2199		e.preventDefault();
2200		
2201		var _id = $(".show_by_id input").val();
2202		
2203		if (_id) {
2204			location.href = '/katalog/product/'+_id;
2205		}
2206	});
2207	
2208	$(".header-black-line_search form, .mobile-header form.mobile-search-form").on('submit', function(e){
2209		e.preventDefault();
2210		
2211		var $search_form = $(this),
2212			search_val = $(this).find('input.black-search_input').val();
2213		
2214		if ($(this).find('input.black-search_input').length == 0) {
2215			search_val = $(this).find('input.mobile-search-form__input').val();
2216		}
2217		
2218		if (search_val && !isNaN(search_val)) {
2219			// Если в строке поиска число - то это может быть поиск по ID.
2220			// Нужно проверить есть ли такой товар
2221			$.ajax({
2222		        type: "HEAD",
2223		        async: true,
2224		        url: '/katalog/product/'+parseInt(search_val),
2225		    }).complete(function(jqXHR){
2226		        if (jqXHR.status >= 200 && jqXHR.status < 400) {
2227		        	location.href = '/katalog/product/'+parseInt(search_val);
2228		        }
2229		        else {
2230		        	$search_form.off('submit');
2231					$search_form.submit();
2232		        }
2233		        
2234		    });
2235
2236			
2237		}
2238		else {
2239			$(this).off('submit');
2240			$(this).submit();
2241		}
2242		
2243	});
2244	
2245	if (document.location.search == '?new_test=1') {
2246		createCookie('new_test', 1, 1);
2247	}
2248});
2249/*
2250$(function(){
2251	$(window).load(function(){
2252		$('.luke-search').addClass('flexed')
2253	});
2254})
2255*/

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.