PageSourceSearch

https://georodgeo.ru/bitrix/templates/centino-heat/js/general.js

js georodgeo.ru collected 2026-10-05 03:36:29 UTC 138,607 bytes, 4,596 lines download raw bytes

1getRandomInt = function(min, max){
2	return Math.floor(Math.random() * (max - min)) + min;
3}
4
5ShowOverlay = function(){
6	$('<div class="jqmOverlay waiting"></div>').appendTo('body');
7}
8
9HideOverlay = function(){
10	$('.jqmOverlay').detach();
11}
12
13$(document).on('mouseenter', 'header td.dropdown.menu-item', function () {
14	var _this = $(this),
15		menu = _this.find('.wrap > .dropdown-menu');
16
17		menu.velocity('stop');
18
19		if(menu.css('opacity') != 0) {
20			menu.css('opacity' , '1');
21		} else {
22			menu.velocity('transition.fadeIn', {
23				duration: 200,
24				delay: 350
25			});
26		}
27
28		_this.one('mouseleave', function () {
29			menu.velocity('stop').velocity('transition.fadeOut', {
30				duration: 150,
31				delay: 300
32			});
33		});
34		
35});
36
37$(document).on('mouseenter', 'header .burger', function () {
38	var _this = $(this),
39		menu = _this.find('> .site_map_wrapper');
40
41		menu.velocity('stop');
42
43		if( menu.css('opacity') != 0 && menu.attr('velo') == 'Y' ) {
44			menu.css('opacity' , '1');
45		} else {
46			menu.velocity('transition.fadeIn', {
47				duration: 200,
48				delay: 350,
49				begin: function() {menu.attr('velo', 'Y')}
50			});
51		}
52
53		_this.one('mouseleave', function () {
54			menu.velocity('stop').velocity('transition.fadeOut', {
55				duration: 150,
56				delay: 300
57			});
58		});
59		
60});
61
62contactsInputHeight = function () {
63	var minHeight = 200;
64	if($('.contacts_1').length) {
65		if(window.matchMedia('(max-width:991px)').matches) {
66			var map = $('.contacts_1 .left_contact_block .contacts-page-map .bx-yandex-map, .contacts_1 .left_contact_block .contacts-page-map .bx-yandex-map .ymaps-map');
67			map.css('height', 500);
68		} else if(window.matchMedia('(min-width:992px)').matches) {
69			var left_block_height = $('.left_contact_block')[0].getBoundingClientRect().height;
70			var descr_height = $('.contacts_1 .contacts div[itemprop=description]').closest('.row')[0].getBoundingClientRect().height;
71			var questions_height = $('.contacts_1 .contacts .top_questions')[0].getBoundingClientRect().height;
72			var bottom_block_height = 0;
73			if($('.contacts_1 .contacts .bottom_block').length){
74				bottom_block_height = $('.contacts_1 .contacts .bottom_block')[0].getBoundingClientRect().height;
75			} else if($('.contacts_1 .contacts .form-footer')) {
76				bottom_block_height = $('.contacts_1 .contacts .form-footer')[0].getBoundingClientRect().height;
77			}
78			var captcha_height = 0;
79			if($('.contacts_1 .contacts .captcha-row').length){
80				var captcha_height = $('.contacts_1 .contacts .captcha-row').outerHeight() + 20;
81			}
82			var form_row_top =  Number($('.contacts_1 .contacts form > .row > div').css('padding-top').replace('px', ''));
83			var form_group_bottom = Number($('.contacts_1 .contacts .message .form-group').css('margin-bottom').replace('px', ''));
84			var button_bottom = 0;
85			if($('.contacts_1 .contacts .bottom_block button').length) {
86				button_bottom = Number($('.contacts_1 .contacts .bottom_block button').css('margin-bottom').replace('px', ''));
87			} else if ($('.contacts_1 .contacts .form-footer input[type=submit]')) {
88				button_bottom = Number($('.contacts_1 .contacts .form-footer input[type=submit]').css('margin-bottom').replace('px', ''));
89			}
90			
91
92			var need_height = left_block_height - (descr_height + questions_height + bottom_block_height + form_row_top + form_group_bottom + captcha_height - button_bottom);
93			need_height = need_height < minHeight ? minHeight : need_height;
94			var mess_block = $('.contacts_1 .contacts .message .input textarea');
95			mess_block.css('height', need_height+'px');
96
97
98			var right_block_height = $('.contacts_1 .left_contact_block').siblings('.col-md-6')[0].getBoundingClientRect().height;
99			var top_block_height = $('.contacts_1 .left_contact_block .contacts')[0].getBoundingClientRect().height;
100			var needHeight = right_block_height - top_block_height - 10;
101			if(needHeight > 500) {
102				var map = $('.contacts_1 .left_contact_block .contacts-page-map .bx-yandex-map, .contacts_1 .left_contact_block .contacts-page-map .bx-yandex-map .ymaps-map');
103				map.css('height', needHeight);
104			}
105
106		}
107	} else if($('.contacts_2').length) {
108		if(window.matchMedia('(min-width:768px)').matches) {
109			var right_block_height = $('.contacts_right_block')[0].getBoundingClientRect().height;
110			var button_bottom = Number($('.contacts_2 .contacts .bottom_block button').css('margin-bottom').replace('px', ''));
111			var mess_block = $('.contacts_2 .contacts .message .input textarea');
112			var need_height = right_block_height - button_bottom;
113			need_height = need_height < minHeight ? minHeight : need_height;
114			mess_block.css('height', need_height + 'px');
115		}
116	}
117}
118
119CheckMenuOffset = function(){
120	$('#headerfixed li.dropdown, #headerfixed li.dropdown-toggle, #headerfixed li.dropdown-submenu').hover(
121		function(){
122			var el = $(this).find('.dropdown-menu')[0];
123			$(this).find('.offsetMenu').css('top', '');
124			$(this).find('.offsetMenu').css('bottom', '');
125			if(el.getBoundingClientRect().bottom > $(window).height()) {
126				el.classList.add('offsetMenu');
127				var bottom = this.getBoundingClientRect().bottom - $(window).height();
128				$(this).find('.offsetMenu').css('top', 'auto');
129				$(this).find('.offsetMenu').css('bottom', bottom+'px');
130			}
131		},
132		function(){}
133	);
134	$('#headerfixed li.dropdown, #headerfixed li.dropdown-toggle, #headerfixed li.dropdown-submenu').on('touchend', function() {
135		var el = $(this).find('.dropdown-menu')[0];
136		$(this).find('.offsetMenu').css('top', '');
137		$(this).find('.offsetMenu').css('bottom', '');
138		if(el.getBoundingClientRect().bottom > $(window).height()) {
139			el.classList.add('offsetMenu');
140			var bottom = this.getBoundingClientRect().bottom - $(window).height();
141			$(this).find('.offsetMenu').css('top', 'auto');
142			$(this).find('.offsetMenu').css('bottom', bottom+'px');
143		}
144	});
145}
146
147CheckTopMenuDotted = function(){
148	var menu = $('nav.mega-menu.sliced');
149	/*if(isMobile)
150		return;*/
151
152	if(window.matchMedia('(max-width:991px)').matches)
153		return;
154
155	if(menu.length)
156	{
157		menu.each(function(){
158			var menuMoreItem = $(this).find('td.js-dropdown');
159			if($(this).parents('.collapse').css('display') == 'none'){
160				return false;
161			}
162
163			var block_w = $(this).closest('div').actual('width');
164			var	menu_w = $(this).find('table').actual('outerWidth');
165			var afterHide = false;
166
167			while(menu_w > block_w) {
168				menuItemOldSave = $(this).find('td').not('.nosave').last();
169				if(menuItemOldSave.length){
170					menuMoreItem.show();
171					menuItemNewSave = '<li class="' + (menuItemOldSave.hasClass('dropdown') ? 'dropdown-submenu ' : '') + (menuItemOldSave.hasClass('active') ? 'active ' : '') + '" data-hidewidth="' + menu_w + '">' + menuItemOldSave.find('.wrap').html() + '</li>';
172					menuItemOldSave.remove();
173					menuMoreItem.find('> .wrap > .dropdown-menu').prepend(menuItemNewSave);
174					menu_w = $(this).find('table').actual('outerWidth');
175					afterHide = true;
176				}
177				//menu.find('.nosave').css('display', 'table-cell');
178				else{
179					break;
180				}
181			}
182
183			if(!afterHide) {
184				do {
185					var menuItemOldSaveCnt = menuMoreItem.find('.dropdown-menu').find('li').length;
186					menuItemOldSave = menuMoreItem.find('.dropdown-menu').find('li').first();
187					if(!menuItemOldSave.length) {
188						menuMoreItem.hide();
189						break;
190					}
191					else {
192						var hideWidth = menuItemOldSave.attr('data-hidewidth');
193						if(hideWidth > block_w) {
194							break
195						}
196						else {
197							menuItemNewSave = '<td class="menu-item hght-100 ' + (menuItemOldSave.hasClass('dropdown-submenu') ? 'dropdown ' : '') + (menuItemOldSave.hasClass('active') ? 'active ' : '') + '" data-hidewidth="' + block_w + '"><div class="wrap hght-100 flex-row-c">' + menuItemOldSave.html() + '</div></td>';
198							menuItemOldSave.remove();
199							$(menuItemNewSave).insertBefore($(this).find('td.js-dropdown'));
200							if(!menuItemOldSaveCnt) {
201								menuMoreItem.hide();
202								break;
203							}
204						}
205					}
206					menu_w = $(this).find('table').actual('outerWidth');
207				}
208				while(menu_w <= block_w);
209			}
210			$(this).find('td').css('visibility', 'visible');
211			$(this).find('td').removeClass('unvisible');
212		})
213
214	}
215	return false;
216}
217
218CheckTopVisibleMenu = function(that) {
219	var dropdownMenu = $('.dropdown-menu:visible').last();
220	if(dropdownMenu.length){
221		dropdownMenu.find('a').css('white-space', '');
222		dropdownMenu.css('left', '');
223		dropdownMenu.css('right', '');
224		dropdownMenu.removeClass('toright');
225
226		var dropdownMenu_left = dropdownMenu.offset().left;
227		if(typeof(dropdownMenu_left) != 'undefined'){
228			var menu = dropdownMenu.parents('.mega-menu');
229			if(!menu.length)
230				menu = dropdownMenu.closest('.logo-row');
231			var menu_width = menu.outerWidth();
232			var menu_left = menu.offset().left;
233			var menu_right = menu_left + menu_width;
234			var isToRight = dropdownMenu.parents('.toright').length > 0;
235			var parentsDropdownMenus = dropdownMenu.parents('.dropdown-menu');
236			var isHasParentDropdownMenu = parentsDropdownMenus.length > 0;
237			if(isHasParentDropdownMenu){
238				var parentDropdownMenu_width = parentsDropdownMenus.first().outerWidth();
239				var parentDropdownMenu_left = parentsDropdownMenus.first().offset().left;
240				var parentDropdownMenu_right = parentDropdownMenu_width + parentDropdownMenu_left;
241			}
242
243			if(parentDropdownMenu_right + dropdownMenu.outerWidth() > menu_right){
244				dropdownMenu.find('a').css('white-space', 'normal');
245			}
246
247			var dropdownMenu_width = dropdownMenu.outerWidth();
248			var dropdownMenu_right = dropdownMenu_left + dropdownMenu_width;
249
250			if(dropdownMenu_right > menu_right || isToRight){
251
252
253				var addleft = 0;
254				addleft = menu_right - dropdownMenu_right;
255				if(isHasParentDropdownMenu || isToRight){
256
257					dropdownMenu.css('left', 'auto');
258					dropdownMenu.css('right', '100%');
259					dropdownMenu.addClass('toright');
260				}
261				else{
262					var dropdownMenu_curLeft = parseInt(dropdownMenu.css('left'));
263					dropdownMenu.css('left', (dropdownMenu_curLeft + addleft) + 'px');
264				}
265			}
266		}
267	}
268}
269
270MegaMenuFixed = function(){
271	var animationTime = 150;
272
273	$('.logo_and_menu-row .burger').on('click', function(){
274		$('.mega_fixed_menu').fadeIn(animationTime);
275	});
276
277	$('.mega_fixed_menu .svg.svg-close').on('click', function(){
278		$(this).closest('.mega_fixed_menu').fadeOut(animationTime);
279	});
280
281	$('.mega_fixed_menu .dropdown-menu .arrow').on('click', function(e){
282		e.preventDefault();
283		e.stopPropagation();
284		$(this).closest('.dropdown-submenu').find('.dropdown-menu').slideToggle(animationTime);
285		$(this).closest('.dropdown-submenu').addClass('opened');
286	});
287}
288
289CheckPopupTop = function(){
290	var popup = $('.jqmWindow.show');
291	if(popup.length){
292		var documentScollTop = $(document).scrollTop();
293		var windowHeight = $(window).height();
294		var popupTop = parseInt(popup.css('top'));
295		var popupHeight = popup.height();
296
297		if(windowHeight >= popupHeight){
298			// center
299			popupTop = (windowHeight - popupHeight) / 2;
300		}
301		else{
302			if(documentScollTop > documentScrollTopLast){
303				// up
304				popupTop -= documentScollTop - documentScrollTopLast;
305			}
306			else if(documentScollTop < documentScrollTopLast){
307				// down
308				popupTop += documentScrollTopLast - documentScollTop;
309			}
310
311			if(popupTop + popupHeight < windowHeight){
312				// bottom
313				popupTop = windowHeight - popupHeight;
314			}
315			else if(popupTop > 0){
316				// top
317				popupTop = 0;
318			}
319		}
320		popup.css('top', popupTop + 'px');
321	}
322}
323
324CheckMainBannerSliderVText = function(slider){
325	/*if(slider.parents('.banners-big').length){
326		var sh = slider.height();
327		slider.find('.item').each(function() {
328			var curSlideTextInner = $(this).find('.text .inner');
329			if(curSlideTextInner.length){
330				var ith = curSlideTextInner.actual('height');
331				var p = (ith >= sh ? 0 : Math.floor((sh - ith) / 2));
332				curSlideTextInner.css('padding-top', p + 'px');
333			}
334		});
335	}*/
336}
337
338CheckStickyFooter = function() {
339	BX.addCustomEvent('onWindowResize', function(eventdata){
340		if(!isMobile)
341		{
342			try{
343				var footerHeight = $('footer').outerHeight();
344				ignoreResize.push(true);
345				$('footer').css('margin-top', '-' + footerHeight + 'px');
346				$('.body').css('margin-bottom', '-' + footerHeight + 'px');
347				$('.main').css('padding-bottom', footerHeight + 0 + 'px');
348				ignoreResize.pop();
349			}
350			catch(e){}
351		}
352	});
353}
354
355verticalAlign = function(class_name){
356	if(typeof class_name == "undefined")
357		class_name = 'auto_align';
358    if($('.'+class_name).length)
359    {
360	    maxHeight = 0;
361	    $('.'+class_name).each(function(){
362	        if ($(this).height()> maxHeight){
363	            maxHeight = $(this).height();
364	        };
365	    });
366	    $('.'+class_name).each(function(){
367
368	            delta = Math.round((maxHeight - $(this).height())/2);
369	            $(this).css({'padding-top': delta+'px', 'padding-bottom': delta+'px'});
370	    });
371	}
372}
373
374getGridSize = function(counts, custom_counts) {
375	var z = parseInt($('.body_media').css('top'));
376	if(typeof(custom_counts) != 'undefined')
377	{
378		if(window.matchMedia('(max-width: 700px)').matches)
379			return (counts[3] ? counts[3] : counts[2]);
380		else if(window.matchMedia('(max-width: 850px)').matches)
381			return counts[2];
382		else if(window.matchMedia('(max-width: 1200px)').matches)
383			return counts[1];
384		else
385			return counts[0];
386	}
387	else
388	{
389		if(window.matchMedia('(max-width: 600px)').matches)
390		{
391			return (counts[3] ? counts[3] : counts[2]);
392		}
393		else
394			return (z == 2 ? counts[0] : z == 1 ? counts[1] : counts[2]);
395	}
396}
397
398CheckFlexSlider = function(){
399	$('.flexslider:not(.thmb):visible').each(function(){
400		var slider = $(this);
401		slider.resize();
402		var counts = slider.data('flexslider').vars.counts,
403			slide_counts = slider.data('flexslider').vars.slide_counts;
404		if(typeof(counts) != 'undefined'){
405			var cnt = getGridSize(counts, slider.data('flexslider').vars.customGrid);
406			var to0 = (cnt != slider.data('flexslider').vars.minItems || cnt != slider.data('flexslider').vars.maxItems || cnt != slider.data('flexslider').vars.move);
407			if(to0){
408				slider.data('flexslider').vars.minItems = cnt;
409				slider.data('flexslider').vars.maxItems = cnt;
410				if(typeof(slide_counts) != 'undefined')
411					slider.data('flexslider').vars.move = slide_counts;
412				else
413					slider.data('flexslider').vars.move = cnt;
414
415				slider.flexslider(0);
416				slider.resize();
417				slider.resize(); // twise!
418			}
419		}
420	});
421}
422
423CheckBreadcrumbFixed  = function(){
424	var Breadcrumb_fixed = $('.breadcrumbFixed');
425	var header = $('header').first();
426	var breadCrumb = $('.page-top .breadcrumb');
427
428	if(!breadCrumb.length) {
429		var headerBreadCrumb = $('#headerfixed .breadcrumb');
430		headerBreadCrumb.remove();
431		return false;
432	}
433
434	if(header.length && !$('body.index').length)
435	{
436		var isBreadcrumbFixed = false,
437			BreadcrumbCanFix = true,
438			BreadcrumbFixedHeight = Breadcrumb_fixed.actual('outerHeight'),
439			headerNormalHeight = header.actual('outerHeight'),
440			headerDiffHeight = headerNormalHeight - BreadcrumbFixedHeight + 30,
441			mobileBtnMenu = $('.btn.btn-responsive-nav'),
442			headerTop = $('#panel:visible').actual('outerHeight');
443			topBlock = $('.TOP_HEADER').first();
444
445		if(headerDiffHeight <= 0)
446			headerDiffHeight = 0;
447		if(topBlock.length)
448			headerTop += topBlock.actual('outerHeight');
449
450		$(window).scroll(function(){
451				var scrollTop = $(window).scrollTop();
452				BreadcrumbCanFix = !mobileBtnMenu.is(':visible')/* && !$('.dropdown-menu:visible').length*/;
453
454				var current_is = $('.search-wrapper .search-input:visible'),
455					title_search_result = $('.title-search-result.'+current_is.attr('id')),
456					pos, pos_input;
457
458				if(!isBreadcrumbFixed)
459				{
460					if((scrollTop > headerNormalHeight + headerTop) && BreadcrumbCanFix)
461					{
462						if($('.breadcrumb_wrapper_fixed').length) {
463							var breadHeight = $('.breadcrumb_wrapper').outerHeight();
464							var breadcrumb = $('.breadcrumb_wrapper #navigation');
465							$('.breadcrumb_wrapper').css('height', breadHeight+'px');
466							$('.breadcrumb_wrapper').empty();
467							$('.breadcrumb_wrapper_fixed').append(breadcrumb);
468						}
469
470						isBreadcrumbFixed = true;
471						Breadcrumb_fixed.css('top', '-' + headerNormalHeight + 'px');
472						
473						Breadcrumb_fixed.addClass('fixed');
474						
475						// header_fixed.stop(0).animate({top: '0'}, 300);
476
477						Breadcrumb_fixed.animate({top: '0'}, {duration:300, complete:
478							function(){}
479						});
480					}
481				}
482				else if(isBreadcrumbFixed || !BreadcrumbCanFix)
483				{
484					if((scrollTop <= headerDiffHeight + headerTop) || !BreadcrumbCanFix)
485					{
486						if($('.breadcrumb_wrapper_fixed').length) {
487							var breadcrumb = $('.breadcrumb_wrapper_fixed #navigation');
488							$('.breadcrumb_wrapper_fixed').empty();
489							$('.breadcrumb_wrapper').append(breadcrumb);
490						}
491						isBreadcrumbFixed = false;
492						Breadcrumb_fixed.removeClass('fixed');
493					}
494				}
495			// }
496		});
497	}
498}
499
500CheckHeaderFixed = function(){
501	var header_fixed = $('#headerfixed');
502		header = $('header').first();
503	var breadCrumb = $('.page-top .breadcrumb');
504	var breadCrumbFixed = $('#headerfixed .breadcrumb');
505
506	if(!breadCrumb.length) {
507		breadCrumbFixed.remove();
508	}
509	
510	if(header_fixed.length){
511		if(header.length)
512		{
513			var isHeaderFixed = false,
514				headerCanFix = true,
515				headerFixedHeight = header_fixed.actual('outerHeight'),
516				headerNormalHeight = header.actual('outerHeight'),
517				headerDiffHeight = headerNormalHeight - headerFixedHeight + 30,
518				mobileBtnMenu = $('.btn.btn-responsive-nav'),
519				headerTop = $('#panel:visible').actual('outerHeight');
520				topBlock = $('.TOP_HEADER').first();
521
522			if(headerDiffHeight <= 0)
523				headerDiffHeight = 0;
524			if(topBlock.length)
525				headerTop += topBlock.actual('outerHeight');
526
527			$(window).scroll(function(){
528				/*if(!isMobile && window.matchMedia('(min-width: 992px)').matches)
529				{*/
530					var scrollTop = $(window).scrollTop();
531					headerCanFix = !mobileBtnMenu.is(':visible')/* && !$('.dropdown-menu:visible').length*/;
532
533					var current_is = $('.search-wrapper .search-input:visible'),
534						title_search_result = $('.title-search-result.'+current_is.attr('id')),
535						pos, pos_input;
536
537					if(!isHeaderFixed)
538					{
539						if((scrollTop > headerNormalHeight + headerTop) && headerCanFix)
540						{
541							if(breadCrumb.length) {
542								if($('.breadcrumb_wrapper_fixed').length) {
543									var breadHeight = $('.breadcrumb_wrapper').outerHeight();
544									var breadcrumb = $('.breadcrumb_wrapper #navigation');
545									$('.breadcrumb_wrapper').css('height', breadHeight+'px');
546									$('.breadcrumb_wrapper').empty();
547									$('.breadcrumb_wrapper_fixed').append(breadcrumb);
548								}
549							}
550							
551
552							isHeaderFixed = true;
553							header_fixed.css('top', '-' + headerNormalHeight + 'px');
554							
555							header_fixed.addClass('fixed');
556							
557							// header_fixed.stop(0).animate({top: '0'}, 300);
558
559							header_fixed.animate({top: '0'}, {duration:300, complete:
560								function(){}
561							});
562							CheckTopMenuDotted();
563							CheckMenuOffset();
564						}
565					}
566					else if(isHeaderFixed || !headerCanFix)
567					{
568						if((scrollTop <= headerDiffHeight + headerTop) || !headerCanFix)
569						{
570							if(breadCrumb.length) {
571								if($('.breadcrumb_wrapper_fixed').length) {
572									var breadcrumb = $('.breadcrumb_wrapper_fixed #navigation');
573									$('.breadcrumb_wrapper_fixed').empty();
574									$('.breadcrumb_wrapper').append(breadcrumb);
575								}
576							}
577							isHeaderFixed = false;
578							header_fixed.removeClass('fixed');
579						}
580					}
581				// }
582			});
583		}
584	} else {
585		CheckBreadcrumbFixed();
586	}
587}
588
589CheckObjectsSizes = function() {
590	$('.container iframe,.container object,.container video').each(function() {
591		var height_attr = $(this).attr('height');
592		var width_attr = $(this).attr('width');
593		
594		if (height_attr && width_attr) {
595			$(this).css('height', $(this).outerWidth() * height_attr / width_attr);
596		}
597	});
598}
599
600scrollToTop = function(){
601	if(window.matchMedia('(min-width: 767px)').matches){
602		if(arHeatOptions['THEME']['SCROLLTOTOP_TYPE'] !== 'NONE'){
603			scrollToTopAnimateClassIn = arHeatOptions.THEME.SCROLLTOTOP_TYPE.indexOf('ROUND') !== -1 ? 'rotateIn' : 'rubberBand';
604			scrollToTopAnimateClassOut = arHeatOptions.THEME.SCROLLTOTOP_TYPE.indexOf('ROUND') !== -1 ? 'rotateOut' : 'flipOutX';
605			if(BX.browser.IsMac())
606			{
607				scrollToTopAnimateClassIn = scrollToTopAnimateClassOut = '';
608			}
609			var _isScrolling = false;
610			// Append Button
611			$('body').append($('<a />').addClass('scroll-to-top ' + arHeatOptions['THEME']['SCROLLTOTOP_TYPE'] + ' ' + arHeatOptions['THEME']['SCROLLTOTOP_POSITION']).attr({'href': '#', 'id': 'scrollToTop'}));
612			$scrolltotop = $('#scrollToTop');
613			$scrolltotop.click(function(e){
614				e.preventDefault();
615				$('body, html').animate({scrollTop : 0}, 500);
616				return false;
617			});
618			// Show/Hide Button on Window Scroll event.
619			$(window).scroll(function(){
620				if(!_isScrolling) {
621					_isScrolling = true;
622					var bottom = 100,
623						scrollVal = $(window).scrollTop(),
624						windowHeight = $(window).height();
625
626					var footerOffset = 0;
627					if ($('footer').get(0)) {
628						footerOffset = $('footer').offset().top;
629					}
630					if(scrollVal > 150){
631						$('#scrollToTop').stop(true, true).addClass('visible');
632						_isScrolling = false;
633					}
634					else{
635						$('#scrollToTop').stop(true, true).removeClass('visible');
636						_isScrolling = false;
637					}
638					CheckScrollToTop();
639				}
640			});
641		}
642	}
643}
644
645CheckScrollToTop = function(){
646	if(window.matchMedia('(min-width: 767px)').matches){
647		if(arHeatOptions["THEME"]["SCROLLTOTOP_TYPE"] !== "NONE")
648		{
649			if(documentScrollTop > 150){
650				//$scrolltotop.stop(true, true).addClass('visible').addClass('animated');
651				if(scrollToTopAnimateClassOut){
652					$scrolltotop.removeClass(scrollToTopAnimateClassOut);
653				}
654				if(scrollToTopAnimateClassIn){
655					$scrolltotop.addClass(scrollToTopAnimateClassIn);
656				}
657			}
658			else{
659				$scrolltotop.stop(true, true).removeClass('visible');
660				if(scrollToTopAnimateClassIn){
661					$scrolltotop.removeClass(scrollToTopAnimateClassIn);
662				}
663				if(scrollToTopAnimateClassOut){
664					$scrolltotop.addClass(scrollToTopAnimateClassOut);
665				}
666			}
667		}
668		var bottom = 100,
669			scrollVal = $(window).scrollTop(),
670			windowHeight = $(window).height();
671		if($('footer').length) {
672			var footerOffset = $('footer').offset().top;
673			var footerHeight = $('footer').outerHeight();
674		}
675
676		if(parseInt($('#scrollToTop').css('bottom')) > bottom){
677			$('#scrollToTop').css('bottom', bottom);
678		}
679	}
680}
681
682var isMobile = jQuery.browser.mobile;
683var players = {};
684
685if(isMobile){
686	document.documentElement.className += ' mobile';
687}
688
689$.fn.equalizeHeights = function( outer, classNull, minHeight, autoHeightBlock ){
690	var maxHeight = this.map( function( i, e ){
691		var minus_height=0,
692			calc_height=0;
693		if(classNull !== false && $(e).find(classNull).is(':visible'))
694			minus_height=parseInt($(e).find(classNull).actual('outerHeight'));
695		if(minus_height)
696			minus_height+=15;
697		$(e).css('height', '');
698		if(autoHeightBlock !== false)
699		{
700			var height_tmp = $(e).find(autoHeightBlock).css('height');
701			$(e).find(autoHeightBlock).css('height', '');
702		}
703		if( outer == true ){
704			calc_height=$(e).actual('outerHeight')-minus_height;
705		}else{
706			calc_height=$(e).actual('height')-minus_height;
707		}
708
709		if(autoHeightBlock !== false)
710		{
711			$(e).find(autoHeightBlock).css('height', height_tmp);
712		}
713		if(minHeight!==false){
714			if(calc_height<minHeight){
715				calc_height+=(minHeight-calc_height);
716			}
717			if(window.matchMedia('(max-width: 520px)').matches){
718				calc_height=300;
719			}
720			if(window.matchMedia('(max-width: 400px)').matches){
721				calc_height=200;
722			}
723		}
724		return calc_height;
725	}).get();
726
727	for(var i = 0, c = maxHeight.length; i < c; ++i){
728		if(maxHeight[i] % 2){
729			--maxHeight[i];
730		}
731	}
732
733
734	return this.height( Math.max.apply( this, maxHeight ) );
735}
736
737$.fn.getFloatWidth = function(){
738	var width = 0
739
740	if($(this).length){
741		var rect = $(this)[0].getBoundingClientRect()
742		if(!(width = rect.width)){
743			width = rect.right - rect.left
744		}
745	}
746
747	return width
748}
749
750$.fn.sliceHeight = function( options ){
751	function _slice(el){
752		el.each(function() {
753			$(this).css('line-height', '');
754			$(this).css('height', '');
755		});
756		if(typeof(options.autoslicecount) == 'undefined' || options.autoslicecount !== false){
757			var elsw=(typeof(options.row) !== 'undefined' && options.row.length) ?  el.first().parents(options.row).getFloatWidth() : el.first().parents('.items').getFloatWidth(),
758				elw=(typeof(options.item) !== 'undefined' && options.item.length) ? $(options.item).first().getFloatWidth() : (el.first().hasClass('item') ? el.first().getFloatWidth() : el.first().parents('.item').getFloatWidth());
759
760			if(!elsw){
761				elsw = el.first().parents('.row').getFloatWidth();
762			}
763			if(elw && options.fixWidth)
764				elw -= options.fixWidth;
765
766			if(elsw && elw && !options.slice){
767				options.slice = Math.floor(elsw / elw);
768			}
769		}
770		if(typeof(options.typeResize) == 'undefined' || options.typeResize == false)
771		{
772			if(options.sliceEqualLength && el.closest('.flexslider').length)
773				options.slice = el.length;
774			if(options.slice){
775				for(var i = 0; i < el.length; i += options.slice){
776					$(el.slice(i, i + options.slice)).equalizeHeights(options.outer, options.classNull, options.minHeight, options.autoHeightBlock);
777				}
778			}
779			if(options.lineheight){
780				var lineheightAdd = parseInt(options.lineheight);
781				if(isNaN(lineheightAdd)){
782					lineheightAdd = 0;
783				}
784				el.each(function() {
785					$(this).css('line-height', ($(this).actual('height') + lineheightAdd) + 'px');
786				});
787			}
788		}
789
790		if(typeof options.callback == 'function')
791			options.callback(el);
792	}
793	var options = $.extend({
794		slice: null,
795		outer: false,
796		lineheight: false,
797		autoslicecount: true,
798		classNull: false,
799		minHeight: false,
800		row:false,
801		item:false,
802		typeResize:false,
803		resize:true,
804		typeValue:false,
805		sliceEqualLength:false,
806		fixWidth:0,
807		callback:false,
808		autoHeightBlock:false,
809	}, options);
810
811	var el = $(this);
812	ignoreResize.push(true);
813	_slice(el);
814	ignoreResize.pop();
815
816	if(options.resize != false)
817	{
818		BX.addCustomEvent('onWindowResize', function(eventdata) {
819			ignoreResize.push(true);
820			_slice(el);
821			ignoreResize.pop();
822		});
823	}
824}
825
826waitingExists = function(selector, delay, callback){
827	if(typeof(callback) !== 'undefined' && selector.length && delay > 0){
828		delay = parseInt(delay);
829		delay = (delay < 0 ? 0 : delay);
830
831		if(!$(selector).length){
832			setTimeout(function(){
833				waitingExists(selector, delay, callback);
834			}, delay);
835		}
836		else{
837			callback();
838		}
839	}
840}
841
842waitingNotExists = function(selectorExists, selectorNotExists, delay, callback){
843	if(typeof(callback) !== 'undefined' && selectorExists.length && selectorNotExists.length && delay > 0){
844		delay = parseInt(delay);
845		delay = (delay < 0 ? 0 : delay);
846
847		setTimeout(function(){
848			if(selectorExists.length && !$(selectorNotExists).length){
849				callback();
850			}
851		}, delay);
852	}
853}
854
855InitSlickSlider = function() {
856	$('.slick-slider:not(.slick-initialized):visible').each(function(){
857		var $this = $(this);
858		var defaults = {
859			infinite: false,
860			dots: false,
861			speed: 300,
862			autoplaySpeed: 5000,
863			slidesToShow: 1,
864			slidesToScroll: 1,
865			swipeToSlide: true,
866			draggable: true,
867			lazyLoad: 'ondemand',
868			waitForAnimate: false,
869			arrows : true,
870			prevArrow : '<div class="slick_prev"></div>',
871			nextArrow: '<div class="slick_next"></div>',
872			customPaging: function (slider, i) {
873				var slides_on_page = $this.data('plugin_options').slidesToShow;
874				if(i % slides_on_page ==0 || i == 0) {
875					return '<a class="dot" role="button"></a>';
876				} else {
877					return '<a class="dot hidden" role="button"></a>';
878				}
879          	}
880		}
881		var options = $.extend({}, defaults, $this.data('plugin_options'));
882		$this.slick(options);
883	});
884}
885
886InitSlickSliderClass = function(class_name) {
887	//$(selector).each(function(){
888		var $this = $(class_name);
889		var defaults = {
890			infinite: false,
891			dots: false,
892			speed: 300,
893			autoplaySpeed: 5000,
894			slidesToShow: 1,
895			slidesToScroll: 1,
896			swipeToSlide: true,
897			draggable: true,
898			lazyLoad: 'ondemand',
899			waitForAnimate: false,
900			arrows : true,
901			prevArrow : '<div class="slick_prev"></div>',
902			nextArrow: '<div class="slick_next"></div>',
903			customPaging: function (slider, i) {
904				var slides_on_page = $this.data('plugin_options').slidesToShow;
905				if(i % slides_on_page ==0 || i == 0) {
906					return '<a class="dot" role="button"></a>';
907				} else {
908					return '<a class="dot hidden" role="button"></a>';
909				}
910          	}
911		}
912		var options = $.extend({}, defaults, $this.data('plugin_options'));
913		$this.slick(options);
914	//});
915}
916
917function onLoadjqm(hash){
918	var name = $(hash.t).data('name'),
919		top = (($(window).height() > hash.w.height()) ? Math.floor(($(window).height() - hash.w.height()) / 2) : 0) + 'px';
920	$.each($(hash.t).get(0).attributes, function(index, attr){
921		if(/^data\-autoload\-(.+)$/.test(attr.nodeName)){
922			var key = attr.nodeName.match(/^data\-autoload\-(.+)$/)[1];
923			var el = $('input[name="'+key.toUpperCase()+'"]');
924			if(!el.length) //is form block
925				el = $('input[data-sid="'+key.toUpperCase()+'"]');
926
927			var value = $(hash.t).data('autoload-'+key);
928			value = value.replace(/%99/g, '\\'); // replace symbol \
929
930			el.val(BX.util.htmlspecialcharsback(value)).attr('readonly', 'readonly');
931			el.closest('.form-group').addClass('input-filed');
932			el.attr('title', el.val());
933		}
934	});
935
936	var eventdata = {action:'loadForm'};
937	BX.onCustomEvent('onCompleteAction', [eventdata, $(hash.t)[0]]);
938
939	if($(hash.t).data('autohide')){
940		$(hash.w).data('autohide', $(hash.t).data('autohide'));
941	}
942	if(name == 'order_product'){
943		if($(hash.t).data('product')) {
944			$('input[name="PRODUCT"]').closest('.form-group').addClass('input-filed');
945			$('input[name="PRODUCT"]').val($(hash.t).data('product')).attr('readonly', 'readonly').attr('title', $('input[name="PRODUCT"]').val());
946		}
947	}
948	if(name == 'question'){
949		if($(hash.t).data('product')) {
950			$('input[name="NEED_PRODUCT"]').closest('.form-group').addClass('input-filed');
951			$('input[name="NEED_PRODUCT"]').val($(hash.t).data('product')).attr('readonly', 'readonly').attr('title', $('input[name="NEED_PRODUCT"]').val());
952		}
953	}
954
955	if(arHeatOptions['THEME']['REGIONALITY_SEARCH_ROW'] == 'Y' && (hash.w.hasClass('city_chooser_frame ') || hash.w.hasClass('city_chooser_small_frame')))
956		hash.w.addClass('small_popup_regions')
957
958	hash.w.addClass('show').css({'margin-left': '-' + Math.floor(hash.w.width() / 2) + 'px', 'top': top, 'opacity': 1});
959}
960
961function onHide(hash){
962	if($(hash.w).data('autohide')){
963		eval($(hash.w).data('autohide'));
964	}
965	// hash.w.css('opacity', 0).hide();
966	hash.w.animate({'opacity': 0}, 200, function(){
967		hash.w.hide();
968		hash.w.empty();
969		hash.o.remove();
970		hash.w.removeClass('show');
971	});
972}
973
974function parseUrlQuery() {
975	var data = {};
976	if(location.search) {
977		var pair = (location.search.substr(1)).split('&');
978		for(var i = 0; i < pair.length; i ++) {
979			var param = pair[i].split('=');
980			data[param[0]] = param[1];
981		}
982	}
983	return data;
984}
985
986function scroll_block(block){
987	if(block.length)
988	{
989		var topPos = block.offset().top,
990			headerH = $('header').outerHeight(true,true);
991		if($(".stores_tab").length){
992			$(".stores_tab").addClass("active").siblings().removeClass("active");
993		}else{
994			$(".prices_tab").addClass("active").siblings().removeClass("active");
995			if($(".prices_tab .opener").length && !$(".prices_tab .opener .opened").length){
996				var item = $(".prices_tab .opener").first();
997				item.find(".opener_icon").addClass("opened");
998				item.parents("tr").addClass("nb")
999				item.parents("tr").next(".offer_stores").find(".stores_block_wrap").slideDown(200);
1000			}
1001		}
1002		$('html,body').animate({'scrollTop':topPos-80},150);
1003	}
1004}
1005
1006$.fn.jqmEx = function(){
1007
1008	$(this).each(function(){
1009		var _this = $(this);
1010		var name = _this.data('name');
1011
1012		if(name.length){
1013			var script = arHeatOptions['SITE_DIR'] + 'ajax/form.php';
1014			var paramsStr = ''; var trigger = ''; var arTriggerAttrs = {};
1015			$.each(_this.get(0).attributes, function(index, attr){
1016				var attrName = attr.nodeName;
1017				var attrValue = _this.attr(attrName);
1018				trigger += '[' + attrName + '=\"' + attrValue + '\"]';
1019				arTriggerAttrs[attrName] = attrValue;
1020				if(/^data\-param\-(.+)$/.test(attrName)){
1021					var key = attrName.match(/^data\-param\-(.+)$/)[1];
1022					paramsStr += key + '=' + attrValue + '&';
1023				}
1024				
1025			});
1026			var triggerAttrs = JSON.stringify(arTriggerAttrs);
1027			var encTriggerAttrs = encodeURIComponent(triggerAttrs);
1028			if(name == 'auth')
1029				script += '?' + paramsStr + 'auth=Y';
1030			else
1031				script += '?' + paramsStr + 'data-trigger=' + encTriggerAttrs;
1032
1033			if(!$('.' + name + '_frame[data-trigger="' + encTriggerAttrs + '"]').length){
1034				if(_this.attr('disabled') != 'disabled'){
1035					$('body').find('.' + name + '_frame[data-trigger="' + encTriggerAttrs + '"]').remove();
1036					$('body').append('<div class="' + name + '_frame jqmWindow" style="width:500px" data-trigger="' + encTriggerAttrs + '"></div>');
1037					$('.' + name + '_frame[data-trigger="' + encTriggerAttrs + '"]').jqm({trigger: trigger, onLoad: function(hash){onLoadjqm(hash);}, onHide: function(hash){onHide(hash);}, ajax:script});
1038				}
1039			}
1040		}
1041		return;
1042	});
1043}
1044
1045InitFlexSlider = function() {
1046	$('.flexslider:not(.thmb):not(.flexslider-init):visible').each(function(){
1047		var slider = $(this);
1048		var options;
1049		var defaults = {
1050			animationLoop: false,
1051			controlNav: false,
1052			directionNav: true,
1053			animation: "slide",
1054		}
1055		var config = $.extend({}, defaults, options, slider.data('plugin-options'));
1056		if(typeof(config.counts) != 'undefined' && config.direction !== 'vertical'){
1057			var slide_counts = '';
1058			if(typeof(slider.data('plugin-options')) != 'undefined')
1059			{
1060				if('slide_counts' in slider.data('plugin-options'))
1061					slide_counts = slider.data('plugin-options').slide_counts;
1062			}
1063			config.maxItems =  getGridSize(config.counts, config);
1064			config.minItems = getGridSize(config.counts, config);
1065
1066			if(slide_counts)
1067				config.move = slide_counts;
1068			else
1069				config.move = getGridSize(config.counts);
1070
1071			config.itemWidth = 200;
1072		}
1073
1074		// custom direction nav
1075		if(typeof(config.customDirection) != 'undefined')
1076			config.customDirectionNav = $(config.customDirection);
1077
1078		config.prevText = BX.message("FANCY_PREV"),           //String: Set the text for the "previous" directionNav item
1079		config.nextText = BX.message("FANCY_NEXT"),
1080
1081		config.after = config.start = function(slider){
1082			var eventdata = {slider: slider};
1083			BX.onCustomEvent('onSlide', [eventdata]);
1084		}
1085
1086		config.before = function(slider){
1087			var eventdata = {slider: slider};
1088			BX.onCustomEvent('onSlideBefore', [eventdata]);
1089		}
1090
1091		config.end = function(slider){
1092			var eventdata = {slider: slider};
1093			BX.onCustomEvent('onSlideEnd', [eventdata]);
1094		}
1095
1096		/*if(typeof(config.nav) == 'undefined')
1097			slider.addClass('dark-nav');*/
1098		slider.flexslider(config).addClass('flexslider-init');
1099		if(config.controlNav)
1100			slider.addClass('flexslider-control-nav');
1101		if(config.directionNav)
1102			slider.addClass('flexslider-direction-nav');
1103
1104		setTimeout(function() {$('.flexslider .bx-viewport').unbind();}, 100);
1105	});
1106
1107	
1108	
1109}
1110
1111InitFlexSliderClass = function(class_name) {
1112	//$('.flexslider:not(.thmb):not(.flexslider-init)').each(function(){
1113
1114		var slider = $(class_name);
1115		var options;
1116		var defaults = {
1117			animationLoop: false,
1118			controlNav: false,
1119			directionNav: true,
1120			animation: "slide"
1121		}
1122		var config = $.extend({}, defaults, options, slider.data('plugin-options'));
1123
1124		var slide_counts = '';
1125		if(typeof(slider.data('plugin-options')) != 'undefined')
1126		{
1127			if('slide_counts' in slider.data('plugin-options'))
1128				slide_counts = slider.data('plugin-options').slide_counts;
1129		}
1130
1131		if(typeof(config.counts) != 'undefined' && config.direction !== 'vertical'){
1132			config.maxItems =  getGridSize(config.counts);
1133			config.minItems = getGridSize(config.counts);
1134			config.move = getGridSize(config.counts);
1135
1136			config.itemWidth = 200;
1137		}
1138		if(slide_counts)
1139			config.move = slide_counts;
1140
1141		// custom direction nav
1142		if(typeof(config.customDirection) != 'undefined')
1143			config.customDirectionNav = $(config.customDirection);
1144
1145		config.prevText = BX.message("FANCY_PREV"),           //String: Set the text for the "previous" directionNav item
1146		config.nextText = BX.message("FANCY_NEXT"),
1147
1148		config.after = config.start = function(slider){
1149			var eventdata = {slider: slider};
1150			BX.onCustomEvent('onSlide', [eventdata]);
1151		}
1152
1153		config.before = function(slider){
1154			var eventdata = {slider: slider};
1155			BX.onCustomEvent('onSlideBefore', [eventdata]);
1156		}
1157
1158		config.end = function(slider){
1159			var eventdata = {slider: slider};
1160			BX.onCustomEvent('onSlideEnd', [eventdata]);
1161		}
1162
1163		slider.flexslider(config).addClass('flexslider-init');
1164		if(config.controlNav)
1165			slider.addClass('flexslider-control-nav');
1166		if(config.directionNav)
1167			slider.addClass('flexslider-direction-nav');
1168	//});
1169}
1170
1171InitOwlSlider = function() {
1172	$('.owl-carousel:not(.thmb):not(.owlslider-init)').each(function(){
1173		var slider = $(this);
1174		var options;
1175		var defaults = {
1176		}
1177		var config = $.extend({}, defaults, options, slider.data('plugin_options'));
1178		if(typeof(config.counts) != 'undefined' && config.direction !== 'vertical'){
1179			var slide_counts = '';
1180			if(typeof(slider.data('plugin_options')) != 'undefined')
1181			{
1182				if('slide_counts' in slider.data('plugin-options'))
1183					slide_counts = slider.data('plugin-options').slide_counts;
1184			}
1185			config.maxItems =  getGridSize(config.counts, config);
1186			config.minItems = getGridSize(config.counts, config);
1187
1188			if(slide_counts)
1189				config.move = slide_counts;
1190			else
1191				config.move = getGridSize(config.counts);
1192
1193			config.itemWidth = 200;
1194		}
1195
1196		// custom direction nav
1197		if(typeof(config.customDirection) != 'undefined')
1198			config.customDirectionNav = $(config.customDirection);
1199
1200		config.prevText = BX.message("FANCY_PREV"),           //String: Set the text for the "previous" directionNav item
1201		config.nextText = BX.message("FANCY_NEXT"),
1202
1203		config.after = config.start = function(slider){
1204			var eventdata = {slider: slider};
1205			BX.onCustomEvent('onSlide', [eventdata]);
1206		}
1207
1208		config.before = function(slider){
1209			var eventdata = {slider: slider};
1210			BX.onCustomEvent('onSlideBefore', [eventdata]);
1211		}
1212
1213		config.end = function(slider){
1214			var eventdata = {slider: slider};
1215			BX.onCustomEvent('onSlideEnd', [eventdata]);
1216		}
1217
1218		if(typeof(config.nav) == 'undefined')
1219			slider.addClass('dark-nav');
1220		slider.owlCarousel(config).addClass('owlslider-init');
1221		if(config.controlNav)
1222			slider.addClass('flexslider-control-nav');
1223		if(config.directionNav)
1224			slider.addClass('flexslider-direction-nav');
1225
1226		setTimeout(function() {$('.flexslider .bx-viewport').unbind();}, 100);
1227	});
1228}
1229
1230InitOwlSliderClass = function(class_name) {
1231		var slider = $(class_name);
1232		var options;
1233		var defaults = {
1234		}
1235		var config = $.extend({}, defaults, options, slider.data('plugin_options'));
1236		if(typeof(config.counts) != 'undefined' && config.direction !== 'vertical'){
1237			var slide_counts = '';
1238			if(typeof(slider.data('plugin_options')) != 'undefined')
1239			{
1240				if('slide_counts' in slider.data('plugin-options'))
1241					slide_counts = slider.data('plugin-options').slide_counts;
1242			}
1243			config.maxItems =  getGridSize(config.counts, config);
1244			config.minItems = getGridSize(config.counts, config);
1245
1246			if(slide_counts)
1247				config.move = slide_counts;
1248			else
1249				config.move = getGridSize(config.counts);
1250
1251			config.itemWidth = 200;
1252		}
1253
1254		// custom direction nav
1255		if(typeof(config.customDirection) != 'undefined')
1256			config.customDirectionNav = $(config.customDirection);
1257
1258		config.prevText = BX.message("FANCY_PREV"),           //String: Set the text for the "previous" directionNav item
1259		config.nextText = BX.message("FANCY_NEXT"),
1260
1261		config.after = config.start = function(slider){
1262			var eventdata = {slider: slider};
1263			BX.onCustomEvent('onSlide', [eventdata]);
1264		}
1265
1266		config.before = function(slider){
1267			var eventdata = {slider: slider};
1268			BX.onCustomEvent('onSlideBefore', [eventdata]);
1269		}
1270
1271		config.end = function(slider){
1272			var eventdata = {slider: slider};
1273			BX.onCustomEvent('onSlideEnd', [eventdata]);
1274		}
1275
1276		if(typeof(config.nav) == 'undefined')
1277			slider.addClass('dark-nav');
1278
1279		slider.owlCarousel(config).addClass('owlslider-init');
1280		if(config.controlNav)
1281			slider.addClass('flexslider-control-nav');
1282		if(config.directionNav)
1283			slider.addClass('flexslider-direction-nav');
1284
1285		setTimeout(function() {$('.flexslider .bx-viewport').unbind();}, 100);
1286}
1287
1288
1289SliceHeightBlocks = function(){
1290	$('*[data-slice="Y"]').each(function(){
1291		var slice_class = '';
1292		if($(this).data('slice-class') != undefined) {
1293			slice_class = $(this).data('slice-class');
1294			slice_class = slice_class.replace(/\s+/g, '');
1295			slice_class = slice_class.split(',');
1296			for (var i = 0; i < slice_class.length; i++) {
1297				var slice_els = $(this).find('.'+slice_class[i]+'[data-slice-block="Y"]');
1298				if(slice_els.length)
1299				{
1300					var slice_params = {};
1301					if(slice_els.data('slice-params'))
1302						slice_params = slice_els.data('slice-params');
1303					slice_els.sliceHeight(slice_params);
1304				}
1305			}
1306		} else {
1307			var slice_els = $(this).find('*[data-slice-block="Y"]');
1308			if(slice_els.length)
1309			{
1310				var slice_params = {};
1311				if(slice_els.data('slice-params'))
1312					slice_params = slice_els.data('slice-params');
1313				slice_els.sliceHeight(slice_params);
1314			}
1315		}
1316	});
1317}
1318
1319SliceHeightBlocksClass = function(object){
1320	$(object).find('*[data-slice="Y"]').each(function(){
1321		var slice_class = '';
1322		if($(this).data('slice-class') != undefined) {
1323			slice_class = $(this).data('slice-class');
1324			slice_class = slice_class.replace(/\s+/g, '');
1325			slice_class = slice_class.split(',');
1326			for (var i = 0; i < slice_class.length; i++) {
1327				var slice_els = $(this).find('.'+slice_class[i]+'[data-slice-block="Y"]');
1328				if(slice_els.length)
1329				{
1330					var slice_params = {};
1331					if(slice_els.data('slice-params'))
1332						slice_params = slice_els.data('slice-params');
1333					slice_els.sliceHeight(slice_params);
1334				}
1335			}
1336		} else {
1337			var slice_els = $(this).find('*[data-slice-block="Y"]');
1338			if(slice_els.length)
1339			{
1340				var slice_params = {};
1341				if(slice_els.data('slice-params'))
1342					slice_params = slice_els.data('slice-params');
1343				slice_els.sliceHeight(slice_params);
1344			}
1345		}
1346	})
1347}
1348
1349createTableCompare = function(originalTable, appendDiv, cloneTable){
1350	try{
1351		if($('.tarifs .head-block:visible').length){
1352			var clone = originalTable.clone().addClass('clone');
1353			if(cloneTable.length){
1354				cloneTable.remove();
1355				appendDiv.html('');
1356				appendDiv.html(clone);
1357			}else{
1358				appendDiv.append(clone);
1359			}
1360		}
1361	}
1362	catch(e){}
1363	finally{}
1364}
1365
1366
1367InitTopestMenuGummi = function(){
1368	if(!isOnceInited){
1369		function _init(){
1370			var arItems = $menuTopest.find('>
1370li:not(.more)');
1371			var cntItems = arItems.length;
1372			if(cntItems){
1373				var itemsWidth = 0;
1374				for(var i = 0; i < cntItems; ++i){
1375					var item = arItems.eq(i);
1376					var itemWidth = item.actual('outerWidth',{includeMargin: true});
1377					arItemsHideWidth[i] = (itemsWidth += itemWidth) + (i !== (cntItems - 1) ? moreWidth : 0);
1378				}
1379			}
1380		}
1381
1382		function _gummi(){
1383			var rowWidth = $menuTopest.actual('innerWidth');
1384			var arItems = $menuTopest.find('>li:not(.more),li.more>.dropdown>li');
1385			var cntItems = arItems.length;
1386			if(cntItems){
1387				var bMore = false;
1388				for(var i = cntItems - 1; i >= 0; --i){
1389					var item = arItems.eq(i);
1390					var bInMore = item.parents('.more').length > 0;
1391					if(!bInMore){
1392						if(arItemsHideWidth[i] > rowWidth){
1393							if(!bMore){
1394								bMore = true;
1395								more.removeClass('hidden');
1396							}
1397							var clone = item.clone();
1398							clone.find('>a').addClass('dark_font');
1399							clone.prependTo(moreDropdown);
1400							item.addClass('cloned');
1401						}
1402					}
1403				}
1404				for(var i = 0; i < cntItems; ++i){
1405					var item = arItems.eq(i);
1406					var bInMore = item.parents('.more').length > 0;
1407					if(bInMore){
1408						if(arItemsHideWidth[i] <= rowWidth){
1409							if(i === (cntItems - 1)){
1410								bMore = false;
1411								more.addClass('hidden');
1412							}
1413							var clone = item.clone();
1414							clone.find('>a').removeClass('dark_font');
1415							clone.insertBefore(more);
1416							item.addClass('cloned');
1417						}
1418					}
1419				}
1420				$menuTopest.find('li.cloned').remove();
1421			}
1422		}
1423
1424		var $menuTopest = $('.menu.topest');
1425		if($menuTopest.length)
1426		{
1427			var more = $menuTopest.find('>.more');
1428			var moreDropdown = more.find('>.dropdown');
1429			var moreWidth = more.actual('outerWidth',{includeMargin: true});
1430			var arItemsHideWidth = [];
1431
1432			ignoreResize.push(true);
1433			_init();
1434			_gummi();
1435			ignoreResize.pop();
1436
1437			BX.addCustomEvent('onWindowResize', function(eventdata) {
1438				try{
1439					ignoreResize.push(true);
1440					_gummi();
1441				}
1442				catch(e){}
1443				finally{
1444					ignoreResize.pop();
1445				}
1446			});
1447		}
1448	}
1449}
1450
1451CheckHeaderFixedMenu = function(){
1452	if(arHeatOptions['THEME']['HEADER_FIXED'] == 2 && $('#headerfixed .js-nav').length && window.matchMedia('(min-width: 992px)').matches)
1453	{
1454		$('#headerfixed .js-nav').css('width','0');
1455		var all_width = 0,
1456			cont_width = $('#headerfixed .maxwidth-theme').actual('width'),
1457			padding_menu = $('#headerfixed .logo-row.v2 .menu-block').actual('outerWidth')-$('#headerfixed .logo-row.v2 .menu-block').actual('width');
1458		$('#headerfixed .logo-row.v2 > .inner-table-block').each(function(){
1459			if(!$(this).hasClass('menu-block'))
1460				all_width += $(this).actual('outerWidth');
1461		})
1462		$('#headerfixed .js-nav').width(cont_width-all_width-padding_menu);
1463	}
1464}
1465
1466CheckTopMenuPadding = function(){
1467	if($('.logo_and_menu-row .right-icons .wrap_icon').length && $('.logo_and_menu-row .menu-row').length){
1468		var menuPosition = $('.menu-row .menu-only').position().left,
1469			maxWidth = $('.logo_and_menu-row .maxwidth-theme').width() - 32,
1470			leftPadding = 0,
1471			rightPadding = 0;
1472
1473		$('.logo_and_menu-row .menu-row>div').each(function(indx){
1474			if(!$(this).hasClass('menu-only')){
1475				var elementPosition = $(this).position().left,
1476					elementWidth = $(this).outerWidth();
1477
1478				if(elementPosition > menuPosition){
1479					rightPadding += elementWidth;
1480				}else{
1481					leftPadding += elementWidth;
1482				}
1483			}
1484		}).promise().done(function(){
1485			$('.logo_and_menu-row .menu-only').css({'padding-left': leftPadding, 'padding-right': rightPadding+1});
1486		});
1487	}
1488}
1489
1490CheckTopMenuOncePadding = function(){
1491	if($('.menu-row.sliced .right-icons .wrap_icon').length){
1492		var menuPosition = $('.menu-row .menu-only').position().left,
1493			maxWidth = $('.logo_and_menu-row .maxwidth-theme').width() - 32,
1494			leftPadding = 0,
1495			rightPadding = 0;
1496
1497		$('.menu-row.sliced > .maxwidth-theme>div>div').each(function(indx){
1498			if(!$(this).hasClass('menu-only')){
1499
1500				var elementPosition = $(this).position().left,
1501					elementWidth = $(this).outerWidth();
1502
1503				if(elementPosition > menuPosition){
1504					rightPadding += elementWidth;
1505				}else{
1506					leftPadding += elementWidth;
1507				}
1508			}
1509		}).promise().done(function(){
1510			$('.menu-row.sliced .menu-only').css({'padding-left': leftPadding, 'padding-right': rightPadding+1});
1511		});
1512	}
1513}
1514
1515CheckSearchWidth = function(){
1516	if($('.logo_and_menu-row .search_wrap').length){
1517		var searchPosition = $('.logo_and_menu-row .search_wrap').position().left,
1518			maxWidth = $('.logo_and_menu-row .maxwidth-theme').width() - 32;
1519			width = 0;
1520
1521		$('.logo_and_menu-row .maxwidth-theme>div').each(function(){
1522			if(!$(this).hasClass('search_wrap')){
1523				var elementWidth = $(this).outerWidth();
1524
1525				width = (width ? width - elementWidth : maxWidth - elementWidth);
1526			}
1527		}).promise().done(function(){
1528			$('.logo_and_menu-row .search_wrap').outerWidth(width).css({'opacity': 1, 'visibility': 'visible'});
1529		});
1530	}
1531}
1532
1533waitCounter = function(idCounter, delay, callback){
1534	var obCounter = window['yaCounter' + idCounter];
1535	if(typeof obCounter == 'object')
1536	{
1537		if(typeof callback == 'function')
1538			callback();
1539		
1540	}
1541	else
1542	{
1543		setTimeout(function(){
1544			waitCounter(idCounter, delay, callback);
1545		}, delay);
1546	}
1547}
1548
1549var waitReCaptcha = function(delay, callback){
1550	if(typeof grecaptcha == 'object'){
1551		if(typeof callback == 'function'){
1552			callback();
1553		}
1554	}
1555	else{
1556		setTimeout(function(){
1557			waitReCaptcha(delay, callback);
1558		}, delay);
1559	}
1560}
1561
1562var reCaptchaRender = function(response){
1563	if($('.g-recaptcha:not(.rendered)').length){
1564		waitReCaptcha(50, function(){
1565			$('.g-recaptcha:not(.rendered)').each(function(){
1566				$this = $(this);
1567				$this.addClass('rendered')
1568				var id = grecaptcha.render($this[0], {
1569					sitekey: $this.attr('data-sitekey'),
1570					theme: $this.attr('data-theme'),
1571					size: $this.attr('data-size'),
1572					callback: $this.attr('data-callback'),
1573				});
1574				$this.attr('data-widgetid', id);
1575			});
1576		});
1577	}
1578}
1579
1580var reCaptchaVerify = function(response){
1581	$('.g-recaptcha.rendered').each(function(){
1582		var id = $(this).attr('data-widgetid');
1583		if(typeof(id) !== 'undefined'){
1584			if(grecaptcha.getResponse(id) != ''){
1585				$(this).closest('form').find('.recaptcha').valid();
1586			}
1587		}
1588	});
1589}
1590
1591var reCaptchaVerifyHidden = function(response){
1592	$('.g-recaptcha.rendered:last').each(function(){
1593		var id = $(this).attr('data-widgetid');
1594		if(typeof(id) !== 'undefined' && response){
1595			if(!$(this).closest('form').find('.g-recaptcha-response').val())
1596				$(this).closest('form').find('.g-recaptcha-response').val(response)
1597			$(this).closest('form').submit();
1598		}
1599	});
1600}
1601
1602waitYTPlayer = function(delay, callback){
1603	if((typeof YT !== "undefined") && YT && YT.Player)
1604	{
1605		if(typeof callback == 'function')
1606			callback();
1607	}
1608	else
1609	{
1610		setTimeout(function(){
1611			waitYTPlayer(delay, callback);
1612		}, delay);
1613	}
1614}
1615
1616var scrollToTopAnimateClassIn = false;
1617var scrollToTopAnimateClassOut = false;
1618
1619var $body = {}
1620var $scrolltotop = {}
1621var isOnceInited = false;
1622
1623if(navigator.userAgent.indexOf("Edge") != -1)
1624	document.documentElement.className += ' edge';
1625
1626initFull = function(){
1627	checkMobileRegion();
1628}
1629
1630var isFrameDataReceived = false;
1631if (typeof window.frameCacheVars !== "undefined"){
1632	BX.addCustomEvent("onFrameDataReceived", function (json){
1633		initFull();
1634
1635		isFrameDataReceived = true;
1636	});
1637}else{
1638	$( document ).ready(initFull);
1639}
1640
1641
1642checkMobileRegion = function(){
1643	if($('.confirm_region').length)
1644	{
1645		if(!$('.top_mobile_region').length)
1646			$('<div class="top_mobile_region"><div class="confirm_region"></div><div class="close_popup"></div></div>').insertBefore($('#mobileheader'));
1647		$('.top_mobile_region .confirm_region').html($('.confirm_region').html());
1648
1649		$('.top_mobile_region .close_popup').click(function(){
1650			$(this).remove();
1651			$('.confirm_region').remove();
1652		})
1653	}
1654}
1655
1656footer_arrows_slide = function(){
1657	$('.item-link').on('click', function() {
1658		if($(window).width() <= 767){
1659			if(!$(this).parent().parent(".bottom-menu").hasClass('closed')){
1660				$(this).parent().parent(".bottom-menu").addClass('closed');
1661				$(this).parent(".items").children(".wrap").slideUp();
1662			} else {
1663				$(this).parent(".items").children(".wrap").slideDown();
1664				$(this).parent().parent(".bottom-menu").removeClass('closed');
1665			}
1666		}
1667	});
1668
1669	if($(window).width() <= 767){
1670		$('.item-link').parent().parent(".bottom-menu").addClass('closed');
1671		$('.item-link').parent(".items").children(".wrap").css('display', 'none');
1672	}
1673}
1674
1675$(window).resize(function() {
1676
1677	if(window.matchMedia('(min-width:767px)').matches){
1678		$('footer .bottom-menu .items .wrap').css('display', '');
1679	}
1680
1681	contactsInputHeight();
1682
1683	if(window.matchMedia('(min-width: 992px)').matches) {
1684		$('.style-switcher').css('display', 'flex');
1685	} else {
1686		$('.style-switcher').css('display', '');
1687		var $mobileMenu = $("#mobilemenu");
1688		if($mobileMenu.length){
1689			$mobileMenu.isOpen = $mobileMenu.hasClass('show');
1690			if($mobileMenu.isOpen) {
1691				$('.style-switcher').hide();
1692			}
1693		}
1694	}
1695	
1696});
1697
1698$(document).ready(function(){
1699	var timerId = setInterval(function(){
1700		if(arHeatOptions){
1701			scrollToTop();
1702			clearInterval(timerId);
1703		}
1704	}, 150);
1705	
1706	CheckStickyFooter();
1707
1708	footer_arrows_slide();
1709
1710	HardHover();
1711
1712	$('.nav-tabs li a').click(function() {
1713		setTimeout(HardHover, 200);
1714		setTimeout(CheckObjectsSizes, 1);
1715	});
1716
1717	if(!jQuery.browser.safari){
1718		CheckTopMenuPadding();
1719		CheckTopMenuOncePadding();
1720		CheckHeaderFixed();
1721		CheckTopMenuDotted();
1722		CheckMenuOffset();
1723		MegaMenuFixed();
1724		CheckSearchWidth();
1725		InitTopestMenuGummi();
1726		isOnceInited = true;
1727
1728		setTimeout(function() {
1729			$(window).resize(); // need to check resize flexslider & menu
1730		}, 350);
1731
1732		setTimeout(function() {$(window).scroll();}, 250); // need to check position fixed ask block
1733	}
1734	else{
1735		setTimeout(function() {
1736			$(window).resize(); // need to check resize flexslider & menu
1737			setTimeout(function(){
1738				CheckTopMenuPadding();
1739				CheckTopMenuOncePadding();
1740				CheckHeaderFixed();
1741				CheckTopMenuDotted();
1742				CheckMenuOffset();
1743				MegaMenuFixed();
1744				CheckSearchWidth();
1745				InitTopestMenuGummi();
1746				isOnceInited = true;
1747				setTimeout(function(){
1748					$(window).scroll();
1749				}, 50);
1750			}, 50);
1751		}, 350);
1752	}
1753
1754	$('.wide_menu .li_container').mCustomScrollbar({
1755		mouseWheel: {
1756			scrollAmount: 150,
1757			preventDefault: true
1758		},
1759	});
1760
1761	if(arHeatOptions['THEME']['USE_DEBUG_GOALS'] === 'Y'){
1762		$.cookie('_ym_debug', '1');
1763	}
1764	else{
1765		$.cookie('_ym_debug', null);
1766	}
1767
1768	/*  --- Bind mobile menu  --- */
1769	var $mobileMenu = $("#mobilemenu")
1770	if($mobileMenu.length){
1771		$mobileMenu.isLeftSide = $mobileMenu.hasClass('leftside')
1772		$mobileMenu.isOpen = $mobileMenu.hasClass('show')
1773		$mobileMenu.isDowndrop = $mobileMenu.find('>.scroller').hasClass('downdrop')
1774
1775		$('#mobileheader .burger').click(function(){
1776			SwipeMobileMenu()
1777		})
1778
1779		if($mobileMenu.isLeftSide){
1780			$mobileMenu.parent().append('<div id="mobilemenu-overlay"></div>')
1781			var $mobileMenuOverlay = $('#mobilemenu-overlay')
1782
1783			$mobileMenuOverlay.click(function(){
1784				if($mobileMenu.isOpen){
1785					CloseMobileMenu()
1786				}
1787			});
1788
1789			$(document).swiperight(function(e) {
1790				if(!$(e.target).closest('.flexslider').length && !$(e.target).closest('.swipeignore').length){
1791					OpenMobileMenu()
1792				}
1793			});
1794
1795			$(document).swipeleft(function(e) {
1796				if(!$(e.target).closest('.flexslider').length && !$(e.target).closest('.swipeignore').length){
1797					CloseMobileMenu()
1798				}
1799			});
1800		}
1801		else{
1802			$('#mobileheader').click(function(e){
1803				if(!$(e.target).closest('#mobilemenu').length && !$(e.target).closest('.burger').length && $mobileMenu.isOpen){
1804					CloseMobileMenu()
1805				}
1806			});
1807		}
1808
1809		$('#mobilemenu .menu a,#mobilemenu .social-icons a').click(function(e){
1810			var $this = $(this)
1811			if($this.hasClass('parent')){
1812				e.preventDefault()
1813
1814				if(!$mobileMenu.isDowndrop){
1815					$this.closest('li').addClass('expanded')
1816					MoveMobileMenuWrapNext()
1817				}
1818				else{
1819					if(!$this.closest('li').hasClass('expanded')){
1820						$this.closest('li').addClass('expanded')
1821					}
1822					else{
1823						$this.closest('li').removeClass('expanded')
1824					}
1825				}
1826			}
1827			else{
1828				if($this.closest('li').hasClass('counters')){
1829					var href = $this.attr('href')
1830					if(typeof href !== 'undefined'){
1831						window.location.href = href
1832						window.location.reload()
1833					}
1834				}
1835
1836				if(!$this.closest('.menu_back').length){
1837					CloseMobileMenu()
1838				}
1839			}
1840		})
1841
1842		$('#mobilemenu .dropdown .menu_back').click(function(e){
1843			e.preventDefault()
1844			var $this = $(this)
1845			MoveMobileMenuWrapPrev()
1846			setTimeout(function(){
1847				$this.closest('.expanded').removeClass('expanded')
1848			}, 400)
1849		})
1850
1851		OpenMobileMenu = function(){
1852			if(!$mobileMenu.isOpen){
1853				// hide styleswitcher
1854				// if($('.style-switcher').hasClass('active')){
1855				// 	$('.style-switcher .switch').trigger('click')
1856				// }
1857				$('.style-switcher').hide()
1858
1859				if($mobileMenu.isLeftSide){
1860					// show overlay
1861					setTimeout(function(){
1862						$mobileMenuOverlay.fadeIn('fast')
1863					}, 100)
1864				}
1865				else{
1866					// scroll body to top & set fixed
1867					$('body').scrollTop(0).css({position: 'fixed'})
1868
1869					// set menu top = bottom of header
1870					$mobileMenu.css({top: + ($('#mobileheader').height() + $('#mobileheader').offset().top) + 'px'})
1871
1872					// change burger icon
1873					$('#mobileheader .burger').addClass('c')
1874				}
1875
1876				// show menu
1877				$mobileMenu.addClass('show')
1878				$mobileMenu.isOpen = true
1879
1880				if(!$mobileMenu.isDowndrop){
1881					var $wrap = $mobileMenu.find('.wrap').first()
1882					var params =  $wrap.data('params')
1883					if(typeof params === 'undefined'){
1884						params = {
1885							depth: 0,
1886							scroll: {},
1887							height: {}
1888						}
1889					}
1890					$wrap.data('params', params)
1891				}
1892			}
1893		}
1894
1895		CloseMobileMenu = function(){
1896			if($mobileMenu.isOpen){
1897				// hide menu
1898				$mobileMenu.removeClass('show')
1899				$mobileMenu.isOpen = false
1900
1901				// show styleswitcher
1902				$('.style-switcher').css('display', '');
1903
1904				if($mobileMenu.isLeftSide){
1905					// hide overlay
1906					setTimeout(function(){
1907						$mobileMenuOverlay.fadeOut('fast')
1908					}, 100)
1909				}
1910				else{
1911					// change burger icon
1912					$('#mobileheader .burger').removeClass('c')
1913
1914					// body unset fixed
1915					$('body').css({position: ''})
1916				}
1917
1918				if(!$mobileMenu.isDowndrop){
1919					setTimeout(function(){
1920						var $scroller = $mobileMenu.find('.scroller').first()
1921						var $wrap = $mobileMenu.find('.wrap').first()
1922						var params =  $wrap.data('params')
1923						params.depth = 0
1924						$wrap.data('params', params).attr('style', '')
1925						$mobileMenu.scrollTop(0)
1926						$scroller.css('height', '')
1927					}, 400)
1928				}
1929			}
1930		}
1931
1932		SwipeMobileMenu = function(){
1933			if($mobileMenu.isOpen){
1934				CloseMobileMenu()
1935			}
1936			else{
1937				OpenMobileMenu()
1938			}
1939		}
1940
1941		function MoveMobileMenuWrapNext(){
1942			if(!$mobileMenu.isDowndrop){
1943				var $scroller = $mobileMenu.find('.scroller').first()
1944				var $wrap = $mobileMenu.find('.wrap').first()
1945				if($wrap.length){
1946					var params =  $wrap.data('params')
1947					var $dropdownNext = $mobileMenu.find('.expanded>.dropdown').eq(params.depth)
1948					if($dropdownNext.length){
1949						// save scroll position
1950						params.scroll[params.depth] = parseInt($mobileMenu.scrollTop())
1951
1952						// height while move animating
1953						params.height[params.depth + 1] = Math.max($dropdownNext.height(), (!params.depth ? $wrap.height() : $mobileMenu.find('.expanded>.dropdown').eq(params.depth - 1).height()))
1954						$scroller.css('height', params.height[params.depth + 1] + 'px')
1955
1956						// inc depth
1957						++params.depth
1958
1959						// translateX for move
1960						$wrap.css('transform', 'translateX(' + -100 * params.depth + '%)')
1961
1962						// scroll to top
1963						setTimeout(function() {
1964							$mobileMenu.animate({scrollTop : 0}, 200);
1965						}, 100)
1966
1967						// height on enimating end
1968						var h = $dropdownNext.height()
1969						setTimeout(function() {
1970							if(h){
1971								$scroller.css('height', h + 'px')
1972							}
1973							else{
1974								$scroller.css('height', '')
1975							}
1976						}, 200)
1977					}
1978
1979					$wrap.data('params', params)
1980				}
1981			}
1982		}
1983
1984		function MoveMobileMenuWrapPrev(){
1985			if(!$mobileMenu.isDowndrop){
1986				var $scroller = $mobileMenu.find('.scroller').first()
1987				var $wrap = $mobileMenu.find('.wrap').first()
1988				if($wrap.length){
1989					var params =  $wrap.data('params')
1990					if(params.depth > 0){
1991						var $dropdown = $mobileMenu.find('.expanded>.dropdown').eq(params.depth - 1)
1992						if($dropdown.length){
1993							// height while move animating
1994							$scroller.css('height', params.height[params.depth] + 'px')
1995
1996							// dec depth
1997							--params.depth
1998
1999							// translateX for move
2000							$wrap.css('transform', 'translateX(' + -100 * params.depth + '%)')
2001
2002							// restore scroll position
2003							setTimeout(function() {
2004								$mobileMenu.animate({scrollTop : params.scroll[params.depth]}, 200);
2005							}, 100)
2006
2007							// height on enimating end
2008							var h = (!params.depth ? false : $mobileMenu.find('.expanded>.dropdown').eq(params.depth - 1).height())
2009							setTimeout(function() {
2010								if(h){
2011									$scroller.css('height', h + 'px')
2012								}
2013								else{
2014									$scroller.css('height', '')
2015								}
2016							}, 200)
2017						}
2018					}
2019
2020					$wrap.data('params', params)
2021				}
2022			}
2023		}
2024	}
2025	/*  --- END Bind mobile menu  --- */
2026
2027
2028	/* change type2 menu for fixed */
2029	if($('#headerfixed .js-nav').length)
2030	{
2031		if(arHeatOptions['THEME']['HEADER_FIXED'] == 2)
2032			CheckHeaderFixedMenu();
2033
2034		setTimeout(function(){
2035			$('#headerfixed .js-nav').addClass('opacity1');
2036		},350);
2037	}
2038
2039	/* close search block */
2040	$("html, body").on('mousedown', function(e){
2041		if(typeof e.target.className == 'string' && e.target.className.indexOf('adm') < 0)
2042		{
2043			e.stopPropagation();
2044			var search_target = $(e.target).closest('.bx_searche');
2045			if(!$(e.target).hasClass('inline-search-block') && !$(e.target).hasClass('svg') && !search_target.length)
2046			{
2047				$('.inline-search-block').removeClass('show');
2048				$('.title-search-result').hide();
2049				$('.title-search-result').addClass('hidden');
2050				if(arHeatOptions['THEME']['TYPE_SEARCH'] == 'fixed')
2051					$('.jqmOverlay.search').detach();
2052			}
2053
2054			if(isMobile)
2055			{
2056				if(search_target.length)
2057					location.href = search_target.attr('href');
2058			}
2059			var class_name = $(e.target).attr('class');
2060			if(typeof(class_name) == 'undefined' || class_name.indexOf('tooltip') < 0) //tooltip link
2061				$('.tooltip-link').tooltip('hide');
2062		}
2063	});
2064	$('.inline-search-block').find('*').on('mousedown', function(e){
2065		e.stopPropagation();
2066	});
2067
2068	$('.filter-action').on('click', function(){
2069		$(this).toggleClass('active');
2070		$(this).find('.svg').toggleClass('white');
2071		if($('.introtext').length)
2072		{
2073			var top_pos = $('.filters-wrap').position();
2074			$('.bx_filter').css({'top':top_pos.top+40});
2075		}
2076		$('.bx_filter').slideToggle();
2077	})
2078
2079	waitingNotExists('#bx-composite-banner .bx-composite-btn', '#footer .col-sm-3.hidden-md.hidden-lg #bx-composite-banner .bx-composite-btn', 500, function() {
2080		$('#footer .col-sm-3.hidden-md.hidden-lg #bx-composite-banner').html($('#bx-composite-banner .bx-composite-btn').parent().html());
2081	});
2082
2083	$.extend( $.validator.messages, {
2084		required: BX.message('JS_REQUIRED'),
2085		email: BX.message('JS_FORMAT'),
2086		equalTo: BX.message('JS_PASSWORD_COPY'),
2087		minlength: BX.message('JS_PASSWORD_LENGTH'),
2088		remote: BX.message('JS_ERROR')
2089	});
2090
2091	$.validator.addMethod(
2092		'regexp', function( value, element, regexp ){
2093			var re = new RegExp( regexp );
2094			return this.optional( element ) || re.test( value );
2095		},
2096		BX.message('JS_FORMAT')
2097	);
2098
2099	$.validator.addMethod(
2100		'filesize', function( value, element, param ){
2101			return this.optional( element ) || ( element.files[0].size <= param )
2102		},
2103		BX.message('JS_FILE_SIZE')
2104	);
2105
2106	$.validator.addMethod(
2107		'date', function( value, element, param ) {
2108			var status = false;
2109			if(!value || value.length <= 0){
2110				status = true;
2111			}
2112			else{
2113				var re = new RegExp('^([0-9]{2})(.)([0-9]{2})(.)([0-9]{4})$');
2114				var matches = re.exec(value);
2115				if(matches){
2116					var composedDate = new Date(matches[5], (matches[3] - 1), matches[1]);
2117					status = ((composedDate.getMonth() == (matches[3] - 1)) && (composedDate.getDate() == matches[1]) && (composedDate.getFullYear() == matches[5]));
2118				}
2119			}
2120			return status;
2121		}, BX.message('JS_DATE')
2122	);
2123
2124	$.validator.addMethod(
2125		'datetime', function( value, element, param ) {
2126			var status = false;
2127			if(!value || value.length <= 0){
2128				status = true;
2129			}
2130			else{
2131				var re = new RegExp('^([0-9]{2})(.)([0-9]{2})(.)([0-9]{4}) ([0-9]{1,2}):([0-9]{1,2})$');
2132				var matches = re.exec(value);
2133				if(matches){
2134					var composedDate = new Date(matches[5], (matches[3] - 1), matches[1], matches[6], matches[7]);
2135					status = ((composedDate.getMonth() == (matches[3] - 1)) && (composedDate.getDate() == matches[1]) && (composedDate.getFullYear() == matches[5]) && (composedDate.getHours() == matches[6]) && (composedDate.getMinutes() == matches[7]));
2136				}
2137			}
2138			return status;
2139		}, BX.message('JS_DATETIME')
2140	);
2141
2142	$.validator.addMethod(
2143		'extension', function(value, element, param){
2144			param = typeof param === 'string' ? param.replace(/,/g, '|') : 'png|jpe?g|gif';
2145			return this.optional(element) || value.match(new RegExp('.(' + param + ')$', 'i'));
2146		}, BX.message('JS_FILE_EXT')
2147	);
2148
2149	$.validator.addMethod(
2150		'captcha', function( value, element, params ){
2151			return $.validator.methods.remote.call(this, value, element,{
2152				url: arHeatOptions['SITE_DIR'] + 'ajax/check-captcha.php',
2153				type: 'post',
2154				data:{
2155					captcha_word: value,
2156					captcha_sid: function(){
2157						return $(element).closest('form').find('input[name="captcha_sid"]').val();
2158					}
2159				}
2160			});
2161		},
2162		BX.message('JS_ERROR')
2163    );
2164
2165    $.validator.addMethod(
2166		'recaptcha', function(value, element, param){
2167			var id = $(element).closest('form').find('.g-recaptcha').attr('data-widgetid');
2168			if(typeof id !== 'undefined'){
2169				return grecaptcha.getResponse(id) != '';
2170			}
2171			else{
2172				return true;
2173			}
2174		}, BX.message('JS_RECAPTCHA_ERROR')
2175	);
2176
2177	/*reload captcha*/
2178	$('body').on( 'click', '.refresh', function(e){
2179		e.preventDefault();
2180		$.ajax({
2181			url: arHeatOptions['SITE_DIR'] + 'ajax/captcha.php'
2182		}).done(function(text){
2183			if($('.captcha_sid').length)
2184			{
2185				$('.captcha_sid').val(text);
2186				$('.captcha_img').attr('src', '/bitrix/tools/captcha.php?captcha_sid=' + text);
2187			}
2188		});
2189	});
2190
2191	$.validator.addClassRules({
2192		'phone':{
2193			regexp: arHeatOptions['THEME']['VALIDATE_PHONE_MASK']
2194		},
2195		'confirm_password':{
2196			equalTo: 'input.password',
2197			minlength: 6
2198		},
2199		'password':{
2200			minlength: 6
2201		},
2202		'inputfile':{
2203			extension: arHeatOptions['THEME']['VALIDATE_FILE_EXT'],
2204			filesize: 5000000
2205		},
2206		'datetime':{
2207			datetime: ''
2208		},
2209		'captcha':{
2210			captcha: ''
2211		},
2212		'recaptcha':{
2213			recaptcha: ''
2214		}
2215	});
2216
2217	$.validator.setDefaults({
2218	   highlight: function( element ){
2219			$(element).parent().addClass('error');
2220		},
2221		unhighlight: function( element ){
2222			$(element).parent().removeClass('error');
2223		}
2224	});
2225
2226	/*city*/
2227	$('select.region').on('change', function(){
2228		var val = parseInt($(this).val());
2229		if($('select.city').length)
2230		{
2231			if(val)
2232			{
2233				$('select.city option').hide();
2234				$('select.city option').prop('disabled', 'disabled');
2235				$('select.city option[data-parent_section='+val+']').prop('disabled', '');
2236				$('select.city option:eq(0)').prop('disabled', '');
2237				// $('select.city').ikSelect('reset');
2238				$('select.city option[data-parent_section='+val+']').show();
2239			}
2240			else
2241				$('select.city option').prop('disabled', 'disabled');
2242				$('select.city option:eq(0)').prop('disabled', '');
2243				// $('select.city').ikSelect('reset');
2244		}
2245	})
2246
2247	$('select.city, select.region').on('change', function(){
2248		var _this = $(this),
2249			val = parseInt(_this.val());
2250		if(_this.hasClass('region'))
2251		{
2252			$('select.city option:eq(0)').show();
2253			$('select.city').val(0);
2254		}
2255
2256		if((_this.hasClass('region') && !val) || _this.hasClass('city'))
2257		{
2258			$.ajax({
2259				type: 'POST',
2260				data: {ID: val},
2261			}).success(function(html){
2262				var ob = BX.processHTML(html);
2263				$('.ajax_items')[0].innerHTML = ob.HTML;
2264				BX.ajax.processScripts(ob.SCRIPT);
2265			})
2266		}
2267	})
2268
2269	$('.mobile_regions .city_item').on('click', function(e){
2270    	e.preventDefault();
2271    	var _this = $(this);
2272    	$.removeCookie('current_region');
2273
2274		if(arHeatOptions['SITE_ADDRESS'].indexOf(',') != '-1')
2275		{
2276			var arDomains = arHeatOptions['SITE_ADDRESS'].split(',');
2277			if(arDomains)
2278			{
2279				for(var i in arDomains)
2280				{
2281					var domain_name = arDomains[i].replace("\n", "");
2282						domain_name = arDomains[i].replace("'", "");
2283					$.cookie('current_region', _this.data('id'), {path: '/',domain: domain_name});
2284				}
2285			}
2286		}
2287		else
2288			$.cookie('current_region', _this.data('id'), {path: '/',domain: arHeatOptions['SITE_ADDRESS']});
2289
2290		location.href = _this.attr('href');
2291    })
2292
2293	InitFlexSlider();
2294	InitSlickSlider();
2295	InitOwlSlider();
2296
2297	// for check flexslider bug in composite mode
2298	waitingNotExists('.detail .galery #slider', '.detail .galery #slider .flex-viewport', 
22981000, function() {
2299		InitFlexSlider();
2300		InitSlickSlider();
2301		setTimeout(function() {
2302			$(window).resize();
2303		}, 350);
2304	});
2305
2306	/* change view type catalog */
2307	$('.view-button').on('click', function(){
2308		$(this).siblings().removeClass('cur');
2309		$(this).addClass('cur');
2310	})
2311
2312	// -- escape close popup form
2313	$(document).on('keydown', function(e){
2314		if(e.keyCode == 27)
2315		{
2316			if($('.jqmWindow.show').length)
2317				$('.jqmWindow.show .jqmClose').click();
2318			if($('.inline-search-block.fixed.show').length)
2319				$('.inline-search-block.fixed .inline-search-hide').click();
2320		}
2321	});
2322
2323	/*check mobile device*/
2324	if(jQuery.browser.mobile){
2325		$('.hint span').remove();
2326
2327		$(document).on('click', '*[data-event="jqm"]', function(e){
2328			e.preventDefault();
2329			var _this = $(this);
2330			var name = _this.data('name');
2331
2332			if(window.matchMedia('(min-width:992px)').matches)
2333			{
2334				e.stopPropagation();
2335				_this.jqmEx();
2336				_this.trigger('click');
2337			}
2338			else if(name.length){
2339				var script = arHeatOptions['SITE_DIR'] + 'form/';
2340				var paramsStr = ''; var arTriggerAttrs = {};
2341				$.each(_this.get(0).attributes, function(index, attr){
2342					var attrName = attr.nodeName;
2343					var attrValue = _this.attr(attrName);
2344					attrValue = attrValue.replace(/%99/g, '\\'); // replace symbol \
2345					arTriggerAttrs[attrName] = attrValue;
2346					if(/^data\-param\-(.+)$/.test(attrName)){
2347						var key = attrName.match(/^data\-param\-(.+)$/)[1];
2348						paramsStr += key + '=' + attrValue + '&';
2349					}
2350				});
2351				var triggerAttrs = JSON.stringify(arTriggerAttrs);
2352				var encTriggerAttrs = encodeURIComponent(triggerAttrs);
2353				script += '?name=' + name + '&' + paramsStr + 'data-trigger=' + encTriggerAttrs;
2354				location.href = script;
2355			}
2356		});
2357
2358		// $('.fancybox').removeClass('fancybox');
2359	}
2360	else{		
2361		$(document).on('click', '*[data-event="jqm"]', function(e){
2362			e.preventDefault();
2363			e.stopPropagation();
2364			if($(this).closest('form.subscribe-form').length){
2365				var email = $(this).closest('form').find('input[name=EMAIL]').val();
2366				 $(this).data('autoload-email', email);
2367			}
2368			
2369			var _this = $(this);
2370			
2371			//setTimeout(function(){
2372				//var newButton = _this.clone().addClass('clone');
2373				//$('body').append(newButton);
2374				_this.jqmEx();
2375				_this.trigger('click');
2376				//newButton.remove();
2377			//}, 1000);
2378
2379		});
2380	}
2381	
2382	$('.animate-load').on('click', function(){
2383		$(this).parent().addClass('loadings');
2384	})
2385
2386	BX.addCustomEvent('onCompleteAction', function(eventdata, _this){
2387		try{
2388			if(eventdata.action === 'loadForm')
2389			{
2390				$(_this).parent().removeClass('loadings');
2391			}
2392			else if(eventdata.action === 'loadBasket')
2393			{
2394				var basket_link = $('.basket-link');
2395				if(basket_link.length)
2396				{
2397					basket_link.attr('title', $(_this).find('a').attr('title'));
2398					if($(_this).find('a .count').length)
2399					{
2400						var count = basket_link.find('.count').length ? parseInt($(_this).find('.count').text()) : parseInt($(_this).find('.count').text());
2401						basket_link.find('.prices').text($(_this).find('.icon').data('summ'));
2402						if(basket_link.find('.count').length)
2403						{
2404							basket_link.find('.count').text(count);
2405							if(count)
2406								basket_link.addClass('basket-count');
2407							else
2408								basket_link.removeClass('basket-count');
2409						}
2410						else
2411						{
2412							basket_link.find('.js-basket-block').append($(_this).find('.count'));
2413							basket_link.addClass('basket-count');
2414							CheckHeaderFixedMenu();
2415						}
2416
2417						$('#mobilemenu .menu .ready .count').text(count);
2418						if(count){
2419							$('#mobilemenu .menu .ready .count').removeClass('empted');
2420						}
2421						else{
2422							$('#mobilemenu .menu .ready .count').addClass('empted');
2423						}
2424					}
2425					else if($(_this).find('.opener').length)
2426					{
2427						var count = parseInt($(_this).find('.opener .count').text());
2428
2429						if(basket_link.find('.count').length)
2430						{
2431							basket_link.find('.count').text(count);
2432							if(count)
2433								basket_link.addClass('basket-count');
2434							else
2435								basket_link.removeClass('basket-count');
2436							basket_link.attr('title', $(_this).find('.opener').attr('title'));
2437						}
2438						$('#mobilemenu .menu .ready .count').text(count);
2439						if(count){
2440							$('#mobilemenu .menu .ready .count').removeClass('empted');
2441						}
2442						else{
2443							$('#mobilemenu .menu .ready .count').addClass('empted');
2444						}
2445					}
2446					else
2447					{
2448						basket_link.find('.count').remove();
2449						basket_link.removeClass('basket-count');
2450						CheckHeaderFixedMenu();
2451					}
2452				}
2453			}
2454			else if(eventdata.action === 'loadRSS')
2455			{
2456			}
2457			else if(eventdata.action === 'ajaxContentLoaded')
2458			{
2459				if('type' in eventdata)
2460				{
2461					if(eventdata.type == 'table_block')
2462					{
2463						$('.catalog.item-views.table .item').sliceHeight({"classNull" : ".footer-button"});
2464						//$('.catalog.item-views.table .item .cont').sliceHeight();
2465						// $('.catalog.item-views.table .item .slice_price').sliceHeight();
2466						//$('.catalog.item-views.table .item').sliceHeight({classNull: '.footer-button'});
2467					}
2468					else if(eventdata.type == 'table_block2')
2469					{
2470						$('.catalog.item-views.table .item').sliceHeight({"classNull" : ".footer-button"});
2471						//$('.catalog.item-views.table .item .cont').sliceHeight({autoHeightBlock: '.cont_inner', classNull: '.props_wrapper'});
2472						// $('.catalog.item-views.table .item .slice_price').sliceHeight();
2473						//$('.catalog.item-views.table .item').sliceHeight({classNull: '.footer-button', autoHeightBlock: '.cont_inner', callback: setHoverHeight});
2474					}
2475				}
2476			}
2477		}
2478		catch(e){
2479			console.error(e)
2480		}
2481	})
2482
2483	BX.addCustomEvent('onCounterGoals', function(eventdata){
2484		if(arHeatOptions['THEME']['YA_GOLAS'] == 'Y' && arHeatOptions['THEME']['YA_COUNTER_ID'])
2485		{
2486			var idCounter = arHeatOptions['THEME']['YA_COUNTER_ID'];
2487			idCounter = parseInt(idCounter);
2488
2489			if(typeof eventdata != 'object')
2490				eventdata = {goal: 'undefined'};
2491			
2492			if(typeof eventdata.goal != 'string')
2493				eventdata.goal = 'undefined';
2494			
2495			if(idCounter)
2496			{
2497				try
2498				{
2499					waitCounter(idCounter, 50, function(){
2500						var obCounter = window['yaCounter' + idCounter];
2501						if(typeof obCounter == 'object'){
2502							obCounter.reachGoal(eventdata.goal);
2503						}
2504					});
2505				}
2506				catch(e)
2507				{
2508					console.error(e)
2509				}
2510			}
2511			else
2512			{
2513				console.info('Bad counter id!', idCounter);
2514			}
2515		}
2516	})
2517
2518	/* show print */
2519	if(arHeatOptions['THEME']['PRINT_BUTTON'] == 'Y')
2520	{
2521		setTimeout(function(){
2522			if($('.page-top .rss-block.top').length)
2523			{
2524				$('<div class="print-link"><i class="svg svg-print"></i></div>').insertBefore($('.page-top .rss-block.top .shares-block'));
2525			}
2526			else if($('.page-top .rss').length)
2527			{
2528				$('<div class="print-link"><i class="svg svg-print"></i></div>').insertAfter($('.page-top .rss'));
2529			}
2530			else if($('.page-top h1#pagetitle').length)
2531				$('<div class="print-link"><i class="svg svg-print"></i></div>').insertBefore($('.page-top h1#pagetitle'));
2532			// else
2533				// $('footer .print-block').html('<div class="print-link"><i class="svg svg-print"><svg id="Print.svg" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path class="cls-1" d="M1553,287h-2v3h-8v-3h-2a2,2,0,0,1-2-2v-5a2,2,0,0,1,2-2h2v-4h8v4h2a2,2,0,0,1,2,2v5A2,2,0,0,1,1553,287Zm-8,1h4v-4h-4v4Zm4-12h-4v2h4v-2Zm4,4h-12v5h2v-3h8v3h2v-5Z" transform="translate(-1539 -274)"/></svg></i></div>');
2534		},150);
2535	}
2536
2537	$(document).on('click', '.print-link', function(){
2538		window.print();
2539	})
2540
2541	$('.head-block .item-link').on('click', function(){
2542		var _this = $(this);
2543		_this.siblings().removeClass('active');
2544		_this.addClass('active');
2545	})
2546
2547	/*$('table.table').each(function(){
2548		var _this = $(this),
2549			first_td = _this.find('thead tr th');
2550		if(!first_td.length)
2551			first_td = _this.find('thead tr td');
2552		if(first_td.length)
2553		{
2554			var j = 0;
2555			_this.find('tbody tr:not(.nomobile) td').each(function(i){
2556				if(j > first_td.length-1)
2557					j = 0;
2558
2559				$('<div class="th-mobile">'+first_td[j].textContent+'</div>').appendTo($(this));
2560				j++;
2561			})
2562		}
2563	})*/
2564
2565	//$('a.fancybox').fancybox();
2566
2567
2568	$(".video_link").fancybox({
2569		padding: [40,40,64,40],
2570		type: "iframe",
2571		maxWidth    : 800,
2572		maxHeight   : 600,
2573		fitToView   : false,
2574		width       : '70%',
2575		height      : '70%',
2576		autoSize    : false,
2577		closeClick  : false,
2578		tpl: {
2579			closeBtn: '<a title="'+BX.message('FANCY_CLOSE')+'" class="fancybox-item fancybox-close fill-theme-hover" href="javascript:;"><svg class="svg svg-close" width="14" height="14" viewBox="0 0 14 14"><path data-name="Rounded Rectangle 568 copy 16" d="M1009.4,953l5.32,5.315a0.987,0.987,0,0,1,0,1.4,1,1,0,0,1-1.41,0L1008,954.4l-5.32,5.315a0.991,0.991,0,0,1-1.4-1.4L1006.6,953l-5.32-5.315a0.991,0.991,0,0,1,1.4-1.4l5.32,5.315,5.31-5.315a1,1,0,0,1,1.41,0,0.987,0.987,0,0,1,0,1.4Z" transform="translate(-1001 -946)"></path></svg></a>',
2580		},
2581		beforeShow: function(){
2582			$('.fancybox-inner').height('100%');
2583			$('.fancybox-skin').width('100%');
2584			$('.fancybox-skin .fancybox-outer').width('100%').height('100%');
2585		},
2586	});
2587
2588	$('a.fancybox').fancybox({
2589		padding: [40,40,64,40],
2590		opacity: true,
2591		tpl: {
2592			prev: '<a title="'+BX.message('FANCY_PREV')+'" class="fancybox-nav fancybox-prev"><span class="bg-theme-hover"></span></a>',
2593			next: '<a title="'+BX.message('FANCY_NEXT')+'" class="fancybox-nav fancybox-next"><span class="bg-theme-hover"></span></a>',
2594			closeBtn: '<a title="'+BX.message('FANCY_CLOSE')+'" class="fancybox-item fancybox-close fill-theme-hover" href="javascript:;"><svg class="svg svg-close" width="14" height="14" viewBox="0 0 14 14"><path data-name="Rounded Rectangle 568 copy 16" d="M1009.4,953l5.32,5.315a0.987,0.987,0,0,1,0,1.4,1,1,0,0,1-1.41,0L1008,954.4l-5.32,5.315a0.991,0.991,0,0,1-1.4-1.4L1006.6,953l-5.32-5.315a0.991,0.991,0,0,1,1.4-1.4l5.32,5.315,5.31-5.315a1,1,0,0,1,1.41,0,0.987,0.987,0,0,1,0,1.4Z" transform="translate(-1001 -946)"></path></svg></a>',
2595		},
2596		touch: 'enabled',
2597		beforeShow: function(event){
2598
2599			var video_block_frame = $('.fancybox-wrap #company_video_iframe');
2600			if(video_block_frame.length)
2601			{
2602				if( video_block_frame.data('src') ) {
2603					video_block_frame.attr('src', video_block_frame.data('src') );
2604				}
2605				video_block_frame.show();
2606			}
2607			if( $('.fancybox-wrap #company_video .video-block').data('src') ) {
2608				$('.fancybox-wrap #company_video .video-block').attr('src', $('.fancybox-wrap #company_video .video-block').data('src') );
2609			}
2610			if($('.fancybox-wrap #company_video').length){
2611				$('.fancybox-wrap').addClass('show_video');
2612			}
2613		},
2614		afterShow: function(){
2615			$('html').addClass('overflow_html');
2616
2617			$('.fancybox-nav').css('opacity', 0);
2618			setTimeout(function(){
2619				$('.fancybox-nav').css('opacity', 1);
2620			}, 150);
2621			if($('.fancybox-wrap #company_video').length){
2622				$('.fancybox-inner').height('100%');
2623				setTimeout(function(){
2624					$('.fancybox-wrap video').resize();
2625					setTimeout(function(){
2626						document.getElementById('company_video').currentTime = 0;
2627						document.getElementById('company_video').play();
2628					}, 300);
2629				}, 150);
2630			}else if($('.fancybox-wrap iframe').length)
2631			{
2632				$('.fancybox-inner').height('100%');
2633				$('.fancybox-skin').width('100%');
2634				$('.fancybox-skin .fancybox-outer').width('100%').height('100%');
2635			}
2636
2637			var video_block_frame = $('.company-block #company_video_iframe');
2638			if(video_block_frame.length)
2639			{
2640				video_block_frame.hide();
2641			}
2642		},
2643		beforeClose: function(){
2644			$('.fancybox-overlay').fadeOut();
2645			if($('#company_video').length){
2646				document.getElementById('company_video').currentTime = 0;
2647				document.getElementById('company_video').pause();
2648			}
2649			if( $('#company_video_iframe').length ) {
2650				var iframe = $('#company_video_iframe');
2651				iframe.attr('data-src', iframe.attr('src'));
2652				iframe.attr('src', '#');
2653			}
2654			
2655			$('html').removeClass('overflow_html');
2656		},
2657		onClosed: function(){
2658			if($('.fancybox-wrap #company_video').length){
2659				document.getElementById('company_video').pause();
2660			}
2661		}
2662	});
2663
2664	/* flex pagination */
2665	$(document).on('mouseenter', '.flex-viewport .item', function(){
2666		$(this).closest('.flexslider').find('.flex-control-nav').toggleClass('noz');
2667		$(this).closest('.flexslider').find('.flex-control-nav').css('z-index','0');
2668	})
2669	$(document).on('mouseleave', '.flex-viewport .item', function(){
2670		$(this).closest('.flexslider').find('.flex-control-nav').toggleClass('noz');
2671		$(this).closest('.flexslider').find('.flex-control-nav').css('z-index','2');
2672	})
2673
2674	/*header burger click*/
2675	$(document).ready(function(){
2676
2677		//var isMobile = navigator.userAgent.toLowerCase().indexOf('mobile')+1;
2678		var close_btn = $('header .top_menu_map_close, #headerfixed  .top_menu_map_close');
2679		var site_map_wrapper = $('header .burger .site_map_wrapper .site_map_menu_wrapper, #headerfixed .burger .site_map_wrapper');
2680
2681		site_map_wrapper.mCustomScrollbar();
2682
2683		if(isMobile) {
2684			$('.burger').click(function(){
2685				$(this).find('.site_map_wrapper').toggle();
2686
2687			});
2688		}
2689		close_btn.click(function(){
2690			var wrapper = $(this).closest('.site_map_wrapper');
2691			wrapper.toggle();
2692			setTimeout(function(){
2693				wrapper.css('display', '');
2694			}, 300);
2695		})
2696		
2697	});
2698
2699	/* ajax more items */
2700	$(document).on('click', '.ajax_load_btn', function() {
2701		var url=$(this).closest('.bottom_nav').find('.module-pagination .next a').attr('href'),
2702			th=$(this).find('.more_text_ajax'),
2703			container = $(this).closest('.bottom_nav');
2704		var ajax_block = '';
2705		if(container.hasClass('index_block') && container.data('class')) {
2706			var class_block = th.closest('.drag-block').data('class').replace('_drag', '');
2707			class_block = class_block.replace(/\s/g, '');
2708			ajax_block = '&BLOCK=' + class_block;
2709		}
2710		if(!th.hasClass('loading'))
2711		{
2712			th.addClass('loading');
2713			var objUrl = parseUrlQuery(),
2714				add_url = '',
2715				obData = {"AJAX_REQUEST": "Y"};
2716			if('clear_cache' in objUrl)
2717			{
2718				if(objUrl.clear_cache == 'Y')
2719					add_url = '&clear_cache=Y';
2720			}
2721			if($('.banners-small.front').length)
2722			{
2723				obData.MD = $('.banners-small.front').find('.items').data('colmd');
2724				obData.SM = $('.banners-small.front').find('.items').data('colsm');
2725			}
2726			$.ajax({
2727				url: url+''+add_url,
2728				data: BX.ajax.prepareData(obData) + ajax_block,
2729				success: function(html){
2730					var eventdata = {action:'ajaxContentLoaded', content: html};
2731					var items = '';
2732					if( container.data('items') !== undefined ) {
2733						if( container.data('items') == '' ) {
2734							items = html;
2735						} else {
2736							items = $(html).find(container.data('items'));
2737						}
2738					} else {
2739						items = $(html).find('.items > div');
2740					}
2741
2742					if($('.ajax_load').length)
2743					{
2744						th.removeClass('loading');
2745						if($('.ajax_load .item-views.table').length){
2746							$('.ajax_load .item-views.table .items').append(html);
2747							// touchItemBlock('.catalog_item a');
2748							eventdata.type = 'table_block';
2749							if(arHeatOptions['THEME']['CATALOG_BLOCK_TYPE'] == 'catalog_table_2')
2750								eventdata.type = 'table_block2';
2751						}else if($('.ajax_load .item-views').length){
2752							$('.ajax_load .item-views .items').append(items);
2753						}else if($('.ajax_load .module_products_list').length){
2754							$('.ajax_load .module_products_list > tbody').append(html);
2755						}
2756						$('.bottom_nav').html($(html).find('.bottom_nav').html());
2757					}
2758					else
2759					{
2760						if($('.banners-small.front').length)
2761						{
2762							$('.banners-small .items.row').append(html);
2763							$('.bottom_nav').html($('.banners-small .items.row .bottom_nav').html());
2764							$('.banners-small .items.row .bottom_nav').remove();
2765						}
2766						else if(container.hasClass('index_block') && container.data('class')) //index page
2767						{
2768							var html_content = '';
2769							html_content = $(html).find('.'+class_block).find(container.data('class'));
2770							th.closest('.drag-block').find(container.data('class')).find(container.data('item')).append(html_content.find(container.data('item')).html());
2771							th.closest('.nav_wrapper').html(html_content.find('.nav_wrapper').html());
2772						}
2773						else
2774						{
2775							$(html).insertBefore($('.blog .bottom_nav'));
2776							$('.bottom_nav').html($('.blog .bottom_nav:hidden').html());
2777							$('.blog .bottom_nav:hidden').remove();
2778						}
2779					}
2780
2781					
2782					setTimeout(function(){
2783						BX.onCustomEvent('onCompleteAction', [eventdata, th[0]]);
2784						$('.banners-small .item.normal-block').sliceHeight();
2785						th.removeClass('loading');
2786					}, 100);
2787				}
2788			})
2789		}
2790	})
2791
2792	/* bug fix in ff*/
2793	$('img').removeAttr('draggable');
2794
2795	clicked_tab = 0;
2796
2797	$('.title-tab-heading').on('click', function(){
2798		var container = $(this).closest('.tab-pane'),
2799			nav = $(this).closest('.tabs').find('.nav'),
2800			slide_block = $(this).next();
2801
2802		clicked_tab = container.index()+1;
2803
2804		container.siblings().removeClass('active');
2805		container.siblings().find('.title-tab-heading + div').hide();
2806
2807		$('.catalog.detail .nav.nav-tabs li').removeClass('active');
2808		nav.find('li').removeClass('active');
2809
2810		if(container.hasClass('active'))
2811		{
2812			slide_block.slideUp(200, function(){
2813
2814				container.removeClass('active');
2815				nav.find('li:eq('+container.index()+')').removeClass('active');
2816			});
2817		}
2818		else
2819		{
2820			container.addClass('active');
2821			scrollToBlock(container);
2822			nav.find('li:eq('+container.index()+')').addClass('active');
2823			slide_block.slideDown();
2824			setTimeout(CheckObjectsSizes, 1);
2825		}
2826	})
2827
2828	// Responsive Menu Events
2829	var addActiveClass = false;
2830	$('#mainMenu li.dropdown > a > i, #mainMenu li.dropdown-submenu > a > i').on('click', function(e){
2831		e.preventDefault();
2832		if($(window).width() > 979) return;
2833		addActiveClass = $(this).closest('li').hasClass('resp-active');
2834		// $('#mainMenu').find('.resp-active').removeClass('resp-active');
2835		if(!addActiveClass){
2836			$(this).closest("li").addClass("resp-active");
2837		}else{
2838			$(this).closest("li").removeClass("resp-active");
2839		}
2840	});
2841
2842	/*animate increment*/
2843	if($('.spincrement').length)
2844	{
2845		$('.spincrement').counterUp({
2846			delay: 80,
2847			time: 1000
2848		});
2849	}
2850
2851	$('.bx_filter_input_container input[type=text]').numeric({allow:"."});
2852
2853	$('.toggle .more_items').on('click', function(){
2854		$(this).closest('.toggle').find('.collapsed').fadeToggle();
2855		$(this).remove();
2856		if(typeof $(this).data('resize') !== 'undefined' && $(this).data('resize'))
2857			$(window).resize();
2858	})
2859	$('.toggle_menu .more_items').on('click', function(){
2860		$(this).closest('.toggle_menu').find('.collapsed').addClass('clicked_exp');
2861		$(this).remove();
2862	})
2863
2864	/* search sync */
2865	$(document).on('keyup', '.search-input-div input', function(e){
2866		var inputValue = $(this).val();
2867		$('.search-input-div input').val(inputValue);
2868
2869		if($(this).closest('#headerfixed').length)
2870		{
2871			if(e.keyCode == 13)
2872				$('.search form').submit();
2873		}
2874	});
2875	$(document).on('click', '.search-button-div button', function(e){
2876		if($(this).closest('#headerfixed').length)
2877			$('.search form').submit();
2878	});
2879
2880	$('.inline-search-show, .inline-search-hide').on('click', function(e){
2881		if(window.matchMedia('(min-width: 600px)').matches)
2882		{
2883			if(typeof($(this).data('type_search')) != 'undefined' && $(this).data('type_search') == 'fixed')
2884				$('.inline-search-block').addClass('fixed');
2885
2886			if(arHeatOptions['THEME']['TYPE_SEARCH'] != 'fixed')
2887			{
2888				var height_block = 0;
2889				
2890				height_block = $(this).closest('.maxwidth-theme').actual('outerHeight');
2891				if($(this).closest('header.long').length)
2892					height_block = $(this).closest('header.long').actual('outerHeight');
2893				if($('header > .top-block').length)
2894				{
2895					height_block += $('header > .top-block').actual('outerHeight');
2896					height_block -= 6;
2897				}
2898				if($('#bx-panel').length)
2899					height_block += $('#bx-panel').actual('outerHeight');
2900				$('.inline-search-block').css({
2901					'height': height_block,
2902					'line-height': height_block-4+'px',
2903					'top': -height_block
2904				})
2905			}
2906
2907			$('.inline-search-block').toggleClass('show');
2908
2909			$('#title-search-input').focus();
2910			$('.title-search-result').removeClass('hidden');
2911
2912			if($('.top-block').length)
2913			{
2914				if($('.inline-search-block').hasClass('show'))
2915					$('.inline-search-block').css('background', $('.top-block').css('background-color'));
2916				else
2917					$('.inline-search-block').css('background', '#fff');
2918			}
2919			if(arHeatOptions['THEME']['TYPE_SEARCH'] == 'fixed')
2920			{
2921				if($('.inline-search-block').hasClass('show'))
2922					$('<div class="jqmOverlay search"></div>').appendTo('body');
2923				else {
2924					$('.title-search-result').addClass('hidden');
2925					$('.jqmOverlay').detach();
2926				}
2927			}
2928		}
2929		else
2930			location.href = arHeatOptions['SITE_DIR'] + 'search/';
2931	})
2932
2933	if($('.styled-block .row > div.col-md-3').length){
2934		BX.addCustomEvent('onWindowResize', function(eventdata) {
2935			try{
2936				ignoreResize.push(true);
2937				$('.styled-block .row > div.col-md-3').each(function() {
2938					$(this).css({'height': '', 'line-height': ''});
2939					var z = parseInt($('.body_media').css('top'));
2940					if(z > 0){
2941						var rowHeight = $(this).parents('.row').first().actual('outerHeight');
2942						$(this).css({'height': rowHeight + 'px', 'line-height' : rowHeight + 'px'});
2943					}
2944				});
2945			}
2946			catch(e){}
2947			finally{
2948				ignoreResize.pop();
2949			}
2950		});
2951	}
2952
2953	if($('.order-block').length){
2954		BX.addCustomEvent('onWindowResize', function(eventdata) {
2955			try{
2956				ignoreResize.push(true);
2957				$('.order-block').each(function() {
2958					var cols = $(this).find('.row > div');
2959					if(cols.length){
2960						var colFirst = cols.first();
2961						var colLast = cols.last();
2962						var colText = colFirst.find('.text');
2963						var bText = colText.length;
2964						var bOnlyText = cols.length === 1 && bText;
2965						var bPrice = colFirst.find('.price').length;
2966						var z = parseInt($('.body_media').css('top'));
2967
2968						cols.css({'height': '', 'padding-top': '', 'padding-bottom': ''});
2969						colText.css({'height': '', 'padding-top': '', 'padding-bottom': ''});
2970						if((!bPrice && z > 0) || (bPrice && z > 1)){
2971							var minHeight = 83;
2972
2973							if(!bOnlyText){
2974								var colLast_height = colLast.outerHeight();
2975								colLast_height = colLast_height >= minHeight ? colLast_height : minHeight;
2976							}
2977
2978							if(bText){
2979								var colFirst_height = colFirst.outerHeight();
2980								colFirst_height = colFirst_height >= minHeight ? colFirst_height : minHeight;
2981							}
2982
2983							var colMax_height = (bText ? (!bOnlyText ? (colLast_height >= colFirst_height ? colLast_height : colFirst_height) : colLast_height) : colFirst_height);
2984
2985							if(!bOnlyText){
2986								var textPadding = 41 + (colMax_height - colFirst.outerHeight()) / 2;
2987								colLast.find('.btns').css({'padding-top': textPadding + 'px', 'padding-bottom': textPadding + 'px', 'height': colMax_height + 'px'});
2988							}
2989							if(bText){
2990								colLast.css({'height': colMax_height + 'px'});
2991								var textPadding = 41 + (colMax_height - colText.outerHeight()) / 2;
2992								colText.css({'padding-top': textPadding + 'px', 'padding-bottom': textPadding + 'px', 'height': colMax_height + 'px'});
2993							}
2994						}
2995					}
2996				});
2997			}
2998			catch(e){}
2999			finally{
3000				ignoreResize.pop();
3001			}
3002		});
3003	}
3004
3005	if($('.equal-padding').length)
3006	{
3007		BX.addCustomEvent('onWindowResize', function(eventdata){
3008			try{
3009				ignoreResize.push(true);
3010				$('.equal-padding').each(function() {
3011					$(this).find('.text').css({'padding-top': '0px', 'padding-bottom': '0px'});
3012					var equal_block = $(this).siblings('.equals'),
3013						height = $(this).actual('outerHeight');
3014
3015					delta = Math.round((equal_block.actual('outerHeight') - height)/2);
3016					if(delta)
3017						$(this).find('.text').css({'padding-top': delta+'px', 'padding-bottom': delta+'px'});
3018				})
3019			}
3020			catch(e){}
3021			finally{
3022				ignoreResize.pop();
3023			}
3024		});
3025	}
3026
3027	$(document).on('click', '.mega-menu .dropdown-menu', function(e){
3028		e.stopPropagation();
3029	});
3030
3031	$(document).on('click', '.mega-menu .dropdown-toggle.more-items', function(e){
3032		e.preventDefault();
3033	});
3034
3035	$('.table-menu .dropdown,.table-menu .dropdown-submenu,.table-menu .dropdown-toggle').on('mouseenter', function() {
3036		CheckTopVisibleMenu();
3037	});
3038
3039	$('.mega-menu .search-item .search-icon, .menu-row #title-search .fa-close').on('click', function(e) {
3040		e.preventDefault();
3041		$('.menu-row #title-search').toggleClass('hide');
3042	});
3043
3044	$('.mega-menu ul.nav .search input').on('keyup', function(e) {
3045		var inputValue = $(this).val();
3046		$('.menu-row > .search input').val(inputValue);
3047		if(e.keyCode == 13){
3048			$('.menu-row > .search form').submit();
3049		}
3050	});
3051
3052	$('.menu-row > .search input').on('keyup', function(e) {
3053		var inputValue = $(this).val();
3054		$('.mega-menu ul.nav .search input').val(inputValue);
3055		if(e.keyCode == 13){
3056			$('.menu-row > .search form').submit();
3057		}
3058	});
3059
3060	$('.mega-menu ul.nav .search button').on('click', function(e) {
3061		e.preventDefault();
3062		var inputValue = $(this).parents('.search').find('input').val();
3063		$('.menu-and-search .search input').val(inputValue);
3064		$('.menu-row > .search form').submit();
3065	});
3066
3067	$('.filter .calendar').on('click', function() {
3068		var button = $(this).next();
3069		if(button.hasClass('calendar-icon')){
3070			button.trigger('click');
3071		}
3072	});
3073
3074	/* sync bxslider*/
3075	$(document).on('click', '.bxSlider.top-small .slides li', function(){
3076		var index = $(this).data('slide_key');
3077		$(this).siblings().removeClass('flex-active-slide');
3078		$(this).addClass('flex-active-slide');
3079		$(this).siblings('[data-slide_key="'+index+'"]').addClass('flex-active-slide');
3080		$('.top-bigs').data('flexslider').flexAnimate(index);
3081	})
3082
3083	/*sliceheights*/
3084	if($('.banners-small .item.normal-block').length)
3085		$('.banners-small .item.normal-block').sliceHeight();
3086	if($('.teasers .item').length)
3087		$('.teasers .item').sliceHeight();
3088	if($('.wrap-portfolio-front .row.items > div').length)
3089		$('.wrap-portfolio-front .row.items > div').sliceHeight({'row': '.row.items', 'item': '.item1'});
3090	if($('.float_banners_v4 .row.items > div').length) {
3091		$('.float_banners_v4 .row.items > div .text-wrapper').sliceHeight();
3092	}
3093	if($('.popular_container .wraps.goods-block .item').length) {
3094		$('.popular_container .wraps.goods-block .item .title').sliceHeight();
3095		$('.popular_container .wraps.goods-block .item .section_name').sliceHeight();
3096		$('.popular_container .wraps.goods-block .item .slice_price').sliceHeight();
3097	}
3098	 
3099
3100	SliceHeightBlocks();
3101
3102	/* toggle */
3103	var $this = this,
3104		previewParClosedHeight = 25;
3105
3106	$('section.toggle > label').prepend($('<i />').addClass('fa fa-plus'));
3107	$('section.toggle > label').prepend($('<i />').addClass('fa fa-minus'));
3108	$('section.toggle.active > p').addClass('preview-active');
3109	$('section.toggle.active > div.toggle-content').slideDown(350, function() {});
3110
3111	$('section.toggle > label').click(function(e){
3112		var parentSection = $(this).parent(),
3113			parentWrapper = $(this).parents('div.toogle'),
3114			previewPar = false,
3115			isAccordion = parentWrapper.hasClass('toogle-accordion');
3116
3117		if(isAccordion && typeof(e.originalEvent) != 'undefined') {
3118			parentWrapper.find('section.toggle.active > label').trigger('click');
3119		}
3120
3121		parentSection.toggleClass('active');
3122
3123		// Preview Paragraph
3124		if( parentSection.find('> p').get(0) ){
3125			previewPar = parentSection.find('> p');
3126			var previewParCurrentHeight = previewPar.css('height');
3127			previewPar.css('height', 'auto');
3128			var previewParAnimateHeight = previewPar.css('height');
3129			previewPar.css('height', previewParCurrentHeight);
3130		}
3131
3132		// Content
3133		var toggleContent = parentSection.find('> div.toggle-content');
3134
3135		if( parentSection.hasClass('active') ){
3136			$(previewPar).animate({
3137				height: previewParAnimateHeight
3138			}, 350, function() {
3139				$(this).addClass('preview-active');
3140			});
3141			toggleContent.slideDown(350, function() {});
3142		}
3143		else{
3144			$(previewPar).animate({
3145				height: previewParClosedHeight
3146			}, 350, function() {
3147				$(this).removeClass('preview-active');
3148			});
3149			toggleContent.slideUp(350, function() {});
3150		}
3151	});
3152
3153	/* accordion */
3154	$('.accordion-head').on('click', function(e){
3155		e.preventDefault();
3156		if(!$(this).next().hasClass('collapsing')){
3157			$(this).toggleClass('accordion-open');
3158			$(this).toggleClass('accordion-close');
3159		}
3160	});
3161
3162	/* progress bar */
3163	$('[data-appear-progress-animation]').each(function(){
3164		var $this = $(this);
3165		$this.appear(function(){
3166			var delay = ($this.attr('data-appear-animation-delay') ? $this.attr('data-appear-animation-delay') : 1);
3167			if( delay > 1 )
3168				$this.css('animation-delay', delay + 'ms');
3169			$this.addClass($this.attr('data-appear-animation'));
3170
3171			setTimeout(function(){
3172				$this.animate({
3173					width: $this.attr('data-appear-progress-animation')
3174				}, 1500, 'easeOutQuad', function() {
3175					$this.find('.progress-bar-tooltip').animate({
3176						opacity: 1
3177					}, 500, 'easeOutQuad');
3178				});
3179			}, delay);
3180		}, {accX: 0, accY: -50});
3181	});
3182
3183	/* portfolio item */
3184	$('.item.animated-block').appear(function(){
3185		var $this = $(this);
3186
3187		$this.addClass($this.data('animation')).addClass('visible');
3188
3189	}, {accX: 0, accY: 150})
3190
3191	$('a[rel=tooltip]').tooltip();
3192	$('span[data-toggle=tooltip]').tooltip();
3193
3194	$('select.sort').on('change', function(){
3195		location.href = $(this).val();
3196	});
3197
3198	setTimeout(function(th){
3199		$('.catalog.group.list .item').each(function(){
3200			var th = $(this);
3201			if((tmp = th.find('.image').outerHeight() - th.find('.text_info').outerHeight()) > 0){
3202				th.find('.text_info .titles').height(th.find('.text_info .titles').outerHeight() + tmp);
3203			}
3204		})
3205	}, 50);
3206
3207	/* ajax tabs*/
3208	$(document).on('click', '.head-block .item-link', function() {
3209		var index = $(this).index(),
3210			body_block = $(this).closest('.catalog').find('.body-block'),
3211			obQuery = parseUrlQuery(),
3212			url_post = arHeatOptions['SITE_DIR'] + 'include/mainpage/comp_catalog_ajax.php';
3213		$(this).siblings().removeClass('active');
3214		$(this).addClass('active');
3215
3216		if('clear_cache' in obQuery)
3217			url_post += '?clear_cache='+obQuery.clear_cache;
3218
3219		if(!$(this).hasClass('clicked'))
3220		{
3221			var template = '';
3222			if($(this).data('custom_template')) {
3223				template = $(this).data('custom_template');
3224			}
3225			$.ajax({
3226				url: url_post,
3227				type: 'POST',
3228				data: {AJAX_POST: 'Y', CUSTOM_TEMPLATE: template, AJAX_PARAMS: $(this).closest('.item-views.catalog').find('.request-data').data('value'), GLOBAL_FILTER: body_block.find('.item-block:eq('+index+')').data('filter')},
3229			}).success(function(html){
3230				body_block.find('.item-block:eq('+index+')').html(html);
3231
3232				InitFlexSliderClass(body_block.find('.item-block:eq('+index+')').find('.flexslider')); //reinit flexslider
3233				
3234				body_block.css('height', body_block.find('.item-block.active').actual('outerHeight'));
3235
3236				body_block.find('.item-block').removeClass('active').removeClass('opacity1').addClass('opacity0');
3237				body_block.find('.item-block:eq('+index+')').addClass('active');
3238
3239				setTimeout(function(){
3240					body_block.css('height', 'auto');
3241
3242					//recalculate height
3243					//body_block.find('.item-block:eq('+index+') .catalog.item-views.table .item .title').sliceHeight({sliceEqualLength: true});
3244					//body_block.find('.item-block:eq('+index+') .catalog.item-views.table .item .cont').sliceHeight({sliceEqualLength: true});
3245					//body_block.find('.item-block:eq('+index+') .catalog.item-views.table .item .slice_price').sliceHeight({sliceEqualLength: true});
3246					//body_block.find('.item-block:eq('+index+') .catalog.item-views.table .item').sliceHeight({classNull: '.footer-button', sliceEqualLength: true});
3247					SliceHeightBlocksClass(body_block.find('.item-block:eq('+index+')')[0]);
3248
3249					body_block.find('.item-block:eq('+index+')').removeClass('opacity0').addClass('opacity1');
3250					if(typeof setHoverHeight == "function")
3251						setHoverHeight();
3252				},10);
3253				InitSlickSliderClass(body_block.find('.item-block:eq('+index+')').find('.slick-slider'));
3254				
3255				setBasketItemsClasses();
3256			});
3257		}
3258		else
3259		{
3260			body_block.find('.item-block').removeClass('active').removeClass('opacity1').addClass('opacity0');
3261			body_block.find('.item-block:eq('+index+')').addClass('active').removeClass('opacity0').addClass('opacity1');
3262
3263			if(!body_block.find('.item-block.active .flex-control-nav li').length)
3264			{
3265				$('.item-views.catalog .flex-direction-nav li a').addClass('flex-disabled');
3266			}
3267			else
3268			{
3269				$('.item-views.catalog .flex-direction-nav li a').removeClass('flex-disabled');
3270			}
3271			setBasketItemsClasses();
3272			if(typeof setHoverHeight == "function")
3273				setHoverHeight();
3274			body_block.find('.item-block:eq('+index+')').find('.slick-slider').slick('unslick');
3275			InitSlickSliderClass(body_block.find('.item-block:eq('+index+')').find('.slider-debug'));
3276			var list = body_block.find('.item-block:eq('+index+')').find('.slick-list');
3277			if(!list.hasClass('fixed_height')){
3278				var total_height = String(list.outerHeight()) + "px";
3279				list.addClass('fixed_height');
3280				list.css('height', total_height);
3281			}
3282			
3283		}
3284		$(this).addClass('clicked');
3285	})
3286
3287	/*item galery*/
3288	$('.thumbs .item a').on('click', function(e){
3289		e.preventDefault();
3290		$('.thumbs .item').removeClass('current');
3291		$(this).closest('.item').toggleClass('current');
3292		$('.slides li' + $(this).attr('href')).addClass('current').siblings().removeClass('current');
3293	});
3294
3295	$('header.fixed .btn-responsive-nav').on('click', function() {
3296		$('html, body').animate({scrollTop: 0}, 400);
3297	});
3298
3299	$('body').on('click', '.form .refresh-page', function(){
3300		location.href = location.href;
3301	});
3302
3303	// click on HTML5 video
3304	$(document).on('click', 'video.video', function(e){
3305		var videoID = e.target.id.replace('player_', '')
3306	    if(videoID){
3307	    	if(players[videoID].playing){
3308				e.target.pause()
3309	    	}
3310	    	else{
3311	    		e.target.play()
3312	    	}
3313	    }
3314	})
3315
3316	// START VIDEO BUTTON
3317	/*$(document).on('click', '.banners-big .item .btn-video', function(){
3318		$(this).addClass('loading');
3319		startMainBannerSlideVideo($(this).closest('.item'));
3320	});*/
3321	
3322	$(document).on('click', '.basket.fly .opener', function(){
3323		if(window.matchMedia('(max-width: 767px)').matches)
3324			location.href = arHeatOptions['THEME']['URL_BASKET_SECTION'];
3325		else
3326			$(this).closest('.ajax_basket').toggleClass('opened');
3327	})
3328	
3329	$(document).on('click', '.basket.fly .close_block', function()
3330	{
3331		$('.basket.fly .opener').trigger('click');
3332	})
3333
3334	/* show props */
3335	$(document).on('click', ".show_props", function(){
3336		$(this).prev(".props_list").stop().slideToggle(333);
3337		$(this).find(".char_title").toggleClass("opened");
3338	});
3339
3340	/* animated labels */
3341	$(document).on("focus", ".animated-labels input,.animated-labels textarea", function(){
3342		$(this).closest(".animated-labels").addClass("input-filed");
3343	}).on("focusout", ".animated-labels input,.animated-labels textarea", function(){
3344		if("" != $(this).val() && " " != $(this).val())
3345			$(this).closest(".animated-labels").addClass("input-filed");
3346		else
3347			$(this).closest(".animated-labels").removeClass("input-filed");
3348	})
3349
3350	/* accordion action*/
3351	$('.panel-collapse').on('hidden.bs.collapse', function(){
3352		$(this).parent().toggleClass('opened');
3353	})
3354	$('.panel-collapse').on('show.bs.collapse', function(){
3355		$(this).parent().toggleClass('opened');
3356	})
3357
3358	// DIGITAL BASKET
3359	// - basket fly close
3360	$(document).on('click', function(){
3361		if($('.basket.fly').length && $('.ajax_basket').hasClass('opened')){
3362			$('.ajax_basket').removeClass('opened');
3363		}
3364	});
3365
3366	$(document).on('click', '.basket.fly', function(e){
3367		e.stopPropagation();
3368	});
3369
3370	// - COUNTER
3371	var timerBasketCounter = false;
3372
3373	// -- keyup input
3374	$(document).on('keydown', '.count', function(e){
3375		// Allow: backspace, delete, tab, escape, enter and .
3376		if($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
3377			 // Allow: Ctrl+A, Command+A
3378			(e.keyCode === 65 && (e.ctrlKey === true || e.metaKey === true)) ||
3379			 // Allow: home, end, left, right, down, up
3380			(e.keyCode >= 35 && e.keyCode <= 40)) {
3381				 // let it happen, don't do anything
3382				 return;
3383		}
3384		// Ensure that it is a number and stop the keypress
3385		if((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)){
3386			e.preventDefault();
3387		}
3388	});
3389	$(document).on('keyup', '.count', function(e){
3390		var $this = $(this),
3391			counterInputValueNew = $this.val(),
3392			price = $this.closest('.item').find('input[name=PRICE]').val();
3393
3394		Summ($this, counterInputValueNew, price);
3395	});
3396
3397	// -- scroll after apply option
3398	if($('.instagram_ajax').length)
3399	{
3400		BX.addCustomEvent('onCompleteAction', function(eventdata){
3401			if(eventdata.action === 'instagrammLoaded')
3402				scrollPreviewBlock();
3403		});
3404	}
3405	else
3406		scrollPreviewBlock();
3407
3408	$('select.region').on('change', function(){
3409		var val = parseInt($(this).val());
3410		if($('select.city').length)
3411		{
3412			if(val)
3413			{
3414				$('select.city').removeAttr('disabled');
3415				$('select.city option').hide();
3416				$('select.city option[data-parent_section='+val+']').show();
3417			}
3418			else
3419				$('select.city').attr('disabled', 'disabled');
3420		}
3421	})
3422
3423	$('select.city, select.region').on('change', function(){
3424		var _this = $(this),
3425			val = parseInt(_this.val());
3426		if(_this.hasClass('region'))
3427		{
3428			$('select.city option:eq(0)').show();
3429			$('select.city').val(0);
3430		}
3431
3432		if((_this.hasClass('region') && !val) || _this.hasClass('city'))
3433		{
3434			$.ajax({
3435				type: 'POST',
3436				data: {ID: val},
3437			}).success(function(html){
3438				var ob = BX.processHTML(html);
3439				$('.ajax_items')[0].innerHTML = ob.HTML;
3440				BX.ajax.processScripts(ob.SCRIPT);
3441			})
3442		}
3443	})
3444
3445	// -- blur input
3446	$(document).on('blur', '.count', function(){
3447		BasketCounter($(this));
3448	});
3449
3450	// -- click minus, plus button
3451	$(document).on('click', '.minus, .plus', function(e){
3452		e.stopPropagation();
3453		BasketCounter($(this));
3454	});
3455
3456	// - Add2Basket
3457	$(document).on('click', '.to_cart', function(e){
3458		e.stopPropagation();
3459		var item = $(this).closest('[data-item]'),
3460			_this = $(this),
3461			itemData = item.data('item'),
3462			buyBlock = item.find('.buy_block'),
3463			counter = buyBlock.find('.counter'),
3464			buttonToCart = buyBlock.find('.to_cart'),
3465			itemQuantity = parseFloat(buttonToCart.data('quantity')),
3466			countItem = ($('.basket').length ? parseInt($('.basket .count').text()) : parseInt($('.basket_top:visible .count').text()));
3467
3468		if(typeof(arBasketItems) === 'object' && typeof(arBasketItems[itemData.ID]) !== 'object')
3469			arBasketItems[itemData.ID] = {'ID': itemData.ID};
3470
3471		$('.basket_top .count').text(countItem + 1).removeClass('empted');
3472		$('.basket .count').text(countItem + 1).removeClass('empted');
3473
3474		if(typeof(arHeatOptions['THEME']['ORDER_BASKET_VIEW']) !== 'undefined')
3475		{
3476			if($.trim(arHeatOptions['THEME']['ORDER_BASKET_VIEW']) === 'HEADER' && $('.basket_top').length)
3477				var bBasketTop = true;
3478			else if($('.basket.fly').length)
3479				var bBasketFly = true;
3480		}
3481
3482		if(isNaN(itemQuantity) || itemQuantity <= 0){
3483			itemQuantity = 1;
3484		}
3485
3486		if(!isNaN(itemData.ID) && parseInt(itemData.ID) > 0){
3487			buyBlock.addClass('in');
3488
3489			$.ajax({
3490				url: arHeatOptions['SITE_DIR'] + 'include/footer/site-basket.php',
3491				type: 'POST',
3492				data: {itemData: itemData, quantity: itemQuantity},
3493			}).success(function(html){
3494				var eventdata = {action:'loadForm'};
3495				BX.onCustomEvent('onCompleteAction', [eventdata, _this[0]]);
3496
3497				if(bBasketTop)
3498				{
3499					$('.ajax_basket').html(html);
3500				}
3501
3502				if(bBasketFly)
3503				{
3504					if($('.basket.fly').length)
3505					{
3506						$('.ajax_basket').html(html);
3507						setTimeout(function(){
3508							if(!$('.ajax_basket').hasClass('opened')){
3509								$('.ajax_basket').addClass('opened');
3510							}
3511						}, 50);
3512					}
3513				}
3514				
3515				var eventdata = {action:'loadBasket'};
3516				BX.onCustomEvent('onCompleteAction', [eventdata, $('.ajax_basket')[0]]);
3517
3518				if(arHeatOptions['THEME']['USE_SALE_GOALS'] != 'N')
3519				{
3520					var eventdata = {goal: 'goal_basket_add', params: {itemData: itemData, quantity: itemQuantity}};
3521					BX.onCustomEvent('onCounterGoals', [eventdata]);
3522				}
3523			});
3524		}
3525		else{
3526			return;
3527		}
3528	});
3529
3530	// - Remove9Basket
3531	$(document).on('click', '.remove', function(){
3532		var item = $(this).closest('[data-item]'),
3533			itemData = item.data('item'),
3534			bRemove = 'Y',
3535			bRemoveAll = ($.trim($(this).closest('[data-remove_all]').data('remove_all')) === 'Y' ? 'Y' : false);
3536			getCurUri = $.trim($('input[name=getPageUri]').val()),
3537			countItem = ($('.basket').length ? parseInt($('.basket .item').length) : parseInt($('.basket_top:visible .item').length)),
3538			bOneItem = (countItem - 1 <= 0),
3539			scrollTop = ($('.basket.fly').length ? $('.basket.fly .items_wrap').scrollTop() : ($('.basket_top:visible').length ? $('.basket_top .items:visible').scrollTop() : ''));
3540
3541		if(typeof(arBasketItems) === 'object' && itemData && typeof(arBasketItems[itemData.ID]) === 'object')
3542			delete arBasketItems[itemData.ID];
3543
3544		var _ajax = function(){
3545			$.ajax({
3546				url: arHeatOptions['SITE_DIR'] + 'include/footer/site-basket.php',
3547				data: {itemData: itemData, remove: bRemove, removeAll: bRemoveAll},
3548			}).success(function(html){
3549
3550				if(bBasketTop){
3551					$('.ajax_basket').html(html);
3552					$('.basket_top .items').scrollTop(scrollTop);
3553				}
3554
3555				if(getCurUri){
3556					$.ajax({
3557						url: getCurUri,
3558						type: 'POST',
3559					}).success(function(html){
3560						if($('.basket.default').length){
3561							$('.basket.default').html(html);
3562						}
3563					});
3564				}
3565
3566				if(bBasketFly){
3567					$('.ajax_basket').html(html);
3568					$('.ajax_basket').addClass('opened');
3569					$('.basket.fly .items_wrap').scrollTop(scrollTop);
3570				}
3571
3572				var eventdata = {action:'loadBasket'};
3573				BX.onCustomEvent('onCompleteAction', [eventdata, $(html)]);
3574
3575				if(arHeatOptions['THEME']['USE_SALE_GOALS'] != 'N')
3576				{
3577					var eventdata = {goal: 'goal_basket_remove', params: {itemData: itemData, remove: bRemove, removeAll: bRemoveAll}};
3578					BX.onCustomEvent('onCounterGoals', [eventdata]);
3579				}
3580			});
3581		}
3582
3583		if(typeof(arHeatOptions['THEME']['ORDER_BASKET_VIEW']) !== 'undefined')
3584		{
3585			if($.trim(arHeatOptions['THEME']['ORDER_BASKET_VIEW']) === 'HEADER' && $('.basket_top').length)
3586				var bBasketTop = true;
3587			else if($('.basket.fly').length)
3588				var bBasketFly = true;
3589		}
3590
3591		if(typeof(itemData) !== 'undefined' && (!isNaN(itemData.ID) && itemData.ID > 0) || bRemoveAll){
3592			if(bRemoveAll){
3593				$('.buy_block').removeClass('in');
3594				$('.basket .count').text(0).addClass('empted');
3595				$('.basket_top .count').text(0).addClass('empted');
3596				$('#mobilemenu .menu .ready .count').text(0).addClass('empted');
3597			}
3598			else{
3599				$('[data-item]').each(function(){
3600					if($(this).data('item').ID == itemData.ID){
3601						$(this).find('.buy_block').removeClass('in');
3602					}
3603				});
3604				if($('.basket').length){
3605					if($('.basket_top .count').length)
3606						$('.basket_top .count').text(parseFloat($('.basket_top:visible .count').text()) - 1);
3607					else
3608					{
3609						$('.basket .count').text(parseFloat($('.basket .count').text()) - 1);
3610						$('.basket_top .count').text(parseFloat($('.basket .count').text()) - 1);
3611					}
3612				}
3613				else{
3614					$('.basket_top .count').text(parseFloat($('.basket_top:visible .count').text()) - 1);
3615				}
3616
3617				$('#mobilemenu .menu .ready .count').text(parseFloat($('#mobilemenu .menu .ready .count').text()) - 1);
3618			}
3619
3620			if(bOneItem && !bRemoveAll){
3621				if(item.closest('.basket_top').length){
3622					item.closest('.dropdown').animate({opacity: 0}, 200, function(){
3623						_ajax();
3624					});
3625				}
3626				else{
3627					item.closest('.basket').find('.count').addClass('empted');
3628					item.closest('.basket_wrap').fadeOut(200, function(){
3629						item.closest('.basket').find('.basket_empty').fadeIn(200, function(){
3630							_ajax();
3631						});
3632					});
3633				}
3634			}
3635			else if(bRemoveAll){
3636				$('.basket_wrap').fadeOut(200, function(){
3637					$('.remove.all').remove();
3638					$('.basket').find('.basket_empty').fadeIn(200, function(){
3639						_ajax();
3640					});
3641				});
3642			}
3643			else if(!bOneItem){
3644				item.animate({opacity: 0}, 200).slideUp(200, function(){
3645					_ajax();
3646				});
3647			}
3648		}
3649		else{
3650			return;
3651		}
3652	});
3653	$(document).on('click', '.print', function(){
3654		window.print();
3655	});
3656
3657	$('.choise').on('click', function(){
3658		var _this = $(this);
3659		if(typeof(_this.data('block')) != 'undefined')
3660		{
3661			scrollToBlock(_this.data('block'));
3662		}
3663	})
3664
3665	/*touch event*/
3666	document.addEventListener('touchend', function(event) {
3667		if(!$(event.target).closest('.menu-item').length && !$(event.target).hasClass('menu-item') && !$(event.target).closest('#mobileheader').length){
3668			$('.mega-menu .dropdown-menu').css({'display':'none','opacity':0});
3669			$('.menu-item').removeClass('hover');
3670			$('.bx-breadcrumb-item.drop').removeClass('hover');
3671		}
3672		if(!$(event.target).closest('.menu.topest').length){
3673			$('.menu.topest').css({'overflow': 'hidden'});	
3674			$('.menu.topest > li').removeClass('hover');
3675		}
3676		if(!$(event.target).closest('.full.has-child').length){
3677			$('.menu_top_block.catalog_block li').removeClass('hover');
3678		}
3679		/*if(!$(event.target).closest('.basket_block').length){
3680			$('.basket_block .link').removeClass('hover');
3681			$('.basket_block .basket_popup_wrapp').slideUp();
3682		}
3683		if(!$(event.target).closest('.catalog_item').length){
3684			var tabsContentUnhoverHover = $('.tab:visible').attr('data-unhover') * 1;
3685			$('.tab:visible').stop().animate({'height': tabsContentUnhoverHover}, 100);
3686			$('.tab:visible').find('.catalog_item').removeClass('hover');
3687			$('.tab:visible').find('.catalog_item .buttons_block').stop().fadeOut(233);
3688			if($('.catalog_block').length){
3689				$('.catalog_block').find('.catalog_item_wrapp').removeClass('hover');
3690				$('.catalog_block').find('.catalog_item').removeClass('hover');
3691			}
3692		}*/
3693
3694	}, false);
3695
3696	touchMenu('.mega-menu .menu-item');
3697	touchSubMenu('.mega-menu .dropdown-submenu');
3698	touchTopMenu('.menu.topest li');
3699});
3700
3701function touchSubMenu(selector){
3702	if(isMobile){
3703		if($(selector).length)
3704		{
3705			$(selector).each(function(){
3706				var th=$(this);
3707				th.on('touchend', function(e) {
3708					var _th = $(e.target).closest('.dropdown-submenu');
3709					
3710					$('.mega-menu > li.dropdown-submenu').removeClass('hover');
3711
3712					if (_th.find('.dropdown-menu').length && !_th.hasClass('hover')) {
3713						e.preventDefault();
3714						e.stopPropagation();
3715						_th.siblings().removeClass('hover');
3716						_th.addClass('hover');
3717						$('.menu-row .dropdown-submenu .dropdown-menu').css({'display':'none', 'opacity':0});
3718						if(_th.hasClass('dropdown-submenu'))
3719						{
3720							_th.closest('.dropdown-menu').css({'display':'block', 'opacity':1});
3721						}
3722						if(_th.find('> .wrap > .dropdown-menu').length)
3723						{
3724							_th.find('> .wrap > .dropdown-menu').css({'display':'block', 'opacity':1});
3725						}
3726						else if(_th.find('> .dropdown-menu').length)
3727						{
3728							_th.find('> .dropdown-menu').css({'display':'block', 'opacity':1});
3729						}
3730						CheckTopVisibleMenu();
3731					}
3732					else
3733					{
3734						var href = ($(e.target).attr('href') ? $(e.target).attr('href') : $(e.target).closest('a').attr('href'))
3735						if(href && href !== 'undefined')
3736							location.href = href;
3737					}
3738				})
3739			})
3740		}
3741	}else{
3742		$(selector).off();
3743	}
3744}
3745
3746function touchMenu(selector){
3747	if(isMobile){
3748		if($(selector).length)
3749		{
3750			$(selector).each(function(){
3751				var th=$(this);
3752				th.on('touchend', function(e) {
3753					var _th = $(e.target).closest('.menu-item');
3754					
3755					$('.menu.topest > li').removeClass('hover');
3756					$('.menu_top_block.catalog_block li').removeClass('hover');
3757					$('.bx-breadcrumb-item.drop').removeClass('hover');
3758
3759					if (_th.find('.dropdown-menu').length && !_th.hasClass('hover')) {
3760						e.preventDefault();
3761						e.stopPropagation();
3762						_th.siblings().removeClass('hover');
3763						_th.addClass('hover');
3764						$('.menu-row .dropdown-menu').css({'display':'none', 'opacity':0});
3765						if(_th.hasClass('menu-item'))
3766						{
3767							_th.closest('.dropdown-menu').css({'display':'block', 'opacity':1});
3768						}
3769						if(_th.find('> .wrap > .dropdown-menu'))
3770						{
3771							_th.find('> .wrap > .dropdown-menu').css({'display':'block', 'opacity':1});
3772						}
3773						else if(_th.find('> .dropdown-menu'))
3774						{
3775							_th.find('> .dropdown-menu').css({'display':'block', 'opacity':1});
3776						}
3777						CheckTopVisibleMenu();
3778					}
3779					else
3780					{
3781						var href = ($(e.target).attr('href') ? $(e.target).attr('href') : $(e.target).closest('a').attr('href'))
3782						if(href && href !== 'undefined')
3783							location.href = href;
3784					}
3785				})
3786			})
3787		}
3788	}else{
3789		$(selector).off();
3790	}
3791}
3792
3793function touchTopMenu(selector){
3794	if(isMobile){
3795		if($(selector).length)
3796		{
3797			$(selector).each(function(){
3798				var th=$(this);
3799				th.on('touchend', function(e) {
3800					var _th = $(e.target).closest('li');
3801
3802					$('.menu-item').removeClass('hover');
3803					$('.menu-item .dropdown-menu').css({'display':'none', 'opacity':0});
3804					$('.menu_top_block.catalog_block li').removeClass('hover');
3805					$('.bx-breadcrumb-item.drop').removeClass('hover');
3806
3807					if (_th.hasClass('more') && !_th.hasClass('hover')) {
3808						e.preventDefault();
3809						e.stopPropagation();
3810						_th.siblings().removeClass('hover');
3811						_th.addClass('hover');
3812						$('.menu.topest').css({'overflow': 'visible'});
3813					}
3814					else
3815					{
3816						var href = ($(e.target).attr('href') ? $(e.target).attr('href') : $(e.target).closest('a').attr('href'))
3817						if(href && href !== 'undefined')
3818							location.href = href;
3819					}
3820				})
3821			})
3822		}
3823	}else{
3824		$(selector).off();
3825	}
3826}
3827
3828scrollPreviewBlock = function(){
3829	if(typeof($.cookie('scoll_block')) != 'undefined' && $.cookie('scoll_block'))
3830	{
3831		var scoll_block = $($.cookie('scoll_block'));
3832		if(scoll_block.length)
3833		{
3834			$('body, html').animate({scrollTop: scoll_block.offset().top}, 500);
3835			$.cookie('scoll_block', null);
3836		}
3837	}
3838}
3839
3840scrollToBlock = function(block){
3841	if($(block).length)
3842	{
3843		var offset = $(block).offset().top;
3844		if(typeof($(block).data('toggle')) != 'undefined')
3845			$(block).click();
3846
3847		if(typeof($(block).data('offset')) != 'undefined')
3848			offset += $(block).data('offset');
3849
3850		$('body, html').animate({scrollTop: offset}, 500);
3851	}
3852}
3853
3854// START VIDEO BUTTON
3855$('.banners-big .maxwidth-banner .item.vvideo .maxwidth-theme').on('click', function(e){
3856	if(!$(e.target).hasClass('btn-video'))
3857	{
3858		if($(this).hasClass('loading'))
3859		{
3860			e.stopPropagation();
3861			$(this).find('.btn-video').trigger('click');
3862		}
3863	}
3864})
3865
3866$(document).on('click', '.banners-big .item.current  .btn-video', function(e){
3867	e.stopPropagation();
3868	if(!$(this).hasClass('loading'))
3869	{
3870		$(this).addClass('loading');
3871		$(this).closest('.maxwidth-theme').addClass('loading');
3872	}
3873	else
3874	{
3875		$(this).removeClass('loading');
3876		$(this).closest('.maxwidth-theme').removeClass('loading');
3877	}
3878
3879	startMainBannerSlideVideo($(this).closest('.item'));
3880});
3881
3882//DIGITAL BASKET
3883function number_format(number, decimals, dec_point, thousands_sep) {
3884	number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
3885	var n = !isFinite(+number) ? 0 : +number,
3886	prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
3887	sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
3888	dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
3889	s = '',
3890	toFixedFix = function(n, prec){
3891		var k = Math.pow(10, prec);
3892		return '' + (Math.round(n*k)/k).toFixed(prec);
3893	};
3894
3895	// Fix for IE parseFloat(0.55).toFixed(0) = 0;
3896	s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
3897
3898	if (s[0].length > 3) {
3899		s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
3900	}
3901
3902	if ((s[1] || '')
3903		.length < prec) {
3904		s[1] = s[1] || '';
3905		s[1] += new Array(prec - s[1].length + 1).join('0');
3906	}
3907
3908	return s.join(dec);
3909}
3910
3911
3912setBasketItemsClasses = function(){
3913	if(typeof(arBasketItems) !== 'undefined' && typeof(arBasketItems) !== 'string'){
3914		if(Object.keys(arBasketItems).length){
3915			for(var key in arBasketItems){
3916				$('[data-item]').each(function(){
3917					if($(this).data('item').ID == key){
3918						$(this).find('.buy_block').addClass('in');
3919					}
3920				});
3921			}
3922		}
3923	}
3924}
3925
3926function Summ(el, counterInputValueNew, price){
3927	if(counterInputValueNew <= 0){
3928		counterInputValueNew = 1;
3929	}
3930
3931	var summ = number_format(counterInputValueNew*price, 0, '.', ' '),
3932		allSumm = 0;
3933
3934	el.closest('.items').find('.item').each(function(){
3935		var $this = $(this),
3936			price = parseFloat($this.find('input[name=PRICE]').val()),
3937			count =  parseFloat($this.find('input.count').val());
3938
3939		if(count <= 0){
3940			count = 1;
3941		}
3942
3943		if(!isNaN(price) && !isNaN(count)){
3944			allSumm += count*price;
3945		}
3946	});
3947
3948	allSumm = number_format(parseFloat(allSumm), 0, '.', ' ');
3949
3950	el.closest('.item').find('.summ .price_val').text(summ);
3951	el.closest('.basket').find('.foot .total>span').text(allSumm);
3952}
3953
3954var timerBasketUpdate = false;
3955// - COUNTER
3956BasketCounter = function(el){
3957	var elClass = $.trim(el.attr('class')),
3958		bClassMinus = (elClass.indexOf('minus') > -1),
3959		bClassPlus = (elClass.indexOf('plus') > -1),
3960		bClassCount = (elClass.indexOf('count') > -1),
3961		getCurUri = $.trim($('input[name=getPageUri]').val()),
3962		buyBlock = el.closest('.buy_block'),
3963		buttonToCart = buyBlock.find('.to_cart'),
3964		counterInput = el.closest('.counter').find('input.count'),
3965		counterInputValue = parseFloat($.trim(counterInput.val())),
3966		price = parseFloat(buyBlock.find('input[name=PRICE]').val()),
3967		counterInputMaxCount = Math.pow(10, parseInt(counterInput.attr('maxlength'))) - 1,
3968		bAjax = (el.closest('.basket').length ? true : false);
3969
3970	// class minus button
3971	if(bClassMinus){
3972		var counterInputValueNew = counterInputValue - 1;
3973
3974		if(counterInputValueNew <= 0){
3975			counterInputValueNew = 1;
3976		}
3977
3978		counterInput.val(counterInputValueNew);
3979
3980		if(bAjax){
3981			Summ(el, counterInputValueNew, price);
3982	
3983			if(timerBasketUpdate){
3984				clearTimeout(timerBasketUpdate);
3985				timerBasketUpdate = false;
3986			}
3987	
3988			timerBasketUpdate = setTimeout(function(){
3989				BasketUpdate(el, counterInputValueNew);
3990				timerBasketUpdate = false;
3991			}, 700);
3992		}
3993	}
3994	// class plus button
3995	else if(bClassPlus){
3996		var counterInputValueNew = counterInputValue + 1;
3997
3998		if(counterInputValueNew > counterInputMaxCount){
3999			counterInputValueNew = counterInputMaxCount;
4000		}
4001
4002		counterInput.val(counterInputValueNew);
4003
4004		if(bAjax){
4005			Summ(el, counterInputValueNew, price);
4006	
4007			if(timerBasketUpdate){
4008				clearTimeout(timerBasketUpdate);
4009				timerBasketUpdate = false;
4010			}
4011	
4012			timerBasketUpdate = setTimeout(function(){
4013				BasketUpdate(el, counterInputValueNew);
4014				timerBasketUpdate = false;
4015			}, 700);
4016		}
4017	}
4018	// class input
4019	else if(bClassCount){
4020		var counterInputValueNew = counterInputValue;
4021
4022		if(counterInputValueNew <= 0 || isNaN(counterInputValueNew)){
4023			counterInputValueNew = 1;
4024		}
4025		el.val(counterInputValueNew);
4026		
4027		if(bAjax){
4028			BasketUpdate(el, counterInputValueNew);
4029		}
4030	}
4031
4032	if(!getCurUri && !el.closest('.basket.fly').length){
4033		buttonToCart.data('quantity', counterInputValueNew);
4034	}
4035}
4036
4037BasketUpdate = function(el, counterInputValueNew){
4038	var	itemData = el.closest('[data-item]').data('item'),
4039		itemData = (typeof(arBasketItems) === 'object' && typeof(arBasketItems[itemData.ID]) === 'object' ? arBasketItems[itemData.ID] : itemData),
4040		buyBlock = el.closest('.buy_block'),
4041		buttonToCart = buyBlock.find('.to_cart'),
4042		getCurUri = $.trim($('input[name=getPageUri]').val())
4043		scrollTop = ($('.basket.fly').length ? $('.basket.fly .items_wrap').scrollTop() : ($('.basket_top:visible').length ? $('.basket_top .items:visible').scrollTop() : ''));
4044
4045	if(typeof(arHeatOptions['THEME']['ORDER_BASKET_VIEW']) !== 'undefined' && $.trim(arHeatOptions['THEME']['ORDER_BASKET_VIEW']) === 'FLY' && $('.basket.fly').length){
4046		var bBasketFly = true;
4047	}
4048
4049	if(typeof(arHeatOptions['THEME']['ORDER_BASKET_VIEW']) !== 'undefined' && $.trim(arHeatOptions['THEME']['ORDER_BASKET_VIEW']) === 'HEADER' && $('.basket_top').length){
4050		var bBasketTop = true;
4051	}
4052
4053	else{
4054		if(typeof(itemData) != 'undefined' && !isNaN(itemData.ID) && itemData.ID > 0){
4055			$.ajax({
4056				// url: arHeatOptions['SITE_DIR'] + 'ajax/basket_items.php',
4057				url: arHeatOptions['SITE_DIR'] + 'include/footer/site-basket.php',
4058				data: {itemData: itemData, quantity: counterInputValueNew},
4059			}).success(function(data){
4060				if(typeof(data) === 'object'){
4061					arBasketItems = data;
4062				}
4063				if(bBasketTop){
4064					$.ajax({
4065						url: arHeatOptions['SITE_DIR'] + 'include/footer/site-basket.php',
4066						type: 'POST',
4067						data: {'ajaxPost': 'Y'},
4068					}).success(function(html){
4069						buyBlock.removeClass('in');
4070						$('.ajax_basket').html(html);
4071
4072						/*if(!getCurUri){
4073							setTimeout(function(){
4074								$('.basket_top .dropdown').addClass('expanded');
4075							}, 100);
4076
4077							setTimeout(function(){
4078								$('.basket_top .dropdown').removeClass('expanded');
4079							}, 1000);
4080						}*/
4081					});
4082				}
4083
4084				if(bBasketFly){
4085					$.ajax({
4086						url: arHeatOptions['SITE_DIR'] + 'include/footer/site-basket.php',
4087						type: 'POST',
4088						data: {'ajaxPost': 'Y'},
4089					}).success(function(html){
4090						if($('.basket.fly').length){
4091							$('.ajax_basket').html(html);
4092							$('.basket.fly .items_wrap').scrollTop(scrollTop);
4093						}
4094					});
4095				}
4096
4097				var eventdata = {action:'loadBasket'};
4098				BX.onCustomEvent('onCompleteAction', [eventdata, $(data)]);
4099
4100				if(getCurUri){
4101					$.ajax({
4102						url: getCurUri,
4103						type: 'POST',
4104					}).success(function(html){
4105						if($('.basket.default').length){
4106							$('.basket.default').html(html);
4107						}
4108					});
4109				}
4110			});
4111		}
4112		else{
4113			return;
4114		}
4115	}
4116}
4117
4118showTopIcons = function(){
4119	$('h1#pagetitle').addClass('shares');
4120	$(document).ready(function(){
4121		if($('a.rss').length)
4122			$('a.rss').after($('.share.top'));
4123		else
4124			$('h1#pagetitle').before($('.share.top'));
4125	})
4126}
4127
4128CheckTabActive = function(){
4129	if(typeof(clicked_tab) && clicked_tab)
4130	{
4131		/*if(window.matchMedia('(min-width: 768px)').matches)
4132		{
4133			clicked_tab--;
4134			$('.catalog.detail .nav.nav-tabs li:eq('+clicked_tab+')').addClass('active');
4135			$('.catalog.detail .tab-content .tab-pane:eq('+clicked_tab+')').addClass('active');
4136			$('.catalog.detail .tab-content .tab-pane .title-tab-heading').next().removeAttr('style');
4137			clicked_tab = 0;
4138		}*/
4139	}
4140}
4141
4142/* parallax bg */
4143ParallaxBg = function(){
4144	if($('*[data-type=parallax-bg]').length)
4145	{
4146		var x = $(window).scrollTop()/$(document).height();
4147		x=parseInt(-x * 280);
4148		$('*[data-type=parallax-bg]').stop().animate({'background-position-y':  x + 'px'}, 400, 'swing');
4149	}
4150}
4151SetFixedAskBlock = function(){
4152	if($('.ask_a_question_wrapper.fixed_ask_block').length)
4153	{
4154
4155		var offset = $('.ask_a_question_wrapper.fixed_ask_block').offset(),
4156			block = $('.ask_a_question_wrapper.fixed_ask_block').find('.ask_a_question'),
4157			block_offset = BX.pos(block[0]),
4158			block_height = block_offset.bottom-block_offset.top,
4159			ask_block_offset = 130,
4160			diff_top_scroll = $('#headerfixed').height() + $('.breadcrumb.fixed').height() + 20,
4161			footer_block = $('footer').offset().top;
4162
4163		if(block_height+ask_block_offset < block.closest('.fixed_wrapper').height())
4164		{
4165
4166			if(block_height+ask_block_offset > block.closest('.fixed_wrapper').height())
4167				block.addClass('nonfixed');
4168			else
4169				block.removeClass('nonfixed');
4170
4171			if(block.closest('.fixed_wrapper').length)
4172				footer_block = BX.pos(block.closest('.fixed_wrapper')[0]).bottom;
4173
4174
4175			if(block_height+diff_top_scroll+documentScrollTopLast + 80 > footer_block)
4176			{
4177				block.removeClass('fixed').css({'top': 'auto', 'width': 'auto', 'bottom': 0}).addClass('normal');
4178				block.parent().css('position', 'static');
4179				block.parent().parent().css('position', 'static');
4180			}
4181			else
4182			{
4183				block.removeClass('normal');
4184				block.parent().removeAttr('style');
4185				block.parent().parent().removeAttr('style');
4186
4187				if(documentScrollTopLast + diff_top_scroll-30 > offset.top)
4188					block.addClass('fixed').css({'top': diff_top_scroll, 'bottom': 'auto', 'width': $('.fixed_block_fix').width()});
4189				else
4190					block.removeClass('fixed').css({'top': 0, 'width': 'auto'});
4191			}
4192		}
4193	}
4194}
4195
4196HardHover = function() {
4197	$('.hoverTarget:visible').each(function(){
4198		$(this).find('.hoverWrapper').css('height', $(this).find('.hoverWrapper').css('height'));
4199		var wrapperHeight = $(this).find('.hoverWrapper').css('height');
4200		var wrapperPaddingTop = Number($(this).find('.hoverWrapper').css('padding-top').replace('px', ''));
4201		var wrapperPaddingBottom = Number($(this).find('.hoverWrapper').css('padding-bottom').replace('px', ''));
4202		var lower = 0;
4203		$(this).hover(
4204			function() {
4205				var date = 0;
4206				var name = 0;
4207				var text = 0;
4208				if($(this).find('.hoverWrapper .hoverTitle').length) {
4209					name = Number($(this).find('.hoverWrapper .hoverTitle').outerHeight(true));
4210				}
4211				if($(this).find('.hoverWrapper .hoverText').length) {
4212					text = Number($(this).find('.hoverWrapper .hoverText').outerHeight(true));
4213				}
4214				if($(this).find('.hoverWrapper .hoverDate').length) {
4215					date = Number($(this).find('.hoverWrapper .hoverDate').outerHeight(true));
4216				}
4217
4218				var height_val = String((name + text + date + wrapperPaddingTop + wrapperPaddingBottom)+"px");
4219
4220				$(this).find('.hoverWrapper').animate({
4221					height: height_val
4222				}, 200 );
4223			},
4224			function() {
4225				$(this).find('.hoverWrapper').animate({
4226					height: wrapperHeight
4227				}, 200 );
4228			}
4229		);
4230	});
4231}
4232
4233
4234// Events
4235var timerScroll = false, ignoreScroll = [], documentScrollTopLast = $(document).scrollTop(), documentScrollTop = $(document).scrollTop();;
4236$(window).scroll(function(){
4237	documentScrollTop = $(document).scrollTop();
4238	CheckPopupTop();
4239	SetFixedAskBlock();
4240	if(!ignoreScroll.length){
4241		if(timerScroll){
4242			clearTimeout(timerScroll);
4243			timerScroll = false;
4244		}
4245		timerScroll = setTimeout(function(){
4246			BX.onCustomEvent('onWindowScroll', false);
4247		}, 100);
4248	}
4249	documentScrollTopLast = $(document).scrollTop();
4250});
4251
4252var timerResize = false, ignoreResize = [];
4253
4254$(window).resize(function(){
4255	documentScrollTop = $(document).scrollTop();
4256	CheckPopupTop();
4257	if(typeof(arHeatOptions) == "undefined" || typeof($scrolltotop.stop) != 'function') {
4258		var timerId = setInterval(function(){
4259			if(typeof(arHeatOptions) !== "undefined" && typeof($scrolltotop.stop) == 'function'){
4260				CheckScrollToTop();
4261				clearInterval(timerId);
4262			}
4263		}, 150);
4264	} else {
4265		CheckScrollToTop();
4266	}
4267	
4268	if(!ignoreResize.length){
4269		if(timerResize){
4270			clearTimeout(timerResize);
4271			timerResize = false;
4272		}
4273		timerResize = setTimeout(function(){
4274			BX.onCustomEvent('onWindowResize', false);
4275		}, 100);
4276	}
4277	documentScrollTopLast = $(document).scrollTop();
4278});
4279
4280BX.addCustomEvent('onWindowScroll', function(eventdata) {
4281	try{
4282		ignoreScroll.push(true);
4283		ParallaxBg();
4284
4285		if(arHeatOptions['THEME']['TYPE_SEARCH'] != 'fixed')
4286		{
4287			if(!$('header > .top-block').length)
4288			{
4289				var height_block = 0,
4290					scrollVal = $(window).scrollTop();
4291				height_block = $('.logo_and_menu-row').actual('outerHeight');
4292				if(!scrollVal)
4293				{
4294					$('.inline-search-block').css({
4295						'height': height_block,
4296						'line-height': height_block-4+'px',
4297						'top': -height_block
4298					})
4299				}
4300			}
4301		}
4302
4303	}
4304	catch(e){}
4305	finally{
4306		ignoreScroll.pop();
4307	}
4308});
4309
4310BX.addCustomEvent('onWindowResize', function(eventdata) {
4311	try{
4312		ignoreResize.push(true);
4313
4314		CheckHeaderFixedMenu();
4315		CheckTopMenuDotted();
4316		CheckMenuOffset();
4317		CheckTopVisibleMenu();
4318		CheckFlexSlider();
4319		CheckMainBannerSliderVText($('.banners-big .flexslider'));
4320		CheckObjectsSizes();
4321		CoverPlayer();
4322		verticalAlign();
4323		CheckTabActive();
4324		setTimeout(function(){
4325			createTableCompare($('.main-block .items .title-block:not(.clone) .item'), $('.prop_title_table'), $('.main-block .prop_title_table .item.clone'));
4326		}, 100);
4327		SliceHeightBlocks();
4328	}
4329	catch(e){}
4330	finally{
4331		ignoreResize.pop();
4332	}
4333});
4334
4335BX.addCustomEvent('onSlide', function(eventdata) {
4336	try{
4337		ignoreResize.push(true);
4338		if(eventdata){
4339			var slider = eventdata.slider;
4340			if(slider){
4341				// add classes .curent & .shown to slide
4342				slider.find('.item').removeClass('current');
4343				var curSlide = slider.find('.item.flex-active-slide');
4344				var curSlideIndex = curSlide.attr('data-slide_index');
4345
4346				curSlide.addClass('current');
4347				slider.find('.item[data-slide_index=' + curSlideIndex + ']').addClass('shown');
4348				slider.resize();
4349				
4350				if(typeof(curSlideIndex) !== 'undefined' && curSlideIndex.length){
4351					// set main banners text vertical center
4352					CheckMainBannerSliderVText(slider);
4353
4354					if($('.item.vvideo'))
4355					{
4356						$('.item.vvideo .maxwidth-theme').removeClass('loading');
4357						$('.item.vvideo .maxwidth-theme .btn-video').removeClass('loading');
4358						$('.item.vvideo[data-video_autoplay=1] .maxwidth-theme').addClass('loading');
4359						$('.item.vvideo[data-video_autoplay=1] .maxwidth-theme .btn-video').addClass('loading');
4360					}
4361
4362					// pause play video
4363					if(typeof(players) !== 'undefined' && players){
4364						for(var j in players){
4365							if(players[j].playing && !players[j].clone && (players[j].slideIndex != curSlideIndex)){
4366								if((typeof window[players[j].id] == 'object')){
4367									if(players[j].videoPlayer === 'YOUTUBE'){
4368										window[players[j].id].pauseVideo()
4369									}
4370									else if(players[j].videoPlayer === 'VIMEO'){
4371										window[players[j].id].pause()
4372									}
4373									else if(players[j].videoPlayer === 'RUTUBE'){
4374										document.getElementById(players[j].id).contentWindow.postMessage(JSON.stringify({
4375										    type: 'player:pause',
4376										    data: {}
4377										}), '*')
4378									}
4379									else if(players[j].videoPlayer === 'HTML5'){
4380										document.getElementById(players[j].id).pause()
4381									}
4382								}
4383							}
4384						}
4385					}
4386					// autoplay video
4387					var bVideoAutoPlay = curSlide.attr('data-video_autoplay') == 1
4388					if(bVideoAutoPlay){
4389						startMainBannerSlideVideo(curSlide)
4390					}
4391				}
4392				else
4393				{
4394					slider.find('.item').css('opacity', '1');
4395				}
4396				if(slider.closest('.blocks').length)
4397					slider.closest('.blocks').find('.flex-direction-nav li').addClass('initied');
4398
4399				if(slider.closest('.wraps').length)
4400					slider.closest('.wraps').find('.flex-direction-nav li').addClass('initied');
4401				
4402				if(!slider.find('.flex-control-nav li').length && slider.hasClass('normal'))
4403				{
4404					slider.find('.flex-direction-nav li a').addClass('flex-disabled');
4405				}
4406
4407				if(slider.closest('.banners-big').length)
4408				{
4409					// var curSlide = slider.find('.item.flex-active-slide');
4410					//logo src
4411					var bLogoImg = $('header .logo-block .logo img').length;
4412					if(bLogoImg)
4413						$('header .logo-block .logo img').attr('src', arHeatOptions.THEME.LOGO_IMAGE)
4414					
4415					//nav flex color
4416					slider.find('.flex-control-nav li').removeClass();
4417					
4418					//header color
4419					$('header').removeClass('light dark');
4420					if(typeof(curSlide.data('color')) != 'undefined')
4421					{
4422						slider.find('.flex-control-nav li').addClass(curSlide.data('color'));
4423						$('header').addClass(curSlide.data('color'));
4424						if(bLogoImg)
4425						{
4426							if(arHeatOptions.THEME.LOGO_IMAGE_LIGHT && curSlide.data('color') == 'light')
4427								$('header .logo-block .logo img').attr('src', arHeatOptions.THEME.LOGO_IMAGE_LIGHT)
4428						}
4429					}
4430				}
4431
4432				if(!slider.hasClass('flexslider-init-slice') && slider.hasClass('nav-title') && $('.gallery-block').closest('.tab-pane').hasClass('active'))
4433				{
4434					slider.find('.item').sliceHeight({'lineheight': -3});
4435					slider.addClass('flexslider-init-slice');
4436				}
4437				
4438				if(slider.find('.flex-direction-nav').length){
4439					if(slider.find('.flex-direction-nav').find('a.flex-disabled').length)
4440						slider.find('.flex-direction-nav').removeClass('opacity1').addClass('opacity0');
4441					else
4442						slider.find('.flex-direction-nav').removeClass('opacity0').addClass('opacity1');
4443				}
4444			}
4445		}
4446	}
4447	catch(e){}
4448	finally{
4449		ignoreResize.pop();
4450	}
4451});
4452
4453BX.addCustomEvent('onSlideBefore', function(eventdata) {
4454	try
4455	{
4456		ignoreResize.push(true);
4457		if(eventdata)
4458		{
4459			var slider = eventdata.slider;
4460			if(slider)
4461			{
4462				if(slider.closest('.banners-big').length)
4463				{
4464					setTimeout(function(){
4465						var curSlide = slider.find('.item.flex-active-slide');
4466						//logo src
4467						var bLogoImg = $('header .logo-block .logo img').length;
4468						if(bLogoImg)
4469							$('header .logo-block .logo img').attr('src', arHeatOptions.THEME.LOGO_IMAGE)
4470						
4471						//nav flex color
4472						slider.find('.flex-control-nav li').removeClass();
4473						
4474						//header color
4475						$('header').removeClass('light dark');
4476						if(typeof(curSlide.data('color')) != 'undefined')
4477						{
4478							slider.find('.flex-control-nav li').addClass(curSlide.data('color'));
4479							$('header').addClass(curSlide.data('color'));
4480							if(bLogoImg)
4481							{
4482								if(arHeatOptions.THEME.LOGO_IMAGE_LIGHT && curSlide.data('color') == 'light')
4483									$('header .logo-block .logo img').attr('src', arHeatOptions.THEME.LOGO_IMAGE_LIGHT)
4484							}
4485						}
4486					}, 100)
4487				}
4488				else if(slider.hasClass('top-bigs'))
4489				{
4490					setTimeout(function(){
4491						var index = slider.find('.item.flex-active-slide').data('slide_key');
4492						$('.bxSlider.top-small .slides').data('bxSlider').goToSlide(index);
4493						$('.bxSlider.top-small .slides li').removeClass('flex-active-slide');
4494						$('.bxSlider.top-small .slides li[data-slide_key="'+index+'"]').addClass('flex-active-slide');
4495					}, 100)
4496				}
4497			}
4498		}
4499	}
4500	catch(e){}
4501	finally{
4502		ignoreResize.pop();
4503	}
4504});
4505
4506BX.addCustomEvent('onSlideEnd', function(eventdata) {
4507	try
4508	{
4509		ignoreResize.push(true);
4510		if(eventdata)
4511		{
4512			var slider = eventdata.slider;
4513			if(slider)
4514			{
4515				
4516			}
4517		}
4518	}
4519	catch(e){}
4520	finally{
4521		ignoreResize.pop();
4522	}
4523});
4524
4525$(window).resize(function(){
4526	CheckTopMenuPadding();
4527	CheckTopMenuOncePadding();
4528	CheckSearchWidth();
4529});
4530
4531var onCaptchaVerifyinvisible = function(response){
4532	$('.g-recaptcha:last').each(function(){
4533		var id = $(this).attr('data-widgetid');
4534		if(typeof(id) !== 'undefined' && response){
4535			if(!$(this).closest('form').find('.g-recaptcha-response').val())
4536				$(this).closest('form').find('.g-recaptcha-response').val(response)
4537			if($('iframe[src*=recaptcha]').length)
4538			{
4539				$('iframe[src*=recaptcha]').each(function(){
4540					var block = $(this).parent().parent();
4541					if(!block.hasClass('grecaptcha-badge'))
4542						block.css('width', '100%');
4543				})
4544			}
4545			if($(this).closest('form').attr('name') == 'form_comment')
4546				BX.submit(BX('form_comment'));
4547			else
4548				$(this).closest('form').submit();
4549		}
4550	})
4551}
4552
4553var onCaptchaVerifynormal = function(response){
4554	$('.g-recaptcha').each(function(){
4555		var id = $(this).attr('data-widgetid');
4556		if(typeof(id) !== 'undefined'){
4557			if(grecaptcha.getResponse(id) != ''){
4558				$(this).closest('form').find('.recaptcha').valid();
4559			}
4560		}
4561	});
4562}
4563
4564BX.addCustomEvent('onSubmitForm', function(eventdata){
4565	try{
4566		if(!window.renderRecaptchaById || !window.centinoRecaptcha || !window.centinoRecaptcha.key)
4567		{
4568			eventdata.form.submit();
4569			$(eventdata.form).closest('.form').addClass('sending');
4570			return true;
4571		}
4572		if(window.centinoRecaptcha.params.recaptchaSize == 'invisible' && typeof grecaptcha != 'undefined')
4573		{
4574			if($(eventdata.form).find('.g-recaptcha-response').val())
4575			{
4576				eventdata.form.submit();
4577				$(eventdata.form).closest('.form').addClass('sending');
4578			}
4579			else
4580			{
4581				grecaptcha.execute($(eventdata.form).find('.g-recaptcha').data('widgetid'));
4582				return false;
4583			}
4584		}
4585		else
4586		{
4587			eventdata.form.submit();
4588			$(eventdata.form).closest('.form').addClass('sending');
4589		}
4590
4591		return true;
4592	}catch (e){
4593		console.error(e);
4594		return true;
4595	}
4596});

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.