PageSourceSearch

https://clinica-integra.com/bitrix/templates/aspro-medc2/js/general.js

js clinica-integra.com collected 2026-10-08 10:24:45 UTC 105,607 bytes, 3,544 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
13CheckBodyPadding = function(){
14	if($('body').hasClass('with_banner')){
15		var bannerHeight = $('.banner_warning').outerHeight(true, true);
16		$('body.with_banner').css('padding-bottom', bannerHeight);
17	}
18}
19
20$(document).on('change', '.uploader input[type=file]', function(){
21    if(!$(this).next().length || !$(this).next().hasClass('resetfile')){
22        $('<span class="resetfile"><svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 11 11"><path d="M1345.19,376.484l4.66,4.659a0.492,0.492,0,0,1,0,.707,0.5,0.5,0,0,1-.71,0l-4.66-4.659-4.65,4.659a0.5,0.5,0,0,1-.71,0,0.492,0.492,0,0,1,0-.707l4.66-4.659-4.66-4.659a0.492,0.492,0,0,1,0-.707,0.5,0.5,0,0,1,.71,0l4.65,4.659,4.66-4.659a0.5,0.5,0,0,1,.71,0,0.492,0.492,0,0,1,0,.707Z" transform="translate(-1339 -371)"/></svg></span>').insertAfter($(this));
23    }
24});
25
26$(document).on('click', '.uploader input[type=file] + .resetfile', function(){
27    var $input = $(this).prev();
28    $input.val('');
29    $.uniform.update($input);
30    $(this).remove();
31});
32
33CheckTopMenuDotted = function(){
34	if(window.matchMedia('(max-width:991px)').matches)
35		return;
36
37	var menu = $('nav.mega-menu.sliced');
38
39	if(menu.length)
40	{
41		menu.each(function(){
42			var menuMoreItem = $(this).find('td.js-dropdown');
43			if($(this).parents('.collapse').css('display') == 'none'){
44				return false;
45			}
46
47			var block_w = $(this).closest('div').actual('width');
48			var	menu_w = $(this).find('table').actual('outerWidth');
49			var afterHide = false;
50
51			while(menu_w > block_w) {
52				menuItemOldSave = $(this).find('td').not('.nosave').last();
53				if(menuItemOldSave.length){
54					menuMoreItem.show();
55					menuItemNewSave = '<li class="' + (menuItemOldSave.hasClass('dropdown') ? 'dropdown-submenu ' : '') + (menuItemOldSave.hasClass('active') ? 'active ' : '') + '" data-hidewidth="' + menu_w + '">' + menuItemOldSave.find('.wrap').html() + '</li>';
56					menuItemOldSave.remove();
57					menuMoreItem.find('> .wrap > .dropdown-menu').prepend(menuItemNewSave);
58					menu_w = $(this).find('table').actual('width');
59					afterHide = true;
60				}
61				else{
62					break;
63				}
64			}
65
66			if(!afterHide) {
67				do {
68					var menuItemOldSaveCnt = menuMoreItem.find('.dropdown-menu').find('li').length;
69					menuItemOldSave = menuMoreItem.find('.dropdown-menu').find('li').first();
70					if(!menuItemOldSave.length) {
71						menuMoreItem.hide();
72						break;
73					}
74					else {
75						var hideWidth = menuItemOldSave.attr('data-hidewidth');
76						if(hideWidth > block_w) {
77							break
78						}
79						else {
80							menuItemNewSave = '<td class="' + (menuItemOldSave.hasClass('dropdown-submenu') ? 'dropdown ' : '') + (menuItemOldSave.hasClass('active') ? 'active ' : '') + '" data-hidewidth="' + block_w + '"><div class="wrap">' + menuItemOldSave.html() + '</div></td>';
81							menuItemOldSave.remove();
82							$(menuItemNewSave).insertBefore($(this).find('td.js-dropdown'));
83							if(!menuItemOldSaveCnt) {
84								menuMoreItem.hide();
85								break;
86							}
87						}
88					}
89					menu_w = $(this).find('table').actual('width');
90				}
91				while(menu_w <= block_w);
92			}
93			$(this).find('td').css('visibility', 'visible');
94			$(this).find('td').removeClass('unvisible');
95			$(this).css('overflow', 'visible');
96
97			markerNav();
98		}).promise().done(function(){
99			$('.menu-row.bgcolored .mega-menu .table-menu').css('overflow', 'visible');
100		});
101	}
102	return false;
103}
104
105CheckTopVisibleMenu = function(that) {
106	var dropdownMenu = $('.dropdown-menu:visible').last();
107
108	if(dropdownMenu.length){
109		dropdownMenu.find('a').css('white-space', '');
110		dropdownMenu.css('left', '');
111		dropdownMenu.css('right', '');
112		dropdownMenu.removeClass('toright');
113
114		var dropdownMenu_left = dropdownMenu.offset().left;
115		if(typeof(dropdownMenu_left) != 'undefined'){
116			var menu = dropdownMenu.parents('.mega-menu');
117			if(!menu.length)
118				menu = dropdownMenu.closest('.logo-row');
119			var menu_width = menu.outerWidth();
120			var menu_left = menu.offset().left;
121			var menu_right = menu_left + menu_width;
122			var isToRight = dropdownMenu.parents('.toright').length > 0;
123			var parentsDropdownMenus = dropdownMenu.parents('.dropdown-menu');
124			var isHasParentDropdownMenu = parentsDropdownMenus.length > 0;
125			if(isHasParentDropdownMenu){
126				var parentDropdownMenu_width = parentsDropdownMenus.first().outerWidth();
127				var parentDropdownMenu_left = parentsDropdownMenus.first().offset().left;
128				var parentDropdownMenu_right = parentDropdownMenu_width + parentDropdownMenu_left;
129			}
130
131			if(parentDropdownMenu_right + dropdownMenu.outerWidth() > menu_right){
132				dropdownMenu.find('a').css('white-space', 'normal');
133			}
134
135			var dropdownMenu_width = dropdownMenu.outerWidth();
136			var dropdownMenu_right = dropdownMenu_left + dropdownMenu_width;
137
138			if(dropdownMenu_right > menu_right || isToRight){
139				var addleft = 0;
140				addleft = menu_right - dropdownMenu_right;
141				if(isHasParentDropdownMenu || isToRight){
142					dropdownMenu.css('left', 'auto');
143					dropdownMenu.css('right', '100%');
144					dropdownMenu.addClass('toright');
145				}
146				else{
147					var dropdownMenu_curLeft = parseInt(dropdownMenu.css('left'));
148					dropdownMenu.css('left', (dropdownMenu_curLeft + addleft) + 'px');
149				}
150			}
151		}
152	}
153}
154
155InitTopestMenuGummi = function(){
156	//if(!isOnceInited){
157		function _init(){
158			var arItems = $menuTopest.find('>div:not(.more)');
159			var cntItems = arItems.length;
160			if(cntItems){
161				var itemsWidth = 0;
162				for(var i = 0; i < cntItems; ++i){
163					var item = arItems.eq(i);
164					var itemWidth = item.actual('outerWidth',{includeMargin: true});
165					arItemsHideWidth[i] = (itemsWidth += itemWidth) + (i !== (cntItems - 1) ? moreWidth : 0);
166				}
167			}
168		}
169
170		function _gummi(){
171			var rowWidth = $menuTopest.actual('innerWidth');
172			var arItems = $menuTopest.find('>div:not(.more),.more>.dropdown>.wrap>div');
173			var cntItems = arItems.length;
174			if(cntItems){
175				var bMore = false;
176				for(var i = cntItems - 1; i >= 0; --i){
177					var item = arItems.eq(i);
178					var bInMore = item.parents('.more').length > 0;
179					if(!bInMore){
180						if(arItemsHideWidth[i] > rowWidth){
181							if(!bMore){
182								bMore = true;
183								more.removeClass('hidden');
184							}
185							var clone = item.clone();
186							clone.prependTo(moreDropdown);
187							item.addClass('cloned');
188						}
189					}
190				}
191				for(var i = 0; i < cntItems; ++i){
192					var item = arItems.eq(i);
193					var bInMore = item.parents('.more').length > 0;
194					if(bInMore){
195						if(arItemsHideWidth[i] <= rowWidth){
196							if(i === (cntItems - 1)){
197								bMore = false;
198								more.addClass('hidden');
199							}
200							var clone = item.clone();
201							clone.find('>a').removeClass('dark_font');
202							clone.insertBefore(more);
203							item.addClass('cloned');
204						}
205					}
206				}
207				$menuTopest.find('div.cloned').remove();
208			}
209		}
210
211		var $menuTopest = $('.menu.topest');
212		var more = $menuTopest.find('>.more');
213		var moreDropdown = more.find('>.dropdown>.wrap');
214		var moreWidth = more.actual('outerWidth',{includeMargin: true});
215		var arItemsHideWidth = [];
216
217		ignoreResize.push(true);
218		_init();
219		_gummi();
220		ignoreResize.pop();
221
222		$(window).resize(function(){
223			ignoreResize.push(true);
224			_gummi();
225			ignoreResize.pop();
226		});
227	//}
228}
229
230MegaMenuFixed = function(){
231	var animationTime = 150;
232
233	$('.burger').on('click', function(){
234		$('.mega_fixed_menu').fadeIn(animationTime);
235	});
236
237	$('.mega_fixed_menu .svg.svg-close').on('click', function(){
238		$(this).closest('.mega_fixed_menu').fadeOut(animationTime);
239	});
240
241	$('.mega_fixed_menu .dropdown-menu .arrow').on('click', function(e){
242		e.preventDefault();
243		e.stopPropagation();
244		$(this).closest('.dropdown-submenu').find('.dropdown-menu').slideToggle(animationTime);
245		$(this).closest('.dropdown-submenu').toggleClass('opened');
246	});
247}
248
249CheckPopupTop = function(){
250	var popup = $('.jqmWindow.show');
251	if(popup.length){
252		var documentScollTop = $(document).scrollTop();
253		var windowHeight = $(window).height();
254		var popupTop = parseInt(popup.css('top'));
255		var popupHeight = popup.height();
256
257		if(windowHeight >= popupHeight){
258			// center
259			popupTop = (windowHeight - popupHeight) / 2;
260		}
261		else{
262			if(documentScollTop > documentScrollTopLast){
263				// up
264				popupTop -= documentScollTop - documentScrollTopLast;
265			}
266			else if(documentScollTop < documentScrollTopLast){
267				// down
268				popupTop += documentScrollTopLast - documentScollTop;
269			}
270
271			if(popupTop + popupHeight < windowHeight){
272				// bottom
273				popupTop = windowHeight - popupHeight;
274			}
275			else if(popupTop > 0){
276				// top
277				popupTop = 0;
278			}
279		}
280		popup.css('top', popupTop + 'px');
281	}
282}
283
284CheckMainBannerSliderVText = function(slider){
285	if(slider.parents('.banners-big').length){
286		var sh = slider.height();
287		slider.parents('.banners-big').find('.item').each(function() {
288			var curSlideTextInner = $(this).find('.text .inner');
289			if(curSlideTextInner.length){
290				var ith = curSlideTextInner.actual('height');
291				var p = (ith >= sh ? 0 : Math.floor((sh - ith) / 2));
292				curSlideTextInner.css('padding-top', p + 'px');
293			}
294		});
295	}
296}
297
298CheckStickyFooter = function() {
299	BX.addCustomEvent('onWindowResize', function(eventdata){
300		if(!isMobile)
301		{
302			try{
303				/*var footerHeight = $('footer').outerHeight();
304				ignoreResize.push(true);
305				$('footer').css('margin-top', '-' + footerHeight + 'px');
306				$('.body').css('margin-bottom', '-' + footerHeight + 'px');
307				$('.main').css('padding-bottom', footerHeight + 0 + 'px');*/
308				var bodyHeight = $('.body').outerHeight(true, true),
309					footeHeight = $('footer').outerHeight(true, true),
310					headerHeight = $('header').outerHeight(true, true),
311					topHeaderHeight = ($('.top-block').length ? $('.top-block').outerHeight(true, true) : 0),
312					panelHeight = ($('#panel').length ? $('#panel').outerHeight(true, true) : 0),
313					windowHeight = $(window).height(),
314					minBodyHeight = windowHeight - footeHeight - panelHeight - headerHeight - topHeaderHeight;
315
316				$('.body').css('min-height', minBodyHeight);
317				ignoreResize.pop();
318			}
319			catch(e){}
320		}
321	});
322}
323
324verticalAlign = function(class_name){
325	if(typeof class_name == "undefined")
326		class_name = 'auto_align';
327    if($('.'+class_name).length)
328    {
329	    maxHeight = 0;
330	    $('.'+class_name).each(function(){
331	        if ($(this).height()> maxHeight){
332	            maxHeight = $(this).height();
333	        };
334	    });
335	    $('.'+class_name).each(function(){
336
337	            delta = Math.round((maxHeight - $(this).height())/2);
338	            $(this).css({'padding-top': delta+'px', 'padding-bottom': delta+'px'});
339	    });
340	}
341}
342
343getGridSize = function(counts, custom_counts) {
344	var z = parseInt($('.body_media').css('top'));
345	if(typeof(custom_counts) != 'undefined')
346	{
347		if(window.matchMedia('(max-width: 700px)').matches)
348			return (counts[3] ? counts[3] : counts[2]);
349		else if(window.matchMedia('(max-width: 767px)').matches)
350			return counts[2];
351		else if(window.matchMedia('(max-width: 1100px)').matches)
352			return counts[1];
353		else
354			return counts[0];
355	}
356	else
357	{
358		if(window.matchMedia('(max-width: 600px)').matches)
359		{
360			return (counts[3] ? counts[3] : counts[2]);
361		}
362		else
363			return (z == 2 ? counts[0] : z == 1 ? counts[1] : counts[2]);
364	}
365}
366
367CheckFlexSlider = function(){
368	$('.flexslider:not(.thmb):visible').each(function(){
369		var slider = $(this);
370		slider.resize();
371		var counts = slider.data('flexslider').vars.counts,
372			slide_counts = slider.data('flexslider').vars.slide_counts;
373		if(typeof(counts) != 'undefined'){
374			var cnt = getGridSize(counts, slider.data('flexslider').vars.customGrid);
375			var to0 = (cnt != slider.data('flexslider').vars.minItems || cnt != slider.data('flexslider').vars.maxItems || cnt != slider.data('flexslider').vars.move);
376			if(to0){
377				slider.data('flexslider').vars.minItems = cnt;
378				slider.data('flexslider').vars.maxItems = cnt;
379				if(typeof(slide_counts) != 'undefined')
380					slider.data('flexslider').vars.move = slide_counts;
381				else
382					slider.data('flexslider').vars.move = cnt;
383
384				slider.flexslider(0);
385				slider.resize();
386				slider.resize(); // twise!
387			}
388		}
389	});
390}
391
392CheckHeaderFixed = function(){
393	var header_fixed = $('#headerfixed');
394		header = $('header').first();
395	if(header_fixed.length){
396		if(header.length)
397		{
398			var isHeaderFixed = false,
399				headerCanFix = true,
400				headerFixedHeight = header_fixed.actual('outerHeight'),
401				headerNormalHeight = header.actual('outerHeight'),
402				headerDiffHeight = headerNormalHeight - headerFixedHeight,
403				mobileBtnMenu = $('.btn.btn-responsive-nav'),
404				headerTop = $('#panel:visible').actual('outerHeight');
405				topBlock = $('.TOP_HEADER').first();
406
407			if(headerDiffHeight <= 0)
408				headerDiffHeight = 0;
409			if(topBlock.length)
410				headerTop += topBlock.actual('outerHeight');
411
412			$(window).scroll(function(){
413				if(!isMobile)
414				{
415					var scrollTop = $(window).scrollTop();
416					headerCanFix = !mobileBtnMenu.is(':visible')/* && !$('.dropdown-menu:visible').length*/;
417
418					var current_is = $('.search-wrapper .search-input:visible'),
419						title_search_result = $('.title-search-result.'+current_is.attr('id')),
420						pos, pos_input;
421
422					if(!isHeaderFixed)
423					{
424						if((scrollTop > headerNormalHeight + headerTop) && headerCanFix)
425						{
426							isHeaderFixed = true;
427							header_fixed.css('top', '-' + headerNormalHeight + 'px');
428							header_fixed.addClass('fixed');
429							// header_fixed.stop(0).animate({top: '0'}, 300);
430
431							header_fixed.animate({top: '0'}, {duration:300, complete:
432								function(){}
433							});
434							markerNav();
435							CheckTopMenuDotted();
436						}
437					}
438					else if(isHeaderFixed || !headerCanFix)
439					{
440						if((scrollTop <= headerDiffHeight + headerTop) || !headerCanFix)
441						{
442							isHeaderFixed = false;
443							header_fixed.removeClass('fixed');
444						}
445					}
446				}
447			});
448		}
449	}
450}
451
452CheckObjectsSizes = function() {
453	$('.container iframe,.container object,.container video').each(function() {
454		var height_attr = $(this).attr('height');
455		var width_attr = $(this).attr('width');
456		if (height_attr && width_attr) {
457			$(this).css('height', $(this).outerWidth() * height_attr / width_attr);
458		}
459	});
460}
461
462scrollToTop = function(){
463	if(arMedc2Options['THEME']['SCROLLTOTOP_TYPE'] !== 'NONE'){
464		var _isScrolling = false;
465		// Append Button
466		$('body').append($('<a />').addClass('scroll-to-top ' + arMedc2Options['THEME']['SCROLLTOTOP_TYPE'] + ' ' + arMedc2Options['THEME']['SCROLLTOTOP_POSITION']).attr({'href': '#', 'id': 'scrollToTop'}));
467		$('#scrollToTop').click(function(e){
468			e.preventDefault();
469			$('body, html').animate({scrollTop : 0}, 500);
470			return false;
471		});
472		// Show/Hide Button on Window Scroll event.
473		$(window).scroll(function(){
474			if(!_isScrolling) {
475				_isScrolling = true;
476				var bottom = 23,
477					scrollVal = $(window).scrollTop(),
478					windowHeight = $(window).height();
479
480				var footerOffset = 0;
481				if ($('footer').get(0)) {
482					footerOffset = $('footer').offset().top;
483				}
484				if(scrollVal > 150){
485					$('#scrollToTop').stop(true, true).addClass('visible');
486					_isScrolling = false;
487				}
488				else{
489					$('#scrollToTop').stop(true, true).removeClass('visible');
490					_isScrolling = false;
491				}
492				CheckScrollToTop();
493			}
494		});
495	}
496}
497
498CheckScrollToTop = function(){
499	var bottom = 23,
500		scrollVal = $(window).scrollTop(),
501		windowHeight = $(window).height();
502	if($('footer').length)
503		var footerOffset = $('footer').offset().top;
504
505	if(scrollVal + windowHeight > footerOffset){
506		$('#scrollToTop').css('bottom', bottom + scrollVal + windowHeight - footerOffset);
507	}
508	else if(parseInt($('#scrollToTop').css('bottom')) > bottom){
509		$('#scrollToTop').css('bottom', bottom);
510	}
511}
512
513var isMobile = jQuery.browser.mobile;
514var players = {};
515
516if(isMobile){
517	document.documentElement.className += ' mobile';
518}
519
520function startMainBannerSlideVideo($slide){
521	if($('.banners-big').length)
522	{
523		if(typeof(CoverPlayer) === 'undefined'){
524			CoverPlayer = function(){
525				var $videoCover = $('.video.cover');
526				if($videoCover.length){
527					var bannersHeight = $('.banners-big').height()
528					var bannersWidth = $('.banners-big').width()
529					var windowWidth = $(window).width()
530					var height = windowWidth * 9 / 16
531
532					$videoCover.each(function(i, node){
533						node.style.height = height + 'px'
534						node.style.marginTop = ((bannersHeight - height) / 2) + 'px'
535					})
536				}
537			}
538			$(window).resize(function() {
539				if($('.video.cover').length){
540					CoverPlayer();
541				}
542			});
543		}
544
545		var slideActiveIndex = $slide.attr('data-slide_index')
546		var $slides = $slide.closest('.items').find('.item[data-slide_index="'+ slideActiveIndex +'"]')
547		var videoSource = $slide.attr('data-video_source')
548
549		if(videoSource){
550			var videoPlayerSrc = $slide.attr('data-video_src')
551			var videoSoundDisabled = $slide.attr('data-video_disable_sound')
552			var bVideoSoundDisabled = videoSoundDisabled == 1
553			var videoLoop = $slide.attr('data-video_loop')
554			var bVideoLoop = videoLoop == 1
555			var videoCover = $slide.attr('data-video_cover')
556			var bVideoCover = videoCover == 1 && !isMobile
557			var videoUnderText = $slide.attr('data-video_under_text')
558			var bVideoUnderText = videoUnderText == 1
559			if(videoSource === 'LINK'){
560				var videoPlayer = $slide.attr('data-video_player')
561				var bVideoPlayerYoutube = videoPlayer === 'YOUTUBE'
562				var bVideoPlayerVimeo = videoPlayer === 'VIMEO'
563
564				if(videoPlayerSrc && !$slide.find('iframe.video').length){
565					$slides.each(function(i, node){
566						var $_slide = $(node);
567						var videoID = getRandomInt(100, 1000);
568						if(bVideoPlayerVimeo){
569							videoPlayerSrc += '&player_id=vimeoplayer';
570						}
571						pauseMainBanner();
572						$_slide.prepend('<iframe id="player_' + videoID + '" class="video' + (bVideoCover == true ? ' cover' : '') + '" src="'+ videoPlayerSrc +'" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>');
573						if(typeof(players) !== 'undefined' && players){
574							players[videoID] = {id: 'player_' + videoID, mute: (bVideoSoundDisabled ? '1' : '0'), loop: (bVideoLoop ? '1' : '0'), cover: (bVideoCover ? '1' : '0')};
575							if(bVideoPlayerYoutube){
576								waitYTPlayer(150, function(){
577								//setTimeout(function(){
578									window[players[videoID].id] = new YT.Player(
579										players[videoID].id, {
580											events: {
581												'onReady': onYoutubePlayerReady
582											}
583										}
584									);
585									if(bVideoSoundDisabled){
586										window[players[videoID].id].addEventListener('onReady', muteYoutubePlayer);
587									}
588									if(bVideoLoop){
589										window[players[videoID].id].addEventListener('onStateChange', loopYoutubePlayer);
590									}
591								//},150);
592								});
593							}
594							else if(bVideoPlayerVimeo){
595								var iframe = $('#'+players[videoID].id)
596								if(iframe.length){
597									setTimeout(function(){
598										iframe.closest('.item').addClass('started')
599										pauseMainBanner()
600									},150)
601									var player = iframe[0].childNodes
602									// console.log(iframe, player)
603									/*player.addEvent('play', function() {
604										console.log('play')
605									});*/
606								}
607							}
608						}
609					});
610				}
611			}
612			if(videoPlayerSrc && !$slide.find('.video').length){
613				$slides.each(function(i, node){
614					var $_slide = $(node);
615					var videoID = getRandomInt(100, 1000);
616					$_slide.prepend('<video id="player_' + videoID + '" class="video' + (bVideoCover == true ? ' cover' : '') + '"' + (bVideoLoop == true ? ' loop ' : '') + (bVideoSoundDisabled == true ? ' muted ' : '') + ' autoplay><source src="'+ videoPlayerSrc +'" type=\'video/mp4; codecs="avc1.42E01E, mp4a.40.2"\' /><p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video</p></iframe>');
617					if(typeof(players) !== 'undefined' && players){
618						players[videoID] = {id: 'player_' + videoID, mute: (bVideoSoundDisabled ? '1' : '0'), loop: (bVideoLoop ? '1' : '0'), cover: (bVideoCover ? '1' : '0')};
619						// if(bVideoCover){
620							document.getElementById(players[videoID].id).addEventListener('play', onHtml5PlayerPlay);
621						// }
622					}
623				});
624			}
625		}
626	}
627}
628
629function muteYoutubePlayer(e) {
630	e.target.mute()
631}
632
633function loopYoutubePlayer(e) {
634	if(e.data === YT.PlayerState.ENDED){
635		e.target.playVideo()
636	}
637}
638
639function onYoutubePlayerReady(e) {
640    e.target.playVideo()
641    var videoID = e.target.a.id.replace('player_', '')
642    if(videoID){
643    	var $slide = $('#player_' + videoID).closest('.item')
644    	$slide.addClass('started')
645    	pauseMainBanner()
646    	//setMainBannerSlideVerticalCenter($slide)
647		var cover = players[videoID].cover
648		if(cover){
649	    	CoverPlayer()
650	    }
651    }
652}
653
654function onHtml5PlayerPlay(e){
655    var videoID = e.target.id.replace('player_', '')
656    if(videoID){
657    	var $slide = $('#player_' + videoID).closest('.item')
658    	$slide.addClass('started')
659    	pauseMainBanner()
660    	// setMainBannerSlideVerticalCenter($slide)
661		var cover = players[videoID].cover
662		if(cover){
663	    	CoverPlayer()
664	    }
665    }
666}
667
668function pauseMainBanner(){
669	$('.banners-big .flexslider').flexslider('pause');
670}
671
672$.fn.equalizeHeights = function( outer, classNull, minHeight ){
673	var maxHeight = this.map( function( i, e ){
674		var minus_height=0,
675			calc_height=0;
676		if(classNull!==false){
677			minus_height=parseInt($(e).find(classNull).actual('outerHeight'));
678		}
679		if(minus_height)
680			minus_height+=12;
681
682		$(e).css('height', '');
683		if( outer == true ){
684			calc_height=$(e).actual('outerHeight')-minus_height;
685		}else{
686			calc_height=$(e).actual('height')-minus_height;
687		}
688		if(minHeight!==false){
689			if(calc_height<minHeight){
690				calc_height+=(minHeight-calc_height);
691			}
692			if(window.matchMedia('(max-width: 520px)').matches){
693				calc_height=300;
694			}
695			if(window.matchMedia('(max-width: 400px)').matches){
696				calc_height=200;
697			}
698		}
699		return calc_height;
700	}).get();
701
702	for(var i = 0, c = maxHeight.length; i < c; ++i){
703		if(maxHeight[i] % 2){
704			--maxHeight[i];
705		}
706	}
707
708	return this.height( Math.max.apply( this, maxHeight ) );
709}
710
711$.fn.getFloatWidth = function(){
712	var width = 0
713
714	if($(this).length){
715		var rect = $(this)[0].getBoundingClientRect()
716		if(!(width = rect.width)){
717			width = rect.right - rect.left
718		}
719	}
720
721	return width
722}
723
724$.fn.sliceHeight = function( options ){
725	function _slice(el){
726		el.each(function() {
727			$(this).css('line-height', '');
728			$(this).css('height', '');
729
730		});
731		if(typeof(options.autoslicecount) == 'undefined' || options.autoslicecount !== false){
732			var elsw=(typeof(options.row) !== 'undefined' && options.row.length) ?  el.first().parents(options.row).getFloatWidth() : el.first().parents('.items').getFloatWidth(),
733				elw=(typeof(options.item) !== 'undefined' && options.item.length) ? $(options.item).first().getFloatWidth() : (el.first().hasClass('item') ? el.first().getFloatWidth() : el.first().parents('.item').getFloatWidth());
734
735			if(!elsw){
736				elsw = el.first().parents('.row').getFloatWidth();
737			}
738			if(elw && options.fixWidth)
739				elw -= options.fixWidth;
740
741			if(elsw && elw){
742				options.slice = Math.floor(elsw / elw);
743			}
744		}
745		if(typeof(options.typeResize) == 'undefined' || options.typeResize == false)
746		{
747			if(options.slice){
748				for(var i = 0; i < el.length; i += options.slice){
749					$(el.slice(i, i + options.slice)).equalizeHeights(options.outer, options.classNull, options.minHeight, options.typeResize, options.typeValue);
750				}
751			}
752			if(options.lineheight){
753				var lineheightAdd = parseInt(options.lineheight);
754				if(isNaN(lineheightAdd)){
755					lineheightAdd = 0;
756				}
757				el.each(function() {
758					$(this).css('line-height', ($(this).actual('height') + lineheightAdd) + 'px');
759				});
760			}
761		}
762	}
763	var options = $.extend({
764		slice: null,
765		outer: false,
766		lineheight: false,
767		autoslicecount: true,
768		classNull: false,
769		minHeight: false,
770		row:false,
771		item:false,
772		typeResize:false,
773		typeValue:false,
774		fixWidth:0,
775	}, options);
776
777	var el = $(this);
778	ignoreResize.push(true);
779	_slice(el);
780	ignoreResize.pop();
781
782	BX.addCustomEvent('onWindowResize', function(eventdata) {
783		ignoreResize.push(true);
784		_slice(el);
785		ignoreResize.pop();
786	});
787}
788
789waitingExists = function(selector, delay, callback){
790	if(typeof(callback) !== 'undefined' && selector.length && delay > 0){
791		delay = parseInt(delay);
792		delay = (delay < 0 ? 0 : delay);
793
794		if(!$(selector).length){
795			setTimeout(function(){
796				waitingExists(selector, delay, callback);
797			}, delay);
798		}
799		else{
800			callback();
801		}
802	}
803}
804
805waitingNotExists = function(selectorExists, selectorNotExists, delay, callback){
806	if(typeof(callback) !== 'undefined' && selectorExists.length && selectorNotExists.length && delay > 0){
807		delay = parseInt(delay);
808		delay = (delay < 0 ? 0 : delay);
809
810		setTimeout(function(){
811			if(selectorExists.length && !$(selectorNotExists).length){
812				callback();
813			}
814		}, delay);
815	}
816}
817
818function onLoadjqm(hash){
819	var name = $(hash.t).data('name'),
820		top = (($(window).height() > hash.w.height()) ? Math.floor(($(window).height() - hash.w.height()) / 2) : 0) + 'px';
821
822	if($('.popup textarea').length){
823		$('textarea').each(function(){
824			$(this).autoResize();
825		});
826	}
827
828	$.each($(hash.t).get(0).attributes, function(index, attr){
829		if(/^data\-autoload\-(.+)$/.test(attr.nodeName)){
830			var key = attr.nodeName.match(/^data\-autoload\-(.+)$/)[1];
831			var el = ($('[name="'+key.toUpperCase()+'"]').length ? $('[name="'+key.toUpperCase()+'"]') : $('.form-group [data-sid="'+key.toUpperCase()+'"]')) ;//$('[name="'+key.toUpperCase()+'"]');
832			//console.log(el);
833			var ID = $(hash.t).data('autoload-'+key);
834			el.val( $(hash.t).data('autoload-'+key) );
835			el.closest('.form-group').addClass('input-filed');
836
837			if(typeof(el[0]) !== 'undefined' && typeof(el[0].tagName) !== 'undefined' && el[0].tagName == 'SELECT'){
838				el.find('option[data-id='+ID+']').attr('selected', true);
839				if(ID){
840					$(el).closest('form').find('select option').each(function(){
841						var dataID = $(this).data('id').toString(),
842							arDataID = (dataID.indexOf(',') != -1 ? dataID.split(',') : [dataID]);
843
844						if(arDataID.indexOf(ID.toString()) != -1){
845							$(this).show();
846						}
847						else{
848							$(this).hide();
849						}
850
851						/*if(!showSelect){
852							$(this).closest('[data-sid]').hide();
853						}
854						else{
855							$(this).closest('[data-sid]').show();
856						}*/
857					});
858				}
859				el.closest('.row[data-sid]').show();
860			}
861			else{
862				el.attr('title', el.val());
863				el.attr('readonly', 'readonly')
864			}
865
866		}
867	});
868
869	var eventdata = {action:'loadForm'};
870	BX.onCustomEvent('onCompleteAction', [eventdata, $(hash.t)[0]]);
871
872	if($(hash.t).data('autohide')){
873		$(hash.w).data('autohide', $(hash.t).data('autohide'));
874	}
875	if(name == 'order_product'){
876		if($(hash.t).data('product')) {
877			$('input[name="PRODUCT"]').closest('.form-group').addClass('input-filed');
878			$('input[name="PRODUCT"]').val($(hash.t).data('product')).attr('readonly', 'readonly').attr('title', $('input[name="PRODUCT"]').val());
879		}
880	}
881	if(name == 'question'){
882		if($(hash.t).data('product')) {
883			$('input[name="NEED_PRODUCT"]').closest('.form-group').addClass('input-filed');
884			$('input[name="NEED_PRODUCT"]').val($(hash.t).data('product')).attr('readonly', 'readonly').attr('title', $('input[name="NEED_PRODUCT"]').val());
885		}
886	}
887	hash.w.addClass('show').css({'margin-left': '-' + Math.floor(hash.w.width() / 2) + 'px', 'top': top, 'opacity': 1});
888}
889
890function onHide(hash){
891	if($(hash.w).data('autohide')){
892		eval($(hash.w).data('autohide'));
893	}
894	// hash.w.css('opacity', 0).hide();
895	hash.w.animate({'opacity': 0}, 200, function(){
896		hash.w.hide();
897		hash.w.empty();
898		hash.o.remove();
899		hash.w.removeClass('show');
900	});
901}
902
903function parseUrlQuery() {
904	var data = {};
905	if(location.search) {
906		var pair = (location.search.substr(1)).split('&');
907		for(var i = 0; i < pair.length; i ++) {
908			var param = pair[i].split('=');
909			data[param[0]] = param[1];
910		}
911	}
912	return data;
913}
914
915$.fn.jqmEx = function(){
916	$(this).each(function(){
917		var _this = $(this);
918		var name = _this.data('name');
919
920		if(name.length){
921			var script = arMedc2Options['SITE_DIR'] + 'ajax/form.php';
922			var paramsStr = ''; var trigger = ''; var arTriggerAttrs = {};
923			$.each(_this.get(0).attributes, function(index, attr){
924				var attrName = attr.nodeName;
925				var attrValue = _this.attr(attrName);
926				trigger += '[' + attrName + '=\"' + attrValue + '\"]';
927				arTriggerAttrs[attrName] = attrValue;
928				if(/^data\-param\-(.+)$/.test(attrName)){
929					var key = attrName.match(/^data\-param\-(.+)$/)[1];
930					paramsStr += key + '=' + attrValue + '&';
931				}
932			});
933			var triggerAttrs = JSON.stringify(arTriggerAttrs);
934			var encTriggerAttrs = encodeURIComponent(triggerAttrs);
935			if(name == 'auth')
936				script += '?' + paramsStr + 'auth=Y';
937			else
938				script += '?' + paramsStr + 'data-trigger=' + encTriggerAttrs;
939
940			if(!$('.' + name + '_frame[data-trigger="' + encTriggerAttrs + '"]').length){
941				if(_this.attr('disabled') != 'disabled'){
942					$('body').find('.' + name + '_frame[data-trigger="' + encTriggerAttrs + '"]').remove();
943					$('body').append('<div class="' + name + '_frame jqmWindow" style="width:560px" data-trigger="' + encTriggerAttrs + '"></div>');
944					$('.' + name + '_frame[data-trigger="' + encTriggerAttrs + '"]').jqm({trigger: trigger, onLoad: function(hash){onLoadjqm(hash);}, onHide: function(hash){onHide(hash);}, ajax:script});
945				}
946			}
947		}
948	});
949}
950
951InitFlexSlider = function() {
952	$('.flexslider:not(.thmb):visible').each(function(){
953		var slider = $(this);
954		var options;
955		var defaults = {
956			animationLoop: false,
957			controlNav: false,
958			directionNav: true,
959			animation: "slide"
960		}
961		var config = $.extend({}, defaults, options, slider.data('plugin-options'));
962		if(typeof(config.counts) != 'undefined' && config.direction !== 'vertical'){
963			var slide_counts = '';
964			if(typeof(slider.data('plugin-options')) != 'undefined')
965			{
966				if('slide_counts' in slider.data('plugin-options'))
967					slide_counts = slider.data('plugin-options').slide_counts;
968			}
969			config.maxItems =  getGridSize(config.counts);
970			config.minItems = getGridSize(config.counts);
971
972			if(slide_counts)
973				config.move = slide_counts;
974			else
975				config.move = getGridSize(config.counts);
976
977			config.itemWidth = 200;
978		}
979
980		// custom direction nav
981		if(typeof(config.customDirection) != 'undefined')
982			config.customDirectionNav = $(config.customDirection);
983
984		config.prevText = BX.message("FANCY_PREV"),           //String: Set the text for the "previous" directionNav item
985		config.nextText = BX.message("FANCY_NEXT"),
986
987		config.start = function(slider){
988			var eventdata = {slider: slider};
989			BX.onCustomEvent('onSliderStart', [eventdata]);
990			BX.onCustomEvent('onSlide', [eventdata]);
991		}
992
993		config.after = function(slider){
994			var eventdata = {slider: slider};
995			BX.onCustomEvent('onSlide', [eventdata]);
996		}
997
998		config.end = function(slider){
999			var eventdata = {slider: slider};
1000			BX.onCustomEvent('onSlideEnd', [eventdata]);
1001		}
1002
1003		config.before = function(slider){
1004			var eventdata = {slider: slider};
1005			BX.onCustomEvent('onSlideBefore', [eventdata]);
1006		}
1007
1008		slider.addClass('dark-nav');
1009		slider.flexslider(config).addClass('flexslider-init');
1010		if(config.controlNav)
1011			slider.addClass('flexslider-control-nav');
1012		if(config.directionNav)
1013			slider.addClass('flexslider-direction-nav');
1014
1015		if(config.customPagination){
1016
1017		}
1018	});
1019}
1020
1021InitFlexSliderClass = function(class_name) {
1022	//$('.flexslider:not(.thmb):not(.flexslider-init)').each(function(){
1023
1024		var slider = $(class_name);
1025		var options;
1026		var defaults = {
1027			animationLoop: false,
1028			controlNav: false,
1029			directionNav: true,
1030			animation: "slide"
1031		}
1032		var config = $.extend({}, defaults, options, slider.data('plugin-options'));
1033
1034		var slide_counts = '';
1035		if(typeof(slider.data('plugin-options')) != 'undefined')
1036		{
1037			if('slide_counts' in slider.data('plugin-options'))
1038				slide_counts = slider.data('plugin-options').slide_counts;
1039		}
1040
1041		if(typeof(config.counts) != 'undefined' && config.direction !== 'vertical'){
1042			config.maxItems =  getGridSize(config.counts);
1043			config.minItems = getGridSize(config.counts);
1044			config.move = getGridSize(config.counts);
1045
1046			config.itemWidth = 200;
1047		}
1048		if(slide_counts)
1049			config.move = slide_counts;
1050
1051		// custom direction nav
1052		if(typeof(config.customDirection) != 'undefined')
1053			config.customDirectionNav = $(config.customDirection);
1054
1055		config.prevText = BX.message("FANCY_PREV"),           //String: Set the text for the "previous" directionNav item
1056		config.nextText = BX.message("FANCY_NEXT"),
1057
1058		config.after = config.start = function(slider){
1059			var eventdata = {slider: slider};
1060			BX.onCustomEvent('onSlide', [eventdata]);
1061		}
1062
1063		config.end = function(slider){
1064			var eventdata = {slider: slider};
1065			BX.onCustomEvent('onSlideEnd', [eventdata]);
1066		}
1067
1068		slider.flexslider(config).addClass('flexslider-init');
1069		if(config.controlNav)
1070			slider.addClass('flexslider-control-nav');
1071		if(config.directionNav)
1072			slider.addClass('flexslider-direction-nav');
1073	//});
1074}
1075
1076SliceHeightBlocks = function(){
1077	$('*[data-slice="Y"]').each(function(){
1078		var slice_els = $(this).find('*[data-slice-block="Y"]');
1079		if(slice_els.length)
1080		{
1081			var slice_params = {};
1082			if(slice_els.data('slice-params'))
1083				slice_params = slice_els.data('slice-params');
1084			slice_els.sliceHeight(slice_params);
1085		}
1086	})
1087}
1088
1089createTableCompare = function(originalTable, appendDiv, cloneTable){
1090	try{
1091		if($('.tarifs .head-block:visible').length){
1092			var clone = originalTable.clone().addClass('clone');
1093			if(cloneTable.length){
1094				cloneTable.remove();
1095				appendDiv.html('');
1096				appendDiv.html(clone);
1097			}else{
1098				appendDiv.append(clone);
1099			}
1100		}
1101	}
1102	catch(e){}
1103	finally{}
1104}
1105
1106CheckHeaderFixedMenu = function(){
1107	if(arMedc2Options['THEME']['HEADER_FIXED'] == 2 && $('#headerfixed .js-nav').length && window.matchMedia('(min-width: 992px)').matches)
1108	{
1109		$('#headerfixed .js-nav').css('width','0');
1110		var all_width = 0,
1111			cont_width = $('#headerfixed .maxwidth-theme').actual('width'),
1112			padding_menu = $('#headerfixed .logo-row.v2 .menu-block').actual('outerWidth')-$('#headerfixed .logo-row.v2 .menu-block').actual('width');
1113		$('#headerfixed .logo-row.v2 > .inner-table-block').each(function(){
1114			if(!$(this).hasClass('menu-block'))
1115				all_width += $(this).actual('outerWidth');
1116		})
1117		$('#headerfixed .js-nav').width(cont_width-all_width-padding_menu);
1118	}
1119}
1120
1121CheckTopMenuPadding = function(){
1122	if($('.logo_and_menu-row .right-icons .wrap_icon').length && $('.logo_and_menu-row .menu-row').length){
1123		var menuPosition = $('.menu-row .menu-only').position().left,
1124			maxWidth = $('.logo_and_menu-row .maxwidth-theme').width() - 32,
1125			leftPadding = 0,
1126			rightPadding = 0;
1127
1128		$('.logo_and_menu-row .menu-row>div').each(function(indx){
1129			if(!$(this).hasClass('menu-only')){
1130				var elementPosition = $(this).position().left,
1131					elementWidth = $(this).outerWidth();
1132
1133				if(elementPosition > menuPosition){
1134					rightPadding += elementWidth + 1;
1135				}else{
1136					leftPadding += elementWidth + 1;
1137				}
1138			}
1139		}).promise().done(function(){
1140			$('.logo_and_menu-row .menu-only').css({'padding-left': leftPadding, 'padding-right': rightPadding});
1141		});
1142	}
1143}
1144
1145CheckTopMenuOncePadding = function(){
1146	if($('.menu-row.sliced .right-icons .wrap_icon').length){
1147		var menuPosition = $('.menu-row .menu-only').position().left,
1148			maxWidth = $('.logo_and_menu-row .maxwidth-theme').width() - 32,
1149			leftPadding = 0,
1150			rightPadding = 0;
1151
1152		$('.menu-row.sliced .maxwidth-theme>div>div').each(function(indx){
1153			if(!$(this).hasClass('menu-only')){
1154				var elementPosition = $(this).position().left,
1155					elementWidth = $(this).outerWidth();
1156
1157				if(elementPosition > menuPosition){
1158					rightPadding += elementWidth + 1;
1159				}else{
1160					leftPadding += elementWidth + 1;
1161				}
1162			}
1163		}).promise().done(function(){
1164			$('.menu-row.sliced .menu-only').css({'padding-left': leftPadding, 'padding-right': rightPadding});
1165		});
1166	}
1167}
1168
1169CheckSearchWidth = function(){
1170	if($('.logo_and_menu-row .search_wrap').length){
1171		var searchPosition = $('.logo_and_menu-row .search_wrap').position().left,
1172			maxWidth = $('.logo_and_menu-row .maxwidth-theme').width() - 32;
1173			width = 0;
1174
1175		$('.logo_and_menu-row .maxwidth-theme>div').each(function(){
1176			if(!$(this).hasClass('search_wrap')){
1177				var elementWidth = $(this).outerWidth();
1178
1179				width = (width ? width - elementWidth : maxWidth - elementWidth);
1180			}
1181		}).promise().done(function(){
1182			$('.logo_and_menu-row .search_wrap').outerWidth(width).css({'opacity': 1, 'visibility': 'visible'});
1183		});
1184	}
1185}
1186
1187waitCounter = function(idCounter, delay, callback){
1188	var obCounter = window['yaCounter' + idCounter];
1189	if(typeof obCounter == 'object')
1190	{
1191		if(typeof callback == 'function')
1192			callback();
1193
1194	}
1195	else
1196	{
1197		setTimeout(function(){
1198			waitCounter(idCounter, delay, callback);
1199		}, delay);
1200	}
1201}
1202
1203waitYTPlayer = function(delay, callback){
1204	if((typeof YT !== "undefined") && YT && YT.Player)
1205	{
1206		if(typeof callback == 'function')
1207			callback();
1208	}
1209	else
1210	{
1211		setTimeout(function(){
1212			waitYTPlayer(delay, callback);
1213		}, delay);
1214	}
1215}
1216
1217openerFunc = function(el, selectorHideBlock){
1218	var $this = el,
1219		$item = $this.closest('.item'),
1220		$hiddenBlock = (selectorHideBlock ? $item.find(selectorHideBlock) : $item.find('.hidden-block')),
1221		openText = (typeof($this.data('open_text')) !== 'undefined' ? $this.data('open_text') : ''),
1222		closeText = (typeof($this.data('close_text')) !== 'undefined' ? $this.data('close_text') : ''),
1223		btn = ($this.find('.btn').length ? $this.find('.btn') : $this);
1224
1225
1226	$hiddenBlock.slideToggle(200);
1227	$item.toggleClass('opened');
1228
1229	if(!btn.hasClass('opened')){
1230		btn.addClass('opened').removeClass('closed');
1231
1232		if(openText.length){
1233			$this.find('.text').text(openText);
1234		}
1235	}
1236	else if(btn.hasClass('opened')){
1237		btn.addClass('closed').removeClass('opened');
1238
1239		if(closeText.length){
1240			$this.find('.text').text(closeText);
1241		}
1242	}
1243}
1244
1245HoverStaffSliderItem = function(el){
1246	el.find('.item').hover(function(){
1247		var $this = $(this),
1248			$parent = $this.closest('.flex-viewport'),
1249			thisHeight = $this.find('>.wrap').height(),
1250			parentHeight = $parent.data('height'),
1251			deltaHeight = $this.data('delta_height');
1252
1253		$parent.height(parentHeight + deltaHeight);
1254		//$this.find('>.wrap').height(thisHeight + deltaHeight);
1255	}, function(){
1256		var $this = $(this),
1257			$parent = $this.closest('.flex-viewport'),
1258			thisHeight = $this.find('>.wrap').height(),
1259			parentHeight = $parent.data('height'),
1260			deltaHeight = $this.data('delta_height');
1261
1262		//$this.find('>.wrap').height(thisHeight - deltaHeight);
1263		$parent.height(parentHeight);
1264	});
1265}
1266
1267$(document).ready(function(){
1268	scrollToTop();
1269
1270	if(!jQuery.browser.safari){
1271		CheckTopMenuPadding();
1272		CheckTopMenuOncePadding();
1273		CheckTopMenuDotted();
1274		CheckHeaderFixed();
1275		setTimeout(function() {$(window).resize();}, 150); // need to check resize flexslider & menu
1276		setTimeout(function() {$(window).scroll();}, 250); // need to check position fixed ask block
1277	}
1278	else{
1279		setTimeout(function(){
1280			$(window).resize(); // need to check resize flexslider & menu
1281			setTimeout(function(){
1282				CheckTopMenuPadding();
1283				CheckTopMenuOncePadding();
1284				CheckTopMenuDotted();
1285				CheckHeaderFixed();
1286
1287				setTimeout(function(){
1288					$(window).scroll();
1289				}, 50);
1290			}, 50);
1291		}, 350);
1292	}
1293	CheckStickyFooter();
1294	MegaMenuFixed();
1295	CheckSearchWidth();
1296	InitTopestMenuGummi();
1297
1298	// $(window).scroll();
1299
1300	$('.accordion .item .accordion-head').on('click', function(){
1301		$(this).find('.arrow-open').toggleClass('open');
1302	});
1303
1304	if(arMedc2Options['THEME']['USE_DEBUG_GOALS'] === 'Y'){
1305		$.cookie('_ym_debug', '1');
1306	}
1307	else{
1308		$.cookie('_ym_debug', null);
1309	}
1310
1311	if($('textarea').length){
1312		$('textarea').each(function(){
1313			$(this).autoResize();
1314		});
1315	}
1316
1317	$('*[data-trigger=opener]').on('click', function(e){
1318		e.preventDefault();
1319		if(!$(e.target).hasClass('record')){
1320			openerFunc($(this));
1321		}
1322	});
1323
1324	if($('.banners-content').length){
1325		$('.logo_and_menu-row .logo-row, .eye_version_black_color .menu-row:not(.bgcolored) .menu-only, .eye_version_black_color .menu-row.bgcolored .menu-only').css('border', 'none');
1326	}
1327
1328	/*  --- Bind mobile menu  --- */
1329	var $mobileMenu = $("#mobilemenu")
1330	if($mobileMenu.length){
1331		$mobileMenu.isLeftSide = $mobileMenu.hasClass('leftside')
1332		$mobileMenu.isOpen = $mobileMenu.hasClass('show')
1333		$mobileMenu.isDowndrop = $mobileMenu.find('>.scroller').hasClass('downdrop')
1334
1335		$('#mobileheader .burger').click(function(){
1336			SwipeMobileMenu()
1337		})
1338
1339		if($mobileMenu.isLeftSide){
1340			$mobileMenu.parent().append('<div id="mobilemenu-overlay"></div>')
1341			var $mobileMenuOverlay = $('#mobilemenu-overlay')
1342
1343			$mobileMenuOverlay.click(function(){
1344				if($mobileMenu.isOpen){
1345					CloseMobileMenu()
1346				}
1347			});
1348
1349			$(document).swiperight(function(e) {
1350				if(!$(e.target).closest('.flexslider').length && !$(e.target).closest('.swipeignore').length){
1351					OpenMobileMenu()
1352				}
1353			});
1354
1355			$(document).swipeleft(function(e) {
1356				if(!$(e.target).closest('.flexslider').length && !$(e.target).closest('.swipeignore').length){
1357					CloseMobileMenu()
1358				}
1359			});
1360		}
1361		else{
1362			$('#mobileheader').click(function(e){
1363				if(!$(e.target).closest('#mobilemenu').length && !$(e.target).closest('.burger').length && $mobileMenu.isOpen){
1364					CloseMobileMenu()
1365				}
1366			});
1367		}
1368
1369		$('#mobilemenu .menu a,#mobilemenu .social-icons a').click(function(e){
1370			var $this = $(this)
1371			if($this.hasClass('parent')){
1372				e.preventDefault()
1373
1374				if(!$mobileMenu.isDowndrop){
1375					$this.closest('li').addClass('expanded')
1376					MoveMobileMenuWrapNext()
1377				}
1378				else{
1379					if(!$this.closest('li').hasClass('expanded')){
1380						$this.closest('li').addClass('expanded')
1381					}
1382					else{
1383						$this.closest('li').removeClass('expanded')
1384					}
1385				}
1386			}
1387			else{
1388				if($this.closest('li').hasClass('counters')){
1389					var href = $this.attr('href')
1390					if(typeof href !== 'undefined'){
1391						window.location.href = href
1392						window.location.reload()
1393					}
1394				}
1395
1396				if(!$this.closest('.menu_back').length){
1397					CloseMobileMenu()
1398				}
1399			}
1400		})
1401
1402		$('#mobilemenu .dropdown .menu_back').click(function(e){
1403			e.preventDefault()
1404			var $this = $(this)
1405			MoveMobileMenuWrapPrev()
1406			setTimeout(function(){
1407				$this.closest('.expanded').removeClass('expanded')
1408			}, 400)
1409		})
1410
1411		OpenMobileMenu = function(){
1412			if(!$mobileMenu.isOpen){
1413				// hide styleswitcher
1414				if($('.style-switcher').hasClass('active')){
1415					$('.style-switcher .switch').trigger('click')
1416				}
1417				$('.style-switcher .switch').hide()
1418
1419				if($mobileMenu.isLeftSide){
1420					// show overlay
1421					setTimeout(function(){
1422						$mobileMenuOverlay.fadeIn('fast')
1423					}, 100)
1424				}
1425				else{
1426					// scroll body to top & set fixed
1427					$('body').scrollTop(0).css({position: 'fixed'})
1428
1429					// set menu top = bottom of header
1430					$mobileMenu.css({top: + ($('#mobileheader').height() + $('#mobileheader').offset().top) + 'px'})
1431
1432					// change burger icon
1433					$('#mobileheader .burger').addClass('c')
1434				}
1435
1436				// show menu
1437				$mobileMenu.addClass('show')
1438				$mobileMenu.isOpen = true
1439
1440				if(!$mobileMenu.isDowndrop){
1441					var $wrap = $mobileMenu.find('.wrap').first()
1442					var params =  $wrap.data('params')
1443					if(typeof params === 'undefined'){
1444						params = {
1445							depth: 0,
1446							scroll: {},
1447							height: {}
1448						}
1449					}
1450					$wrap.data('params', params)
1451				}
1452			}
1453		}
1454
1455		CloseMobileMenu = function(){
1456			if($mobileMenu.isOpen){
1457				// hide menu
1458				$mobileMenu.removeClass('show');
1459				$mobileMenu.isOpen = false;
1460				$('.mega_fixed_menu').hide();
1461
1462				// show styleswitcher
1463				$('.style-switcher .switch').show()
1464
1465				if($mobileMenu.isLeftSide){
1466					// hide overlay
1467					setTimeout(function(){
1468						$mobileMenuOverlay.fadeOut('fast')
1469					}, 100)
1470				}
1471				else{
1472					// change burger icon
1473					$('#mobileheader .burger').removeClass('c')
1474
1475					// body unset fixed
1476					$('body').css({position: ''})
1477				}
1478
1479				if(!$mobileMenu.isDowndrop){
1480					setTimeout(function(){
1481						var $scroller = $mobileMenu.find('.scroller').first()
1482						var $wrap = $mobileMenu.find('.wrap').first()
1483						var params =  $wrap.data('params')
1484						params.depth = 0
1485						$wrap.data('params', params).attr('style', '')
1486						$mobileMenu.scrollTop(0)
1487						$scroller.css('height', '')
1488					}, 400)
1489				}
1490			}
1491		}
1492
1493		SwipeMobileMenu = function(){
1494			if($mobileMenu.isOpen){
1495				CloseMobileMenu()
1496			}
1497			else{
1498				OpenMobileMenu()
1499			}
1500		}
1501
1502		function MoveMobileMenuWrapNext(){
1503			if(!$mobileMenu.isDowndrop){
1504				var $scroller = $mobileMenu.find('.scroller').first()
1505				var $wrap = $mobileMenu.find('.wrap').first()
1506				if($wrap.length){
1507					var params =  $wrap.data('params')
1508					var $dropdownNext = $mobileMenu.find('.expanded>.dropdown').eq(params.depth)
1509					if($dropdownNext.length){
1510						// save scroll position
1511						params.scroll[params.depth] = parseInt($mobileMenu.scrollTop())
1512
1513						// height while move animating
1514						params.height[params.depth + 1] = Math.max($dropdownNext.height(), (!params.depth ? $wrap.height() : $mobileMenu.find('.expanded>.dropdown').eq(params.depth - 1).height()))
1515						$scroller.css('height', params.height[params.depth + 1] + 'px')
1516
1517						// inc depth
1518						++params.depth
1519
1520						// translateX for move
1521						$wrap.css('transform', 'translateX(' + -100 * params.depth + '%)')
1522
1523						// scroll to top
1524						setTimeout(function() {
1525							$mobileMenu.animate({scrollTop : 0}, 200);
1526						}, 100)
1527
1528						// height on enimating end
1529						var h = $dropdownNext.height()
1530						setTimeout(function() {
1531							if(h){
1532								$scroller.css('height', h + 'px')
1533							}
1534							else{
1535								$scroller.css('height', '')
1536							}
1537						}, 200)
1538					}
1539
1540					$wrap.data('params', params)
1541				}
1542			}
1543		}
1544
1545		function MoveMobileMenuWrapPrev(){
1546			if(!$mobileMenu.isDowndrop){
1547				var $scroller = $mobileMenu.find('.scroller').first()
1548				var $wrap = $mobileMenu.find('.wrap').first()
1549				if($wrap.length){
1550					var params =  $wrap.data('params')
1551					if(params.depth > 0){
1552						var $dropdown = $mobileMenu.find('.expanded>.dropdown').eq(params.depth - 1)
1553						if($dropdown.length){
1554							// height while move animating
1555							$scroller.css('height', params.height[params.depth] + 'px')
1556
1557							// dec depth
1558							--params.depth
1559
1560							// translateX for move
1561							$wrap.css('transform', 'translateX(' + -100 * params.depth + '%)')
1562
1563							// restore scroll position
1564							setTimeout(function() {
1565								$mobileMenu.animate({scrollTop : params.scroll[params.depth]}, 200);
1566							}, 100)
1567
1568							// height on enimating end
1569							var h = (!params.depth ? false : $mobileMenu.find('.expanded>.dropdown').eq(params.depth - 1).height())
1570							setTimeout(function() {
1571								if(h){
1572									$scroller.css('height', h + 'px')
1573								}
1574								else{
1575									$scroller.css('height', '')
1576								}
1577							}, 200)
1578						}
1579					}
1580
1581					$wrap.data('params', params)
1582				}
1583			}
1584		}
1585	}
1586	/*  --- END Bind mobile menu  --- */
1587
1588
1589	/* change type2 menu for fixed */
1590	if($('#headerfixed .js-nav').length)
1591	{
1592		if(arMedc2Options['THEME']['HEADER_FIXED'] == 2)
1593			CheckHeaderFixedMenu();
1594
1595		setTimeout(function(){
1596			$('#headerfixed .js-nav').addClass('opacity1');
1597		},350);
1598	}
1599
1600	/* close search block */
1601	$("html, body").on('mousedown', function(e){
1602		e.stopPropagation();
1603		var search_target = $(e.target).closest('.bx_searche');
1604		if(!$(e.target).hasClass('inline-search-block') && !$(e.target).hasClass('svg') && !search_target.length)
1605		{
1606			$('.inline-search-block').removeClass('show');
1607			$('.title-search-result').hide();
1608			if(arMedc2Options['THEME']['TYPE_SEARCH'] == 'fixed')
1609				$('.jqmOverlay.search').detach();
1610		}
1611
1612		if(isMobile)
1613		{
1614			if(search_target.length)
1615				location.href = search_target.attr('href');
1616		}
1617		var class_name = $(e.target).attr('class');
1618		if(typeof(class_name) == 'undefined' || class_name.indexOf('tooltip') < 0) //tooltip link
1619			$('.tooltip-link').tooltip('hide');
1620	});
1621	$('.inline-search-block').find('*').on('mousedown', function(e){
1622		e.stopPropagation();
1623	});
1624
1625
1626	$('.filter-action').on('click', function(){
1627		$(this).toggleClass('active');
1628		$(this).find('.svg').toggleClass('white');
1629		if($('.text_before_items').length)
1630		{
1631			var top_pos = $('.filters-wrap').position();
1632			$('.bx_filter').css({'top':top_pos.top+40});
1633		}
1634		$('.bx_filter').slideToggle();
1635	})
1636
1637	waitingNotExists('#bx-composite-banner .bx-composite-btn', '#footer .col-sm-3.hidden-md.hidden-lg #bx-composite-banner .bx-composite-btn', 500, function() {
1638		$('#footer .col-sm-3.hidden-md.hidden-lg #bx-composite-banner').html($('#bx-composite-banner .bx-composite-btn').parent().html());
1639	});
1640
1641	$.extend( $.validator.messages, {
1642		required: BX.message('JS_REQUIRED'),
1643		email: BX.message('JS_FORMAT'),
1644		equalTo: BX.message('JS_PASSWORD_COPY'),
1645		minlength: BX.message('JS_PASSWORD_LENGTH'),
1646		remote: BX.message('JS_ERROR')
1647	});
1648
1649	$.validator.addMethod(
1650		'regexp', function( value, element, regexp ){
1651			var re = new RegExp( regexp );
1652			return this.optional( element ) || re.test( value );
1653		},
1654		BX.message('JS_FORMAT')
1655	);
1656
1657	$.validator.addMethod(
1658		'filesize', function( value, element, param ){
1659			return this.optional( element ) || ( element.files[0].size <= param )
1660		},
1661		BX.message('JS_FILE_SIZE')
1662	);
1663
1664	$.validator.addMethod(
1665		'date', function( value, element, param ) {
1666			var status = false;
1667			if((!value || value.length <= 0) && $(element).hasClass('required')){
1668				status = false;
1669			}
1670			else{
1671				var re = new RegExp('^([0-9]{2})(.)([0-9]{2})(.)([0-9]{4})$');
1672				var matches = re.exec(value);
1673				if(matches){
1674					var composedDate = new Date(matches[5], (matches[3] - 1), matches[1]);
1675					status = ((composedDate.getMonth() == (matches[3] - 1)) && (composedDate.getDate() == matches[1]) && (composedDate.getFullYear() == matches[5]));
1676				}
1677
1678				if(!$(element).hasClass('required') && !value){
1679					status = true;
1680				}
1681			}
1682			return status;
1683		}, BX.message('JS_DATE')
1684	);
1685
1686	$.validator.addMethod(
1687		'datetime', function( value, element, param ) {
1688			var status = false;
1689			if(!value || value.length <= 0){
1690				status = false;
1691			}
1692			else{
1693				var re = new RegExp('^([0-9]{2})(.)([0-9]{2})(.)([0-9]{4}) ([0-9]{1,2}):([0-9]{1,2})$');
1694				var matches = re.exec(value);
1695				if(matches){
1696					var composedDate = new Date(matches[5], (matches[3] - 1), matches[1], matches[6], matches[7]);
1697					status = ((composedDate.getMonth() == (matches[3] - 1)) && (composedDate.getDate() == matches[1]) && (composedDate.getFullYear() == matches[5]) && (composedDate.getHours() == matches[6]) && (composedDate.getMinutes() == matches[7]));
1698				}
1699			}
1700			return status;
1701		}, BX.message('JS_DATETIME')
1702	);
1703
1704	$.validator.addMethod(
1705		'extension', function(value, element, param){
1706			param = typeof param === 'string' ? param.replace(/,/g, '|') : 'png|jpe?g|gif';
1707			return this.optional(element) || value.match(new RegExp('.(' + param + ')$', 'i'));
1708		}, BX.message('JS_FILE_EXT')
1709	);
1710
1711	$.validator.addMethod(
1712		'captcha', function( value, element, params ){
1713			return $.validator.methods.remote.call(this, value, element,{
1714				url: arMedc2Options['SITE_DIR'] + 'ajax/check-captcha.php',
1715				type: 'post',
1716				data:{
1717					captcha_word: value,
1718					captcha_sid: function(){
1719						return $(element).closest('form').find('input[name="captcha_sid"]').val();
1720					}
1721				}
1722			});
1723		},
1724		BX.message('JS_ERROR')
1725    );
1726
1727	/*reload captcha*/
1728	$('body').on( 'click', '.refresh', function(e){
1729		e.preventDefault();
1730		$.ajax({
1731			url: arMedc2Options['SITE_DIR'] + 'ajax/captcha.php'
1732		}).done(function(text){
1733			if($('.captcha_sid').length)
1734			{
1735				$('.captcha_sid').val(text);
1736				$('.captcha_img').attr('src', '/bitrix/tools/captcha.php?captcha_sid=' + text);
1737			}
1738		});
1739	});
1740
1741	$.validator.addClassRules({
1742		'phone':{
1743			regexp: arMedc2Options['THEME']['VALIDATE_PHONE_MASK']
1744		},
1745		'confirm_password':{
1746			equalTo: 'input.password',
1747			minlength: 6
1748		},
1749		'password':{
1750			minlength: 6
1751		},
1752		'inputfile':{
1753			extension: arMedc2Options['THEME']['VALIDATE_FILE_EXT'],
1754			filesize: 5000000
1755		},
1756		'datetime':{
1757			datetime: ''
1758		},
1759		'date':{
1760			date: ''
1761		},
1762		'captcha':{
1763			captcha: ''
1764		}
1765	});
1766
1767	$.validator.setDefaults({
1768	   highlight: function( element ){
1769			$(element).parent().addClass('error');
1770		},
1771		unhighlight: function( element ){
1772			$(element).parent().removeClass('error');
1773		}
1774	});
1775
1776	InitFlexSlider();
1777
1778	// for check flexslider bug in composite mode
1779	waitingNotExists('.detail .galery #slider', '.detail .galery #slider .flex-viewport', 1000, function() {
1780		InitFlexSlider();
1781		setTimeout(function() {
1782			$(window).resize();
1783		}, 350);
1784	});
1785
1786	/*check mobile device*/
1787	if(jQuery.browser.mobile){
1788		$('.hint span').remove();
1789
1790		$(document).on('click', '*[data-event="jqm"]' , function(e){
1791			e.preventDefault();
1792			var _this = $(this);
1793			var name = _this.data('name');
1794
1795			if(name.length){
1796				var script = arMedc2Options['SITE_DIR'] + 'form/';
1797				var paramsStr = ''; var arTriggerAttrs = {};
1798				$.each(_this.get(0).attributes, function(index, attr){
1799					var attrName = attr.nodeName;
1800					var attrValue = _this.attr(attrName);
1801					arTriggerAttrs[attrName] = attrValue;
1802					if(/^data\-param\-(.+)$/.test(attrName)){
1803						var key = attrName.match(/^data\-param\-(.+)$/)[1];
1804						paramsStr += key + '=' + attrValue + '&';
1805					}
1806				});
1807
1808				var triggerAttrs = JSON.stringify(arTriggerAttrs);
1809				var encTriggerAttrs = encodeURIComponent(triggerAttrs);
1810				script += '?name=' + name + '&' + paramsStr + 'data-trigger=' + encTriggerAttrs;
1811				location.href = script;
1812			}
1813		});
1814
1815		$('.fancybox').removeClass('fancybox');
1816	}
1817	else{
1818		$(document).on('click', '*[data-event="jqm"]', function(e){
1819			e.preventDefault();
1820			e.stopPropagation();
1821			$(this).jqmEx();
1822			$(this).trigger('click');
1823
1824		});
1825	}
1826
1827	$('.animate-load').on('click', function(){
1828		$(this).parent().addClass('loadings');
1829	});
1830
1831	BX.addCustomEvent('onCompleteAction', function(eventdata, _this){
1832		try{
1833			if(eventdata.action === 'loadForm')
1834			{
1835				$(_this).parent().removeClass('loadings');
1836			}
1837			else if(eventdata.action === 'loadBasket')
1838			{
1839				var basket_link = $('.basket-link');
1840				if(basket_link.length)
1841				{
1842					basket_link.attr('title', $(_this).find('a').attr('title'));
1843					if($(_this).find('a .count').length){
1844						var count = basket_link.find('.count').length ? $(_this).find('.count').text() : $(_this).find('.count').text();
1845						basket_link.find('.prices').text($(_this).find('.icon').data('summ'));
1846						if(basket_link.find('.count').length)
1847						{
1848							basket_link.find('.count').text(count);
1849							if(count)
1850								basket_link.addClass('basket-count');
1851							else
1852								basket_link.removeClass('basket-count');
1853						}
1854						else
1855						{
1856							basket_link.find('.js-basket-block').append($(_this).find('.count'));
1857							basket_link.addClass('basket-count');
1858							CheckHeaderFixedMenu();
1859						}
1860
1861						$('#mobilemenu .menu .ready .count').text(count);
1862						if(count){
1863							$('#mobilemenu .menu .ready .count').removeClass('empted');
1864						}
1865						else{
1866							$('#mobilemenu .menu .ready .count').addClass('empted');
1867						}
1868					}
1869					else
1870					{
1871						basket_link.find('.count').remove();
1872						basket_link.removeClass('basket-count');
1873						CheckHeaderFixedMenu();
1874					}
1875				}
1876			}
1877			else if(eventdata.action === 'loadRSS')
1878			{
1879			}
1880		}
1881		catch(e){
1882			console.error(e)
1883		}
1884	})
1885
1886	BX.addCustomEvent('onCounterGoals', function(eventdata){
1887		if(arMedc2Options['THEME']['YA_GOLAS'] == 'Y' && arMedc2Options['THEME']['YA_COUNTER_ID'])
1888		{
1889			var idCounter = arMedc2Options['THEME']['YA_COUNTER_ID'];
1890			idCounter = parseInt(idCounter);
1891
1892			if(typeof eventdata != 'object')
1893				eventdata = {goal: 'undefined'};
1894
1895			if(typeof eventdata.goal != 'string')
1896				eventdata.goal = 'undefined';
1897
1898			if(idCounter)
1899			{
1900				try
1901				{
1902					waitCounter(idCounter, 50, function(){
1903						var obCounter = window['yaCounter' + idCounter];
1904						if(typeof obCounter == 'object'){
1905							obCounter.reachGoal(eventdata.goal);
1906						}
1907					});
1908				}
1909				catch(e)
1910				{
1911					console.error(e)
1912				}
1913			}
1914			else
1915			{
1916				console.info('Bad counter id!', idCounter);
1917			}
1918		}
1919	})
1920
1921	/* show print */
1922	if(arMedc2Options['THEME']['PRINT_BUTTON'] == 'Y')
1923	{
1924		setTimeout(function(){
1925			if($('.page-top .rss-block.top').length)
1926			{
1927				$('<div class="print-link"><i class="svg svg-print"></i></div>').insertAfter($('.page-top .rss'));
1928			}
1929			else if($('.page-top .rss').length)
1930			{
1931				$('<div class="print-link"><i class="svg svg-print"></i></div>').insertAfter($('.page-top .rss'));
1932			}
1933			else if($('.page-top h1').length)
1934				$('<div class="print-link"><i class="svg svg-print"></i></div>').insertBefore($('.page-top h1'));
1935			// else
1936				// $('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>');
1937		},150);
1938	}
1939
1940	$(document).on('click', '.print-link', function(){
1941		window.print();
1942	});
1943
1944	$(document).on('click', '.eye-link', function(){
1945		if($(this).hasClass('show_eye_version')){
1946			$.cookie('MEDC2_EYE_VERSION\[\VALUE\]', '', {path: arMedc2Options['SITE_DIR'], expires: 365});
1947		}
1948		else{
1949			$.cookie('MEDC2_EYE_VERSION\[\VALUE\]', 'Y', {path: arMedc2Options['SITE_DIR'], expires: 365});
1950		}
1951
1952		window.location.href = window.location.href;
1953	});
1954
1955	$('.head-block .item-link').on('click', function(){
1956		var _this = $(this);
1957		_this.siblings().removeClass('active');
1958		_this.addClass('active');
1959	});
1960
1961	$('table.table').each(function(){
1962		var _this = $(this),
1963			first_td = _this.find('thead tr th');
1964		if(!first_td.length)
1965			first_td = _this.find('thead tr td');
1966		if(first_td.length)
1967		{
1968			var j = 0;
1969			_this.find('tbody tr td').each(function(i){
1970				if(j > first_td.length-1)
1971					j = 0;
1972
1973				$('<div class="th-mobile">'+first_td[j].textContent+'</div>').appendTo($(this));
1974				j++;
1975			})
1976		}
1977	});
1978
1979	// menu marker
1980	$(document).on('mouseenter', 'table td .wrap > a', function(){
1981		/*$(this).stop(true, true);
1982		var itemParentPos = $(this).closest('td').position().left,
1983			itemPos = $(this).position().left,
1984			mainPos = itemParentPos + itemPos + parseInt($(this).css('padding-left'));
1985		$(this).closest('.mega-menu').find('.marker-nav').css('left', mainPos);
1986		$(this).closest('.mega-menu').find('.marker-nav').css('width', $(this).find('.line-wrapper').actual('outerWidth'));*/
1987	});
1988
1989	$(document).on('mouseleave', '.mega-menu', function(){
1990		markerNav();
1991	});
1992
1993	$('a.fancybox').fancybox();
1994
1995	/* flex pagination */
1996	$('.flex-viewport .item').on('mouseenter', function(){
1997		$(this).closest('.flexslider').find('.flex-control-nav').toggleClass('noz');
1998		$(this).closest('.flexslider').find('.flex-control-nav').css('z-index','0');
1999	})
2000	$('.flex-viewport .item').on('mouseleave', function(){
2001		$(this).closest('.flexslider').find('.flex-control-nav').toggleClass('noz');
2002		$(this).closest('.flexslider').find('.flex-control-nav').css('z-index','2');
2003	})
2004
2005	/* ajax more items */
2006	$(document).on('click', '.ajax_load_btn', function(){
2007		var url=$(this).closest('.bottom_nav').find('.module-pagination .flex-direction-nav .flex-next').attr('href'),
2008			th=$(this).find('.more_text_ajax');
2009		if(!th.hasClass('loading'))
2010		{
2011			th.addClass('loading');
2012
2013			$.ajax({
2014				url: url,
2015				data: {"AJAX_REQUEST": "Y"},
2016				success: function(html){
2017
2018					if($('.banners-small.front').length)
2019					{
2020						$('.banners-small .items.row').append(html);
2021						$('.bottom_nav').html($('.banners-small .items.row .bottom_nav').html());
2022						$('.banners-small .items.row .bottom_nav').remove();
2023					}
2024					else
2025					{
2026						$(html).insertBefore($('.blog .bottom_nav'));
2027						$('.bottom_nav').html($('.blog .bottom_nav:hidden').html());
2028						$('.blog .bottom_nav:hidden').remove();
2029					}
2030
2031					var eventdata = {action:'ajaxContentLoaded'};
2032					BX.onCustomEvent('onCompleteAction', [eventdata, th[0]]);
2033
2034					setTimeout(function(){
2035						$('.banners-small .item.normal-block').sliceHeight();
2036						th.removeClass('loading');
2037					}, 100);
2038				}
2039			})
2040		}
2041	});
2042
2043	$(document).on('click', '.ajax_load_btn_pagination', function(){
2044		var $this = $(this),
2045			url = $this.closest('.pagination_nav').find('.pagination .next a').attr('href');
2046
2047		if($('[detail-pagination]').length) {
2048			var wrapperId = $this.closest('.tab-pane').attr('id');
2049		}
2050
2051
2052		if(!$this.hasClass('loadings')){
2053			$this.addClass('loadings');
2054			$.ajax({
2055				url: url,
2056				data: {"AJAX_REQUEST": "Y"},
2057				success: function(html){
2058
2059					//$(html).insertBefore($('.item-views .bottom_nav'));
2060					var htmlPagination = $(html).find('.pagination_nav').html(),
2061						htmlContent = $(html).find('.items').html();
2062
2063					if($(html).find('[detail-pagination]').length) {
2064						var htmlPagination = $(html).find($(html).find('#'+wrapperId+'[detail-pagination]').data('page-module')).html();
2065						var container = $(html).find('#'+wrapperId+'[detail-pagination]').attr('detail-pagination');
2066						var htmlContent = $(html).find(container).html();
2067						$this.closest('.tabs').find(container).append(htmlContent);
2068						$this.closest('.item-views').find('.pagination_nav').html(htmlPagination);
2069					} else {
2070						$this.closest('.item-views').find('.items').append(htmlContent);
2071						$this.closest('.item-views').find('.pagination_nav').html(htmlPagination);
2072					}
2073
2074
2075
2076					var eventdata = {action:'ajaxContentLoaded'};
2077					BX.onCustomEvent('onCompleteAction', [eventdata, $(this).find('.more_text_ajax')[0]]);
2078					BX.onCustomEvent('onCompleteActionComponent', [eventdata, $(this).find('.more_text_ajax')[0]]);
2079					$this.removeClass('loadings');
2080				}
2081			});
2082		}
2083	});
2084
2085	$(document).on('click', '.front.sections .ajax_btn .btn', function(){
2086		var $this = $(this),
2087			parent = $(this).parent(),
2088			params = $this.data('params'),
2089			template = $this.data('template');
2090		console.log(template);
2091		if(!parent.hasClass('loadings')){
2092			parent.addClass('loadings');
2093
2094			$.ajax({
2095				data: {AJAX_POST: 'Y', AJAX_PARAMS: params, TEMPLATE: template},
2096				type: 'POST',
2097				url: arMedc2Options['SITE_DIR'] + 'include/mainpage/comp_sections.php',
2098				success: function(html){
2099					$('#ajax_reload_sections').html(html);
2100					$('.sections.item-views.front .item').sliceHeight();
2101				}
2102			});
2103		}
2104	});
2105
2106	/* bug fix in ff*/
2107	$('img').removeAttr('draggable');
2108
2109	$('.detail .nav-tabs>li a').on('click', function(){
2110		var $this = $(this),
2111			$parent = $this.parent(),
2112			thisIndex = $parent.index();
2113
2114			if(!$parent.hasClass('active')){
2115			$this.closest('.tabs').find('.tab-pane .title-tab-heading .btn').removeClass('opened open').addClass('closed');
2116			$this.closest('.tabs').find('.tab-pane').eq(thisIndex).find('.toggle-block').show();
2117			$this.closest('.tabs').find('.tab-content>.tab-pane').eq(thisIndex).find('.title-tab-heading .btn').removeClass('closed').addClass('opened');
2118		}
2119	});
2120
2121	$('.title-tab-heading').on('click', function(){
2122		var $this = $(this),
2123			$parent = $this.parent(),
2124			$toggleBlock = $parent.find('.toggle-block'),
2125			animationTime = 200;
2126
2127		if(!$parent.hasClass('active')){
2128			var thisIndex = $parent.index();
2129
2130			$this.closest('.tabs').find('.nav-tabs>li').removeClass('active');
2131			$this.closest('.tabs').find('.nav-tabs>li').eq(thisIndex).addClass('active');
2132			$this.closest('.tab-content').find('.toggle-block').slideUp(animationTime);
2133			$this.closest('.tab-content').find('.tab-pane').removeClass('active');
2134			$this.closest('.tab-content').find('.title-tab-heading .btn').each(function(){
2135				if($(this).hasClass('opened') || $(this).hasClass('open')){
2136					$(this).removeClass('opened open').addClass('closed');
2137				}
2138			});
2139			$this.closest('.tab-content').find('.title-tab-heading .btn').removeClass('opened open').addClass('closed');
2140			$this.find('.btn').removeClass('closed').addClass('opened');
2141			$toggleBlock.slideDown(animationTime, function(){
2142				$parent.addClass('active');
2143				var offsetTop = $this.offset().top;
2144
2145				$('html, body').animate({scrollTop: offsetTop}, 200);
2146			});
2147		}
2148		else{
2149			$this.find('.btn').removeClass('opened open').addClass('closed');
2150			$toggleBlock.slideUp(animationTime, function(){
2151				$parent.removeClass('active');
2152			});
2153		}
2154	});
2155
2156	// Responsive Menu Events
2157	var addActiveClass = false;
2158	$('#mainMenu li.dropdown > a > i, #mainMenu li.dropdown-submenu > a > i').on('click', function(e){
2159		e.preventDefault();
2160		if($(window).width() > 979) return;
2161		addActiveClass = $(this).closest('li').hasClass('resp-active');
2162		// $('#mainMenu').find('.resp-active').removeClass('resp-active');
2163		if(!addActiveClass){
2164			$(this).closest("li").addClass("resp-active");
2165		}else{
2166			$(this).closest("li").removeClass("resp-active");
2167		}
2168	});
2169
2170	/*animate increment*/
2171	$('.spincrement').counterUp({
2172		delay: 160,
2173    	time: 750,
2174	});
2175
2176	$('.bx_filter_input_container input[type=text]').numeric({allow:"."});
2177
2178	/* search sync */
2179	$(document).on('keyup', '.search-input-div input', function(e){
2180		var inputValue = $(this).val();
2181		$('.search-input-div input').val(inputValue);
2182
2183		if($(this).closest('#headerfixed').length)
2184		{
2185			if(e.keyCode == 13)
2186				$('.search form').submit();
2187		}
2188	});
2189	$(document).on('click', '.search-button-div button', function(e){
2190		if($(this).closest('#headerfixed').length)
2191			$('.search form').submit();
2192	});
2193
2194	$('.inline-search-show, .inline-search-hide').on('click', function(e){
2195		if(window.matchMedia('(min-width: 600px)').matches)
2196		{
2197			if(typeof($(this).data('type_search')) != 'undefined' && $(this).data('type_search') == 'fixed')
2198				$('.inline-search-block').addClass('fixed');
2199
2200			$('.inline-search-block').toggleClass('show');
2201
2202			if(arMedc2Options['THEME']['TYPE_SEARCH'] != 'fixed')
2203			{
2204				var height_block = 0;
2205				if(!$('header > .top-block').length)
2206				{
2207					height_block = $('.inline-search-block.fixed.show .search-wrapper').actual('outerHeight');//$(this).closest('.maxwidth-theme').actual('outerHeight');
2208					console.log(height_block);
2209					if($(this).closest('.top-block').length)
2210						height_block = $(this).closest('.top-block').actual('outerHeight');
2211					else if($(this).closest('header.header-v8').length)
2212						height_block = $(this).closest('header.header-v8').actual('outerHeight');
2213					/*$('.inline-search-block').css({
2214						'height': height_block,
2215						'line-height': height_block-4+'px',
2216						'top': -height_block
2217					})*/
2218				}
2219			}
2220
2221
2222
2223			if($('.inline-search-block').hasClass('show')){
2224				$('.inline-search-block').find('.search-input').focus();
2225			}
2226
2227			if($('.top-block').length)
2228			{
2229				if($('.inline-search-block').hasClass('show'))
2230					$('.inline-search-block').css('background', $('.top-block').css('background-color'));
2231				else
2232					$('.inline-search-block').css('background', '#fff');
2233			}
2234			if(arMedc2Options['THEME']['TYPE_SEARCH'] == 'fixed')
2235			{
2236				if($('.inline-search-block').hasClass('show'))
2237					$('<div class="jqmOverlay search"></div>').appendTo('body');
2238				else
2239					$('.jqmOverlay').detach();
2240			}
2241		}
2242		else
2243			location.href = arMedc2Options['SITE_DIR'] + 'search/';
2244	})
2245
2246	if($('.styled-block .row > div.col-md-3').length){
2247		BX.addCustomEvent('onWindowResize', function(eventdata) {
2248			try{
2249				ignoreResize.push(true);
2250				$('.styled-block .row > div.col-md-3').each(function() {
2251					$(this).css({'height': '', 'line-height': ''});
2252					var z = parseInt($('.body_media').css('top'));
2253					if(z > 0){
2254						var rowHeight = $(this).parents('.row').first().actual('outerHeight');
2255						$(this).css({'height': rowHeight + 'px', 'line-height' : rowHeight + 'px'});
2256					}
2257				});
2258			}
2259			catch(e){}
2260			finally{
2261				ignoreResize.pop();
2262			}
2263		});
2264	}
2265
2266	if($('.order-block').length){
2267		BX.addCustomEvent('onWindowResize', function(eventdata) {
2268			try{
2269				ignoreResize.push(true);
2270				$('.order-block').each(function() {
2271					var cols = $(this).find('.row > div');
2272					if(cols.length){
2273						var colFirst = cols.first();
2274						var colLast = cols.last();
2275						var colText = colFirst.find('.text');
2276						var bText = colText.length;
2277						var bOnlyText = cols.length === 1 && bText;
2278						var bPrice = colFirst.find('.price').length;
2279						var z = parseInt($('.body_media').css('top'));
2280
2281						cols.css({'height': '', 'padding-top': '', 'padding-bottom': ''});
2282						colText.css({'height': '', 'padding-top': '', 'padding-bottom': ''});
2283						if((!bPrice && z > 0) || (bPrice && z > 1)){
2284							var minHeight = 83;
2285
2286							if(!bOnlyText){
2287								var colLast_height = colLast.outerHeight();
2288								colLast_height = colLast_height >= minHeight ? colLast_height : minHeight;
2289							}
2290
2291							if(bText){
2292								var colFirst_height = colFirst.outerHeight();
2293								colFirst_height = colFirst_height >= minHeight ? colFirst_height : minHeight;
2294							}
2295
2296							var colMax_height = (bText ? (!bOnlyText ? (colLast_height >= colFirst_height ? colLast_height : colFirst_height) : colLast_height) : colFirst_height);
2297
2298							if(!bOnlyText){
2299								var textPadding = 41 + (colMax_height - colFirst.outerHeight()) / 2;
2300								colLast.find('.btns').css({'padding-top': textPadding + 'px', 'padding-bottom': textPadding + 'px', 'height': colMax_height + 'px'});
2301							}
2302							if(bText){
2303								colLast.css({'height': colMax_height + 'px'});
2304								var textPadding = 41 + (colMax_height - colText.outerHeight()) / 2;
2305								colText.css({'padding-top': textPadding + 'px', 'padding-bottom': textPadding + 'px', 'height': colMax_height + 'px'});
2306							}
2307						}
2308					}
2309				});
2310			}
2311			catch(e){}
2312			finally{
2313				ignoreResize.pop();
2314			}
2315		});
2316	}
2317
2318	if($('.equal-padding').length)
2319	{
2320		BX.addCustomEvent('onWindowResize', function(eventdata){
2321			try{
2322				ignoreResize.push(true);
2323				$('.equal-padding').each(function() {
2324					$(this).find('.text').css({'padding-top': '0px', 'padding-bottom': '0px'});
2325					var equal_block = $(this).siblings('.equals'),
2326						height = $(this).actual('outerHeight');
2327
2328					delta = Math.round((equal_block.actual('outerHeight') - height)/2);
2329					if(delta)
2330						$(this).find('.text').css({'padding-top': delta+'px', 'padding-bottom': delta+'px'});
2331				})
2332			}
2333			catch(e){}
2334			finally{
2335				ignoreResize.pop();
2336			}
2337		});
2338	}
2339
2340	$(document).on('click', '.mega-menu .dropdown-menu', function(e){
2341		e.stopPropagation()
2342	});
2343
2344	$(document).on('click', '.mega-menu .dropdown-toggle.more-items', function(e){
2345		e.preventDefault();
2346	});
2347
2348	$('.table-menu .dropdown,.table-menu .dropdown-submenu,.table-menu .dropdown-toggle').on('mouseenter', function() {
2349		CheckTopVisibleMenu();
2350	});
2351
2352	$('.mega-menu .search-item .search-icon, .menu-row #title-search .fa-close').on('click', function(e) {
2353		e.preventDefault();
2354		$('.menu-row #title-search').toggleClass('hide');
2355	});
2356
2357	$('.mega-menu ul.nav .search input').on('keyup', function(e) {
2358		var inputValue = $(this).val();
2359		$('.menu-row > .search input').val(inputValue);
2360		if(e.keyCode == 13){
2361			$('.menu-row > .search form').submit();
2362		}
2363	});
2364
2365	$('.menu-row > .search input').on('keyup', function(e) {
2366		var inputValue = $(this).val();
2367		$('.mega-menu ul.nav .search input').val(inputValue);
2368		if(e.keyCode == 13){
2369			$('.menu-row > .search form').submit();
2370		}
2371	});
2372
2373	$('.mega-menu ul.nav .search button').on('click', function(e) {
2374		e.preventDefault();
2375		var inputValue = $(this).parents('.search').find('input').val();
2376		$('.menu-and-search .search input').val(inputValue);
2377		$('.menu-row > .search form').submit();
2378	});
2379
2380	$('.filter .calendar').on('click', function() {
2381		var button = $(this).next();
2382		if(button.hasClass('calendar-icon')){
2383			button.trigger('click');
2384		}
2385	});
2386
2387	/*sliceheights*/
2388	if($('.banners-small .item.normal-block').length)
2389		$('.banners-small .item.normal-block').sliceHeight();
2390	if($('.sections .item').length)
2391		$('.sections .item').sliceHeight();
2392	if($('.teasers .item').length)
2393		$('.teasers .item').sliceHeight();
2394	if($('.wrap-portfolio-front .row.items > div').length)
2395		$('.wrap-portfolio-front .row.items > div').sliceHeight({'row': '.row.items', 'item': '.item1'});
2396
2397	SliceHeightBlocks();
2398
2399	/* toggle */
2400	var $this = this,
2401		previewParClosedHeight = 25;
2402
2403	$('section.toggle > label').prepend($('<i />').addClass('fa fa-plus'));
2404	$('section.toggle > label').prepend($('<i />').addClass('fa fa-minus'));
2405	$('section.toggle.active > p').addClass('preview-active');
2406	$('section.toggle.active > div.toggle-content').slideDown(350, function() {});
2407
2408	$('section.toggle > label').click(function(e){
2409		var parentSection = $(this).parent(),
2410			parentWrapper = $(this).parents('div.toogle'),
2411			previewPar = false,
2412			isAccordion = parentWrapper.hasClass('toogle-accordion');
2413
2414		if(isAccordion && typeof(e.originalEvent) != 'undefined') {
2415			parentWrapper.find('section.toggle.active > label').trigger('click');
2416		}
2417
2418		parentSection.toggleClass('active');
2419
2420		// Preview Paragraph
2421		if( parentSection.find('> p').get(0) ){
2422			previewPar = parentSection.find('> p');
2423			var previewParCurrentHeight = previewPar.css('height');
2424			previewPar.css('height', 'auto');
2425			var previewParAnimateHeight = previewPar.css('height');
2426			previewPar.css('height', previewParCurrentHeight);
2427		}
2428
2429		// Content
2430		var toggleContent = parentSection.find('> div.toggle-content');
2431
2432		if( parentSection.hasClass('active') ){
2433			$(previewPar).animate({
2434				height: previewParAnimateHeight
2435			}, 350, function() {
2436				$(this).addClass('preview-active');
2437			});
2438			toggleContent.slideDown(350, function() {});
2439		}
2440		else{
2441			$(previewPar).animate({
2442				height: previewParClosedHeight
2443			}, 350, function() {
2444				$(this).removeClass('preview-active');
2445			});
2446			toggleContent.slideUp(350, function() {});
2447		}
2448	});
2449
2450	/* accordion */
2451	$('.accordion-head').on('click', function(e){
2452		e.preventDefault();
2453		if(!$(this).next().hasClass('collapsing')){
2454			$(this).toggleClass('accordion-open');
2455			$(this).toggleClass('accordion-close');
2456		}
2457	});
2458
2459	/* progress bar */
2460	$('[data-appear-progress-animation]').each(function(){
2461		var $this = $(this);
2462		$this.appear(function(){
2463			var delay = ($this.attr('data-appear-animation-delay') ? $this.attr('data-appear-animation-delay') : 1);
2464			if( delay > 1 )
2465				$this.css('animation-delay', delay + 'ms');
2466			$this.addClass($this.attr('data-appear-animation'));
2467
2468			setTimeout(function(){
2469				$this.animate({
2470					width: $this.attr('data-appear-progress-animation')
2471				}, 1500, 'easeOutQuad', function() {
2472					$this.find('.progress-bar-tooltip').animate({
2473						opacity: 1
2474					}, 500, 'easeOutQuad');
2475				});
2476			}, delay);
2477		}
2477, {accX: 0, accY: -50});
2478	});
2479
2480	/* portfolio item */
2481	$('.item.animated-block').appear(function(){
2482		var $this = $(this);
2483
2484		$this.addClass($this.data('animation')).addClass('visible');
2485
2486	}, {accX: 0, accY: 150})
2487
2488	$('a[rel=tooltip]').tooltip();
2489	$('span[data-toggle=tooltip]').tooltip();
2490
2491	$('select.sort').on('change', function(){
2492		location.href = $(this).val();
2493	});
2494
2495	setTimeout(function(th){
2496		$('.catalog.group.list .item').each(function(){
2497			var th = $(this);
2498			if((tmp = th.find('.image').outerHeight() - th.find('.text_info').outerHeight()) > 0){
2499				th.find('.text_info .titles').height(th.find('.text_info .titles').outerHeight() + tmp);
2500			}
2501		})
2502	}, 50);
2503
2504	/* ajax tabs*/
2505	$('.tabs_ajax .head-block .item-link').on('click', function(){
2506		var index = $(this).index(),
2507			body_block = $(this).closest('.tabs_ajax').find('.body-block'),
2508			obQuery = parseUrlQuery(),
2509			url_post = arMedc2Options['SITE_DIR'] + 'include/mainpage/comp_catalog_ajax.php';
2510		$(this).siblings().removeClass('active');
2511		$(this).addClass('active');
2512
2513		if('clear_cache' in obQuery)
2514			url_post += '?clear_cache='+obQuery.clear_cache;
2515
2516		if(!$(this).hasClass('clicked'))
2517		{
2518			$.ajax({
2519				url: url_post,
2520				type: 'POST',
2521				data: {AJAX_POST: 'Y', AJAX_PARAMS: $(this).closest('.item-views.catalog').find('.request-data').data('value'), GLOBAL_FILTER: body_block.find('.item-block:eq('+index+')').data('filter')},
2522			}).success(function(html){
2523				body_block.find('.item-block:eq('+index+')').html(html);
2524
2525				InitFlexSliderClass(body_block.find('.item-block:eq('+index+')').find('.flexslider')); //reinit flexslider
2526
2527				body_block.css('height', body_block.find('.item-block.active').actual('outerHeight'));
2528
2529				body_block.find('.item-block').removeClass('active').removeClass('opacity1').addClass('opacity0');
2530				body_block.find('.item-block:eq('+index+')').addClass('active');
2531
2532				setTimeout(function(){
2533					body_block.css('height', 'auto');
2534
2535					//recalculate height
2536					body_block.find('.item-block:eq('+index+') .catalog.item-views.table .item .title').sliceHeight();
2537					body_block.find('.item-block:eq('+index+') .catalog.item-views.table .item .cont').sliceHeight();
2538					body_block.find('.item-block:eq('+index+') .catalog.item-views.table .item .slice_price').sliceHeight();
2539					body_block.find('.item-block:eq('+index+') .catalog.item-views.table .item').sliceHeight({classNull: '.footer-button'});
2540
2541					body_block.find('.item-block:eq('+index+')').removeClass('opacity0').addClass('opacity1');
2542				},100)
2543			});
2544		}
2545		else
2546		{
2547			body_block.find('.item-block').removeClass('active').removeClass('opacity1').addClass('opacity0');
2548			body_block.find('.item-block:eq('+index+')').addClass('active').removeClass('opacity0').addClass('opacity1');
2549		}
2550		$(this).addClass('clicked');
2551	})
2552
2553	/*item galery*/
2554	$('.thumbs .item a').on('click', function(e){
2555		e.preventDefault();
2556		$('.thumbs .item').removeClass('current');
2557		$(this).closest('.item').toggleClass('current');
2558		$('.slides li' + $(this).attr('href')).addClass('current').siblings().removeClass('current');
2559	});
2560
2561	$('header.fixed .btn-responsive-nav').on('click', function() {
2562		$('html, body').animate({scrollTop: 0}, 400);
2563	});
2564
2565	$('body').on('click', '.form .refresh-page', function(){
2566		location.href = location.href;
2567	});
2568
2569
2570
2571	$(document).on('click', '.basket.fly .opener', function(){
2572		if(window.matchMedia('(max-width: 767px)').matches)
2573			location.href = arMedc2Options['THEME']['URL_BASKET_SECTION'];
2574		else
2575			$(this).closest('.ajax_basket').toggleClass('opened');
2576	})
2577
2578	$(document).on('click', '.basket.fly .close_block', function()
2579	{
2580		$('.basket.fly .opener').trigger('click');
2581	})
2582
2583
2584	if($('.form-control').length){
2585		$('.form-control').each(function(){
2586			var value = $(this).val();
2587
2588			if(value){
2589				$(this).closest('.animated-labels').addClass('input-filed');
2590			}
2591		});
2592	}
2593	/* animated labels */
2594	$(document).on("focus", ".animated-labels input,.animated-labels textarea", function(){
2595		$(this).closest(".animated-labels").addClass("input-filed");
2596	}).on("focusout", ".animated-labels input,.animated-labels textarea", function(){
2597		if("" != $(this).val())
2598			$(this).closest(".animated-labels").addClass("input-filed");
2599		else
2600			$(this).closest(".animated-labels").removeClass("input-filed");
2601	});
2602
2603	$(document).on('click', '.animated-labels select', function(){
2604		var $input = $(this).closest('.animated-labels');
2605
2606		if(!$input.hasClass('input-filed') && !$input.hasClass('changed')){
2607			$(this).closest('.animated-labels').addClass('input-filed');
2608		}
2609
2610		$(this).closest('.animated-labels').removeClass('changed');
2611	});
2612
2613	$(document).on('change', '.animated-labels select', function(){
2614		var value = $(this).val();
2615		if(!value){
2616			$(this).closest('.animated-labels').removeClass('input-filed').addClass('changed');
2617		}
2618	});
2619
2620	$(document).on('blur', '.animated-labels select', function(){
2621		var value = $(this).val();
2622
2623		if(!value){
2624			$(this).closest('.animated-labels').removeClass('input-filed').addClass('changed');
2625		}
2626	});
2627
2628	/* accordion action*/
2629	$('.panel-collapse').on('hidden.bs.collapse', function(){
2630		$(this).parent().toggleClass('opened');
2631	})
2632	$('.panel-collapse').on('show.bs.collapse', function(){
2633		$(this).parent().toggleClass('opened');
2634	})
2635
2636	// MEDC2 BASKET
2637	// - basket fly close
2638	$(document).on('click', function(){
2639		if($('.basket.fly').length && $('.ajax_basket').hasClass('opened')){
2640			$('.ajax_basket').removeClass('opened');
2641		}
2642	});
2643
2644	$(document).on('click', '.basket.fly', function(e){
2645		e.stopPropagation();
2646	});
2647
2648	// - COUNTER
2649	var timerBasketCounter = false;
2650
2651	// -- keyup input
2652	$(document).on('keydown', '.count', function(e){
2653		// Allow: backspace, delete, tab, escape, enter and .
2654		if($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
2655			 // Allow: Ctrl+A, Command+A
2656			(e.keyCode === 65 && (e.ctrlKey === true || e.metaKey === true)) ||
2657			 // Allow: home, end, left, right, down, up
2658			(e.keyCode >= 35 && e.keyCode <= 40)) {
2659				 // let it happen, don't do anything
2660				 return;
2661		}
2662		// Ensure that it is a number and stop the keypress
2663		if((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)){
2664			e.preventDefault();
2665		}
2666	});
2667	$(document).on('keyup', '.count', function(e){
2668		var $this = $(this),
2669			counterInputValueNew = $this.val(),
2670			price = $this.closest('.item').find('input[name=PRICE]').val();
2671
2672		Summ($this, counterInputValueNew, price);
2673	});
2674
2675	// -- scroll after apply option
2676	if($('.instagram_ajax').length)
2677	{
2678		BX.addCustomEvent('onCompleteAction', function(eventdata){
2679			if(eventdata.action === 'instagrammLoaded')
2680				scrollPreviewBlock();
2681		});
2682	}
2683	else
2684		scrollPreviewBlock();
2685
2686	$('select.region').on('change', function(){
2687		var val = parseInt($(this).val());
2688		if($('select.city').length)
2689		{
2690			if(val)
2691			{
2692				$('select.city').removeAttr('disabled');
2693				$('select.city option').hide();
2694				$('select.city option[data-parent_section='+val+']').show();
2695			}
2696			else
2697				$('select.city').attr('disabled', 'disabled');
2698		}
2699	})
2700
2701	$('select.city, select.region').on('change', function(){
2702		var _this = $(this),
2703			val = parseInt(_this.val());
2704		if(_this.hasClass('region'))
2705		{
2706			$('select.city option:eq(0)').show();
2707			$('select.city').val(0);
2708		}
2709
2710		if((_this.hasClass('region') && !val) || _this.hasClass('city'))
2711		{
2712			$.ajax({
2713				type: 'POST',
2714				data: {ID: val},
2715			}).success(function(html){
2716				var ob = BX.processHTML(html);
2717				$('.ajax_items')[0].innerHTML = ob.HTML;
2718				BX.ajax.processScripts(ob.SCRIPT);
2719			})
2720		}
2721	})
2722
2723	// -- blur input
2724	$(document).on('blur', '.count', function(){
2725		BasketCounter($(this));
2726	});
2727
2728	// -- click minus, plus button
2729	$(document).on('click', '.minus, .plus', function(e){
2730		e.stopPropagation();
2731		BasketCounter($(this));
2732	});
2733
2734	// - Add2Basket
2735	$(document).on('click', '.to_cart', function(e){
2736		e.stopPropagation();
2737		var item = $(this).closest('[data-item]'),
2738			_this = $(this),
2739			itemData = item.data('item'),
2740			buyBlock = item.find('.buy_block'),
2741			counter = buyBlock.find('.counter'),
2742			buttonToCart = buyBlock.find('.to_cart'),
2743			itemQuantity = parseFloat(buttonToCart.data('quantity')),
2744			countItem = ($('.basket').length ? parseInt($('.basket .count').text()) : parseInt($('.basket_top:visible .count').text()));
2745
2746		$('.basket_top .count').text(countItem + 1).removeClass('empted');
2747		$('.basket .count').text(countItem + 1).removeClass('empted');
2748
2749		if(typeof(arMedc2Options['THEME']['ORDER_BASKET_VIEW']) !== 'undefined')
2750		{
2751			if($.trim(arMedc2Options['THEME']['ORDER_BASKET_VIEW']) === 'HEADER' && $('.basket_top').length)
2752				var bBasketTop = true;
2753			else if($('.basket.fly').length)
2754				var bBasketFly = true;
2755		}
2756
2757		if(isNaN(itemQuantity) || itemQuantity <= 0){
2758			itemQuantity = 1;
2759		}
2760
2761		if(!isNaN(itemData.ID) && parseInt(itemData.ID) > 0){
2762			buyBlock.addClass('in');
2763
2764			$.ajax({
2765				url: arMedc2Options['SITE_DIR'] + 'include/footer/site-basket.php',
2766				type: 'POST',
2767				data: {itemData: itemData, quantity: itemQuantity},
2768			}).success(function(html){
2769				var eventdata = {action:'loadForm'};
2770				BX.onCustomEvent('onCompleteAction', [eventdata, _this[0]]);
2771
2772				if(bBasketTop){
2773					$('.ajax_basket').html(html);
2774					var eventdata = {action:'loadBasket'};
2775					BX.onCustomEvent('onCompleteAction', [eventdata, $('.ajax_basket')[0]]);
2776				}
2777
2778				if(bBasketFly){
2779					if($('.basket.fly').length){
2780						$('.ajax_basket').html(html);
2781						setTimeout(function(){
2782							if(!$('.ajax_basket').hasClass('opened')){
2783								$('.ajax_basket').addClass('opened');
2784							}
2785						}, 50);
2786					}
2787				}
2788
2789				if(arMedc2Options['THEME']['USE_SALE_GOALS'] != 'N')
2790				{
2791					var eventdata = {goal: 'goal_basket_add', params: {itemData: itemData, quantity: itemQuantity}};
2792					BX.onCustomEvent('onCounterGoals', [eventdata]);
2793				}
2794			});
2795		}
2796		else{
2797			return;
2798		}
2799	});
2800
2801	// - Remove9Basket
2802	$(document).on('click', '.remove', function(){
2803		var item = $(this).closest('[data-item]'),
2804			itemData = item.data('item'),
2805			bRemove = 'Y',
2806			bRemoveAll = ($.trim($(this).closest('[data-remove_all]').data('remove_all')) === 'Y' ? 'Y' : false);
2807			getCurUri = $.trim($('input[name=getPageUri]').val()),
2808			countItem = ($('.basket').length ? parseInt($('.basket .item').length) : parseInt($('.basket_top:visible .item').length)),
2809			bOneItem = (countItem - 1 <= 0),
2810			scrollTop = ($('.basket.fly').length ? $('.basket.fly .items_wrap').scrollTop() : ($('.basket_top:visible').length ? $('.basket_top .items:visible').scrollTop() : ''));
2811
2812		var _ajax = function(){
2813			$.ajax({
2814				url: arMedc2Options['SITE_DIR'] + 'include/footer/site-basket.php',
2815				data: {itemData: itemData, remove: bRemove, removeAll: bRemoveAll},
2816			}).success(function(html){
2817
2818				if(bBasketTop){
2819					$('.ajax_basket').html(html);
2820					$('.basket_top .items').scrollTop(scrollTop);
2821				}
2822
2823				if(getCurUri){
2824					$.ajax({
2825						url: getCurUri,
2826						type: 'POST',
2827					}).success(function(html){
2828						if($('.basket.default').length){
2829							$('.basket.default').html(html);
2830						}
2831					});
2832				}
2833
2834				if(bBasketFly){
2835					$('.ajax_basket').html(html);
2836					$('.ajax_basket').addClass('opened');
2837					$('.basket.fly .items_wrap').scrollTop(scrollTop);
2838				}
2839
2840				if(arMedc2Options['THEME']['USE_SALE_GOALS'] != 'N')
2841				{
2842					var eventdata = {goal: 'goal_basket_remove', params: {itemData: itemData, remove: bRemove, removeAll: bRemoveAll}};
2843					BX.onCustomEvent('onCounterGoals', [eventdata]);
2844				}
2845			});
2846		}
2847
2848		if(typeof(arMedc2Options['THEME']['ORDER_BASKET_VIEW']) !== 'undefined')
2849		{
2850			if($.trim(arMedc2Options['THEME']['ORDER_BASKET_VIEW']) === 'HEADER' && $('.basket_top').length)
2851				var bBasketTop = true;
2852			else if($('.basket.fly').length)
2853				var bBasketFly = true;
2854		}
2855
2856		if(typeof(itemData) !== 'undefined' && (!isNaN(itemData.ID) && itemData.ID > 0) || bRemoveAll){
2857			if(bRemoveAll){
2858				$('.buy_block').removeClass('in');
2859				$('.basket .count').text(0).addClass('empted');
2860				$('.basket_top .count').text(0).addClass('empted');
2861				$('#mobilemenu .menu .ready .count').text(0).addClass('empted');
2862			}
2863			else{
2864				$('[data-item]').each(function(){
2865					if($(this).data('item').ID == itemData.ID){
2866						$(this).find('.buy_block').removeClass('in');
2867					}
2868				});
2869				if($('.basket').length){
2870					if($('.basket_top .count').length)
2871						$('.basket_top .count').text(parseFloat($('.basket_top:visible .count').text()) - 1);
2872					else
2873					{
2874						$('.basket .count').text(parseFloat($('.basket .count').text()) - 1);
2875						$('.basket_top .count').text(parseFloat($('.basket .count').text()) - 1);
2876					}
2877				}
2878				else{
2879					$('.basket_top .count').text(parseFloat($('.basket_top:visible .count').text()) - 1);
2880				}
2881
2882				$('#mobilemenu .menu .ready .count').text(parseFloat($('#mobilemenu .menu .ready .count').text()) - 1);
2883			}
2884
2885			if(bOneItem && !bRemoveAll){
2886				if(item.closest('.basket_top').length){
2887					item.closest('.dropdown').animate({opacity: 0}, 200, function(){
2888						_ajax();
2889					});
2890				}
2891				else{
2892					item.closest('.basket').find('.count').addClass('empted');
2893					item.closest('.basket_wrap').fadeOut(200, function(){
2894						item.closest('.basket').find('.basket_empty').fadeIn(200, function(){
2895							_ajax();
2896						});
2897					});
2898				}
2899			}
2900			else if(bRemoveAll){
2901				$('.basket_wrap').fadeOut(200, function(){
2902					$('.remove.all').remove();
2903					$('.basket').find('.basket_empty').fadeIn(200, function(){
2904						_ajax();
2905					});
2906				});
2907			}
2908			else if(!bOneItem){
2909				item.animate({opacity: 0}, 200).slideUp(200, function(){
2910					_ajax();
2911				});
2912			}
2913		}
2914		else{
2915			return;
2916		}
2917	});
2918	$(document).on('click', '.print', function(){
2919		window.print();
2920	});
2921
2922	$('.choise').on('click', function(){
2923		var _this = $(this);
2924		if(typeof(_this.data('block')) != 'undefined')
2925		{
2926			scrollToBlock(_this.data('block'));
2927		}
2928	});
2929
2930	if($('#bx-composite-banner .bx-composite-btn').length){
2931		$('footer .confidentiality').css('padding-right', '236px');
2932		$('footer.footer-v2 .menu-bottom-wrap').css('padding-left', '226px');
2933		$('footer.footer-v3 .menu-bottom-wrap').css('padding-left', '226px');
2934	}
2935});
2936
2937scrollPreviewBlock = function(){
2938	if(typeof($.cookie('scoll_block')) != 'undefined' && $.cookie('scoll_block'))
2939	{
2940		var scoll_block = $($.cookie('scoll_block'));
2941		if(scoll_block.length)
2942		{
2943			$('body, html').animate({scrollTop: scoll_block.offset().top}, 500);
2944			$.cookie('scoll_block', null);
2945		}
2946	}
2947}
2948
2949scrollToBlock = function(block){
2950	if($(block).length)
2951	{
2952		var offset = $(block).offset().top;
2953		if(typeof($(block).data('toggle')) != 'undefined')
2954			$(block).click();
2955
2956		if(typeof($(block).data('offset')) != 'undefined')
2957			offset += $(block).data('offset');
2958		$('body, html').animate({scrollTop: offset}, 500);
2959	}
2960}
2961
2962// START VIDEO BUTTON
2963$(document).on('click', '.banners-big .item .btn-video', function(){
2964	$(this).addClass('loading');
2965	$(this).closest('.item').addClass('loading');
2966	startMainBannerSlideVideo($(this).closest('.item'));
2967});
2968
2969//MEDC2 BASKET
2970function number_format(number, decimals, dec_point, thousands_sep) {
2971	number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
2972	var n = !isFinite(+number) ? 0 : +number,
2973	prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
2974	sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
2975	dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
2976	s = '',
2977	toFixedFix = function(n, prec){
2978		var k = Math.pow(10, prec);
2979		return '' + (Math.round(n*k)/k).toFixed(prec);
2980	};
2981
2982	// Fix for IE parseFloat(0.55).toFixed(0) = 0;
2983	s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
2984
2985	if (s[0].length > 3) {
2986		s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
2987	}
2988
2989	if ((s[1] || '')
2990		.length < prec) {
2991		s[1] = s[1] || '';
2992		s[1] += new Array(prec - s[1].length + 1).join('0');
2993	}
2994
2995	return s.join(dec);
2996}
2997
2998
2999setBasketItemsClasses = function(){
3000	if(typeof(arBasketItems) !== 'undefined' && typeof(arBasketItems) !== 'string'){
3001		if(Object.keys(arBasketItems).length){
3002			for(var key in arBasketItems){
3003				$('[data-item]').each(function(){
3004					if($(this).data('item').ID == key){
3005						$(this).find('.buy_block').addClass('in');
3006					}
3007				});
3008			}
3009		}
3010	}
3011}
3012
3013function Summ(el, counterInputValueNew, price){
3014	if(counterInputValueNew <= 0){
3015		counterInputValueNew = 1;
3016	}
3017
3018	var summ = number_format(counterInputValueNew*price, 0, '.', ' '),
3019		allSumm = 0;
3020
3021	el.closest('.items').find('.item').each(function(){
3022		var $this = $(this),
3023			price = parseFloat($this.find('input[name=PRICE]').val()),
3024			count =  parseFloat($this.find('input.count').val());
3025
3026		if(count <= 0){
3027			count = 1;
3028		}
3029
3030		if(!isNaN(price) && !isNaN(count)){
3031			allSumm += count*price;
3032		}
3033	});
3034
3035	allSumm = number_format(parseFloat(allSumm), 0, '.', ' ');
3036
3037	el.closest('.item').find('.summ .price_val').text(summ);
3038	el.closest('.basket').find('.foot .total>span').text(allSumm);
3039}
3040
3041var timerBasketUpdate = false;
3042// - COUNTER
3043BasketCounter = function(el){
3044	var elClass = $.trim(el.attr('class')),
3045		bClassMinus = (elClass.indexOf('minus') > -1),
3046		bClassPlus = (elClass.indexOf('plus') > -1),
3047		bClassCount = (elClass.indexOf('count') > -1),
3048		getCurUri = $.trim($('input[name=getPageUri]').val()),
3049		buyBlock = el.closest('.buy_block'),
3050		buttonToCart = buyBlock.find('.to_cart'),
3051		counterInput = el.closest('.counter').find('input.count'),
3052		counterInputValue = parseFloat($.trim(counterInput.val())),
3053		price = parseFloat(buyBlock.find('input[name=PRICE]').val()),
3054		counterInputMaxCount = Math.pow(10, parseInt(counterInput.attr('maxlength'))) - 1;
3055
3056	// class minus button
3057	if(bClassMinus){
3058		var counterInputValueNew = counterInputValue - 1;
3059
3060		if(counterInputValueNew <= 0){
3061			counterInputValueNew = 1;
3062		}
3063
3064		counterInput.val(counterInputValueNew);
3065
3066		Summ(el, counterInputValueNew, price);
3067
3068		if(timerBasketUpdate){
3069			clearTimeout(timerBasketUpdate);
3070			timerBasketUpdate = false;
3071		}
3072
3073		timerBasketUpdate = setTimeout(function(){
3074			BasketUpdate(el, counterInputValueNew);
3075			timerBasketUpdate = false;
3076		}, 700);
3077	}
3078	// class plus button
3079	else if(bClassPlus){
3080		var counterInputValueNew = counterInputValue + 1;
3081
3082		if(counterInputValueNew > counterInputMaxCount){
3083			counterInputValueNew = counterInputMaxCount;
3084		}
3085
3086		counterInput.val(counterInputValueNew);
3087		Summ(el, counterInputValueNew, price);
3088
3089		if(timerBasketUpdate){
3090			clearTimeout(timerBasketUpdate);
3091			timerBasketUpdate = false;
3092		}
3093
3094		timerBasketUpdate = setTimeout(function(){
3095			BasketUpdate(el, counterInputValueNew);
3096			timerBasketUpdate = false;
3097		}, 700);
3098	}
3099	// class input
3100	else if(bClassCount){
3101		var counterInputValueNew = counterInputValue;
3102
3103		if(counterInputValueNew <= 0 || isNaN(counterInputValueNew)){
3104			counterInputValueNew = 1;
3105		}
3106		el.val(counterInputValueNew);
3107		BasketUpdate(el, counterInputValueNew);
3108	}
3109
3110	if(!getCurUri && !el.closest('.basket.fly').length){
3111		buttonToCart.data('quantity', counterInputValueNew);
3112	}
3113}
3114
3115BasketUpdate = function(el, counterInputValueNew){
3116	var	itemData = el.closest('[data-item]').data('item'),
3117		itemData = (typeof(arBasketItems) === 'object' && typeof(arBasketItems[itemData.ID]) === 'object' ? arBasketItems[itemData.ID] : itemData),
3118		buyBlock = el.closest('.buy_block'),
3119		buttonToCart = buyBlock.find('.to_cart'),
3120		getCurUri = $.trim($('input[name=getPageUri]').val())
3121		scrollTop = ($('.basket.fly').length ? $('.basket.fly .items_wrap').scrollTop() : ($('.basket_top:visible').length ? $('.basket_top .items:visible').scrollTop() : ''));
3122
3123	if(typeof(arMedc2Options['THEME']['ORDER_BASKET_VIEW']) !== 'undefined' && $.trim(arMedc2Options['THEME']['ORDER_BASKET_VIEW']) === 'FLY' && $('.basket.fly').length){
3124		var bBasketFly = true;
3125	}
3126
3127	if(typeof(arMedc2Options['THEME']['ORDER_BASKET_VIEW']) !== 'undefined' && $.trim(arMedc2Options['THEME']['ORDER_BASKET_VIEW']) === 'HEADER' && $('.basket_top').length){
3128		var bBasketTop = true;
3129	}
3130
3131	else{
3132		if(typeof(itemData) != 'undefined' && !isNaN(itemData.ID) && itemData.ID > 0){
3133			$.ajax({
3134				// url: arMedc2Options['SITE_DIR'] + 'ajax/basket_items.php',
3135				url: arMedc2Options['SITE_DIR'] + 'include/footer/site-basket.php',
3136				data: {itemData: itemData, quantity: counterInputValueNew},
3137			}).success(function(data){
3138				if(typeof(data) === 'object'){
3139					arBasketItems = data;
3140				}
3141				if(bBasketTop){
3142					$.ajax({
3143						url: arMedc2Options['SITE_DIR'] + 'include/footer/site-basket.php',
3144						type: 'POST',
3145						data: {'ajaxPost': 'Y'},
3146					}).success(function(html){
3147						buyBlock.removeClass('in');
3148						$('.ajax_basket').html(html);
3149
3150						/*if(!getCurUri){
3151							setTimeout(function(){
3152								$('.basket_top .dropdown').addClass('expanded');
3153							}, 100);
3154
3155							setTimeout(function(){
3156								$('.basket_top .dropdown').removeClass('expanded');
3157							}, 1000);
3158						}*/
3159					});
3160				}
3161
3162				if(bBasketFly){
3163					$.ajax({
3164						url: arMedc2Options['SITE_DIR'] + 'include/footer/site-basket.php',
3165						type: 'POST',
3166						data: {'ajaxPost': 'Y'},
3167					}).success(function(html){
3168						if($('.basket.fly').length){
3169							$('.ajax_basket').html(html);
3170							$('.basket.fly .items_wrap').scrollTop(scrollTop);
3171						}
3172					});
3173				}
3174
3175				if(getCurUri){
3176					$.ajax({
3177						url: getCurUri,
3178						type: 'POST',
3179					}).success(function(html){
3180						if($('.basket.default').length){
3181							$('.basket.default').html(html);
3182						}
3183					});
3184				}
3185			});
3186		}
3187		else{
3188			return;
3189		}
3190	}
3191}
3192
3193CheckTabActive = function(){
3194	if(typeof(clicked_tab) && clicked_tab)
3195	{
3196		if(window.matchMedia('(min-width: 768px)').matches)
3197		{
3198			clicked_tab--;
3199			$('.catalog.detail .nav.nav-tabs li:eq('+clicked_tab+')').addClass('active');
3200			$('.catalog.detail .tab-content .tab-pane:eq('+clicked_tab+')').addClass('active');
3201			$('.catalog.detail .tab-content .tab-pane .title-tab-heading').next().removeAttr('style');
3202			clicked_tab = 0;
3203		}
3204	}
3205}
3206
3207/* menu marker */
3208markerNav= function(){
3209	/*if($('table td.active .wrap > a').length > 0)
3210	{
3211		$('table td.active .wrap > a').each(function(){
3212			var item = $(this),
3213				itemParentPos = item.closest('td').position().left,
3214				itemPos = item.position().left,
3215				mainPos = itemParentPos + itemPos + parseInt(item.css('padding-left'))
3216				nav = item.closest('.mega-menu').find('.marker-nav');
3217
3218			nav.css('left', mainPos);
3219			if(window.matchMedia('(min-width: 992px)').matches)
3220				nav.css('width', item.find('.line-wrapper').actual('outerWidth'));
3221		})
3222	}
3223	else
3224		$('.marker-nav').css('width', 0);
3225
3226	if(!$('.marker-nav').hasClass('opacity1'))
3227	{
3228		setTimeout(function(){
3229			$('.marker-nav').addClass('opacity1');
3230		}, 100);
3231	}*/
3232}
3233
3234/* parallax bg */
3235ParallaxBg = function(){
3236	if($('*[data-type=parallax-bg]').length)
3237	{
3238		var x = $(window).scrollTop()/$(document).height();
3239		x=parseInt(-x * 280);
3240		$('*[data-type=parallax-bg]').stop().animate({'background-position-y':  x + 'px'}, 400, 'swing');
3241	}
3242}
3243SetFixedAskBlock = function(){
3244	if($('.ask_a_question_wrapper').length)
3245	{
3246		var offset = $('.ask_a_question_wrapper').offset(),
3247			block = $('.ask_a_question_wrapper').find('.ask_a_question'),
3248			block_offset = BX.pos(block[0]),
3249			block_height = block_offset.bottom-block_offset.top,
3250			diff_top_scroll = $('#headerfixed').height() + 20;
3251
3252		if(/*offset.top+*/block_height+130 > block.closest('.fixed_wrapper').height())
3253			block.addClass('nonfixed');
3254		else
3255			block.removeClass('nonfixed');
3256
3257		if($('footer').length && block_height+diff_top_scroll+documentScrollTopLast + 130 > $('footer').offset().top)
3258		{
3259			block.removeClass('fixed').css({'top': 'auto', 'width': 'auto', 'bottom': 0});
3260			block.parent().css('position', 'static');
3261			block.parent().parent().css('position', 'static');
3262		}
3263		else
3264		{
3265			block.parent().removeAttr('style');
3266			block.parent().parent().removeAttr('style');
3267
3268			if(documentScrollTopLast + diff_top_scroll > offset.top)
3269				block.addClass('fixed').css({'top': diff_top_scroll, 'bottom': 'auto', 'width': $('.fixed_block_fix').width()});
3270			else
3271				block.removeClass('fixed').css({'top': 0, 'width': $('.fixed_block_fix').width()});
3272		}
3273	}
3274}
3275
3276
3277// Events
3278var timerScroll = false, ignoreScroll = [], documentScrollTopLast = $(document).scrollTop();
3279var bMenuResize = false;
3280$(window).scroll(function(){
3281	CheckPopupTop();
3282	SetFixedAskBlock();
3283	if(!ignoreScroll.length){
3284		if(timerScroll){
3285			clearTimeout(timerScroll);
3286			timerScroll = false;
3287		}
3288		timerScroll = setTimeout(function(){
3289			BX.onCustomEvent('onWindowScroll', false);
3290		}, 100);
3291	}
3292	documentScrollTopLast = $(document).scrollTop();
3293
3294	if($('#headerfixed').hasClass('fixed') && !bMenuResize){
3295		$(window).resize();
3296		bMenuResize = true;
3297	}
3298	else if(!$('#headerfixed').hasClass('fixed')){
3299		bMenuResize = false;
3300	}
3301});
3302
3303var timerResize = false, ignoreResize = [];
3304
3305$(window).resize(function(){
3306	CheckBodyPadding();
3307	CheckPopupTop();
3308	CheckScrollToTop();
3309	if(!ignoreResize.length){
3310		if(timerResize){
3311			clearTimeout(timerResize);
3312			timerResize = false;
3313		}
3314		timerResize = setTimeout(function(){
3315			BX.onCustomEvent('onWindowResize', false);
3316		}, 100);
3317	}
3318	documentScrollTopLast = $(document).scrollTop();
3319});
3320
3321BX.addCustomEvent('onWindowScroll', function(eventdata) {
3322	try{
3323		ignoreScroll.push(true);
3324		ParallaxBg();
3325
3326		if(arMedc2Options['THEME']['TYPE_SEARCH'] != 'fixed')
3327		{
3328			if(!$('header > .top-block').length)
3329			{
3330				var height_block = 0,
3331					scrollVal = $(window).scrollTop();
3332				height_block = $('.logo_and_menu-row').actual('outerHeight');
3333				if(!scrollVal)
3334				{
3335					$('.inline-search-block').css({
3336						'height': height_block,
3337						'line-height': height_block-4+'px',
3338						'top': -height_block
3339					})
3340				}
3341			}
3342		}
3343
3344	}
3345	catch(e){}
3346	finally{
3347		ignoreScroll.pop();
3348	}
3349});
3350
3351BX.addCustomEvent('onWindowResize', function(eventdata) {
3352	try{
3353		ignoreResize.push(true);
3354
3355		CheckHeaderFixedMenu();
3356		CheckTopMenuDotted();
3357		CheckTopVisibleMenu();
3358		CheckFlexSlider();
3359		CheckMainBannerSliderVText($('.banners-big .flexslider'));
3360		CheckMainBannerSliderVText($('.banners-content .maxwidth-banner'));
3361		CheckObjectsSizes();
3362		verticalAlign();
3363		CheckTabActive();
3364		setTimeout(function(){
3365			createTableCompare($('.main-block .items .title-block:not(.clone) .item'), $('.prop_title_table'), $('.main-block .prop_title_table .item.clone'));
3366		}, 100);
3367		SliceHeightBlocks();
3368	}
3369	catch(e){}
3370	finally{
3371		ignoreResize.pop();
3372	}
3373});
3374
3375BX.addCustomEvent('onSliderStart', function(eventdata) {
3376	try{
3377		ignoreResize.push(true);
3378		if(eventdata){
3379			var slider = eventdata.slider;
3380			if(slider){
3381				if(slider.closest('.staff-type-2').length){
3382					var sliderHeight = slider.outerHeight(true, true) - 3;
3383
3384					//$parent.height(parentHeight);
3385					slider.height(sliderHeight);
3386					slider.find('.flex-viewport').height(sliderHeight);
3387
3388					slider.find('.flex-viewport').data('height', sliderHeight + 1);
3389					slider.find('.item').each(function(){
3390						var deltaSliderHeight = $(this).find('.bottom-block').outerHeight();
3391						$(this).data('delta_height', deltaSliderHeight);
3392					});
3393
3394					$(slider).each(function(){
3395						if($(this).closest('.staff-type-2').length){
3396							HoverStaffSliderItem($(this).closest('.staff-type-2'));
3397						}
3398					});
3399				}
3400			}
3401		}
3402	}
3403	catch(e){}
3404	finally{
3405		ignoreResize.pop();
3406	}
3407})
3408
3409BX.addCustomEvent('onSlide', function(eventdata) {
3410	try{
3411		ignoreResize.push(true);
3412		if(eventdata){
3413			var slider = eventdata.slider;
3414			if(slider){
3415				// add classes .curent & .shown to slide
3416				slider.find('.item').removeClass('current');
3417				var curSlide = slider.find('.item.flex-active-slide');
3418				var curSlideId = curSlide.attr('id');
3419				curSlide.addClass('current');
3420
3421				slider.find('.item').css('opacity', '1');
3422
3423				if(curSlide.hasClass('shown')){
3424					slider.find('.item.clone[id=' + curSlideId + '_clone]').addClass('shown');
3425				}
3426
3427				curSlide.addClass('shown');
3428				//slider.resize();
3429
3430				// set main banners text vertical center
3431				CheckMainBannerSliderVText(slider);
3432
3433				//video
3434				var videoAutoPlay = curSlide.attr('data-video_autoplay')
3435				var bVideoAutoPlay = videoAutoPlay == 1
3436
3437				if(typeof(window["players"]) == 'object' && curSlide.length) // pause video
3438				{
3439					for(var j in window["players"])
3440					{
3441						var curVideoSlide = $('iframe[id='+window["players"][j].id+']').closest('.item'),
3442							videoPlayer = curVideoSlide.attr('data-video_player'),
3443							bVideoPlayerYoutube = videoPlayer === 'YOUTUBE',
3444							bVideoPlayerVimeo = videoPlayer === 'VIMEO';
3445
3446						if(!curVideoSlide.hasClass('current') && bVideoPlayerYoutube)
3447						{
3448							window[window["players"][j].id].pauseVideo();
3449						}
3450					}
3451				}
3452
3453				if(bVideoAutoPlay){
3454					startMainBannerSlideVideo(curSlide)
3455				}
3456				if(!slider.find('.flex-control-nav li').length && slider.hasClass('normal'))
3457				{
3458					slider.find('.flex-direction-nav li a').addClass('flex-disabled');
3459				}
3460
3461				if(!slider.hasClass('flexslider-init-slice') && slider.hasClass('nav-title') && $('.gallery-block').closest('.tab-pane').hasClass('active'))
3462				{
3463					slider.find('.item').sliceHeight({'lineheight': -3});
3464					slider.addClass('flexslider-init-slice');
3465				}
3466				if(slider.find('.flex-direction-nav').length){
3467					if(slider.find('.flex-direction-nav').find('a.flex-disabled').length)
3468						slider.find('.flex-direction-nav').removeClass('opacity1').addClass('opacity0');
3469					else
3470						slider.find('.flex-direction-nav').removeClass('opacity0').addClass('opacity1');
3471				}
3472
3473				if(slider.closest('.galerys-block').find('.title.big-gallery').length){
3474					var indexActiveSlide = slider.data('flexslider').currentSlide + 1;
3475					slider.closest('.galerys-block').find('.title.big-gallery .slide-number').text(indexActiveSlide);
3476				}
3477			}
3478		}
3479	}
3480	catch(e){}
3481	finally{
3482		ignoreResize.pop();
3483	}
3484});
3485
3486BX.addCustomEvent('onSlideEnd', function(eventdata) {
3487	try{
3488		ignoreResize.push(true);
3489		if(eventdata){
3490			var slider = eventdata.slider;
3491			if(slider){
3492
3493			}
3494		}
3495	}
3496	catch(e){}
3497	finally{
3498		ignoreResize.pop();
3499	}
3500});
3501
3502$(window).resize(function(){
3503	SetFixedAskBlock();
3504	CheckTopMenuPadding();
3505	CheckTopMenuOncePadding();
3506	CheckSearchWidth();
3507
3508
3509	$('.flexslider').each(function(indx){
3510		var $this = $(this);
3511		setTimeout(function(){
3512			var pluginOptions = $this.data('plugin-options'),
3513				indexActiveSlide = $this.data('flexslider').currentSlide,
3514				sliderHeight = $this.find('.item').eq(indexActiveSlide).outerHeight(true, true);
3515
3516			if(pluginOptions.smoothHeight === true){
3517				$this.find('.flex-viewport').height(sliderHeight);
3518			}
3519		}, 300);
3520	});
3521
3522	if(window.matchMedia('(min-width: 768px)').matches){
3523		$('.detail .tabs').each(function(){
3524			var $this = $(this),
3525				indexTabActive = $this.find('.nav-tabs li.active').index();
3526
3527			$this.find('.tab-pane').eq(indexTabActive).addClass('active');
3528			$this.find('.tab-pane').eq(indexTabActive).find('.toggle-block').show();
3529		});
3530	}
3531	else{
3532		$('.detail .tabs').each(function(){
3533			var $this = $(this),
3534				indexTabActive = $this.find('.nav-tabs li.active').index();
3535
3536			$this.find('.tab-pane').each(function(indx){
3537				if($(this).index() != indexTabActive){
3538					$(this).remove('active');
3539					$(this).find('.toggle-block').hide();
3540				}
3541			});
3542		});
3543	}
3544});

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.