PageSourceSearch

https://www.aib.ru/bitrix/cache/js/s1/aib_flex/template_c4b6104dbc…31ff0399b5138ab4be62_v1.js?1790052522179002

js aib.ru collected 2026-09-24 22:14:51 UTC 179,002 bytes, 3,419 lines download raw bytes

vendor: 15,255 bytes, lines 1-471
1
2; /* Start:"a:4:{s:4:"full";s:72:"/bitrix/templates/aib_flex/js/jquery.mCustomScrollbar.js?172535148392949";s:6:"source";s:56:"/bitrix/templates/aib_flex/js/jquery.mCustomScrollbar.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/
3/*
4== malihu jquery custom scrollbar plugin == 
5Version: 3.1.5 
6Plugin URI: http://manos.malihu.gr/jquery-custom-content-scroller 
7Author: malihu
8Author URI: http://manos.malihu.gr
9License: MIT License (MIT)
10*/
11
12/*
13Copyright Manos Malihutsakis (email: [email protected])
14
15Permission is hereby granted, free of charge, to any person obtaining a copy
16of this software and associated documentation files (the "Software"), to deal
17in the Software without restriction, including without limitation the rights
18to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19copies of the Software, and to permit persons to whom the Software is
20furnished to do so, subject to the following conditions:
21
22The above copyright notice and this permission notice shall be included in
23all copies or substantial portions of the Software.
24
25THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31THE SOFTWARE.
32*/
33
34/*
35The code below is fairly long, fully commented and should be normally used in development. 
36For production, use either the minified jquery.mCustomScrollbar.min.js script or 
37the production-ready jquery.mCustomScrollbar.concat.min.js which contains the plugin 
38and dependencies (minified). 
39*/
40
41(function(factory){
42	if(typeof define==="function" && define.amd){
43		define(["jquery"],factory);
44	}else if(typeof module!=="undefined" && module.exports){
45		module.exports=factory;
46	}else{
47		factory(jQuery,window,document);
48	}
49}(function($){
50(function(init){
51	var _rjs=typeof define==="function" && define.amd, /* RequireJS */
52		_njs=typeof module !== "undefined" && module.exports, /* NodeJS */
53		_dlp=("https:"==document.location.protocol) ? "https:" : "http:", /* location protocol */
54		_url="cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.13/jquery.mousewheel.min.js";
55	if(!_rjs){
56		if(_njs){
57			require("jquery-mousewheel")($);
58		}else{
59			/* load jquery-mousewheel plugin (via CDN) if it's not present or not loaded via RequireJS 
60			(works when mCustomScrollbar fn is called on window load) */
61			$.event.special.mousewheel || $("head").append(decodeURI("%3Cscript src="+_dlp+"//"+_url+"%3E%3C/script%3E"));
62		}
63	}
64	init();
65}(function(){
66	
67	/* 
68	----------------------------------------
69	PLUGIN NAMESPACE, PREFIX, DEFAULT SELECTOR(S) 
70	----------------------------------------
71	*/
72	
73	var pluginNS="mCustomScrollbar",
74		pluginPfx="mCS",
75		defaultSelector=".mCustomScrollbar",
76	
77	
78		
79	
80	
81	/* 
82	----------------------------------------
83	DEFAULT OPTIONS 
84	----------------------------------------
85	*/
86	
87		defaults={
88			/*
89			set element/content width/height programmatically 
90			values: boolean, pixels, percentage 
91				option						default
92				-------------------------------------
93				setWidth					false
94				setHeight					false
95			*/
96			/*
97			set the initial css top property of content  
98			values: string (e.g. "-100px", "10%" etc.)
99			*/
100			setTop:0,
101			/*
102			set the initial css left property of content  
103			values: string (e.g. "-100px", "10%" etc.)
104			*/
105			setLeft:0,
106			/* 
107			scrollbar axis (vertical and/or horizontal scrollbars) 
108			values (string): "y", "x", "yx"
109			*/
110			axis:"y",
111			/*
112			position of scrollbar relative to content  
113			values (string): "inside", "outside" ("outside" requires elements with position:relative)
114			*/
115			scrollbarPosition:"inside",
116			/*
117			scrolling inertia
118			values: integer (milliseconds)
119			*/
120			scrollInertia:950,
121			/* 
122			auto-adjust scrollbar dragger length
123			values: boolean
124			*/
125			autoDraggerLength:true,
126			/*
127			auto-hide scrollbar when idle 
128			values: boolean
129				option						default
130				-------------------------------------
131				autoHideScrollbar			false
132			*/
133			/*
134			auto-expands scrollbar on mouse-over and dragging
135			values: boolean
136				option						default
137				-------------------------------------
138				autoExpandScrollbar			false
139			*/
140			/*
141			always show scrollbar, even when there's nothing to scroll 
142			values: integer (0=disable, 1=always show dragger rail and buttons, 2=always show dragger rail, dragger and buttons), boolean
143			*/
144			alwaysShowScrollbar:0,
145			/*
146			scrolling always snaps to a multiple of this number in pixels
147			values: integer, array ([y,x])
148				option						default
149				-------------------------------------
150				snapAmount					null
151			*/
152			/*
153			when snapping, snap with this number in pixels as an offset 
154			values: integer
155			*/
156			snapOffset:0,
157			/* 
158			mouse-wheel scrolling
159			*/
160			mouseWheel:{
161				/* 
162				enable mouse-wheel scrolling
163				values: boolean
164				*/
165				enable:true,
166				/* 
167				scrolling amount in pixels
168				values: "auto", integer 
169				*/
170				scrollAmount:"auto",
171				/* 
172				mouse-wheel scrolling axis 
173				the default scrolling direction when both vertical and horizontal scrollbars are present 
174				values (string): "y", "x" 
175				*/
176				axis:"y",
177				/* 
178				prevent the default behaviour which automatically scrolls the parent element(s) when end of scrolling is reached 
179				values: boolean
180					option						default
181					-------------------------------------
182					preventDefault				null
183				*/
184				/*
185				the reported mouse-wheel delta value. The number of lines (translated to pixels) one wheel notch scrolls.  
186				values: "auto", integer 
187				"auto" uses the default OS/browser value 
188				*/
189				deltaFactor:"auto",
190				/*
191				normalize mouse-wheel delta to -1 or 1 (disables mouse-wheel acceleration) 
192				values: boolean
193					option						default
194					-------------------------------------
195					normalizeDelta				null
196				*/
197				/*
198				invert mouse-wheel scrolling direction 
199				values: boolean
200					option						default
201					-------------------------------------
202					invert						null
203				*/
204				/*
205				the tags that disable mouse-wheel when cursor is over them
206				*/
207				disableOver:["select","option","keygen","datalist","textarea"]
208			},
209			/* 
210			scrollbar buttons
211			*/
212			scrollButtons:{ 
213				/*
214				enable scrollbar buttons
215				values: boolean
216					option						default
217					-------------------------------------
218					enable						null
219				*/
220				/*
221				scrollbar buttons scrolling type 
222				values (string): "stepless", "stepped"
223				*/
224				scrollType:"stepless",
225				/*
226				scrolling amount in pixels
227				values: "auto", integer 
228				*/
229				scrollAmount:"auto"
230				/*
231				tabindex of the scrollbar buttons
232				values: false, integer
233					option						default
234					-------------------------------------
235					tabindex					null
236				*/
237			},
238			/* 
239			keyboard scrolling
240			*/
241			keyboard:{ 
242				/*
243				enable scrolling via keyboard
244				values: boolean
245				*/
246				enable:true,
247				/*
248				keyboard scrolling type 
249				values (string): "stepless", "stepped"
250				*/
251				scrollType:"stepless",
252				/*
253				scrolling amount in pixels
254				values: "auto", integer 
255				*/
256				scrollAmount:"auto"
257			},
258			/*
259			enable content touch-swipe scrolling 
260			values: boolean, integer, string (number)
261			integer values define the axis-specific minimum amount required for scrolling momentum
262			*/
263			contentTouchScroll:25,
264			/*
265			enable/disable document (default) touch-swipe scrolling 
266			*/
267			documentTouchScroll:true,
268			/*
269			advanced option parameters
270			*/
271			advanced:{
272				/*
273				auto-expand content horizontally (for "x" or "yx" axis) 
274				values: boolean, integer (the value 2 forces the non scrollHeight/scrollWidth method, the value 3 forces the scrollHeight/scrollWidth method)
275					option						default
276					-------------------------------------
277					autoExpandHorizontalScroll	null
278				*/
279				/*
280				auto-scroll to elements with focus
281				*/
282				autoScrollOnFocus:"input,textarea,select,button,datalist,keygen,a[tabindex],area,object,[contenteditable='true']",
283				/*
284				auto-update scrollbars on content, element or viewport resize 
285				should be true for fluid layouts/elements, adding/removing content dynamically, hiding/showing elements, content with images etc. 
286				values: boolean
287				*/
288				updateOnContentResize:true,
289				/*
290				auto-update scrollbars each time each image inside the element is fully loaded 
291				values: "auto", boolean
292				*/
293				updateOnImageLoad:"auto",
294				/*
295				auto-update scrollbars based on the amount and size changes of specific selectors 
296				useful when you need to update the scrollbar(s) automatically, each time a type of element is added, removed or changes its size 
297				values: boolean, string (e.g. "ul li" will auto-update scrollbars each time list-items inside the element are changed) 
298				a value of true (boolean) will auto-update scrollbars each time any element is changed
299					option						default
300					-------------------------------------
301					updateOnSelectorChange		null
302				*/
303				/*
304				extra selectors that'll allow scrollbar dragging upon mousemove/up, pointermove/up, touchend etc. (e.g. "selector-1, selector-2")
305					option						default
306					-------------------------------------
307					extraDraggableSelectors		null
308				*/
309				/*
310				extra selectors that'll release scrollbar dragging upon mouseup, pointerup, touchend etc. (e.g. "selector-1, selector-2")
311					option						default
312					-------------------------------------
313					releaseDraggableSelectors	null
314				*/
315				/*
316				auto-update timeout 
317				values: integer (milliseconds)
318				*/
319				autoUpdateTimeout:60
320			},
321			/* 
322			scrollbar theme 
323			values: string (see CSS/plugin URI for a list of ready-to-use themes)
324			*/
325			theme:"light",
326			/*
327			user defined callback functions
328			*/
329			callbacks:{
330				/*
331				Available callbacks: 
332					callback					default
333					-------------------------------------
334					onCreate					null
335					onInit						null
336					onScrollStart				null
337					onScroll					null
338					onTotalScroll				null
339					onTotalScrollBack			null
340					whileScrolling				null
341					onOverflowY					null
342					onOverflowX					null
343					onOverflowYNone				null
344					onOverflowXNone				null
345					onImageLoad					null
346					onSelectorChange			null
347					onBeforeUpdate				null
348					onUpdate					null
349				*/
350				onTotalScrollOffset:0,
351				onTotalScrollBackOffset:0,
352				alwaysTriggerOffsets:true
353			}
354			/*
355			add scrollbar(s) on all elements matching the current selector, now and in the future 
356			values: boolean, string 
357			string values: "on" (enable), "once" (disable after first invocation), "off" (disable)
358			liveSelector values: string (selector)
359				option						default
360				-------------------------------------
361				live						false
362				liveSelector				null
363			*/
364		},
365	
366	
367	
368	
369	
370	/* 
371	----------------------------------------
372	VARS, CONSTANTS 
373	----------------------------------------
374	*/
375	
376		totalInstances=0, /* plugin instances amount */
377		liveTimers={}, /* live option timers */
378		oldIE=(window.attachEvent && !window.addEventListener) ? 1 : 0, /* detect IE < 9 */
379		touchActive=false,touchable, /* global touch vars (for touch and pointer events) */
380		/* general plugin classes */
381		classes=[
382			"mCSB_dragger_onDrag","mCSB_scrollTools_onDrag","mCS_img_loaded","mCS_disabled","mCS_destroyed","mCS_no_scrollbar",
383			"mCS-autoHide","mCS-dir-rtl","mCS_no_scrollbar_y","mCS_no_scrollbar_x","mCS_y_hidden","mCS_x_hidden","mCSB_draggerContainer",
384			"mCSB_buttonUp","mCSB_buttonDown","mCSB_buttonLeft","mCSB_buttonRight"
385		],
386		
387	
388	
389	
390	
391	/* 
392	----------------------------------------
393	METHODS 
394	----------------------------------------
395	*/
396	
397		methods={
398			
399			/* 
400			plugin initialization method 
401			creates the scrollbar(s), plugin data object and options
402			----------------------------------------
403			*/
404			
405			init:function(options){
406				
407				var options=$.extend(true,{},defaults,options),
408					selector=_selector.call(this); /* validate selector */
409				
410				/* 
411				if live option is enabled, monitor for elements matching the current selector and 
412				apply scrollbar(s) when found (now and in the future) 
413				*/
414				if(options.live){
415					var liveSelector=options.liveSelector || this.selector || defaultSelector, /* live selector(s) */
416						$liveSelector=$(liveSelector); /* live selector(s) as jquery object */
417					if(options.live==="off"){
418						/* 
419						disable live if requested 
420						usage: $(selector).mCustomScrollbar({live:"off"}); 
421						*/
422						removeLiveTimers(liveSelector);
423						return;
424					}
425					liveTimers[liveSelector]=setTimeout(function(){
426						/* call mCustomScrollbar fn on live selector(s) every half-second */
427						$liveSelector.mCustomScrollbar(options);
428						if(options.live==="once" && $liveSelector.length){
429							/* disable live after first invocation */
430							removeLiveTimers(liveSelector);
431						}
432					},500);
433				}else{
434					removeLiveTimers(liveSelector);
435				}
436				
437				/* options backward compatibility (for versions < 3.0.0) and normalization */
438				options.setWidth=(options.set_width) ? options.set_width : options.setWidth;
439				options.setHeight=(options.set_height) ? options.set_height : options.setHeight;
440				options.axis=(options.horizontalScroll) ? "x" : _findAxis(options.axis);
441				options.scrollInertia=options.scrollInertia>0 && options.scrollInertia<17 ? 17 : options.scrollInertia;
442				if(typeof options.mouseWheel!=="object" &&  options.mouseWheel==true){ /* old school mouseWheel option (non-object) */
443					options.mouseWheel={enable:true,scrollAmount:"auto",axis:"y",preventDefault:false,deltaFactor:"auto",normalizeDelta:false,invert:false}
444				}
445				options.mouseWheel.scrollAmount=!options.mouseWheelPixels ? options.mouseWheel.scrollAmount : options.mouseWheelPixels;
446				options.mouseWheel.normalizeDelta=!options.advanced.normalizeMouseWheelDelta ? options.mouseWheel.normalizeDelta : options.advanced.normalizeMouseWheelDelta;
447				options.scrollButtons.scrollType=_findScrollButtonsType(options.scrollButtons.scrollType); 
448				
449				_theme(options); /* theme-specific options */
450				
451				/* plugin constructor */
452				return $(selector).each(function(){
453					
454					var $this=$(this);
455					
456					if(!$this.data(pluginPfx)){ /* prevent multiple instantiations */
457					
458						/* store options and create objects in jquery data */
459						$this.data(pluginPfx,{
460							idx:++totalInstances, /* instance index */
461							opt:options, /* options */
462							scrollRatio:{y:null,x:null}, /* scrollbar to content ratio */
463							overflowed:null, /* overflowed axis */
464							contentReset:{y:null,x:null}, /* object to check when content resets */
465							bindEvents:false, /* object to check if events are bound */
466							tweenRunning:false, /* object to check if tween is running */
467							sequential:{}, /* sequential scrolling object */
468							langDir:$this.css("direction"), /* detect/store direction (ltr or rtl) */
469							cbOffsets:null, /* object to check whether callback offsets always trigger */
470							/* 
471							object to check how scrolling events where last triggered 
472							"internal" (default - triggered by this script), "external" (triggered by other scripts, e.g. via scrollTo method) 
473							usage: object.data("mCS").trigger
474							*/
475							trigger:null,
476							/* 
477							object to check for changes in elements in order to call the update method automatically 
478							*/
479							poll:{size:{o:0,n:0},img:{o:0,n:0},change:{o:0,n:0}}
480						});
481						
482						var d=$this.data(pluginPfx),o=d.opt,
483							/* HTML data attributes */
484							htmlDataAxis=$this.data("mcs-axis"),htmlDataSbPos=$this.data("mcs-scrollbar-position"),htmlDataTheme=$this.data("mcs-theme");
485						 
486						if(htmlDataAxis){o.axis=htmlDataAxis;} /* usage example: data-mcs-axis="y" */
487						if(htmlDataSbPos){o.scrollbarPosition=htmlDataSbPos;} /* usage example: data-mcs-scrollbar-position="outside" */
488						if(htmlDataTheme){ /* usage example: data-mcs-theme="minimal" */
489							o.theme=htmlDataTheme;
490							_theme(o); /* theme-specific options */
491						}
492						
493						_pluginMarkup.call(this); /* add plugin markup */
494						
495						if(d && o.callbacks.onCreate && typeof o.callbacks.onCreate==="function"){o.callbacks.onCreate.call(this);} /* callbacks: onCreate */
496						
497						$("#mCSB_"+d.idx+"_container img:not(."+classes[2]+")").addClass(classe
vendor: 73,065 bytes, lines 497-2364
497s[2]); /* flag loaded images */
498						
499						methods.update.call(null,$this); /* call the update method */
500					
501					}
502					
503				});
504				
505			},
506			/* ---------------------------------------- */
507			
508			
509			
510			/* 
511			plugin update method 
512			updates content and scrollbar(s) values, events and status 
513			----------------------------------------
514			usage: $(selector).mCustomScrollbar("update");
515			*/
516			
517			update:function(el,cb){
518				
519				var selector=el || _selector.call(this); /* validate selector */
520				
521				return $(selector).each(function(){
522					
523					var $this=$(this);
524					
525					if($this.data(pluginPfx)){ /* check if plugin has initialized */
526						
527						var d=$this.data(pluginPfx),o=d.opt,
528							mCSB_container=$("#mCSB_"+d.idx+"_container"),
529							mCustomScrollBox=$("#mCSB_"+d.idx),
530							mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")];
531						
532						if(!mCSB_container.length){return;}
533						
534						if(d.tweenRunning){_stop($this);} /* stop any running tweens while updating */
535						
536						if(cb && d && o.callbacks.onBeforeUpdate && typeof o.callbacks.onBeforeUpdate==="function"){o.callbacks.onBeforeUpdate.call(this);} /* callbacks: onBeforeUpdate */
537						
538						/* if element was disabled or destroyed, remove class(es) */
539						if($this.hasClass(classes[3])){$this.removeClass(classes[3]);}
540						if($this.hasClass(classes[4])){$this.removeClass(classes[4]);}
541						
542						/* css flexbox fix, detect/set max-height */
543						mCustomScrollBox.css("max-height","none");
544						if(mCustomScrollBox.height()!==$this.height()){mCustomScrollBox.css("max-height",$this.height());}
545						
546						_expandContentHorizontally.call(this); /* expand content horizontally */
547						
548						if(o.axis!=="y" && !o.advanced.autoExpandHorizontalScroll){
549							mCSB_container.css("width",_contentWidth(mCSB_container));
550						}
551						
552						d.overflowed=_overflowed.call(this); /* determine if scrolling is required */
553						
554						_scrollbarVisibility.call(this); /* show/hide scrollbar(s) */
555						
556						/* auto-adjust scrollbar dragger length analogous to content */
557						if(o.autoDraggerLength){_setDraggerLength.call(this);}
558						
559						_scrollRatio.call(this); /* calculate and store scrollbar to content ratio */
560						
561						_bindEvents.call(this); /* bind scrollbar events */
562						
563						/* reset scrolling position and/or events */
564						var to=[Math.abs(mCSB_container[0].offsetTop),Math.abs(mCSB_container[0].offsetLeft)];
565						if(o.axis!=="x"){ /* y/yx axis */
566							if(!d.overflowed[0]){ /* y scrolling is not required */
567								_resetContentPosition.call(this); /* reset content position */
568								if(o.axis==="y"){
569									_unbindEvents.call(this);
570								}else if(o.axis==="yx" && d.overflowed[1]){
571									_scrollTo($this,to[1].toString(),{dir:"x",dur:0,overwrite:"none"});
572								}
573							}else if(mCSB_dragger[0].height()>mCSB_dragger[0].parent().height()){
574								_resetContentPosition.call(this); /* reset content position */
575							}else{ /* y scrolling is required */
576								_scrollTo($this,to[0].toString(),{dir:"y",dur:0,overwrite:"none"});
577								d.contentReset.y=null;
578							}
579						}
580						if(o.axis!=="y"){ /* x/yx axis */
581							if(!d.overflowed[1]){ /* x scrolling is not required */
582								_resetContentPosition.call(this); /* reset content position */
583								if(o.axis==="x"){
584									_unbindEvents.call(this);
585								}else if(o.axis==="yx" && d.overflowed[0]){
586									_scrollTo($this,to[0].toString(),{dir:"y",dur:0,overwrite:"none"});
587								}
588							}else if(mCSB_dragger[1].width()>mCSB_dragger[1].parent().width()){
589								_resetContentPosition.call(this); /* reset content position */
590							}else{ /* x scrolling is required */
591								_scrollTo($this,to[1].toString(),{dir:"x",dur:0,overwrite:"none"});
592								d.contentReset.x=null;
593							}
594						}
595						
596						/* callbacks: onImageLoad, onSelectorChange, onUpdate */
597						if(cb && d){
598							if(cb===2 && o.callbacks.onImageLoad && typeof o.callbacks.onImageLoad==="function"){
599								o.callbacks.onImageLoad.call(this);
600							}else if(cb===3 && o.callbacks.onSelectorChange && typeof o.callbacks.onSelectorChange==="function"){
601								o.callbacks.onSelectorChange.call(this);
602							}else if(o.callbacks.onUpdate && typeof o.callbacks.onUpdate==="function"){
603								o.callbacks.onUpdate.call(this);
604							}
605						}
606						
607						_autoUpdate.call(this); /* initialize automatic updating (for dynamic content, fluid layouts etc.) */
608						
609					}
610					
611				});
612				
613			},
614			/* ---------------------------------------- */
615			
616			
617			
618			/* 
619			plugin scrollTo method 
620			triggers a scrolling event to a specific value
621			----------------------------------------
622			usage: $(selector).mCustomScrollbar("scrollTo",value,options);
623			*/
624		
625			scrollTo:function(val,options){
626				
627				/* prevent silly things like $(selector).mCustomScrollbar("scrollTo",undefined); */
628				if(typeof val=="undefined" || val==null){return;}
629				
630				var selector=_selector.call(this); /* validate selector */
631				
632				return $(selector).each(function(){
633					
634					var $this=$(this);
635					
636					if($this.data(pluginPfx)){ /* check if plugin has initialized */
637					
638						var d=$this.data(pluginPfx),o=d.opt,
639							/* method default options */
640							methodDefaults={
641								trigger:"external", /* method is by default triggered externally (e.g. from other scripts) */
642								scrollInertia:o.scrollInertia, /* scrolling inertia (animation duration) */
643								scrollEasing:"mcsEaseInOut", /* animation easing */
644								moveDragger:false, /* move dragger instead of content */
645								timeout:60, /* scroll-to delay */
646								callbacks:true, /* enable/disable callbacks */
647								onStart:true,
648								onUpdate:true,
649								onComplete:true
650							},
651							methodOptions=$.extend(true,{},methodDefaults,options),
652							to=_arr.call(this,val),dur=methodOptions.scrollInertia>0 && methodOptions.scrollInertia<17 ? 17 : methodOptions.scrollInertia;
653						
654						/* translate yx values to actual scroll-to positions */
655						to[0]=_to.call(this,to[0],"y");
656						to[1]=_to.call(this,to[1],"x");
657						
658						/* 
659						check if scroll-to value moves the dragger instead of content. 
660						Only pixel values apply on dragger (e.g. 100, "100px", "-=100" etc.) 
661						*/
662						if(methodOptions.moveDragger){
663							to[0]*=d.scrollRatio.y;
664							to[1]*=d.scrollRatio.x;
665						}
666						
667						methodOptions.dur=_isTabHidden() ? 0 : dur; //skip animations if browser tab is hidden
668						
669						setTimeout(function(){ 
670							/* do the scrolling */
671							if(to[0]!==null && typeof to[0]!=="undefined" && o.axis!=="x" && d.overflowed[0]){ /* scroll y */
672								methodOptions.dir="y";
673								methodOptions.overwrite="all";
674								_scrollTo($this,to[0].toString(),methodOptions);
675							}
676							if(to[1]!==null && typeof to[1]!=="undefined" && o.axis!=="y" && d.overflowed[1]){ /* scroll x */
677								methodOptions.dir="x";
678								methodOptions.overwrite="none";
679								_scrollTo($this,to[1].toString(),methodOptions);
680							}
681						},methodOptions.timeout);
682						
683					}
684					
685				});
686				
687			},
688			/* ---------------------------------------- */
689			
690			
691			
692			/*
693			plugin stop method 
694			stops scrolling animation
695			----------------------------------------
696			usage: $(selector).mCustomScrollbar("stop");
697			*/
698			stop:function(){
699				
700				var selector=_selector.call(this); /* validate selector */
701				
702				return $(selector).each(function(){
703					
704					var $this=$(this);
705					
706					if($this.data(pluginPfx)){ /* check if plugin has initialized */
707										
708						_stop($this);
709					
710					}
711					
712				});
713				
714			},
715			/* ---------------------------------------- */
716			
717			
718			
719			/*
720			plugin disable method 
721			temporarily disables the scrollbar(s) 
722			----------------------------------------
723			usage: $(selector).mCustomScrollbar("disable",reset); 
724			reset (boolean): resets content position to 0 
725			*/
726			disable:function(r){
727				
728				var selector=_selector.call(this); /* validate selector */
729				
730				return $(selector).each(function(){
731					
732					var $this=$(this);
733					
734					if($this.data(pluginPfx)){ /* check if plugin has initialized */
735						
736						var d=$this.data(pluginPfx);
737						
738						_autoUpdate.call(this,"remove"); /* remove automatic updating */
739						
740						_unbindEvents.call(this); /* unbind events */
741						
742						if(r){_resetContentPosition.call(this);} /* reset content position */
743						
744						_scrollbarVisibility.call(this,true); /* show/hide scrollbar(s) */
745						
746						$this.addClass(classes[3]); /* add disable class */
747					
748					}
749					
750				});
751				
752			},
753			/* ---------------------------------------- */
754			
755			
756			
757			/*
758			plugin destroy method 
759			completely removes the scrollbar(s) and returns the element to its original state
760			----------------------------------------
761			usage: $(selector).mCustomScrollbar("destroy"); 
762			*/
763			destroy:function(){
764				
765				var selector=_selector.call(this); /* validate selector */
766				
767				return $(selector).each(function(){
768					
769					var $this=$(this);
770					
771					if($this.data(pluginPfx)){ /* check if plugin has initialized */
772					
773						var d=$this.data(pluginPfx),o=d.opt,
774							mCustomScrollBox=$("#mCSB_"+d.idx),
775							mCSB_container=$("#mCSB_"+d.idx+"_container"),
776							scrollbar=$(".mCSB_"+d.idx+"_scrollbar");
777					
778						if(o.live){removeLiveTimers(o.liveSelector || $(selector).selector);} /* remove live timers */
779						
780						_autoUpdate.call(this,"remove"); /* remove automatic updating */
781						
782						_unbindEvents.call(this); /* unbind events */
783						
784						_resetContentPosition.call(this); /* reset content position */
785						
786						$this.removeData(pluginPfx); /* remove plugin data object */
787						
788						_delete(this,"mcs"); /* delete callbacks object */
789						
790						/* remove plugin markup */
791						scrollbar.remove(); /* remove scrollbar(s) first (those can be either inside or outside plugin's inner wrapper) */
792						mCSB_container.find("img."+classes[2]).removeClass(classes[2]); /* remove loaded images flag */
793						mCustomScrollBox.replaceWith(mCSB_container.contents()); /* replace plugin's inner wrapper with the original content */
794						/* remove plugin classes from the element and add destroy class */
795						$this.removeClass(pluginNS+" _"+pluginPfx+"_"+d.idx+" "+classes[6]+" "+classes[7]+" "+classes[5]+" "+classes[3]).addClass(classes[4]);
796					
797					}
798					
799				});
800				
801			}
802			/* ---------------------------------------- */
803			
804		},
805	
806	
807	
808	
809		
810	/* 
811	----------------------------------------
812	FUNCTIONS
813	----------------------------------------
814	*/
815	
816		/* validates selector (if selector is invalid or undefined uses the default one) */
817		_selector=function(){
818			return (typeof $(this)!=="object" || $(this).length<1) ? defaultSelector : this;
819		},
820		/* -------------------- */
821		
822		
823		/* changes options according to theme */
824		_theme=function(obj){
825			var fixedSizeScrollbarThemes=["rounded","rounded-dark","rounded-dots","rounded-dots-dark"],
826				nonExpandedScrollbarThemes=["rounded-dots","rounded-dots-dark","3d","3d-dark","3d-thick","3d-thick-dark","inset","inset-dark","inset-2","inset-2-dark","inset-3","inset-3-dark"],
827				disabledScrollButtonsThemes=["minimal","minimal-dark"],
828				enabledAutoHideScrollbarThemes=["minimal","minimal-dark"],
829				scrollbarPositionOutsideThemes=["minimal","minimal-dark"];
830			obj.autoDraggerLength=$.inArray(obj.theme,fixedSizeScrollbarThemes) > -1 ? false : obj.autoDraggerLength;
831			obj.autoExpandScrollbar=$.inArray(obj.theme,nonExpandedScrollbarThemes) > -1 ? false : obj.autoExpandScrollbar;
832			obj.scrollButtons.enable=$.inArray(obj.theme,disabledScrollButtonsThemes) > -1 ? false : obj.scrollButtons.enable;
833			obj.autoHideScrollbar=$.inArray(obj.theme,enabledAutoHideScrollbarThemes) > -1 ? true : obj.autoHideScrollbar;
834			obj.scrollbarPosition=$.inArray(obj.theme,scrollbarPositionOutsideThemes) > -1 ? "outside" : obj.scrollbarPosition;
835		},
836		/* -------------------- */
837		
838		
839		/* live option timers removal */
840		removeLiveTimers=function(selector){
841			if(liveTimers[selector]){
842				clearTimeout(liveTimers[selector]);
843				_delete(liveTimers,selector);
844			}
845		},
846		/* -------------------- */
847		
848		
849		/* normalizes axis option to valid values: "y", "x", "yx" */
850		_findAxis=function(val){
851			return (val==="yx" || val==="xy" || val==="auto") ? "yx" : (val==="x" || val==="horizontal") ? "x" : "y";
852		},
853		/* -------------------- */
854		
855		
856		/* normalizes scrollButtons.scrollType option to valid values: "stepless", "stepped" */
857		_findScrollButtonsType=function(val){
858			return (val==="stepped" || val==="pixels" || val==="step" || val==="click") ? "stepped" : "stepless";
859		},
860		/* -------------------- */
861		
862		
863		/* generates plugin markup */
864		_pluginMarkup=function(){
865			var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
866				expandClass=o.autoExpandScrollbar ? " "+classes[1]+"_expand" : "",
867				scrollbar=["<div id='mCSB_"+d.idx+"_scrollbar_vertical' class='mCSB_scrollTools mCSB_"+d.idx+"_scrollbar mCS-"+o.theme+" mCSB_scrollTools_vertical"+expandClass+"'><div class='"+classes[12]+"'><div id='mCSB_"+d.idx+"_dragger_vertical' class='mCSB_dragger' style='position:absolute;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>","<div id='mCSB_"+d.idx+"_scrollbar_horizontal' class='mCSB_scrollTools mCSB_"+d.idx+"_scrollbar mCS-"+o.theme+" mCSB_scrollTools_horizontal"+expandClass+"'><div class='"+classes[12]+"'><div id='mCSB_"+d.idx+"_dragger_horizontal' class='mCSB_dragger' style='position:absolute;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>"],
868				wrapperClass=o.axis==="yx" ? "mCSB_vertical_horizontal" : o.axis==="x" ? "mCSB_horizontal" : "mCSB_vertical",
869				scrollbars=o.axis==="yx" ? scrollbar[0]+scrollbar[1] : o.axis==="x" ? scrollbar[1] : scrollbar[0],
870				contentWrapper=o.axis==="yx" ? "<div id='mCSB_"+d.idx+"_container_wrapper' class='mCSB_container_wrapper' />" : "",
871				autoHideClass=o.autoHideScrollbar ? " "+classes[6] : "",
872				scrollbarDirClass=(o.axis!=="x" && d.langDir==="rtl") ? " "+classes[7] : "";
873			if(o.setWidth){$this.css("width",o.setWidth);} /* set element width */
874			if(o.setHeight){$this.css("height",o.setHeight);} /* set element height */
875			o.setLeft=(o.axis!=="y" && d.langDir==="rtl") ? "989999px" : o.setLeft; /* adjust left position for rtl direction */
876			$this.addClass(pluginNS+" _"+pluginPfx+"_"+d.idx+autoHideClass+scrollbarDirClass).wrapInner("<div id='mCSB_"+d.idx+"' class='mCustomScrollBox mCS-"+o.theme+" "+wrapperClass+"'><div id='mCSB_"+d.idx+"_container' class='mCSB_container' style='position:relative; top:"+o.setTop+"; left:"+o.setLeft+";' dir='"+d.langDir+"' /></div>");
877			var mCustomScrollBox=$("#mCSB_"+d.idx),
878				mCSB_container=$("#mCSB_"+d.idx+"_container");
879			if(o.axis!=="y" && !o.advanced.autoExpandHorizontalScroll){
880				mCSB_container.css("width",_contentWidth(mCSB_container));
881			}
882			if(o.scrollbarPosition==="outside"){
883				if($this.css("position")==="static"){ /* requires elements with non-static position */
884					$this.css("position","relative");
885				}
886				$this.css("overflow","visible");
887				mCustomScrollBox.addClass("mCSB_outside").after(scrollbars);
888			}else{
889				mCustomScrollBox.addClass("mCSB_inside").append(scrollbars);
890				mCSB_container.wrap(contentWrapper);
891			}
892			_scrollButtons.call(this); /* add scrollbar buttons */
893			/* minimum dragger length */
894			var mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")];
895			mCSB_dragger[0].css("min-height",mCSB_dragger[0].height());
896			mCSB_dragger[1].css("min-width",mCSB_dragger[1].width());
897		},
898		/* -------------------- */
899		
900		
901		/* calculates content width */
902		_contentWidth=function(el){
903			var val=[el[0].scrollWidth,Math.max.apply(Math,el.children().map(function(){return $(this).outerWidth(true);}).get())],w=el.parent().width();
904			return val[0]>w ? val[0] : val[1]>w ? val[1] : "100%";
905		},
906		/* -------------------- */
907		
908		
909		/* expands content horizontally */
910		_expandContentHorizontally=function(){
911			var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
912				mCSB_container=$("#mCSB_"+d.idx+"_container");
913			if(o.advanced.autoExpandHorizontalScroll && o.axis!=="y"){
914				/* calculate scrollWidth */
915				mCSB_container.css({"width":"auto","min-width":0,"overflow-x":"scroll"});
916				var w=Math.ceil(mCSB_container[0].scrollWidth);
917				if(o.advanced.autoExpandHorizontalScroll===3 || (o.advanced.autoExpandHorizontalScroll!==2 && w>mCSB_container.parent().width())){
918					mCSB_container.css({"width":w,"min-width":"100%","overflow-x":"inherit"});
919				}else{
920					/* 
921					wrap content with an infinite width div and set its position to absolute and width to auto. 
922					Setting width to auto before calculating the actual width is important! 
923					We must let the browser set the width as browser zoom values are impossible to calculate.
924					*/
925					mCSB_container.css({"overflow-x":"inherit","position":"absolute"})
926						.wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />")
927						.css({ /* set actual width, original position and un-wrap */
928							/* 
929							get the exact width (with decimals) and then round-up. 
930							Using jquery outerWidth() will round the width value which will mess up with inner elements that have non-integer width
931							*/
932							"width":(Math.ceil(mCSB_container[0].getBoundingClientRect().right+0.4)-Math.floor(mCSB_container[0].getBoundingClientRect().left)),
933							"min-width":"100%",
934							"position":"relative"
935						}).unwrap();
936				}
937			}
938		},
939		/* -------------------- */
940		
941		
942		/* adds scrollbar buttons */
943		_scrollButtons=function(){
944			var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
945				mCSB_scrollTools=$(".mCSB_"+d.idx+"_scrollbar:first"),
946				tabindex=!_isNumeric(o.scrollButtons.tabindex) ? "" : "tabindex='"+o.scrollButtons.tabindex+"'",
947				btnHTML=[
948					"<a href='#' class='"+classes[13]+"' "+tabindex+" />",
949					"<a href='#' class='"+classes[14]+"' "+tabindex+" />",
950					"<a href='#' class='"+classes[15]+"' "+tabindex+" />",
951					"<a href='#' class='"+classes[16]+"' "+tabindex+" />"
952				],
953				btn=[(o.axis==="x" ? btnHTML[2] : btnHTML[0]),(o.axis==="x" ? btnHTML[3] : btnHTML[1]),btnHTML[2],btnHTML[3]];
954			if(o.scrollButtons.enable){
955				mCSB_scrollTools.prepend(btn[0]).append(btn[1]).next(".mCSB_scrollTools").prepend(btn[2]).append(btn[3]);
956			}
957		},
958		/* -------------------- */
959		
960		
961		/* auto-adjusts scrollbar dragger length */
962		_setDraggerLength=function(){
963			var $this=$(this),d=$this.data(pluginPfx),
964				mCustomScrollBox=$("#mCSB_"+d.idx),
965				mCSB_container=$("#mCSB_"+d.idx+"_container"),
966				mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")],
967				ratio=[mCustomScrollBox.height()/mCSB_container.outerHeight(false),mCustomScrollBox.width()/mCSB_container.outerWidth(false)],
968				l=[
969					parseInt(mCSB_dragger[0].css("min-height")),Math.round(ratio[0]*mCSB_dragger[0].parent().height()),
970					parseInt(mCSB_dragger[1].css("min-width")),Math.round(ratio[1]*mCSB_dragger[1].parent().width())
971				],
972				h=oldIE && (l[1]<l[0]) ? l[0] : l[1],w=oldIE && (l[3]<l[2]) ? l[2] : l[3];
973			mCSB_dragger[0].css({
974				"height":h,"max-height":(mCSB_dragger[0].parent().height()-10)
975			}).find(".mCSB_dragger_bar").css({"line-height":l[0]+"px"});
976			mCSB_dragger[1].css({
977				"width":w,"max-width":(mCSB_dragger[1].parent().width()-10)
978			});
979		},
980		/* -------------------- */
981		
982		
983		/* calculates scrollbar to content ratio */
984		_scrollRatio=function(){
985			var $this=$(this),d=$this.data(pluginPfx),
986				mCustomScrollBox=$("#mCSB_"+d.idx),
987				mCSB_container=$("#mCSB_"+d.idx+"_container"),
988				mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")],
989				scrollAmount=[mCSB_container.outerHeight(false)-mCustomScrollBox.height(),mCSB_container.outerWidth(false)-mCustomScrollBox.width()],
990				ratio=[
991					scrollAmount[0]/(mCSB_dragger[0].parent().height()-mCSB_dragger[0].height()),
992					scrollAmount[1]/(mCSB_dragger[1].parent().width()-mCSB_dragger[1].width())
993				];
994			d.scrollRatio={y:ratio[0],x:ratio[1]};
995		},
996		/* -------------------- */
997		
998		
999		/* toggles scrolling classes */
1000		_onDragClasses=function(el,action,xpnd){
1001			var expandClass=xpnd ? classes[0]+"_expanded" : "",
1002				scrollbar=el.closest(".mCSB_scrollTools");
1003			if(action==="active"){
1004				el.toggleClass(classes[0]+" "+expandClass); scrollbar.toggleClass(classes[1]); 
1005				el[0]._draggable=el[0]._draggable ? 0 : 1;
1006			}else{
1007				if(!el[0]._draggable){
1008					if(action==="hide"){
1009						el.removeClass(classes[0]); scrollbar.removeClass(classes[1]);
1010					}else{
1011						el.addClass(classes[0]); scrollbar.addClass(classes[1]);
1012					}
1013				}
1014			}
1015		},
1016		/* -------------------- */
1017		
1018		
1019		/* checks if content overflows its container to determine if scrolling is required */
1020		_overflowed=function(){
1021			var $this=$(this),d=$this.data(pluginPfx),
1022				mCustomScrollBox=$("#mCSB_"+d.idx),
1023				mCSB_container=$("#mCSB_"+d.idx+"_container"),
1024				contentHeight=d.overflowed==null ? mCSB_container.height() : mCSB_container.outerHeight(false),
1025				contentWidth=d.overflowed==null ? mCSB_container.width() : mCSB_container.outerWidth(false),
1026				h=mCSB_container[0].scrollHeight,w=mCSB_container[0].scrollWidth;
1027			if(h>contentHeight){contentHeight=h;}
1028			if(w>contentWidth){contentWidth=w;}
1029			return [contentHeight>mCustomScrollBox.height(),contentWidth>mCustomScrollBox.width()];
1030		},
1031		/* -------------------- */
1032		
1033		
1034		/* resets content position to 0 */
1035		_resetContentPosition=function(){
1036			var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
1037				mCustomScrollBox=$("#mCSB_"+d.idx),
1038				mCSB_container=$("#mCSB_"+d.idx+"_container"),
1039				mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")];
1040			_stop($this); /* stop any current scrolling before resetting */
1041			if((o.axis!=="x" && !d.overflowed[0]) || (o.axis==="y" && d.overflowed[0])){ /* reset y */
1042				mCSB_dragger[0].add(mCSB_container).css("top",0);
1043				_scrollTo($this,"_resetY");
1044			}
1045			if((o.axis!=="y" && !d.overflowed[1]) || (o.axis==="x" && d.overflowed[1])){ /* reset x */
1046				var cx=dx=0;
1047				if(d.langDir==="rtl"){ /* adjust left position for rtl direction */
1048					cx=mCustomScrollBox.width()-mCSB_container.outerWidth(false);
1049					dx=Math.abs(cx/d.scrollRatio.x);
1050				}
1051				mCSB_container.css("left",cx);
1052				mCSB_dragger[1].css("left",dx);
1053				_scrollTo($this,"_resetX");
1054			}
1055		},
1056		/* -------------------- */
1057		
1058		
1059		/* binds scrollbar events */
1060		_bindEvents=function(){
1061			var $this=$(this),d=$this.data(pluginPfx),o=d.opt;
1062			if(!d.bindEvents){ /* check if events are already bound */
1063				_draggable.call(this);
1064				if(o.contentTouchScroll){_contentDraggable.call(this);}
1065				_selectable.call(this);
1066				if(o.mouseWheel.enable){ /* bind mousewheel fn when plugin is available */
1067					function _mwt(){
1068						mousewheelTimeout=setTimeout(function(){
1069							if(!$.event.special.mousewheel){
1070								_mwt();
1071							}else{
1072								clearTimeout(mousewheelTimeout);
1073								_mousewheel.call($this[0]);
1074							}
1075						},100);
1076					}
1077					var mousewheelTimeout;
1078					_mwt();
1079				}
1080				_draggerRail.call(this);
1081				_wrapperScroll.call(this);
1082				if(o.advanced.autoScrollOnFocus){_focus.call(this);}
1083				if(o.scrollButtons.enable){_buttons.call(this);}
1084				if(o.keyboard.enable){_keyboard.call(this);}
1085				d.bindEvents=true;
1086			}
1087		},
1088		/* -------------------- */
1089		
1090		
1091		/* unbinds scrollbar events */
1092		_unbindEvents=function(){
1093			var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
1094				namespace=pluginPfx+"_"+d.idx,
1095				sb=".mCSB_"+d.idx+"_scrollbar",
1096				sel=$("#mCSB_"+d.idx+",#mCSB_"+d.idx+"_container,#mCSB_"+d.idx+"_container_wrapper,"+sb+" ."+classes[12]+",#mCSB_"+d.idx+"_dragger_vertical,#mCSB_"+d.idx+"_dragger_horizontal,"+sb+">a"),
1097				mCSB_container=$("#mCSB_"+d.idx+"_container");
1098			if(o.advanced.releaseDraggableSelectors){sel.add($(o.advanced.releaseDraggableSelectors));}
1099			if(o.advanced.extraDraggableSelectors){sel.add($(o.advanced.extraDraggableSelectors));}
1100			if(d.bindEvents){ /* check if events are bound */
1101				/* unbind namespaced events from document/selectors */
1102				$(document).add($(!_canAccessIFrame() || top.document)).unbind("."+namespace);
1103				sel.each(function(){
1104					$(this).unbind("."+namespace);
1105				});
1106				/* clear and delete timeouts/objects */
1107				clearTimeout($this[0]._focusTimeout); _delete($this[0],"_focusTimeout");
1108				clearTimeout(d.sequential.step); _delete(d.sequential,"step");
1109				clearTimeout(mCSB_container[0].onCompleteTimeout); _delete(mCSB_container[0],"onCompleteTimeout");
1110				d.bindEvents=false;
1111			}
1112		},
1113		/* -------------------- */
1114		
1115		
1116		/* toggles scrollbar visibility */
1117		_scrollbarVisibility=function(disabled){
1118			var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
1119				contentWrapper=$("#mCSB_"+d.idx+"_container_wrapper"),
1120				content=contentWrapper.length ? contentWrapper : $("#mCSB_"+d.idx+"_container"),
1121				scrollbar=[$("#mCSB_"+d.idx+"_scrollbar_vertical"),$("#mCSB_"+d.idx+"_scrollbar_horizontal")],
1122				mCSB_dragger=[scrollbar[0].find(".mCSB_dragger"),scrollbar[1].find(".mCSB_dragger")];
1123			if(o.axis!=="x"){
1124				if(d.overflowed[0] && !disabled){
1125					scrollbar[0].add(mCSB_dragger[0]).add(scrollbar[0].children("a")).css("display","block");
1126					content.removeClass(classes[8]+" "+classes[10]);
1127				}else{
1128					if(o.alwaysShowScrollbar){
1129						if(o.alwaysShowScrollbar!==2){mCSB_dragger[0].css("display","none");}
1130						content.removeClass(classes[10]);
1131					}else{
1132						scrollbar[0].css("display","none");
1133						content.addClass(classes[10]);
1134					}
1135					content.addClass(classes[8]);
1136				}
1137			}
1138			if(o.axis!=="y"){
1139				if(d.overflowed[1] && !disabled){
1140					scrollbar[1].add(mCSB_dragger[1]).add(scrollbar[1].children("a")).css("display","block");
1141					content.removeClass(classes[9]+" "+classes[11]);
1142				}else{
1143					if(o.alwaysShowScrollbar){
1144						if(o.alwaysShowScrollbar!==2){mCSB_dragger[1].css("display","none");}
1145						content.removeClass(classes[11]);
1146					}else{
1147						scrollbar[1].css("display","none");
1148						content.addClass(classes[11]);
1149					}
1150					content.addClass(classes[9]);
1151				}
1152			}
1153			if(!d.overflowed[0] && !d.overflowed[1]){
1154				$this.addClass(classes[5]);
1155			}else{
1156				$this.removeClass(classes[5]);
1157			}
1158		},
1159		/* -------------------- */
1160		
1161		
1162		/* returns input coordinates of pointer, touch and mouse events (relative to document) */
1163		_coordinates=function(e){
1164			var t=e.type,o=e.target.ownerDocument!==document && frameElement!==null ? [$(frameElement).offset().top,$(frameElement).offset().left] : null,
1165				io=_canAccessIFrame() && e.target.ownerDocument!==top.document && frameElement!==null ? [$(e.view.frameElement).offset().top,$(e.view.frameElement).offset().left] : [0,0];
1166			switch(t){
1167				case "pointerdown": case "MSPointerDown": case "pointermove": case "MSPointerMove": case "pointerup": case "MSPointerUp":
1168					return o ? [e.originalEvent.pageY-o[0]+io[0],e.originalEvent.pageX-o[1]+io[1],false] : [e.originalEvent.pageY,e.originalEvent.pageX,false];
1169					break;
1170				case "touchstart": case "touchmove": case "touchend":
1171					var touch=e.originalEvent.touches[0] || e.originalEvent.changedTouches[0],
1172						touches=e.originalEvent.touches.length || e.originalEvent.changedTouches.length;
1173					return e.target.ownerDocument!==document ? [touch.screenY,touch.screenX,touches>1] : [touch.pageY,touch.pageX,touches>1];
1174					break;
1175				default:
1176					return o ? [e.pageY-o[0]+io[0],e.pageX-o[1]+io[1],false] : [e.pageY,e.pageX,false];
1177			}
1178		},
1179		/* -------------------- */
1180		
1181		
1182		/* 
1183		SCROLLBAR DRAG EVENTS
1184		scrolls content via scrollbar dragging 
1185		*/
1186		_draggable=function(){
1187			var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
1188				namespace=pluginPfx+"_"+d.idx,
1189				draggerId=["mCSB_"+d.idx+"_dragger_vertical","mCSB_"+d.idx+"_dragger_horizontal"],
1190				mCSB_container=$("#mCSB_"+d.idx+"_container"),
1191				mCSB_dragger=$("#"+draggerId[0]+",#"+draggerId[1]),
1192				draggable,dragY,dragX,
1193				rds=o.advanced.releaseDraggableSelectors ? mCSB_dragger.add($(o.advanced.releaseDraggableSelectors)) : mCSB_dragger,
1194				eds=o.advanced.extraDraggableSelectors ? $(!_canAccessIFrame() || top.document).add($(o.advanced.extraDraggableSelectors)) : $(!_canAccessIFrame() || top.document);
1195			mCSB_dragger.bind("contextmenu."+namespace,function(e){
1196				e.preventDefault(); //prevent right click
1197			}).bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace,function(e){
1198				e.stopImmediatePropagation();
1199				e.preventDefault();
1200				if(!_mouseBtnLeft(e)){return;} /* left mouse button only */
1201				touchActive=true;
1202				if(oldIE){document.onselectstart=function(){return false;}} /* disable text selection for IE < 9 */
1203				_iframe.call(mCSB_container,false); /* enable scrollbar dragging over iframes by disabling their events */
1204				_stop($this);
1205				draggable=$(this);
1206				var offset=draggable.offset(),y=_coordinates(e)[0]-offset.top,x=_coordinates(e)[1]-offset.left,
1207					h=draggable.height()+offset.top,w=draggable.width()+offset.left;
1208				if(y<h && y>0 && x<w && x>0){
1209					dragY=y; 
1210					dragX=x;
1211				}
1212				_onDragClasses(draggable,"active",o.autoExpandScrollbar); 
1213			}).bind("touchmove."+namespace,function(e){
1214				e.stopImmediatePropagation();
1215				e.preventDefault();
1216				var offset=draggable.offset(),y=_coordinates(e)[0]-offset.top,x=_coordinates(e)[1]-offset.left;
1217				_drag(dragY,dragX,y,x);
1218			});
1219			$(document).add(eds).bind("mousemove."+namespace+" pointermove."+namespace+" MSPointerMove."+namespace,function(e){
1220				if(draggable){
1221					var offset=draggable.offset(),y=_coordinates(e)[0]-offset.top,x=_coordinates(e)[1]-offset.left;
1222					if(dragY===y && dragX===x){return;} /* has it really moved? */
1223					_drag(dragY,dragX,y,x);
1224				}
1225			}).add(rds).bind("mouseup."+namespace+" touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace,function(e){
1226				if(draggable){
1227					_onDragClasses(draggable,"active",o.autoExpandScrollbar); 
1228					draggable=null;
1229				}
1230				touchActive=false;
1231				if(oldIE){document.onselectstart=null;} /* enable text selection for IE < 9 */
1232				_iframe.call(mCSB_container,true); /* enable iframes events */
1233			});
1234			function _drag(dragY,dragX,y,x){
1235				mCSB_container[0].idleTimer=o.scrollInertia<233 ? 250 : 0;
1236				if(draggable.attr("id")===draggerId[1]){
1237					var dir="x",to=((draggable[0].offsetLeft-dragX)+x)*d.scrollRatio.x;
1238				}else{
1239					var dir="y",to=((draggable[0].offsetTop-dragY)+y)*d.scrollRatio.y;
1240				}
1241				_scrollTo($this,to.toString(),{dir:dir,drag:true});
1242			}
1243		},
1244		/* -------------------- */
1245		
1246		
1247		/* 
1248		TOUCH SWIPE EVENTS
1249		scrolls content via touch swipe 
1250		Emulates the native touch-swipe scrolling with momentum found in iOS, Android and WP devices 
1251		*/
1252		_contentDraggable=function(){
1253			var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
1254				namespace=pluginPfx+"_"+d.idx,
1255				mCustomScrollBox=$("#mCSB_"+d.idx),
1256				mCSB_container=$("#mCSB_"+d.idx+"_container"),
1257				mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")],
1258				draggable,dragY,dragX,touchStartY,touchStartX,touchMoveY=[],touchMoveX=[],startTime,runningTime,endTime,distance,speed,amount,
1259				durA=0,durB,overwrite=o.axis==="yx" ? "none" : "all",touchIntent=[],touchDrag,docDrag,
1260				iframe=mCSB_container.find("iframe"),
1261				events=[
1262					"touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace, //start
1263					"touchmove."+namespace+" pointermove."+namespace+" MSPointerMove."+namespace, //move
1264					"touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace //end
1265				],
1266				touchAction=document.body.style.touchAction!==undefined && document.body.style.touchAction!=="";
1267			mCSB_container.bind(events[0],function(e){
1268				_onTouchstart(e);
1269			}).bind(events[1],function(e){
1270				_onTouchmove(e);
1271			});
1272			mCustomScrollBox.bind(events[0],function(e){
1273				_onTouchstart2(e);
1274			}).bind(events[2],function(e){
1275				_onTouchend(e);
1276			});
1277			if(iframe.length){
1278				iframe.each(function(){
1279					$(this).bind("load",function(){
1280						/* bind events on accessible iframes */
1281						if(_canAccessIFrame(this)){
1282							$(this.contentDocument || this.contentWindow.document).bind(events[0],function(e){
1283								_onTouchstart(e);
1284								_onTouchstart2(e);
1285							}).bind(events[1],function(e){
1286								_onTouchmove(e);
1287							}).bind(events[2],function(e){
1288								_onTouchend(e);
1289							});
1290						}
1291					});
1292				});
1293			}
1294			function _onTouchstart(e){
1295				if(!_pointerTouch(e) || touchActive || _coordinates(e)[2]){touchable=0; return;}
1296				touchable=1; touchDrag=0; docDrag=0; draggable=1;
1297				$this.removeClass("mCS_touch_action");
1298				var offset=mCSB_container.offset();
1299				dragY=_coordinates(e)[0]-offset.top;
1300				dragX=_coordinates(e)[1]-offset.left;
1301				touchIntent=[_coordinates(e)[0],_coordinates(e)[1]];
1302			}
1303			function _onTouchmove(e){
1304				if(!_pointerTouch(e) || touchActive || _coordinates(e)[2]){return;}
1305				if(!o.documentTouchScroll){e.preventDefault();} 
1306				e.stopImmediatePropagation();
1307				if(docDrag && !touchDrag){return;}
1308				if(draggable){
1309					runningTime=_getTime();
1310					var offset=mCustomScrollBox.offset(),y=_coordinates(e)[0]-offset.top,x=_coordinates(e)[1]-offset.left,
1311						easing="mcsLinearOut";
1312					touchMoveY.push(y);
1313					touchMoveX.push(x);
1314					touchIntent[2]=Math.abs(_coordinates(e)[0]-touchIntent[0]); touchIntent[3]=Math.abs(_coordinates(e)[1]-touchIntent[1]);
1315					if(d.overflowed[0]){
1316						var limit=mCSB_dragger[0].parent().height()-mCSB_dragger[0].height(),
1317							prevent=((dragY-y)>0 && (y-dragY)>-(limit*d.scrollRatio.y) && (touchIntent[3]*2<touchIntent[2] || o.axis==="yx"));
1318					}
1319					if(d.overflowed[1]){
1320						var limitX=mCSB_dragger[1].parent().width()-mCSB_dragger[1].width(),
1321							preventX=((dragX-x)>0 && (x-dragX)>-(limitX*d.scrollRatio.x) && (touchIntent[2]*2<touchIntent[3] || o.axis==="yx"));
1322					}
1323					if(prevent || preventX){ /* prevent native document scrolling */
1324						if(!touchAction){e.preventDefault();} 
1325						touchDrag=1;
1326					}else{
1327						docDrag=1;
1328						$this.addClass("mCS_touch_action");
1329					}
1330					if(touchAction){e.preventDefault();} 
1331					amount=o.axis==="yx" ? [(dragY-y),(dragX-x)] : o.axis==="x" ? [null,(dragX-x)] : [(dragY-y),null];
1332					mCSB_container[0].idleTimer=250;
1333					if(d.overflowed[0]){_drag(amount[0],durA,easing,"y","all",true);}
1334					if(d.overflowed[1]){_drag(amount[1],durA,easing,"x",overwrite,true);}
1335				}
1336			}
1337			function _onTouchstart2(e){
1338				if(!_pointerTouch(e) || touchActive || _coordinates(e)[2]){touchable=0; return;}
1339				touchable=1;
1340				e.stopImmediatePropagation();
1341				_stop($this);
1342				startTime=_getTime();
1343				var offset=mCustomScrollBox.offset();
1344				touchStartY=_coordinates(e)[0]-offset.top;
1345				touchStartX=_coordinates(e)[1]-offset.left;
1346				touchMoveY=[]; touchMoveX=[];
1347			}
1348			function _onTouchend(e){
1349				if(!_pointerTouch(e) || touchActive || _coordinates(e)[2]){return;}
1350				draggable=0;
1351				e.stopImmediatePropagation();
1352				touchDrag=0; docDrag=0;
1353				endTime=_getTime();
1354				var offset=mCustomScrollBox.offset(),y=_coordinates(e)[0]-offset.top,x=_coordinates(e)[1]-offset.left;
1355				if((endTime-runningTime)>30){return;}
1356				speed=1000/(endTime-startTime);
1357				var easing="mcsEaseOut",slow=speed<2.5,
1358					diff=slow ? [touchMoveY[touchMoveY.length-2],touchMoveX[touchMoveX.length-2]] : [0,0];
1359				distance=slow ? [(y-diff[0]),(x-diff[1])] : [y-touchStartY,x-touchStartX];
1360				var absDistance=[Math.abs(distance[0]),Math.abs(distance[1])];
1361				speed=slow ? [Math.abs(distance[0]/4),Math.abs(distance[1]/4)] : [speed,speed];
1362				var a=[
1363					Math.abs(mCSB_container[0].offsetTop)-(distance[0]*_m((absDistance[0]/speed[0]),speed[0])),
1364					Math.abs(mCSB_container[0].offsetLeft)-(distance[1]*_m((absDistance[1]/speed[1]),speed[1]))
1365				];
1366				amount=o.axis==="yx" ? [a[0],a[1]] : o.axis==="x" ? [null,a[1]] : [a[0],null];
1367				durB=[(absDistance[0]*4)+o.scrollInertia,(absDistance[1]*4)+o.scrollInertia];
1368				var md=parseInt(o.contentTouchScroll) || 0; /* absolute minimum distance required */
1369				amount[0]=absDistance[0]>md ? amount[0] : 0;
1370				amount[1]=absDistance[1]>md ? amount[1] : 0;
1371				if(d.overflowed[0]){_drag(amount[0],durB[0],easing,"y",overwrite,false);}
1372				if(d.overflowed[1]){_drag(amount[1],durB[1],easing,"x",overwrite,false);}
1373			}
1374			function _m(ds,s){
1375				var r=[s*1.5,s*2,s/1.5,s/2];
1376				if(ds>90){
1377					return s>4 ? r[0] : r[3];
1378				}else if(ds>60){
1379					return s>3 ? r[3] : r[2];
1380				}else if(ds>30){
1381					return s>8 ? r[1] : s>6 ? r[0] : s>4 ? s : r[2];
1382				}else{
1383					return s>8 ? s : r[3];
1384				}
1385			}
1386			function _drag(amount,dur,easing,dir,overwrite,drag){
1387				if(!amount){return;}
1388				_scrollTo($this,amount.toString(),{dur:dur,scrollEasing:easing,dir:dir,overwrite:overwrite,drag:drag});
1389			}
1390		},
1391		/* -------------------- */
1392		
1393		
1394		/* 
1395		SELECT TEXT EVENTS 
1396		scrolls content when text is selected 
1397		*/
1398		_selectable=function(){
1399			var $this=$(this),d=$this.data(pluginPfx),o=d.opt,seq=d.sequential,
1400				namespace=pluginPfx+"_"+d.idx,
1401				mCSB_container=$("#mCSB_"+d.idx+"_container"),
1402				wrapper=mCSB_container.parent(),
1403				action;
1404			mCSB_container.bind("mousedown."+namespace,function(e){
1405				if(touchable){return;}
1406				if(!action){action=1; touchActive=true;}
1407			}).add(document).bind("mousemove."+namespace,function(e){
1408				if(!touchable && action && _sel()){
1409					var offset=mCSB_container.offset(),
1410						y=_coordinates(e)[0]-offset.top+mCSB_container[0].offsetTop,x=_coordinates(e)[1]-offset.left+mCSB_container[0].offsetLeft;
1411					if(y>0 && y<wrapper.height() && x>0 && x<wrapper.width()){
1412						if(seq.step){_seq("off",null,"stepped");}
1413					}else{
1414						if(o.axis!=="x" && d.overflowed[0]){
1415							if(y<0){
1416								_seq("on",38);
1417							}else if(y>wrapper.height()){
1418								_seq("on",40);
1419							}
1420						}
1421						if(o.axis!=="y" && d.overflowed[1]){
1422							if(x<0){
1423								_seq("on",37);
1424							}else if(x>wrapper.width()){
1425								_seq("on",39);
1426							}
1427						}
1428					}
1429				}
1430			}).bind("mouseup."+namespace+" dragend."+namespace,function(e){
1431				if(touchable){return;}
1432				if(action){action=0; _seq("off",null);}
1433				touchActive=false;
1434			});
1435			function _sel(){
1436				return 	window.getSelection ? window.getSelection().toString() : 
1437						document.selection && document.selection.type!="Control" ? document.selection.createRange().text : 0;
1438			}
1439			function _seq(a,c,s){
1440				seq.type=s && action ? "stepped" : "stepless";
1441				seq.scrollAmount=10;
1442				_sequentialScroll($this,a,c,"mcsLinearOut",s ? 60 : null);
1443			}
1444		},
1445		/* -------------------- */
1446		
1447		
1448		/* 
1449		MOUSE WHEEL EVENT
1450		scrolls content via mouse-wheel 
1451		via mouse-wheel plugin (https://github.com/brandonaaron/jquery-mousewheel)
1452		*/
1453		_mousewheel=function(){
1454			if(!$(this).data(pluginPfx)){return;} /* Check if the scrollbar is ready to use mousewheel events (issue: #185) */
1455			var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
1456				namespace=pluginPfx+"_"+d.idx,
1457				mCustomScrollBox=$("#mCSB_"+d.idx),
1458				mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")],
1459				iframe=$("#mCSB_"+d.idx+"_container").find("iframe");
1460			if(iframe.length){
1461				iframe.each(function(){
1462					$(this).bind("load",function(){
1463						/* bind events on accessible iframes */
1464						if(_canAccessIFrame(this)){
1465							$(this.contentDocument || this.contentWindow.document).bind("mousewheel."+namespace,function(e,delta){
1466								_onMousewheel(e,delta);
1467							});
1468						}
1469					});
1470				});
1471			}
1472			mCustomScrollBox.bind("mousewheel."+namespace,function(e,delta){
1473				_onMousewheel(e,delta);
1474			});
1475			function _onMousewheel(e,delta){
1476				_stop($this);
1477				if(_disableMousewheel($this,e.target)){return;} /* disables mouse-wheel when hovering specific elements */
1478				var deltaFactor=o.mouseWheel.deltaFactor!=="auto" ? parseInt(o.mouseWheel.deltaFactor) : (oldIE && e.deltaFactor<100) ? 100 : e.deltaFactor || 100,
1479					dur=o.scrollInertia;
1480				if(o.axis==="x" || o.mouseWheel.axis==="x"){
1481					var dir="x",
1482						px=[Math.round(deltaFactor*d.scrollRatio.x),parseInt(o.mouseWheel.scrollAmount)],
1483						amount=o.mouseWheel.scrollAmount!=="auto" ? px[1] : px[0]>=mCustomScrollBox.width() ? mCustomScrollBox.width()*0.9 : px[0],
1484						contentPos=Math.abs($("#mCSB_"+d.idx+"_container")[0].offsetLeft),
1485						draggerPos=mCSB_dragger[1][0].offsetLeft,
1486						limit=mCSB_dragger[1].parent().width()-mCSB_dragger[1].width(),
1487						dlt=o.mouseWheel.axis==="y" ? (e.deltaY || delta) : e.deltaX;
1488				}else{
1489					var dir="y",
1490						px=[Math.round(deltaFactor*d.scrollRatio.y),parseInt(o.mouseWheel.scrollAmount)],
1491						amount=o.mouseWheel.scrollAmount!=="auto" ? px[1] : px[0]>=mCustomScrollBox.height() ? mCustomScrollBox.height()*0.9 : px[0],
1492						contentPos=Math.abs($("#mCSB_"+d.idx+"_container")[0].offsetTop),
1493						draggerPos=mCSB_dragger[0][0].offsetTop,
1494						limit=mCSB_dragger[0].parent().height()-mCSB_dragger[0].height(),
1495						dlt=e.deltaY || delta;
1496				}
1497				if((dir==="y" && !d.overflowed[0]) || (dir==="x" && !d.overflowed[1])){return;}
1498				if(o.mouseWheel.invert || e.webkitDirectionInvertedFromDevice){dlt=-dlt;}
1499				if(o.mouseWheel.normalizeDelta){dlt=dlt<0 ? -1 : 1;}
1500				if((dlt>0 && draggerPos!==0) || (dlt<0 && draggerPos!==limit) || o.mouseWheel.preventDefault){
1501					e.stopImmediatePropagation();
1502					e.preventDefault();
1503				}
1504				if(e.deltaFactor<5 && !o.mouseWheel.normalizeDelta){
1505					//very low deltaFactor values mean some kind of delta acceleration (e.g. osx trackpad), so adjusting scrolling accordingly
1506					amount=e.deltaFactor; dur=17;
1507				}
1508				_scrollTo($this,(contentPos-(dlt*amount)).toString(),{dir:dir,dur:dur});
1509			}
1510		},
1511		/* -------------------- */
1512		
1513		
1514		/* checks if iframe can be accessed */
1515		_canAccessIFrameCache=new Object(),
1516		_canAccessIFrame=function(iframe){
1517		    var result=false,cacheKey=false,html=null;
1518		    if(iframe===undefined){
1519				cacheKey="#empty";
1520		    }else if($(iframe).attr("id")!==undefined){
1521				cacheKey=$(iframe).attr("id");
1522		    }
1523			if(cacheKey!==false && _canAccessIFrameCache[cacheKey]!==undefined){
1524				return _canAccessIFrameCache[cacheKey];
1525			}
1526			if(!iframe){
1527				try{
1528					var doc=top.document;
1529					html=doc.body.innerHTML;
1530				}catch(err){/* do nothing */}
1531				result=(html!==null);
1532			}else{
1533				try{
1534					var doc=iframe.contentDocument || iframe.contentWindow.document;
1535					html=doc.body.innerHTML;
1536				}catch(err){/* do nothing */}
1537				result=(html!==null);
1538			}
1539			if(cacheKey!==false){_canAccessIFrameCache[cacheKey]=result;}
1540			return result;
1541		},
1542		/* -------------------- */
1543		
1544		
1545		/* switches iframe's pointer-events property (drag, mousewheel etc. over cross-domain iframes) */
1546		_iframe=function(evt){
1547			var el=this.find("iframe");
1548			if(!el.length){return;} /* check if content contains iframes */
1549			var val=!evt ? "none" : "auto";
1550			el.css("pointer-events",val); /* for IE11, iframe's display property should not be "block" */
1551		},
1552		/* -------------------- */
1553		
1554		
1555		/* disables mouse-wheel when hovering specific elements like select, datalist etc. */
1556		_disableMousewheel=function(el,target){
1557			var tag=target.nodeName.toLowerCase(),
1558				tags=el.data(pluginPfx).opt.mouseWheel.disableOver,
1559				/* elements that require focus */
1560				focusTags=["select","textarea"];
1561			return $.inArray(tag,tags) > -1 && !($.inArray(tag,focusTags) > -1 && !$(target).is(":focus"));
1562		},
1563		/* -------------------- */
1564		
1565		
1566		/* 
1567		DRAGGER RAIL CLICK EVENT
1568		scrolls content via dragger rail 
1569		*/
1570		_draggerRail=function(){
1571			var $this=$(this),d=$this.data(pluginPfx),
1572				namespace=pluginPfx+"_"+d.idx,
1573				mCSB_container=$("#mCSB_"+d.idx+"_container"),
1574				wrapper=mCSB_container.parent(),
1575				mCSB_draggerContainer=$(".mCSB_"+d.idx+"_scrollbar ."+classes[12]),
1576				clickable;
1577			mCSB_draggerContainer.bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace,function(e){
1578				touchActive=true;
1579				if(!$(e.target).hasClass("mCSB_dragger")){clickable=1;}
1580			}).bind("touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace,function(e){
1581				touchActive=false;
1582			}).bind("click."+namespace,function(e){
1583				if(!clickable){return;}
1584				clickable=0;
1585				if($(e.target).hasClass(classes[12]) || $(e.target).hasClass("mCSB_draggerRail")){
1586					_stop($this);
1587					var el=$(this),mCSB_dragger=el.find(".mCSB_dragger");
1588					if(el.parent(".mCSB_scrollTools_horizontal").length>0){
1589						if(!d.overflowed[1]){return;}
1590						var dir="x",
1591							clickDir=e.pageX>mCSB_dragger.offset().left ? -1 : 1,
1592							to=Math.abs(mCSB_container[0].offsetLeft)-(clickDir*(wrapper.width()*0.9));
1593					}else{
1594						if(!d.overflowed[0]){return;}
1595						var dir="y",
1596							clickDir=e.pageY>mCSB_dragger.offset().top ? -1 : 1,
1597							to=Math.abs(mCSB_container[0].offsetTop)-(clickDir*(wrapper.height()*0.9));
1598					}
1599					_scrollTo($this,to.toString(),{dir:dir,scrollEasing:"mcsEaseInOut"});
1600				}
1601			});
1602		},
1603		/* -------------------- */
1604		
1605		
1606		/* 
1607		FOCUS EVENT
1608		scrolls content via element focus (e.g. clicking an input, pressing TAB key etc.)
1609		*/
1610		_focus=function(){
1611			var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
1612				namespace=pluginPfx+"_"+d.idx,
1613				mCSB_container=$("#mCSB_"+d.idx+"_container"),
1614				wrapper=mCSB_container.parent();
1615			mCSB_container.bind("focusin."+namespace,function(e){
1616				var el=$(document.activeElement),
1617					nested=mCSB_container.find(".mCustomScrollBox").length,
1618					dur=0;
1619				if(!el.is(o.advanced.autoScrollOnFocus)){return;}
1620				_stop($this);
1621				clearTimeout($this[0]._focusTimeout);
1622				$this[0]._focusTimer=nested ? (dur+17)*nested : 0;
1623				$this[0]._focusTimeout=setTimeout(function(){
1624					var	to=[_childPos(el)[0],_childPos(el)[1]],
1625						contentPos=[mCSB_container[0].offsetTop,mCSB_container[0].offsetLeft],
1626						isVisible=[
1627							(contentPos[0]+to[0]>=0 && contentPos[0]+to[0]<wrapper.height()-el.outerHeight(false)),
1628							(contentPos[1]+to[1]>=0 && contentPos[0]+to[1]<wrapper.width()-el.outerWidth(false))
1629						],
1630						overwrite=(o.axis==="yx" && !isVisible[0] && !isVisible[1]) ? "none" : "all";
1631					if(o.axis!=="x" && !isVisible[0]){
1632						_scrollTo($this,to[0].toString(),{dir:"y",scrollEasing:"mcsEaseInOut",overwrite:overwrite,dur:dur});
1633					}
1634					if(o.axis!=="y" && !isVisible[1]){
1635						_scrollTo($this,to[1].toString(),{dir:"x",scrollEasing:"mcsEaseInOut",overwrite:overwrite,dur:dur});
1636					}
1637				},$this[0]._focusTimer);
1638			});
1639		},
1640		/* -------------------- */
1641		
1642		
1643		/* sets content wrapper scrollTop/scrollLeft always to 0 */
1644		_wrapperScroll=function(){
1645			var $this=$(this),d=$this.data(pluginPfx),
1646				namespace=pluginPfx+"_"+d.idx,
1647				wrapper=$("#mCSB_"+d.idx+"_container").parent();
1648			wrapper.bind("scroll."+namespace,function(e){
1649				if(wrapper.scrollTop()!==0 || wrapper.scrollLeft()!==0){
1650					$(".mCSB_"+d.idx+"_scrollbar").css("visibility","hidden"); /* hide scrollbar(s) */
1651				}
1652			});
1653		},
1654		/* -------------------- */
1655		
1656		
1657		/* 
1658		BUTTONS EVENTS
1659		scrolls content via up, down, left and right buttons 
1660		*/
1661		_buttons=function(){
1662			var $this=$(this),d=$this.data(pluginPfx),o=d.opt,seq=d.sequential,
1663				namespace=pluginPfx+"_"+d.idx,
1664				sel=".mCSB_"+d.idx+"_scrollbar",
1665				btn=$(sel+">a");
1666			btn.bind("contextmenu."+namespace,function(e){
1667				e.preventDefault(); //prevent right click
1668			}).bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace+" mouseup."+namespace+" touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace+" mouseout."+namespace+" pointerout."+namespace+" MSPointerOut."+namespace+" click."+namespace,function(e){
1669				e.preventDefault();
1670				if(!_mouseBtnLeft(e)){return;} /* left mouse button only */
1671				var btnClass=$(this).attr("class");
1672				seq.type=o.scrollButtons.scrollType;
1673				switch(e.type){
1674					case "mousedown": case "touchstart": case "pointerdown": case "MSPointerDown":
1675						if(seq.type==="stepped"){return;}
1676						touchActive=true;
1677						d.tweenRunning=false;
1678						_seq("on",btnClass);
1679						break;
1680					case "mouseup": case "touchend": case "pointerup": case "MSPointerUp":
1681					case "mouseout": case "pointerout": case "MSPointerOut":
1682						if(seq.type==="stepped"){return;}
1683						touchActive=false;
1684						if(seq.dir){_seq("off",btnClass);}
1685						break;
1686					case "click":
1687						if(seq.type!=="stepped" || d.tweenRunning){return;}
1688						_seq("on",btnClass);
1689						break;
1690				}
1691				function _seq(a,c){
1692					seq.scrollAmount=o.scrollButtons.scrollAmount;
1693					_sequentialScroll($this,a,c);
1694				}
1695			});
1696		},
1697		/* -------------------- */
1698		
1699		
1700		/* 
1701		KEYBOARD EVENTS
1702		scrolls content via keyboard 
1703		Keys: up arrow, down arrow, left arrow, right arrow, PgUp, PgDn, Home, End
1704		*/
1705		_keyboard=function(){
1706			var $this=$(this),d=$this.data(pluginPfx),o=d.opt,seq=d.sequential,
1707				namespace=pluginPfx+"_"+d.idx,
1708				mCustomScrollBox=$("#mCSB_"+d.idx),
1709				mCSB_container=$("#mCSB_"+d.idx+"_container"),
1710				wrapper=mCSB_container.parent(),
1711				editables="input,textarea,select,datalist,keygen,[contenteditable='true']",
1712				iframe=mCSB_container.find("iframe"),
1713				events=["blur."+namespace+" keydown."+namespace+" keyup."+namespace];
1714			if(iframe.length){
1715				iframe.each(function(){
1716					$(this).bind("load",function(){
1717						/* bind events on accessible iframes */
1718						if(_canAccessIFrame(this)){
1719							$(this.contentDocument || this.contentWindow.document).bind(events[0],function(e){
1720								_onKeyboard(e);
1721							});
1722						}
1723					});
1724				});
1725			}
1726			mCustomScrollBox.attr("tabindex","0").bind(events[0],function(e){
1727				_onKeyboard(e);
1728			});
1729			function _onKeyboard(e){
1730				switch(e.type){
1731					case "blur":
1732						if(d.tweenRunning && seq.dir){_seq("off",null);}
1733						break;
1734					case "keydown": case "keyup":
1735						var code=e.keyCode ? e.keyCode : e.which,action="on";
1736						if((o.axis!=="x" && (code===38 || code===40)) || (o.axis!=="y" && (code===37 || code===39))){
1737							/* up (38), down (40), left (37), right (39) arrows */
1738							if(((code===38 || code===40) && !d.overflowed[0]) || ((code===37 || code===39) && !d.overflowed[1])){return;}
1739							if(e.type==="keyup"){action="off";}
1740							if(!$(document.activeElement).is(editables)){
1741								e.preventDefault();
1742								e.stopImmediatePropagation();
1743								_seq(action,code);
1744							}
1745						}else if(code===33 || code===34){
1746							/* PgUp (33), PgDn (34) */
1747							if(d.overflowed[0] || d.overflowed[1]){
1748								e.preventDefault();
1749								e.stopImmediatePropagation();
1750							}
1751							if(e.type==="keyup"){
1752								_stop($this);
1753								var keyboardDir=code===34 ? -1 : 1;
1754								if(o.axis==="x" || (o.axis==="yx" && d.overflowed[1] && !d.overflowed[0])){
1755									var dir="x",to=Math.abs(mCSB_container[0].offsetLeft)-(keyboardDir*(wrapper.width()*0.9));
1756								}else{
1757									var dir="y",to=Math.abs(mCSB_container[0].offsetTop)-(keyboardDir*(wrapper.height()*0.9));
1758								}
1759								_scrollTo($this,to.toString(),{dir:dir,scrollEasing:"mcsEaseInOut"});
1760							}
1761						}else if(code===35 || code===36){
1762							/* End (35), Home (36) */
1763							if(!$(document.activeElement).is(editables)){
1764								if(d.overflowed[0] || d.overflowed[1]){
1765									e.preventDefault();
1766									e.stopImmediatePropagation();
1767								}
1768								if(e.type==="keyup"){
1769									if(o.axis==="x" || (o.axis==="yx" && d.overflowed[1] && !d.overflowed[0])){
1770										var dir="x",to=code===35 ? Math.abs(wrapper.width()-mCSB_container.outerWidth(false)) : 0;
1771									}else{
1772										var dir="y",to=code===35 ? Math.abs(wrapper.height()-mCSB_container.outerHeight(false)) : 0;
1773									}
1774									_scrollTo($this,to.toString(),{dir:dir,scrollEasing:"mcsEaseInOut"});
1775								}
1776							}
1777						}
1778						break;
1779				}
1780				function _seq(a,c){
1781					seq.type=o.keyboard.scrollType;
1782					seq.scrollAmount=o.keyboard.scrollAmount;
1783					if(seq.type==="stepped" && d.tweenRunning){return;}
1784					_sequentialScroll($this,a,c);
1785				}
1786			}
1787		},
1788		/* -------------------- */
1789		
1790		
1791		/* scrolls content sequentially (used when scrolling via buttons, keyboard arrows etc.) */
1792		_sequentialScroll=function(el,action,trigger,e,s){
1793			var d=el.data(pluginPfx),o=d.opt,seq=d.sequential,
1794				mCSB_container=$("#mCSB_"+d.idx+"_container"),
1795				once=seq.type==="stepped" ? true : false,
1796				steplessSpeed=o.scrollInertia < 26 ? 26 : o.scrollInertia, /* 26/1.5=17 */
1797				steppedSpeed=o.scrollInertia < 1 ? 17 : o.scrollInertia;
1798			switch(action){
1799				case "on":
1800					seq.dir=[
1801						(trigger===classes[16] || trigger===classes[15] || trigger===39 || trigger===37 ? "x" : "y"),
1802						(trigger===classes[13] || trigger===classes[15] || trigger===38 || trigger===37 ? -1 : 1)
1803					];
1804					_stop(el);
1805					if(_isNumeric(trigger) && seq.type==="stepped"){return;}
1806					_on(once);
1807					break;
1808				case "off":
1809					_off();
1810					if(once || (d.tweenRunning && seq.dir)){
1811						_on(true);
1812					}
1813					break;
1814			}
1815			
1816			/* starts sequence */
1817			function _on(once){
1818				if(o.snapAmount){seq.scrollAmount=!(o.snapAmount instanceof Array) ? o.snapAmount : seq.dir[0]==="x" ? o.snapAmount[1] : o.snapAmount[0];} /* scrolling snapping */
1819				var c=seq.type!=="stepped", /* continuous scrolling */
1820					t=s ? s : !once ? 1000/60 : c ? steplessSpeed/1.5 : steppedSpeed, /* timer */
1821					m=!once ? 2.5 : c ? 7.5 : 40, /* multiplier */
1822					contentPos=[Math.abs(mCSB_container[0].offsetTop),Math.abs(mCSB_container[0].offsetLeft)],
1823					ratio=[d.scrollRatio.y>10 ? 10 : d.scrollRatio.y,d.scrollRatio.x>10 ? 10 : d.scrollRatio.x],
1824					amount=seq.dir[0]==="x" ? contentPos[1]+(seq.dir[1]*(ratio[1]*m)) : contentPos[0]+(seq.dir[1]*(ratio[0]*m)),
1825					px=seq.dir[0]==="x" ? contentPos[1]+(seq.dir[1]*parseInt(seq.scrollAmount)) : contentPos[0]+(seq.dir[1]*parseInt(seq.scrollAmount)),
1826					to=seq.scrollAmount!=="auto" ? px : amount,
1827					easing=e ? e : !once ? "mcsLinear" : c ? "mcsLinearOut" : "mcsEaseInOut",
1828					onComplete=!once ? false : true;
1829				if(once && t<17){
1830					to=seq.dir[0]==="x" ? contentPos[1] : contentPos[0];
1831				}
1832				_scrollTo(el,to.toString(),{dir:seq.dir[0],scrollEasing:easing,dur:t,onComplete:onComplete});
1833				if(once){
1834					seq.dir=false;
1835					return;
1836				}
1837				clearTimeout(seq.step);
1838				seq.step=setTimeout(function(){
1839					_on();
1840				},t);
1841			}
1842			/* stops sequence */
1843			function _off(){
1844				clearTimeout(seq.step);
1845				_delete(seq,"step");
1846				_stop(el);
1847			}
1848		},
1849		/* -------------------- */
1850		
1851		
1852		/* returns a yx array from value */
1853		_arr=function(val){
1854			var o=$(this).data(pluginPfx).opt,vals=[];
1855			if(typeof val==="function"){val=val();} /* check if the value is a single anonymous function */
1856			/* check if value is object or array, its length and create an array with yx values */
1857			if(!(val instanceof Array)){ /* object value (e.g. {y:"100",x:"100"}, 100 etc.) */
1858				vals[0]=val.y ? val.y : val.x || o.axis==="x" ? null : val;
1859				vals[1]=val.x ? val.x : val.y || o.axis==="y" ? null : val;
1860			}else{ /* array value (e.g. [100,100]) */
1861				vals=val.length>1 ? [val[0],val[1]] : o.axis==="x" ? [null,val[0]] : [val[0],null];
1862			}
1863			/* check if array values are anonymous functions */
1864			if(typeof vals[0]==="function"){vals[0]=vals[0]();}
1865			if(typeof vals[1]==="function"){vals[1]=vals[1]();}
1866			return vals;
1867		},
1868		/* -------------------- */
1869		
1870		
1871		/* translates values (e.g. "top", 100, "100px", "#id") to actual scroll-to positions */
1872		_to=function(val,dir){
1873			if(val==null || typeof val=="undefined"){return;}
1874			var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
1875				mCSB_container=$("#mCSB_"+d.idx+"_container"),
1876				wrapper=mCSB_container.parent(),
1877				t=typeof val;
1878			if(!dir){dir=o.axis==="x" ? "x" : "y";}
1879			var contentLength=dir==="x" ? mCSB_container.outerWidth(false)-wrapper.width() : mCSB_container.outerHeight(false)-wrapper.height(),
1880				contentPos=dir==="x" ? mCSB_container[0].offsetLeft : mCSB_container[0].offsetTop,
1881				cssProp=dir==="x" ? "left" : "top";
1882			switch(t){
1883				case "function": /* this currently is not used. Consider removing it */
1884					return val();
1885					break;
1886				case "object": /* js/jquery object */
1887					var obj=val.jquery ? val : $(val);
1888					if(!obj.length){return;}
1889					return dir==="x" ? _childPos(obj)[1] : _childPos(obj)[0];
1890					break;
1891				case "string": case "number":
1892					if(_isNumeric(val)){ /* numeric value */
1893						return Math.abs(val);
1894					}else if(val.indexOf("%")!==-1){ /* percentage value */
1895						return Math.abs(contentLength*parseInt(val)/100);
1896					}else if(val.indexOf("-=")!==-1){ /* decrease value */
1897						return Math.abs(contentPos-parseInt(val.split("-=")[1]));
1898					}else if(val.indexOf("+=")!==-1){ /* inrease value */
1899						var p=(contentPos+parseInt(val.split("+=")[1]));
1900						return p>=0 ? 0 : Math.abs(p);
1901					}else if(val.indexOf("px")!==-1 && _isNumeric(val.split("px")[0])){ /* pixels string value (e.g. "100px") */
1902						return Math.abs(val.split("px")[0]);
1903					}else{
1904						if(val==="top" || val==="left"){ /* special strings */
1905							return 0;
1906						}else if(val==="bottom"){
1907							return Math.abs(wrapper.height()-mCSB_container.outerHeight(false));
1908						}else if(val==="right"){
1909							return Math.abs(wrapper.width()-mCSB_container.outerWidth(false));
1910						}else if(val==="first" || val==="last"){
1911							var obj=mCSB_container.find(":"+val);
1912							return dir==="x" ? _childPos(obj)[1] : _childPos(obj)[0];
1913						}else{
1914							if($(val).length){ /* jquery selector */
1915								return dir==="x" ? _childPos($(val))[1] : _childPos($(val))[0];
1916							}else{ /* other values (e.g. "100em") */
1917								mCSB_container.css(cssProp,val);
1918								methods.update.call(null,$this[0]);
1919								return;
1920							}
1921						}
1922					}
1923					break;
1924			}
1925		},
1926		/* -------------------- */
1927		
1928		
1929		/* calls the update method automatically */
1930		_autoUpdate=function(rem){
1931			var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
1932				mCSB_container=$("#mCSB_"+d.idx+"_container");
1933			if(rem){
1934				/* 
1935				removes autoUpdate timer 
1936				usage: _autoUpdate.call(this,"remove");
1937				*/
1938				clearTimeout(mCSB_container[0].autoUpdate);
1939				_delete(mCSB_container[0],"autoUpdate");
1940				return;
1941			}
1942			upd();
1943			function upd(){
1944				clearTimeout(mCSB_container[0].autoUpdate);
1945				if($this.parents("html").length===0){
1946					/* check element in dom tree */
1947					$this=null;
1948					return;
1949				}
1950				mCSB_container[0].autoUpdate=setTimeout(function(){
1951					/* update on specific selector(s) length and size change */
1952					if(o.advanced.updateOnSelectorChange){
1953						d.poll.change.n=sizesSum();
1954						if(d.poll.change.n!==d.poll.change.o){
1955							d.poll.change.o=d.poll.change.n;
1956							doUpd(3);
1957							return;
1958						}
1959					}
1960					/* update on main element and scrollbar size changes */
1961					if(o.advanced.updateOnContentResize){
1962						d.poll.size.n=$this[0].scrollHeight+$this[0].scrollWidth+mCSB_container[0].offsetHeight+$this[0].offsetHeight+$this[0].offsetWidth;
1963						if(d.poll.size.n!==d.poll.size.o){
1964							d.poll.size.o=d.poll.size.n;
1965							doUpd(1);
1966							return;
1967						}
1968					}
1969					/* update on image load */
1970					if(o.advanced.updateOnImageLoad){
1971						if(!(o.advanced.updateOnImageLoad==="auto" && o.axis==="y")){ //by default, it doesn't run on vertical content
1972							d.poll.img.n=mCSB_container.find("img").length;
1973							if(d.poll.img.n!==d.poll.img.o){
1974								d.poll.img.o=d.poll.img.n;
1975								mCSB_container.find("img").each(function(){
1976									imgLoader(this);
1977								});
1978								return;
1979							}
1980						}
1981					}
1982					if(o.advanced.updateOnSelectorChange || o.advanced.updateOnContentResize || o.advanced.updateOnImageLoad){upd();}
1983				},o.advanced.autoUpdateTimeout);
1984			}
1985			/* a tiny image loader */
1986			function imgLoader(el){
1987				if($(el).hasClass(classes[2])){doUpd(); return;}
1988				var img=new Image();
1989				function createDelegate(contextObject,delegateMethod){
1990					return function(){return delegateMethod.apply(contextObject,arguments);}
1991				}
1992				function imgOnLoad(){
1993					this.onload=null;
1994					$(el).addClass(classes[2]);
1995					doUpd(2);
1996				}
1997				img.onload=createDelegate(img,imgOnLoad);
1998				img.src=el.src;
1999			}
2000			/* returns the total height and width sum of all elements matching the selector */
2001			function sizesSum(){
2002				if(o.advanced.updateOnSelectorChange===true){o.advanced.updateOnSelectorChange="*";}
2003				var total=0,sel=mCSB_container.find(o.advanced.updateOnSelectorChange);
2004				if(o.advanced.updateOnSelectorChange && sel.length>0){sel.each(function(){total+=this.offsetHeight+this.offsetWidth;});}
2005				return total;
2006			}
2007			/* calls the update method */
2008			function doUpd(cb){
2009				clearTimeout(mCSB_container[0].autoUpdate);
2010				methods.update.call(null,$this[0],cb);
2011			}
2012		},
2013		/* -------------------- */
2014		
2015		
2016		/* snaps scrolling to a multiple of a pixels number */
2017		_snapAmount=function(to,amount,offset){
2018			return (Math.round(to/amount)*amount-offset); 
2019		},
2020		/* -------------------- */
2021		
2022		
2023		/* stops content and scrollbar animations */
2024		_stop=function(el){
2025			var d=el.data(pluginPfx),
2026				sel=$("#mCSB_"+d.idx+"_container,#mCSB_"+d.idx+"_container_wrapper,#mCSB_"+d.idx+"_dragger_vertical,#mCSB_"+d.idx+"_dragger_horizontal");
2027			sel.each(function(){
2028				_stopTween.call(this);
2029			});
2030		},
2031		/* -------------------- */
2032		
2033		
2034		/* 
2035		ANIMATES CONTENT 
2036		This is where the actual scrolling happens
2037		*/
2038		_scrollTo=function(el,to,options){
2039			var d=el.data(pluginPfx),o=d.opt,
2040				defaults={
2041					trigger:"internal",
2042					dir:"y",
2043					scrollEasing:"mcsEaseOut",
2044					drag:false,
2045					dur:o.scrollInertia,
2046					overwrite:"all",
2047					callbacks:true,
2048					onStart:true,
2049					onUpdate:true,
2050					onComplete:true
2051				},
2052				options=$.extend(defaults,options),
2053				dur=[options.dur,(options.drag ? 0 : options.dur)],
2054				mCustomScrollBox=$("#mCSB_"+d.idx),
2055				mCSB_container=$("#mCSB_"+d.idx+"_container"),
2056				wrapper=mCSB_container.parent(),
2057				totalScrollOffsets=o.callbacks.onTotalScrollOffset ? _arr.call(el,o.callbacks.onTotalScrollOffset) : [0,0],
2058				totalScrollBackOffsets=o.callbacks.onTotalScrollBackOffset ? _arr.call(el,o.callbacks.onTotalScrollBackOffset) : [0,0];
2059			d.trigger=options.trigger;
2060			if(wrapper.scrollTop()!==0 || wrapper.scrollLeft()!==0){ /* always reset scrollTop/Left */
2061				$(".mCSB_"+d.idx+"_scrollbar").css("visibility","visible");
2062				wrapper.scrollTop(0).scrollLeft(0);
2063			}
2064			if(to==="_resetY" && !d.contentReset.y){
2065				/* callbacks: onOverflowYNone */
2066				if(_cb("onOverflowYNone")){o.callbacks.onOverflowYNone.call(el[0]);}
2067				d.contentReset.y=1;
2068			}
2069			if(to==="_resetX" && !d.contentReset.x){
2070				/* callbacks: onOverflowXNone */
2071				if(_cb("onOverflowXNone")){o.callbacks.onOverflowXNone.call(el[0]);}
2072				d.contentReset.x=1;
2073			}
2074			if(to==="_resetY" || to==="_resetX"){return;}
2075			if((d.contentReset.y || !el[0].mcs) && d.overflowed[0]){
2076				/* callbacks: onOverflowY */
2077				if(_cb("onOverflowY")){o.callbacks.onOverflowY.call(el[0]);}
2078				d.contentReset.x=null;
2079			}
2080			if((d.contentReset.x || !el[0].mcs) && d.overflowed[1]){
2081				/* callbacks: onOverflowX */
2082				if(_cb("onOverflowX")){o.callbacks.onOverflowX.call(el[0]);}
2083				d.contentReset.x=null;
2084			}
2085			if(o.snapAmount){ /* scrolling snapping */
2086				var snapAmount=!(o.snapAmount instanceof Array) ? o.snapAmount : options.dir==="x" ? o.snapAmount[1] : o.snapAmount[0];
2087				to=_snapAmount(to,snapAmount,o.snapOffset);
2088			}
2089			switch(options.dir){
2090				case "x":
2091					var mCSB_dragger=$("#mCSB_"+d.idx+"_dragger_horizontal"),
2092						property="left",
2093						contentPos=mCSB_container[0].offsetLeft,
2094						limit=[
2095							mCustomScrollBox.width()-mCSB_container.outerWidth(false),
2096							mCSB_dragger.parent().width()-mCSB_dragger.width()
2097						],
2098						scrollTo=[to,to===0 ? 0 : (to/d.scrollRatio.x)],
2099						tso=totalScrollOffsets[1],
2100						tsbo=totalScrollBackOffsets[1],
2101						totalScrollOffset=tso>0 ? tso/d.scrollRatio.x : 0,
2102						totalScrollBackOffset=tsbo>0 ? tsbo/d.scrollRatio.x : 0;
2103					break;
2104				case "y":
2105					var mCSB_dragger=$("#mCSB_"+d.idx+"_dragger_vertical"),
2106						property="top",
2107						contentPos=mCSB_container[0].offsetTop,
2108						limit=[
2109							mCustomScrollBox.height()-mCSB_container.outerHeight(false),
2110							mCSB_dragger.parent().height()-mCSB_dragger.height()
2111						],
2112						scrollTo=[to,to===0 ? 0 : (to/d.scrollRatio.y)],
2113						tso=totalScrollOffsets[0],
2114						tsbo=totalScrollBackOffsets[0],
2115						totalScrollOffset=tso>0 ? tso/d.scrollRatio.y : 0,
2116						totalScrollBackOffset=tsbo>0 ? tsbo/d.scrollRatio.y : 0;
2117					break;
2118			}
2119			if(scrollTo[1]<0 || (scrollTo[0]===0 && scrollTo[1]===0)){
2120				scrollTo=[0,0];
2121			}else if(scrollTo[1]>=limit[1]){
2122				scrollTo=[limit[0],limit[1]];
2123			}else{
2124				scrollTo[0]=-scrollTo[0];
2125			}
2126			if(!el[0].mcs){
2127				_mcs();  /* init mcs object (once) to make it available before callbacks */
2128				if(_cb("onInit")){o.callbacks.onInit.call(el[0]);} /* callbacks: onInit */
2129			}
2130			clearTimeout(mCSB_container[0].onCompleteTimeout);
2131			_tweenTo(mCSB_dragger[0],property,Math.round(scrollTo[1]),dur[1],options.scrollEasing);
2132			if(!d.tweenRunning && ((contentPos===0 && scrollTo[0]>=0) || (contentPos===limit[0] && scrollTo[0]<=limit[0]))){return;}
2133			_tweenTo(mCSB_container[0],property,Math.round(scrollTo[0]),dur[0],options.scrollEasing,options.overwrite,{
2134				onStart:function(){
2135					if(options.callbacks && options.onStart && !d.tweenRunning){
2136						/* callbacks: onScrollStart */
2137						if(_cb("onScrollStart")){_mcs(); o.callbacks.onScrollStart.call(el[0]);}
2138						d.tweenRunning=true;
2139						_onDragClasses(mCSB_dragger);
2140						d.cbOffsets=_cbOffsets();
2141					}
2142				},onUpdate:function(){
2143					if(options.callbacks && options.onUpdate){
2144						/* callbacks: whileScrolling */
2145						if(_cb("whileScrolling")){_mcs(); o.callbacks.whileScrolling.call(el[0]);}
2146					}
2147				},onComplete:function(){
2148					if(options.callbacks && options.onComplete){
2149						if(o.axis==="yx"){clearTimeout(mCSB_container[0].onCompleteTimeout);}
2150						var t=mCSB_container[0].idleTimer || 0;
2151						mCSB_container[0].onCompleteTimeout=setTimeout(function(){
2152							/* callbacks: onScroll, onTotalScroll, onTotalScrollBack */
2153							if(_cb("onScroll")){_mcs(); o.callbacks.onScroll.call(el[0]);}
2154							if(_cb("onTotalScroll") && scrollTo[1]>=limit[1]-totalScrollOffset && d.cbOffsets[0]){_mcs(); o.callbacks.onTotalScroll.call(el[0]);}
2155							if(_cb("onTotalScrollBack") && scrollTo[1]<=totalScrollBackOffset && d.cbOffsets[1]){_mcs(); o.callbacks.onTotalScrollBack.call(el[0]);}
2156							d.tweenRunning=false;
2157							mCSB_container[0].idleTimer=0;
2158							_onDragClasses(mCSB_dragger,"hide");
2159						},t);
2160					}
2161				}
2162			});
2163			/* checks if callback function exists */
2164			function _cb(cb){
2165				return d && o.callbacks[cb] && typeof o.callbacks[cb]==="function";
2166			}
2167			/* checks whether callback offsets always trigger */
2168			function _cbOffsets(){
2169				return [o.callbacks.alwaysTriggerOffsets || contentPos>=limit[0]+tso,o.callbacks.alwaysTriggerOffsets || contentPos<=-tsbo];
2170			}
2171			/* 
2172			populates object with useful values for the user 
2173			values: 
2174				content: this.mcs.content
2175				content top position: this.mcs.top 
2176				content left position: this.mcs.left 
2177				dragger top position: this.mcs.draggerTop 
2178				dragger left position: this.mcs.draggerLeft 
2179				scrolling y percentage: this.mcs.topPct 
2180				scrolling x percentage: this.mcs.leftPct 
2181				scrolling direction: this.mcs.direction
2182			*/
2183			function _mcs(){
2184				var cp=[mCSB_container[0].offsetTop,mCSB_container[0].offsetLeft], /* content position */
2185					dp=[mCSB_dragger[0].offsetTop,mCSB_dragger[0].offsetLeft], /* dragger position */
2186					cl=[mCSB_container.outerHeight(false),mCSB_container.outerWidth(false)], /* content length */
2187					pl=[mCustomScrollBox.height(),mCustomScrollBox.width()]; /* content parent length */
2188				el[0].mcs={
2189					content:mCSB_container, /* original content wrapper as jquery object */
2190					top:cp[0],left:cp[1],draggerTop:dp[0],draggerLeft:dp[1],
2191					topPct:Math.round((100*Math.abs(cp[0]))/(Math.abs(cl[0])-pl[0])),leftPct:Math.round((100*Math.abs(cp[1]))/(Math.abs(cl[1])-pl[1])),
2192					direction:options.dir
2193				};
2194				/* 
2195				this refers to the original element containing the scrollbar(s)
2196				usage: this.mcs.top, this.mcs.leftPct etc. 
2197				*/
2198			}
2199		},
2200		/* -------------------- */
2201		
2202		
2203		/* 
2204		CUSTOM JAVASCRIPT ANIMATION TWEEN 
2205		Lighter and faster than jquery animate() and css transitions 
2206		Animates top/left properties and includes easings 
2207		*/
2208		_tweenTo=function(el,prop,to,duration,easing,overwrite,callbacks){
2209			if(!el._mTween){el._mTween={top:{},left:{}};}
2210			var callbacks=callbacks || {},
2211				onStart=callbacks.onStart || function(){},onUpdate=callbacks.onUpdate || function(){},onComplete=callbacks.onComplete || function(){},
2212				startTime=_getTime(),_delay,progress=0,from=el.offsetTop,elStyle=el.style,_request,tobj=el._mTween[prop];
2213			if(prop==="left"){from=el.offsetLeft;}
2214			var diff=to-from;
2215			tobj.stop=0;
2216			if(overwrite!=="none"){_cancelTween();}
2217			_startTween();
2218			function _step(){
2219				if(tobj.stop){return;}
2220				if(!progress){onStart.call();}
2221				progress=_getTime()-startTime;
2222				_tween();
2223				if(progress>=tobj.time){
2224					tobj.time=(progress>tobj.time) ? progress+_delay-(progress-tobj.time) : progress+_delay-1;
2225					if(tobj.time<progress+1){tobj.time=progress+1;}
2226				}
2227				if(tobj.time<duration){tobj.id=_request(_step);}else{onComplete.call();}
2228			}
2229			function _tween(){
2230				if(duration>0){
2231					tobj.currVal=_ease(tobj.time,from,diff,duration,easing);
2232					elStyle[prop]=Math.round(tobj.currVal)+"px";
2233				}else{
2234					elStyle[prop]=to+"px";
2235				}
2236				onUpdate.call();
2237			}
2238			function _startTween(){
2239				_delay=1000/60;
2240				tobj.time=progress+_delay;
2241				_request=(!window.requestAnimationFrame) ? function(f){_tween(); return setTimeout(f,0.01);} : window.requestAnimationFrame;
2242				tobj.id=_request(_step);
2243			}
2244			function _cancelTween(){
2245				if(tobj.id==null){return;}
2246				if(!window.requestAnimationFrame){clearTimeout(tobj.id);
2247				}else{window.cancelAnimationFrame(tobj.id);}
2248				tobj.id=null;
2249			}
2250			function _ease(t,b,c,d,type){
2251				switch(type){
2252					case "linear": case "mcsLinear":
2253						return c*t/d + b;
2254						break;
2255					case "mcsLinearOut":
2256						t/=d; t--; return c * Math.sqrt(1 - t*t) + b;
2257						break;
2258					case "easeInOutSmooth":
2259						t/=d/2;
2260						if(t<1) return c/2*t*t + b;
2261						t--;
2262						return -c/2 * (t*(t-2) - 1) + b;
2263						break;
2264					case "easeInOutStrong":
2265						t/=d/2;
2266						if(t<1) return c/2 * Math.pow( 2, 10 * (t - 1) ) + b;
2267						t--;
2268						return c/2 * ( -Math.pow( 2, -10 * t) + 2 ) + b;
2269						break;
2270					case "easeInOut": case "mcsEaseInOut":
2271						t/=d/2;
2272						if(t<1) return c/2*t*t*t + b;
2273						t-=2;
2274						return c/2*(t*t*t + 2) + b;
2275						break;
2276					case "easeOutSmooth":
2277						t/=d; t--;
2278						return -c * (t*t*t*t - 1) + b;
2279						break;
2280					case "easeOutStrong":
2281						return c * ( -Math.pow( 2, -10 * t/d ) + 1 ) + b;
2282						break;
2283					case "easeOut": case "mcsEaseOut": default:
2284						var ts=(t/=d)*t,tc=ts*t;
2285						return b+c*(0.499999999999997*tc*ts + -2.5*ts*ts + 5.5*tc + -6.5*ts + 4*t);
2286				}
2287			}
2288		},
2289		/* -------------------- */
2290		
2291		
2292		/* returns current time */
2293		_getTime=function(){
2294			if(window.performance && window.performance.now){
2295				return window.performance.now();
2296			}else{
2297				if(window.performance && window.performance.webkitNow){
2298					return window.performance.webkitNow();
2299				}else{
2300					if(Date.now){return Date.now();}else{return new Date().getTime();}
2301				}
2302			}
2303		},
2304		/* -------------------- */
2305		
2306		
2307		/* stops a tween */
2308		_stopTween=function(){
2309			var el=this;
2310			if(!el._mTween){el._mTween={top:{},left:{}};}
2311			var props=["top","left"];
2312			for(var i=0; i<props.length; i++){
2313				var prop=props[i];
2314				if(el._mTween[prop].id){
2315					if(!window.requestAnimationFrame){clearTimeout(el._mTween[prop].id);
2316					}else{window.cancelAnimationFrame(el._mTween[prop].id);}
2317					el._mTween[prop].id=null;
2318					el._mTween[prop].stop=1;
2319				}
2320			}
2321		},
2322		/* -------------------- */
2323		
2324		
2325		/* deletes a property (avoiding the exception thrown by IE) */
2326		_delete=function(c,m){
2327			try{delete c[m];}catch(e){c[m]=null;}
2328		},
2329		/* -------------------- */
2330		
2331		
2332		/* detects left mouse button */
2333		_mouseBtnLeft=function(e){
2334			return !(e.which && e.which!==1);
2335		},
2336		/* -------------------- */
2337		
2338		
2339		/* detects if pointer type event is touch */
2340		_pointerTouch=function(e){
2341			var t=e.originalEvent.pointerType;
2342			return !(t && t!=="touch" && t!==2);
2343		},
2344		/* -------------------- */
2345		
2346		
2347		/* checks if value is numeric */
2348		_isNumeric=function(val){
2349			return !isNaN(parseFloat(val)) && isFinite(val);
2350		},
2351		/* -------------------- */
2352		
2353		
2354		/* returns element position according to content */
2355		_childPos=function(el){
2356			var p=el.parents(".mCSB_container");
2357			return [el.offset().top-p.offset().top,el.offset().left-p.offset().left];
2358		},
2359		/* -------------------- */
2360		
2361		
2362		/* checks if browser tab is hidden/inactive via Page Visibility API */
2363		_isTabHidden=function(){
2364			var prop=_getHiddenProp();
2365			if(!prop) return false;
2366			return document[prop];
2367			function _getHiddenProp(){
2368				var pfx=["webkit","moz","ms","o"];
2369				if("hidden" in document) return "hidden"; //natively supported
2370				for(var i=0; i<pfx.length; i++){ //prefixed
2371				    if((pfx[i]+"Hidden") in document) 
2372				        return pfx[i]+"Hidden";
2373				}
2374				return null; //not supported
2375			}
2376		};
2377		/* -------------------- */
2378		
2379	
2380	
2381	
2382	
2383	/* 
2384	----------------------------------------
2385	PLUGIN SETUP 
2386	----------------------------------------
2387	*/
2388	
2389	/* plugin constructor functions */
2390	$.fn[pluginNS]=function(method){ /* usage: $(selector).mCustomScrollbar(); */
2391		if(methods[method]){
2392			return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
2393		}else if(typeof method==="object" || !method){
2394			return methods.init.apply(this,arguments);
2395		}else{
2396			$.error("Method "+method+" does not exist");
2397		}
2398	};
2399	$[pluginNS]=function(method){ /* usage: $.mCustomScrollbar(); */
2400		if(methods[method]){
2401			return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
2402		}else if(typeof method==="object" || !method){
2403			return methods.init.apply(this,arguments);
2404		}else{
2405			$.error("Method "+method+" does not exist");
2406		}
2407	};
2408	
2409	/* 
2410	allow setting plugin default options. 
2411	usage: $.mCustomScrollbar.defaults.scrollInertia=500; 
2412	to apply any changed default options on default selectors (below), use inside document ready fn 
2413	e.g.: $(document).ready(function(){ $.mCustomScrollbar.defaults.scrollInertia=500; });
2414	*/
2415	$[pluginNS].defaults=defaults;
2416	
2417	/* 
2418	add window object (window.mCustomScrollbar) 
2419	usage: if(window.mCustomScrollbar){console.log("custom scrollbar plugin loaded");}
2420	*/
2421	window[pluginNS]=true;
2422	
2423	$(window).bind("load",function(){
2424		
2425		$(defaultSelector)[pluginNS](); /* add scrollbars automatically on default selector */
2426		
2427		/* extend jQuery expressions */
2428		$.extend($.expr[":"],{
2429			/* checks if element is within scrollable viewport */
2430			mcsInView:$.expr[":"].mcsInView || function(el){
2431				var $el=$(el),content=$el.parents(".mCSB_container"),wrapper,cPos;
2432				if(!content.length){return;}
2433				wrapper=content.parent();
2434				cPos=[content[0].offsetTop,content[0].offsetLeft];
2435				return 	cPos[0]+_childPos($el)[0]>=0 && cPos[0]+_childPos($el)[0]<wrapper.height()-$el.outerHeight(false) && 
2436						cPos[1]+_childPos($el)[1]>=0 && cPos[1]+_childPos($el)[1]<wrapper.width()-$el.outerWidth(false);
2437			},
2438			/* checks if element or part of element is in view of scrollable viewport */
2439			mcsInSight:$.expr[":"].mcsInSight || function(el,i,m){
2440				var $el=$(el),elD,content=$el.parents(".mCSB_container"),wrapperView,pos,wrapperViewPct,
2441					pctVals=m[3]==="exact" ? [[1,0],[1,0]] : [[0.9,0.1],[0.6,0.4]];
2442				if(!content.length){return;}
2443				elD=[$el.outerHeight(false),$el.outerWidth(false)];
2444				pos=[content[0].offsetTop+_childPos($el)[0],content[0].offsetLeft+_childPos($el)[1]];
2445				wrapperView=[content.parent()[0].offsetHeight,content.parent()[0].offsetWidth];
2446				wrapperViewPct=[elD[0]<wrapperView[0] ? pctVals[0] : pctVals[1],elD[1]<wrapperView[1] ? pctVals[0] : pctVals[1]];
2447				return 	pos[0]-(wrapperView[0]*wrapperViewPct[0][0])<0 && pos[0]+elD[0]-(wrapperView[0]*wrapperViewPct[0][1])>=0 && 
2448						pos[1]-(wrapperView[1]*wrapperViewPct[1][0])<0 && pos[1]+elD[1]-(wrapperView[1]*wrapperViewPct[1][1])>=0;
2449			},
2450			/* checks if element is overflowed having visible scrollbar(s) */
2451			mcsOverflow:$.expr[":"].mcsOverflow || function(el){
2452				var d=$(el).data(pluginPfx);
2453				if(!d){return;}
2454				return d.overflowed[0] || d.overflowed[1];
2455			}
2456		});
2457	
2458	});
2459
2460}))}));
2461/* End */
2462;
2463; /* Start:"a:4:{s:4:"full";s:53:"/bitrix/templates/aib_flex/js/grasp.js?17253514833433";s:6:"source";s:38:"/bitrix/templates/aib_flex/js/grasp.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/
2464!function(p) {
2465    function d(t) {
2466        return t.indexOf("px") ? t.substring(0, t.length - 2) : canvas_height.indexOf("%") ? t.substring(0, t.length - 1) : void 0
2467    }
2468    function n(t) {
2469        if (t.toString().indexOf("px") < -1 && t.toString().indexOf("%") < -1)
2470            return t + "px"
2471    }
2472    function g(t, i) {
2473        return i < 0 ? parseInt(t) / 100 * 360 * (Math.PI / 180) - Math.PI / 2 : (parseInt(t) + parseInt(i)) / 100 * 360 * (Math.PI / 180) - Math.PI / 2
2474    }
2475    function h(t) {
2476        var i = d(l.height.toString())
2477          , e = d(l.width.toString())
2478          , n = document.createElement("canvas");
2479        n.height = i,
2480        n.width = e;
2481        var r = n.getContext("2d");
2482        r.strokeStyle = l.color,
2483        r.lineWidth = l.line_width,
2484        r.beginPath();
2485        var s, h = g(l.starting_position, -1), o = g(l.starting_position, l.percent), c = e / 2, a = i / 2;
2486        return s = e <= i ? .9 * e / 2 - 2 * l.line_width : .9 * i / 2 - 2 * l.line_width,
2487        r.arc(c, a, s, h, o, l.counter_clockwise),
2488        r.stroke(),
2489        "percent" == l.text && p(".gmpc-percent-text").text(Math.round(l.percent) + "%"),
2490        n
2491    }
2492    var l = {}
2493      , i = {
2494        init: function(t) {
2495            var i = p.extend({
2496                color: "#0B2546",
2497                height: "200px",
2498                width: "200px",
2499                line_width: 8,
2500                starting_position: 25,
2501                percent: 100,
2502                counter_clockwise: !1,
2503                text: "percent",
2504                font_size: "28px",
2505                font_family: "Helvetica"
2506            }, t);
2507            l = i;
2508            var e = p("<div class='gmpc-percent-text'></div>");
2509            return e.css({
2510                "font-size": l.font_size,
2511                "font-family": l.font_family
2512            }),
2513            "percent" != l.text && e.text(l.text),
2514            p(this).append(e),
2515            100 != l.starting_position && (l.starting_position = l.starting_position % 100),
2516            100 != l.ending_position && (l.ending_position = l.ending_position % 100),
2517            n(l.width),
2518            n(l.height),
2519            p(this).css({
2520                height: l.height,
2521                width: l.width
2522            }),
2523            p(this).addClass("gmpc"),
2524            p(this).find("canvas").remove(),
2525            p(this).append(h(p(this))),
2526            this
2527        },
2528        percent: function(t) {
2529            return l.percent = t,
2530            p(this).css({
2531                height: l.height,
2532                width: l.width
2533            }),
2534            p(this).children("canvas").remove(),
2535            p(this).append(h(p(this))),
2536            this
2537        },
2538        animate: function(t, i) {
2539            p(this).css({
2540                height: l.height,
2541                width: l.width
2542            });
2543            var e = i / 10
2544              , n = (t - l.percent) / e
2545              , r = p(this)
2546              , s = setInterval(function() {
2547                l.percent < t ? (r.children("canvas").remove(),
2548                l.percent += n,
2549                r.append(h())) : clearInterval(s)
2550            }, 10);
2551            return this
2552        }
2553    };
2554    p.fn.gmpc = function(t) {
2555        return i[t] ? i[t].apply(this, Array.prototype.slice.call(arguments, 1)) : "object" != typeof t && t ? void p.error("Method " + t + " does not exist.") 
2555: i.init.apply(this, arguments)
2556    }
2557}(jQuery);
2558
2559/* End */
2560;
2561; /* Start:"a:4:{s:4:"full";s:60:"/bitrix/templates/aib_flex/js/jquery.vide.js?172535148311713";s:6:"source";s:44:"/bitrix/templates/aib_flex/js/jquery.vide.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/
2562/*
2563 *  Vide - v0.5.1
2564 *  Easy as hell jQuery plugin for video backgrounds.
2565 *  http://vodkabears.github.io/vide/
2566 *
2567 *  Made by Ilya Makarov
2568 *  Under MIT License
2569 */
2570!(function (root, factory) {
2571  if (typeof define === 'function' && define.amd) {
2572    define(['jquery'], factory);
2573  } else if (typeof exports === 'object') {
2574    factory(require('jquery'));
2575  } else {
2576    factory(root.jQuery);
2577  }
2578}) (this, function ($) {
2579  'use strict';
2580  /**
2581   * Name of the plugin
2582   * @private
2583   * @const
2584   * @type {String}
2585   */
2586  var PLUGIN_NAME = 'vide';
2587  /**
2588   * Default settings
2589   * @private
2590   * @const
2591   * @type {Object}
2592   */
2593  var DEFAULTS = {
2594    volume: 1,
2595    playbackRate: 1,
2596    muted: true,
2597    loop: true,
2598    autoplay: true,
2599    position: '50% 50%',
2600    posterType: 'detect',
2601    resizing: true,
2602    bgColor: 'transparent',
2603    className: ''
2604  };
2605  /**
2606   * Not implemented error message
2607   * @private
2608   * @const
2609   * @type {String}
2610   */
2611  var NOT_IMPLEMENTED_MSG = 'Not implemented';
2612  /**
2613   * Parse a string with options
2614   * @private
2615   * @param {String} str
2616   * @returns {Object|String}
2617   */
2618  function parseOptions(str) {
2619    var obj = {
2620    };
2621    var delimiterIndex;
2622    var option;
2623    var prop;
2624    var val;
2625    var arr;
2626    var len;
2627    var i;
2628    // Remove spaces around delimiters and split
2629    arr = str.replace(/\s*:\s*/g, ':').replace(/\s*,\s*/g, ',').split(',');
2630    // Parse a string
2631    for (i = 0, len = arr.length; i < len; i++) {
2632      option = arr[i];
2633      // Ignore urls and a string without colon delimiters
2634      if (option.search(/^(http|https|ftp):\/\//) !== - 1 || option.search(':') === - 1
2635      ) {
2636        break;
2637      }
2638      delimiterIndex = option.indexOf(':');
2639      prop = option.substring(0, delimiterIndex);
2640      val = option.substring(delimiterIndex + 1);
2641      // If val is an empty string, make it undefined
2642      if (!val) {
2643        val = undefined;
2644      }      // Convert a string value if it is like a boolean
2645
2646      if (typeof val === 'string') {
2647        val = val === 'true' || (val === 'false' ? false : val);
2648      }      // Convert a string value if it is like a number
2649
2650      if (typeof val === 'string') {
2651        val = !isNaN(val) ? + val : val;
2652      }
2653      obj[prop] = val;
2654    }    // If nothing is parsed
2655
2656    if (prop == null && val == null) {
2657      return str;
2658    }
2659    return obj;
2660  }  /**
2661   * Parse a position option
2662   * @private
2663   * @param {String} str
2664   * @returns {Object}
2665   */
2666
2667  function parsePosition(str) {
2668    str = '' + str;
2669    // Default value is a center
2670    var args = str.split(/\s+/);
2671    var x = '50%';
2672    var y = '50%';
2673    var len;
2674    var arg;
2675    var i;
2676    for (i = 0, len = args.length; i < len; i++) {
2677      arg = args[i];
2678      // Convert values
2679      if (arg === 'left') {
2680        x = '0%';
2681      } else if (arg === 'right') {
2682        x = '100%';
2683      } else if (arg === 'top') {
2684        y = '0%';
2685      } else if (arg === 'bottom') {
2686        y = '100%';
2687      } else if (arg === 'center') {
2688        if (i === 0) {
2689          x = '50%';
2690        } else {
2691          y = '50%';
2692        }
2693      } else {
2694        if (i === 0) {
2695          x = arg;
2696        } else {
2697          y = arg;
2698        }
2699      }
2700    }
2701    return {
2702      x: x,
2703      y: y
2704    };
2705  }  /**
2706   * Search a poster
2707   * @private
2708   * @param {String} path
2709   * @param {Function} callback
2710   */
2711
2712  function findPoster(path, callback) {
2713    var onLoad = function () {
2714      callback(this.src);
2715    };
2716  }  /**
2717   * Vide constructor
2718   * @param {HTMLElement} element
2719   * @param {Object|String} path
2720   * @param {Object|String} options
2721   * @constructor
2722   */
2723
2724  function Vide(element, path, options) {
2725    this.$element = $(element);
2726    // Parse path
2727    if (typeof path === 'string') {
2728      path = parseOptions(path);
2729    }    // Parse options
2730
2731    if (!options) {
2732      options = {
2733      };
2734    } else if (typeof options === 'string') {
2735      options = parseOptions(options);
2736    }    // Remove an extension
2737
2738    if (typeof path === 'string') {
2739      path = path.replace(/\.\w*$/, '');
2740    } else if (typeof path === 'object') {
2741      for (var i in path) {
2742        if (path.hasOwnProperty(i)) {
2743          path[i] = path[i].replace(/\.\w*$/, '');
2744        }
2745      }
2746    }
2747    this.settings = $.extend({
2748    }, DEFAULTS, options);
2749    this.path = path;
2750    // https://github.com/VodkaBears/Vide/issues/110
2751    try {
2752      this.init();
2753    } catch (e) {
2754      if (e.message !== NOT_IMPLEMENTED_MSG) {
2755        throw e;
2756      }
2757    }
2758  }  /**
2759   * Initialization
2760   * @public
2761   */
2762
2763  Vide.prototype.init = function () {
2764    var vide = this;
2765    var path = vide.path;
2766    var poster = path;
2767    var sources = '';
2768    var $element = vide.$element;
2769    var settings = vide.settings;
2770    var position = parsePosition(settings.position);
2771    var posterType = settings.posterType;
2772    var $video;
2773    var $wrapper;
2774    // Set styles of a video wrapper
2775    $wrapper = vide.$wrapper = $('<div>').addClass(settings.className).css({
2776      position: 'absolute',
2777      'z-index': - 1,
2778      top: 0,
2779      left: 0,
2780      bottom: 0,
2781      right: 0,
2782      overflow: 'hidden',
2783      '-webkit-background-size': 'cover',
2784      '-moz-background-size': 'cover',
2785      '-o-background-size': 'cover',
2786      'background-size': 'cover',
2787      'background-color': settings.bgColor,
2788      'background-repeat': 'no-repeat',
2789      'background-position': position.x + ' ' + position.y
2790    });
2791    // Get a poster path
2792    if (typeof path === 'object') {
2793      if (path.poster) {
2794        poster = path.poster;
2795      } else {
2796        if (path.mp4) {
2797          poster = path.mp4;
2798        } else if (path.webm) {
2799          poster = path.webm;
2800        } else if (path.ogv) {
2801          poster = path.ogv;
2802        }
2803      }
2804    }    // Set a video poster
2805
2806    if (posterType === 'detect') {
2807      findPoster(poster, function (url) {
2808        $wrapper.css('background-image', 'url(' + url + ')');
2809      });
2810    } else if (posterType !== 'none') {
2811      $wrapper.css('background-image', 'url(' + poster + '.' + posterType + ')');
2812    }    // If a parent element has a static position, make it relative
2813
2814    if ($element.css('position') === 'static') {
2815      $element.css('position', 'static');
2816    }
2817    $element.prepend($wrapper);
2818    if (typeof path === 'object') {
2819      if (path.mp4) {
2820        sources += '<source src="' + path.mp4 + '.mp4" type="video/mp4">';
2821      }
2822      if (path.webm) {
2823        sources += '<source src="' + path.webm + '.webm" type="video/webm">';
2824      }
2825      if (path.ogv) {
2826        sources += '<source src="' + path.ogv + '.ogv" type="video/ogg">';
2827      }
2828      $video = vide.$video = $('<video>' + sources + '</video>');
2829    } else {
2830      $video = vide.$video = $('<video>' +
2831      '<source src="' + path + '.mp4" type="video/mp4">' +
2832      '<source src="' + path + '.webm" type="video/webm">' +
2833      '<source src="' + path + '.ogv" type="video/ogg">' +
2834      '</video>');
2835    }    // https://github.com/VodkaBears/Vide/issues/110
2836
2837    try {
2838      $video      // Set video properties
2839      .prop({
2840        autoplay: settings.autoplay,
2841        loop: settings.loop,
2842        volume: settings.volume,
2843        muted: settings.muted,
2844        defaultMuted: settings.muted,
2845        playbackRate: settings.playbackRate,
2846        defaultPlaybackRate: settings.playbackRate
2847      });
2848    } catch (e) {
2849      throw new Error(NOT_IMPLEMENTED_MSG);
2850    }    // Video alignment
2851
2852    $video.css({
2853      margin: 'auto',
2854      position: 'absolute',
2855      'z-index': - 1,
2856      top: position.y,
2857      left: position.x,
2858      '-webkit-transform': 'translate(-' + position.x + ', -' + position.y + ')',
2859      '-ms-transform': 'translate(-' + position.x + ', -' + position.y + ')',
2860      '-moz-transform': 'translate(-' + position.x + ', -' + position.y + ')',
2861      transform: 'translate(-' + position.x + ', -' + position.y + ')',
2862      // Disable visibility, while loading
2863      visibility: 'hidden',
2864      opacity: 0
2865    })    // Resize a video, when it's loaded
2866    .one('canplaythrough.' + PLUGIN_NAME, function () {
2867      vide.resize();
2868    })    // Make it visible, when it's already playing
2869    .one('playing.' + PLUGIN_NAME, function () {
2870      $video.css({
2871        visibility: 'visible',
2872        opacity: 1
2873      });
2874      $wrapper.css('background-image', 'none');
2875    });
2876    // Resize event is available only for 'window'
2877    // Use another code solutions to detect DOM elements resizing
2878    $element.on('resize.' + PLUGIN_NAME, function () {
2879      if (settings.resizing) {
2880        vide.resize();
2881      }
2882    });
2883    // Append a video
2884    $wrapper.append($video);
2885  };
2886  /**
2887   * Get a video element
2888   * @public
2889   * @returns {HTMLVideoElement}
2890   */
2891  Vide.prototype.getVideoObject = function () {
2892    return this.$video[0];
2893  };
2894  /**
2895   * Resize a video background
2896   * @public
2897   */
2898  Vide.prototype.resize = function () {
2899    if (!this.$video) {
2900      return;
2901    }
2902    var $wrapper = this.$wrapper;
2903    var $video = this.$video;
2904    var video = $video[0];
2905    // Get a native video size
2906    var videoHeight = video.videoHeight;
2907    var videoWidth = video.videoWidth;
2908    // Get a wrapper size
2909    var wrapperHeight = $wrapper.height();
vendor: 11,142 bytes, lines 2910-3003
2910    var wrapperWidth = $wrapper.width();
2911    if (wrapperWidth / videoWidth > wrapperHeight / videoHeight) {
2912      $video.css({
2913        // +2 pixels to prevent an empty space after transformation
2914        width: wrapperWidth + 2,
2915        height: 'auto'
2916      });
2917    } else {
2918      $video.css({
2919        width: 'auto',
2920        // +2 pixels to prevent an empty space after transformation
2921        height: wrapperHeight + 2
2922      });
2923    }
2924  };
2925  /**
2926   * Destroy a video background
2927   * @public
2928   */
2929  Vide.prototype.destroy = function () {
2930    delete $[PLUGIN_NAME].lookup[this.index];
2931    this.$video && this.$video.off(PLUGIN_NAME);
2932    this.$element.off(PLUGIN_NAME).removeData(PLUGIN_NAME);
2933    this.$wrapper.remove();
2934  };
2935  /**
2936   * Special plugin object for instances.
2937   * @public
2938   * @type {Object}
2939   */
2940  $[PLUGIN_NAME] = {
2941    lookup: [
2942    ]
2943  };
2944  /**
2945   * Plugin constructor
2946   * @param {Object|String} path
2947   * @param {Object|String} options
2948   * @returns {JQuery}
2949   * @constructor
2950   */
2951  $.fn[PLUGIN_NAME] = function (path, options) {
2952    var instance;
2953    this.each(function () {
2954      instance = $.data(this, PLUGIN_NAME);
2955      // Destroy the plugin instance if exists
2956      instance && instance.destroy();
2957      // Create the plugin instance
2958      instance = new Vide(this, path, options);
2959      instance.index = $[PLUGIN_NAME].lookup.push(instance) - 1;
2960      $.data(this, PLUGIN_NAME, instance);
2961    });
2962    return this;
2963  };
2964  $(document).ready(function () {
2965    var $window = $(window);
2966    // Window resize event listener
2967    $window.on('resize.' + PLUGIN_NAME, function () {
2968      for (var len = $[PLUGIN_NAME].lookup.length, i = 0, instance; i < len; i++) {
2969        instance = $[PLUGIN_NAME].lookup[i];
2970        if (instance && instance.settings.resizing) {
2971          instance.resize();
2972        }
2973      }
2974    });
2975    // https://github.com/VodkaBears/Vide/issues/68
2976    $window.on('unload.' + PLUGIN_NAME, function () {
2977      return false;
2978    });
2979    // Auto initialization
2980    // Add 'data-vide-bg' attribute with a path to the video without extension
2981    // Also you can pass options throw the 'data-vide-options' attribute
2982    // 'data-vide-options' must be like 'muted: false, volume: 0.5'
2983    $(document).find('[data-' + PLUGIN_NAME + '-bg]').each(function (i, element) {
2984      var $element = $(element);
2985      var options = $element.data(PLUGIN_NAME + '-options');
2986      var path = $element.data(PLUGIN_NAME + '-bg');
2987      $element[PLUGIN_NAME](path, options);
2988    });
2989  });
2990});
2991
2992
2993/* End */
2994;
2995; /* Start:"a:4:{s:4:"full";s:55:"/bitrix/templates/aib_flex/js/wow.min.js?17253514838183";s:6:"source";s:40:"/bitrix/templates/aib_flex/js/wow.min.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/
2996/*! WOW - v1.1.2 - 2015-04-07
2997* Copyright (c) 2015 Matthieu Aussaguel; Licensed MIT */(function(){var a,b,c,d,e,f=function(a,b){return function(){return a.apply(b,arguments)}},g=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};b=function(){function a(){}return a.prototype.extend=function(a,b){var c,d;for(c in b)d=b[c],null==a[c]&&(a[c]=d);return a},a.prototype.isMobile=function(a){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(a)},a.prototype.createEvent=function(a,b,c,d){var e;return null==b&&(b=!1),null==c&&(c=!1),null==d&&(d=null),null!=document.createEvent?(e=document.createEvent("CustomEvent"),e.initCustomEvent(a,b,c,d)):null!=document.createEventObject?(e=document.createEventObject(),e.eventType=a):e.eventName=a,e},a.prototype.emitEvent=function(a,b){return null!=a.dispatchEvent?a.dispatchEvent(b):b in(null!=a)?a[b]():"on"+b in(null!=a)?a["on"+b]():void 0},a.prototype.addEvent=function(a,b,c){return null!=a.addEventListener?a.addEventListener(b,c,!1):null!=a.attachEvent?a.attachEvent("on"+b,c):a[b]=c},a.prototype.removeEvent=function(a,b,c){return null!=a.removeEventListener?a.removeEventListener(b,c,!1):null!=a.detachEvent?a.detachEvent("on"+b,c):delete a[b]},a.prototype.innerHeight=function(){return"innerHeight"in window?window.innerHeight:document.documentElement.clientHeight},a}(),c=this.WeakMap||this.MozWeakMap||(c=function(){function a(){this.keys=[],this.values=[]}return a.prototype.get=function(a){var b,c,d,e,f;for(f=this.keys,b=d=0,e=f.length;e>d;b=++d)if(c=f[b],c===a)return this.values[b]},a.prototype.set=function(a,b){var c,d,e,f,g;for(g=this.keys,c=e=0,f=g.length;f>e;c=++e)if(d=g[c],d===a)return void(this.values[c]=b);return this.keys.push(a),this.values.push(b)},a}()),a=this.MutationObserver||this.WebkitMutationObserver||this.MozMutationObserver||(a=function(){function a(){"undefined"!=typeof console&&null!==console&&console.warn("MutationObserver is not supported by your browser."),"undefined"!=typeof console&&null!==console&&console.warn("WOW.js cannot detect dom mutations, please call .sync() after loading new content.")}return a.notSupported=!0,a.prototype.observe=function(){},a}()),d=this.getComputedStyle||function(a){return this.getPropertyValue=function(b){var c;return"float"===b&&(b="styleFloat"),e.test(b)&&b.replace(e,function(a,b){return b.toUpperCase()}),(null!=(c=a.currentStyle)?c[b]:void 0)||null},this},e=/(\-([a-z]){1})/g,this.WOW=function(){function e(a){null==a&&(a={}),this.scrollCallback=f(this.scrollCallback,this),this.scrollHandler=f(this.scrollHandler,this),this.resetAnimation=f(this.resetAnimation,this),this.start=f(this.start,this),this.scrolled=!0,this.config=this.util().extend(a,this.defaults),this.animationNameCache=new c,this.wowEvent=this.util().createEvent(this.config.boxClass)}return e.prototype.defaults={boxClass:"wow",animateClass:"animated",offset:0,mobile:!0,live:!0,callback:null},e.prototype.init=function(){var a;return this.element=window.document.documentElement,"interactive"===(a=document.readyState)||"complete"===a?this.start():this.util().addEvent(document,"DOMContentLoaded",this.start),this.finished=[]},e.prototype.start=function(){var b,c,d,e;if(this.stopped=!1,this.boxes=function(){var a,c,d,e;for(d=this.element.querySelectorAll("."+this.config.boxClass),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(b);return e}.call(this),this.all=function(){var a,c,d,e;for(d=this.boxes,e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(b);return e}.call(this),this.boxes.length)if(this.disabled())this.resetStyle();else for(e=this.boxes,c=0,d=e.length;d>c;c++)b=e[c],this.applyStyle(b,!0);return this.disabled()||(this.util().addEvent(window,"scroll",this.scrollHandler),this.util().addEvent(window,"resize",this.scrollHandler),this.interval=setInterval(this.scrollCallback,50)),this.config.live?new a(function(a){return function(b){var c,d,e,f,g;for(g=[],c=0,d=b.length;d>c;c++)f=b[c],g.push(function(){var a,b,c,d;for(c=f.addedNodes||[],d=[],a=0,b=c.length;b>a;a++)e=c[a],d.push(this.doSync(e));return d}.call(a));return g}}(this)).observe(document.body,{childList:!0,subtree:!0}):void 0},e.prototype.stop=function(){return this.stopped=!0,this.util().removeEvent(window,"scroll",this.scrollHandler),this.util().removeEvent(window,"resize",this.scrollHandler),null!=this.interval?clearInterval(this.interval):void 0},e.prototype.sync=function(){return a.notSupported?this.doSync(this.element):void 0},e.prototype.doSync=function(a){var b,c,d,e,f;if(null==a&&(a=this.element),1===a.nodeType){for(a=a.parentNode||a,e=a.querySelectorAll("."+this.config.boxClass),f=[],c=0,d=e.length;d>c;c++)b=e[c],g.call(this.all,b)<0?(this.boxes.push(b),this.all.push(b),this.stopped||this.disabled()?this.resetStyle():this.applyStyle(b,!0),f.push(this.scrolled=!0)):f.push(void 0);return f}},e.prototype.show=function(a){return this.applyStyle(a),a.className=a.className+" "+this.config.animateClass,null!=this.config.callback&&this.config.callback(a),this.util().emitEvent(a,this.wowEvent),this.util().addEvent(a,"animationend",this.resetAnimation),this.util().addEvent(a,"oanimationend",this.resetAnimation),this.util().addEvent(a,"webkitAnimationEnd",this.resetAnimation),this.util().addEvent(a,"MSAnimationEnd",this.resetAnimation),a},e.prototype.applyStyle=function(a,b){var c,d,e;return d=a.getAttribute("data-wow-duration"),c=a.getAttribute("data-wow-delay"),e=a.getAttribute("data-wow-iteration"),this.animate(function(f){return function(){return f.customStyle(a,b,d,c,e)}}(this))},e.prototype.animate=function(){return"requestAnimationFrame"in window?function(a){return window.requestAnimationFrame(a)}:function(a){return a()}}(),e.prototype.resetStyle=function(){var a,b,c,d,e;for(d=this.boxes,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.style.visibility="visible");return e},e.prototype.resetAnimation=function(a){var b;return a.type.toLowerCase().indexOf("animationend")>=0?(b=a.target||a.srcElement,b.className=b.className.replace(this.config.animateClass,"").trim()):void 0},e.prototype.customStyle=function(a,b,c,d,e){return b&&this.cacheAnimationName(a),a.style.visibility=b?"hidden":"visible",c&&this.vendorSet(a.style,{animationDuration:c}),d&&this.vendorSet(a.style,{animationDelay:d}),e&&this.vendorSet(a.style,{animationIterationCount:e}),this.vendorSet(a.style,{animationName:b?"none":this.cachedAnimationName(a)}),a},e.prototype.vendors=["moz","webkit"],e.prototype.vendorSet=function(a,b){var c,d,e,f;d=[];for(c in b)e=b[c],a[""+c]=e,d.push(function(){var b,d,g,h;for(g=this.vendors,h=[],b=0,d=g.length;d>b;b++)f=g[b],h.push(a[""+f+c.charAt(0).toUpperCase()+c.substr(1)]=e);return h}.call(this));return d},e.prototype.vendorCSS=function(a,b){var c,e,f,g,h,i;for(h=d(a),g=h.getPropertyCSSValue(b),f=this.vendors,c=0,e=f.length;e>c;c++)i=f[c],g=g||h.getPropertyCSSValue("-"+i+"-"+b);return g},e.prototype.animationName=function(a){var b;try{b=this.vendorCSS(a,"animation-name").cssText}catch(c){b=d(a).getPropertyValue("animation-name")}return"none"===b?"":b},e.prototype.cacheAnimationName=function(a){return this.animationNameCache.set(a,this.animationName(a))},e.prototype.cachedAnimationName=function(a){return this.animationNameCache.get(a)},e.prototype.scrollHandler=function(){return this.scrolled=!0},e.prototype.scrollCallback=function(){var a;return!this.scrolled||(this.scrolled=!1,this.boxes=function(){var b,c,d,e;for(d=this.boxes,e=[],b=0,c=d.length;c>b;b++)a=d[b],a&&(this.isVisible(a)?this.show(a):e.push(a));return e}.call(this),this.boxes.length||this.config.live)?void 0:this.stop()},e.prototype.offsetTop=function(a){for(var b;void 0===a.offsetTop;)a=a.parentNode;for(b=a.offsetTop;a=a.offsetParent;)b+=a.offsetTop;return b},e.prototype.isVisible=function(a){var b,c,d,e,f;return c=a.getAttribute("data-wow-offset")||this.config.offset,f=window.pageYOffset,e=f+Math.min(this.element.clientHeight,this.util().innerHeight())-c,d=this.offsetTop(a),b=d+a.clientHeight,e>=d&&b>=f},e.prototype.util=function(){return null!=this._util?this._util:this._util=new b},e.prototype.disabled=function(){return!this.config.mobile&&this.util().isMobile(navigator.userAgent)},e}()}).call(this);
2998/* End */
2999;
3000; /* Start:"a:4:{s:4:"full";s:52:"/bitrix/templates/aib_flex/js/main.js?17348499926773";s:6:"source";s:37:"/bitrix/templates/aib_flex/js/main.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/
3001BX.ready(function() {
3002
3003	var offset = 300,
3004	offset_opacity = 1200,
3005	scroll_top_duration = 700,
3006	$back_to_top = $('.cd-top');
3007
3008	$(window).scroll(function(){
3009		( $(this).scrollTop() > offset ) ? $back_to_top.addClass('cd-is-visible') : $back_to_top.removeClass('cd-is-visible cd-fade-out');
3010		if( $(this).scrollTop() > offset_opacity ) {
3011			$back_to_top.addClass('cd-fade-out');
3012		}
3013	});
3014	$back_to_top.on('click', function(event){
3015		event.preventDefault();
3016		$('body,html').animate({
3017			scrollTop: 0 ,
3018			}, scroll_top_duration
3019		);
3020	});
3021
3022	$(function() {
3023		if (!Cookies.get('aibCookies')) {
3024			function getWindow(){
3025				new Noty({
3026					//text: 'Этот сайт использует файлы <strong>cookie</strong>. Продолжая пользоваться данным сайтом, Вы соглашаетесь на использование нами Ваших файлов <strong>cookie</strong>. <a href="/agreement/">Узнать больше</a>',
3027					text: 'Этот сайт использует файлы <strong>cookie</strong>. Продолжая пользоваться данным сайтом, Вы соглашаетесь на использование нами Ваших файлов <strong>cookie</strong>. <a href="/agreement/">Узнать больше</a><button class="cookie-button" type="button">Закрыть</button>',
3028					type: 'alert',
3029					theme: 'metroui',
3030					layout: 'topRight',
3031					closeWith: ['click', 'backdrop'],
3032					modal: false
3033				}).show();
3034			};
3035			setTimeout (getWindow, 5000);
3036		}
3037		Cookies.set('aibCookies', '1991', {path: '/', expires: 180, sameSite: 'Strict', secure: true});
3038	});
3039
3040	/*
3041	var tileStart = function() {
3042		var result = '';
3043		$result = $('#js-tile-toggle').prop('checked');
3044		$.ajax({
3045			//cache: false,
3046			url: '/products/ajax.php',
3047			method: 'post',
3048			dataType: 'html',
3049			data: {
3050				tile: $result
3051			},
3052			success: function(data) {
3053				$('.reslt').html(data)
3054			}
3055		});
3056	}
3057
3058	var tileToggle = function() {
3059		$('#js-tile-toggle').change(function() {
3060			var result = '';
3061			$result = $('#js-tile-toggle').prop('checked');
3062			//var dataSend = $("#js-tile-toggle").serialize();
3063			$.ajax({
3064				//cache: false,
3065				url: '/products/ajax.php',
3066				method: 'post',
3067				dataType: 'html',
3068				data: {
3069					tile: $result
3070				},
3071				success: function(data) {
3072					$('.reslt').html(data)
3073				}
3074			});
3075		});
3076	}
3077	*/
3078
3079	// sideNav Button Initialization
3080	var sideNavToggle = function() {
3081		//$(".button-collapse").sideNav();
3082		// sideNav Scrollbar Initialization
3083		//var sideNavScrollbar = document.querySelector('.custom-scrollbar');
3084		//Ps.initialize(sideNavScrollbar);
3085	}
3086
3087
3088	var window_width = $(window).width();
3089	if(window_width > 767){
3090		new WOW().init();
3091	}
3092
3093
3094	var fullHeight = function() {
3095
3096		// if ( !isMobile.any() ) {
3097			$('.js-fullheight').css('height', $(window).height());
3098			$(window).resize(function(){
3099				$('.js-fullheight').css('height', $(window).height());
3100			});
3101		// }
3102
3103	};
3104
3105	var counter = function() {
3106		$('.js-counter').countTo({
3107			formatter: function (value, options) {
3108				return value.toFixed(options.decimals);
3109			},
3110		});
3111	};
3112
3113	var counterWayPoint = function() {
3114		if ($('#counter-animate').length > 0 ) {
3115			$('#counter-animate').waypoint(function(direction) {
3116				if( direction === 'down' && !$(this.element).hasClass('animated') ) {
3117					setTimeout(counter , 400);
3118					$(this.element).addClass('animated');
3119				}
3120			}, {offset: '90%'});
3121		}
3122	};
3123
3124	var tableRowClick = function() {
3125		//$('tbody tr[data-href]').addClass('clickable').click( function() {
3126		$('tbody tr[data-href]').click( function() {
3127			window.location = $(this).attr('data-href');
3128		});
3129	};
3130
3131	var tableCellClick = function() {
3132		$('tbody tr td[cell-href]').click( function() {
3133			window.location = $(this).attr('cell-href');
3134		});
3135	};
3136
3137
3138	$('.faq-item > div').hide();
3139	$('.faq-item > a').click(function () {
3140		if ($(this).siblings('div').is(':visible')) {
3141			$(this).siblings('div').slideUp(300);
3142			$(this).removeClass('active')
3143		} else {
3144			$(this).siblings('div').slideDown(300);
3145			$(this).addClass('active')
3146		}
3147	});
3148
3149	var letScrollSmooth = function() {
3150		$('a[href*=#]').bind('click', function (d) {
3151			var c = $(this);
3152			$('html, body').stop().animate({
3153			//$('html,body').animate({
3154				scrollTop: $(c.attr('href')).offset().top
3155			}, 700);
3156			d.preventDefault()
3157		});
3158	};
3159
3160	var formFloat = function() {
3161		var inputs = document.querySelectorAll('input[type="text"], input[type="datepicker"], input[type="file"], input[type="textarea"], input[type="password"], input[type="email"], input[type="number"]');
3162		infoTooltip = document.querySelectorAll('.info-tooltip'), body = document.querySelector('body');
3163
3164		//Inputs underline animation
3165		if (inputs) {
3166			for (var i = 0; i < inputs.length; i++) {
3167    				inputs[i].previousElementSibling.classList.add('floating-label');
3168    				inputs[i].addEventListener('focusin', function () {
3169        				this.previousElementSibling.classList.add('label-active');
3170    				})
3171    				inputs[i].addEventListener('focusout', function () {
3172        				if (!(this.value == '')) {
3173            					this.classList.add('input-active');
3174        				}
3175        				else if (this.value == '') {
3176            					this.classList.remove('input-active');
3177            					this.previousElementSibling.classList.remove('label-active');
3178        				}
3179        				else {
3180            					this.previousElementSibling.classList.remove('label-active');
3181        				}
3182    				})
3183			}
3184		}
3185
3186		//Required inputs
3187		if (inputs) {
3188			for (var m = 0;
3188 m < inputs.length; m++) {
3189    				if (inputs[m].hasAttribute('required')) {
3190        				inputs[m].previousElementSibling.classList.add('label-required');
3191    				}
3192			}
3193		}
3194	};
3195
3196	var formFile = function() {
3197		let fields = document.querySelectorAll('.field__file');
3198		Array.prototype.forEach.call(fields, function (input) {
3199			let label = input.nextElementSibling,
3200			labelVal = label.querySelector('.field__file-fake').innerText;
3201			input.addEventListener('change', function (e) {
3202				let fileName = '';
3203				fileName = e.target.value.split('\\' ).pop();
3204				if(fileName)
3205					label.querySelector('.field__file-fake').innerText = fileName;
3206				else
3207					label.querySelector('.field__file-fake').innerText = labelVal;
3208			});
3209		});
3210	}
3211
3212	// Passive event listeners
3213	jQuery.event.special.touchstart = {
3214	    setup: function( _, ns, handle ) {
3215    		this.addEventListener("touchstart", handle, { passive: !ns.includes("noPreventDefault") });
3216	    }
3217	};
3218	jQuery.event.special.touchmove = {
3219	    setup: function( _, ns, handle ) {
3220    		this.addEventListener("touchmove", handle, { passive: !ns.includes("noPreventDefault") });
3221	    }
3222	};
3223
3224	//tileStart();
3225	//tileToggle();
3226	counterWayPoint();
3227	//tableRowClick();
3228	//tableCellClick();
3229	formFile();
3230});
3231
3232/* End */
3233;
3234; /* Start:"a:4:{s:4:"full";s:53:"/bitrix/templates/aib_flex/js/front.js?17347656941677";s:6:"source";s:38:"/bitrix/templates/aib_flex/js/front.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/
3235$(document).ready(function(){992<$(window).outerWidth()&&$("nav.side-navbar").mCustomScrollbar({scrollInertia:200});$("#toggle-btn").on("click",function(e){e.preventDefault(),1194<$(window).outerWidth()?($("nav.side-navbar").toggleClass("shrink"),$(".page").toggleClass("active")):($("nav.side-navbar").toggleClass("show-sm"),$(".page").toggleClass("active-sm"))}),$('[data-toggle="tooltip"]').tooltip();var e=$("input.input-material");e.filter(function(){return""!==$(this).val()}).siblings(".label-material").addClass("active"),e.on("focus",function(){$(this).siblings(".label-material").addClass("active")}),e.on("blur",function(){$(this).siblings(".label-material").removeClass("active"),""!==$(this).val()?$(this).siblings(".label-material").addClass("active"):$(this).siblings(".label-material").removeClass("active")}),$("#progress-circle").gmpc({color:"#33b35a",line_width:5,percent:80}).gmpc("animate",80,3e3),$(".external").on("click",function(e){e.preventDefault(),window.open($(this).attr("href"))});var t=$("link#theme-stylesheet");$("<link id='new-stylesheet' rel='stylesheet'>").insertAfter(t);
3236var hideSearchForm=function(){jQuery('.search-form-top').removeClass('show');};jQuery('.search-top').click(function(){jQuery('.search-form-top').toggleClass('show');setTimeout(function(){jQuery('.search-form-top.show input').focus();},200);jQuery(document).on('keyup',function(e){if(27===e.keyCode){if(jQuery('.search-form-top').hasClass('show')){hideSearchForm();}}});jQuery(document).on('click.outEvent',function(e){if(e.target.closest('.search-form-top')||e.target.closest('.search-top')){return;}
3237hideSearchForm();jQuery(document).off('click.outEvent');});});
3238});
3239/* End */
3240;
3241; /* Start:"a:4:{s:4:"full";
vendor: 4,223 bytes, lines 3241-3244
3241s:61:"/bitrix/templates/aib_flex/js/lazysizes.min.js?17253514837771";s:6:"source";s:46:"/bitrix/templates/aib_flex/js/lazysizes.min.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/
3242/*! lazysizes - v5.2.2 */
3243
3244!function(e){var t=function(u,D,f){"use strict";var k,H;if(function(){var e;var t={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",errorClass:"lazyerror",autosizesClass:"lazyautosizes",srcAttr:"data-src",srcsetAttr:"data-srcset",sizesAttr:"data-sizes",minSize:40,customMedia:{},init:true,expFactor:1.5,hFac:.8,loadMode:2,loadHidden:true,ricTimeout:0,throttleDelay:125};H=u.lazySizesConfig||u.lazysizesConfig||{};for(e in t){if(!(e in H)){H[e]=t[e]}}}(),!D||!D.getElementsByClassName){return{init:function(){},cfg:H,noSupport:true}}var O=D.documentElement,a=u.HTMLPictureElement,P="addEventListener",$="getAttribute",q=u[P].bind(u),I=u.setTimeout,U=u.requestAnimationFrame||I,l=u.requestIdleCallback,j=/^picture$/i,r=["load","error","lazyincluded","_lazyloaded"],i={},G=Array.prototype.forEach,J=function(e,t){if(!i[t]){i[t]=new RegExp("(\\s|^)"+t+"(\\s|$)")}return i[t].test(e[$]("class")||"")&&i[t]},K=function(e,t){if(!J(e,t)){e.setAttribute("class",(e[$]("class")||"").trim()+" "+t)}},Q=function(e,t){var i;if(i=J(e,t)){e.setAttribute("class",(e[$]("class")||"").replace(i," "))}},V=function(t,i,e){var a=e?P:"removeEventListener";if(e){V(t,i)}r.forEach(function(e){t[a](e,i)})},X=function(e,t,i,a,r){var n=D.createEvent("Event");if(!i){i={}}i.instance=k;n.initEvent(t,!a,!r);n.detail=i;e.dispatchEvent(n);return n},Y=function(e,t){var i;if(!a&&(i=u.picturefill||H.pf)){if(t&&t.src&&!e[$]("srcset")){e.setAttribute("srcset",t.src)}i({reevaluate:true,elements:[e]})}else if(t&&t.src){e.src=t.src}},Z=function(e,t){return(getComputedStyle(e,null)||{})[t]},s=function(e,t,i){i=i||e.offsetWidth;while(i<H.minSize&&t&&!e._lazysizesWidth){i=t.offsetWidth;t=t.parentNode}return i},ee=function(){var i,a;var t=[];var r=[];var n=t;var s=function(){var e=n;n=t.length?r:t;i=true;a=false;while(e.length){e.shift()()}i=false};var e=function(e,t){if(i&&!t){e.apply(this,arguments)}else{n.push(e);if(!a){a=true;(D.hidden?I:U)(s)}}};e._lsFlush=s;return e}(),te=function(i,e){return e?function(){ee(i)}:function(){var e=this;var t=arguments;ee(function(){i.apply(e,t)})}},ie=function(e){var i;var a=0;var r=H.throttleDelay;var n=H.ricTimeout;var t=function(){i=false;a=f.now();e()};var s=l&&n>49?function(){l(t,{timeout:n});if(n!==H.ricTimeout){n=H.ricTimeout}}:te(function(){I(t)},true);return function(e){var t;if(e=e===true){n=33}if(i){return}i=true;t=r-(f.now()-a);if(t<0){t=0}if(e||t<9){s()}else{I(s,t)}}},ae=function(e){var t,i;var a=99;var r=function(){t=null;e()};var n=function(){var e=f.now()-i;if(e<a){I(n,a-e)}else{(l||r)(r)}};return function(){i=f.now();if(!t){t=I(n,a)}}},e=function(){var v,m,c,h,e;var y,z,g,p,C,b,A;var n=/^img$/i;var d=/^iframe$/i;var E="onscroll"in u&&!/(gle|ing)bot/.test(navigator.userAgent);var _=0;var w=0;var N=0;var M=-1;var x=function(e){N--;if(!e||N<0||!e.target){N=0}};var W=function(e){if(A==null){A=Z(D.body,"visibility")=="hidden"}return A||!(Z(e.parentNode,"visibility")=="hidden"&&Z(e,"visibility")=="hidden")};var S=function(e,t){var i;var a=e;var r=W(e);g-=t;b+=t;p-=t;C+=t;while(r&&(a=a.offsetParent)&&a!=D.body&&a!=O){r=(Z(a,"opacity")||1)>0;if(r&&Z(a,"overflow")!="visible"){i=a.getBoundingClientRect();r=C>i.left&&p<i.right&&b>i.top-1&&g<i.bottom+1}}return r};var t=function(){var e,t,i,a,r,n,s,l,o,u,f,c;var d=k.elements;if((h=H.loadMode)&&N<8&&(e=d.length)){t=0;M++;for(;t<e;t++){if(!d[t]||d[t]._lazyRace){continue}if(!E||k.prematureUnveil&&k.prematureUnveil(d[t])){R(d[t]);continue}if(!(l=d[t][$]("data-expand"))||!(n=l*1)){n=w}if(!u){u=!H.expand||H.expand<1?O.clientHeight>500&&O.clientWidth>500?500:370:H.expand;k._defEx=u;f=u*H.expFactor;c=H.hFac;A=null;if(w<f&&N<1&&M>2&&h>2&&!D.hidden){w=f;M=0}else if(h>1&&M>1&&N<6){w=u}else{w=_}}if(o!==n){y=innerWidth+n*c;z=innerHeight+n;s=n*-1;o=n}i=d[t].getBoundingClientRect();if((b=i.bottom)>=s&&(g=i.top)<=z&&(C=i.right)>=s*c&&(p=i.left)<=y&&(b||C||p||g)&&(H.loadHidden||W(d[t]))&&(m&&N<3&&!l&&(h<3||M<4)||S(d[t],n))){R(d[t]);r=true;if(N>9){break}}else if(!r&&m&&!a&&N<4&&M<4&&h>
vendor: 4,390 bytes, lines 3244-3254
32442&&(v[0]||H.preloadAfterLoad)&&(v[0]||!l&&(b||C||p||g||d[t][$](H.sizesAttr)!="auto"))){a=v[0]||d[t]}}if(a&&!r){R(a)}}};var i=ie(t);var B=function(e){var t=e.target;if(t._lazyCache){delete t._lazyCache;return}x(e);K(t,H.loadedClass);Q(t,H.loadingClass);V(t,L);X(t,"lazyloaded")};var a=te(B);var L=function(e){a({target:e.target})};var T=function(t,i){try{t.contentWindow.location.replace(i)}catch(e){t.src=i}};var F=function(e){var t;var i=e[$](H.srcsetAttr);if(t=H.customMedia[e[$]("data-media")||e[$]("media")]){e.setAttribute("media",t)}if(i){e.setAttribute("srcset",i)}};var s=te(function(t,e,i,a,r){var n,s,l,o,u,f;if(!(u=X(t,"lazybeforeunveil",e)).defaultPrevented){if(a){if(i){K(t,H.autosizesClass)}else{t.setAttribute("sizes",a)}}s=t[$](H.srcsetAttr);n=t[$](H.srcAttr);if(r){l=t.parentNode;o=l&&j.test(l.nodeName||"")}f=e.firesLoad||"src"in t&&(s||n||o);u={target:t};K(t,H.loadingClass);if(f){clearTimeout(c);c=I(x,2500);V(t,L,true)}if(o){G.call(l.getElementsByTagName("source"),F)}if(s){t.setAttribute("srcset",s)}else if(n&&!o){if(d.test(t.nodeName)){T(t,n)}else{t.src=n}}if(r&&(s||o)){Y(t,{src:n})}}if(t._lazyRace){delete t._lazyRace}Q(t,H.lazyClass);ee(function(){var e=t.complete&&t.naturalWidth>1;if(!f||e){if(e){K(t,"ls-is-cached")}B(u);t._lazyCache=true;I(function(){if("_lazyCache"in t){delete t._lazyCache}},9)}if(t.loading=="lazy"){N--}},true)});var R=function(e){if(e._lazyRace){return}var t;var i=n.test(e.nodeName);var a=i&&(e[$](H.sizesAttr)||e[$]("sizes"));var r=a=="auto";if((r||!m)&&i&&(e[$]("src")||e.srcset)&&!e.complete&&!J(e,H.errorClass)&&J(e,H.lazyClass)){return}t=X(e,"lazyunveilread").detail;if(r){re.updateElem(e,true,e.offsetWidth)}e._lazyRace=true;N++;s(e,t,r,a,i)};var r=ae(function(){H.loadMode=3;i()});var l=function(){if(H.loadMode==3){H.loadMode=2}r()};var o=function(){if(m){return}if(f.now()-e<999){I(o,999);return}m=true;H.loadMode=3;i();q("scroll",l,true)};return{_:function(){e=f.now();k.elements=D.getElementsByClassName(H.lazyClass);v=D.getElementsByClassName(H.lazyClass+" "+H.preloadClass);q("scroll",i,true);q("resize",i,true);q("pageshow",function(e){if(e.persisted){var t=D.querySelectorAll("."+H.loadingClass);if(t.length&&t.forEach){U(function(){t.forEach(function(e){if(e.complete){R(e)}})})}}});if(u.MutationObserver){new MutationObserver(i).observe(O,{childList:true,subtree:true,attributes:true})}else{O[P]("DOMNodeInserted",i,true);O[P]("DOMAttrModified",i,true);setInterval(i,999)}q("hashchange",i,true);["focus","mouseover","click","load","transitionend","animationend"].forEach(function(e){D[P](e,i,true)});if(/d$|^c/.test(D.readyState)){o()}else{q("load",o);D[P]("DOMContentLoaded",i);I(o,2e4)}if(k.elements.length){t();ee._lsFlush()}else{i()}},checkElems:i,unveil:R,_aLSL:l}}(),re=function(){var i;var n=te(function(e,t,i,a){var r,n,s;e._lazysizesWidth=a;a+="px";e.setAttribute("sizes",a);if(j.test(t.nodeName||"")){r=t.getElementsByTagName("source");for(n=0,s=r.length;n<s;n++){r[n].setAttribute("sizes",a)}}if(!i.detail.dataAttr){Y(e,i.detail)}});var a=function(e,t,i){var a;var r=e.parentNode;if(r){i=s(e,r,i);a=X(e,"lazybeforesizes",{width:i,dataAttr:!!t});if(!a.defaultPrevented){i=a.detail.width;if(i&&i!==e._lazysizesWidth){n(e,r,a,i)}}}};var e=function(){var e;var t=i.length;if(t){e=0;for(;e<t;e++){a(i[e])}}};var t=ae(e);return{_:function(){i=D.getElementsByClassName(H.autosizesClass);q("resize",t)},checkElems:t,updateElem:a}}(),t=function(){if(!t.i&&D.getElementsByClassName){t.i=true;re._();e._()}};return I(function(){H.init&&t()}),k={cfg:H,autoSizer:re,loader:e,init:t,uP:Y,aC:K,rC:Q,hC:J,fire:X,gW:s,rAF:ee}}(e,e.document,Date);e.lazySizes=t,"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:{});
3245/* End */
3246;
3247; /* Start:"a:4:{s:4:"full";s:68:"/bitrix/templates/aib_flex/js/jquery.waypoints.min.js?17253514838835";s:6:"source";s:53:"/bitrix/templates/aib_flex/js/jquery.waypoints.min.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/
3248/*!
3249Waypoints - 4.0.0
3250Copyright © 2011-2015 Caleb Troughton
3251Licensed under the MIT license.
3252https://github.com/imakewebthings/waypoints/blog/master/licenses.txt
3253*/
3254!function(){"use strict";function t(o){if(!o)throw new Error("No options passed to Waypoint constructor");if(!o.element)throw new Error("No element option passed to Waypoint constructor");if(!o.handler)throw new Error("No handler option passed to Waypoint constructor");
vendor: 6,526 bytes, line 3254
3254this.key="waypoint-"+e,this.options=t.Adapter.extend({},t.defaults,o),this.element=this.options.element,this.adapter=new t.Adapter(this.element),this.callback=o.handler,this.axis=this.options.horizontal?"horizontal":"vertical",this.enabled=this.options.enabled,this.triggerPoint=null,this.group=t.Group.findOrCreate({name:this.options.group,axis:this.axis}),this.context=t.Context.findOrCreateByElement(this.options.context),t.offsetAliases[this.options.offset]&&(this.options.offset=t.offsetAliases[this.options.offset]),this.group.add(this),this.context.add(this),i[this.key]=this,e+=1}var e=0,i={};t.prototype.queueTrigger=function(t){this.group.queueTrigger(this,t)},t.prototype.trigger=function(t){this.enabled&&this.callback&&this.callback.apply(this,t)},t.prototype.destroy=function(){this.context.remove(this),this.group.remove(this),delete i[this.key]},t.prototype.disable=function(){return this.enabled=!1,this},t.prototype.enable=function(){return this.context.refresh(),this.enabled=!0,this},t.prototype.next=function(){return this.group.next(this)},t.prototype.previous=function(){return this.group.previous(this)},t.invokeAll=function(t){var e=[];for(var o in i)e.push(i[o]);for(var n=0,r=e.length;r>n;n++)e[n][t]()},t.destroyAll=function(){t.invokeAll("destroy")},t.disableAll=function(){t.invokeAll("disable")},t.enableAll=function(){t.invokeAll("enable")},t.refreshAll=function(){t.Context.refreshAll()},t.viewportHeight=function(){return window.innerHeight||document.documentElement.clientHeight},t.viewportWidth=function(){return document.documentElement.clientWidth},t.adapters=[],t.defaults={context:window,continuous:!0,enabled:!0,group:"default",horizontal:!1,offset:0},t.offsetAliases={"bottom-in-view":function(){return this.context.innerHeight()-this.adapter.outerHeight()},"right-in-view":function(){return this.context.innerWidth()-this.adapter.outerWidth()}},window.Waypoint=t}(),function(){"use strict";function t(t){window.setTimeout(t,1e3/60)}function e(t){this.element=t,this.Adapter=n.Adapter,this.adapter=new this.Adapter(t),this.key="waypoint-context-"+i,this.didScroll=!1,this.didResize=!1,this.oldScroll={x:this.adapter.scrollLeft(),y:this.adapter.scrollTop()},this.waypoints={vertical:{},horizontal:{}},t.waypointContextKey=this.key,o[t.waypointContextKey]=this,i+=1,this.createThrottledScrollHandler(),this.createThrottledResizeHandler()}var i=0,o={},n=window.Waypoint,r=window.onload;e.prototype.add=function(t){var e=t.options.horizontal?"horizontal":"vertical";this.waypoints[e][t.key]=t,this.refresh()},e.prototype.checkEmpty=function(){var t=this.Adapter.isEmptyObject(this.waypoints.horizontal),e=this.Adapter.isEmptyObject(this.waypoints.vertical);t&&e&&(this.adapter.off(".waypoints"),delete o[this.key])},e.prototype.createThrottledResizeHandler=function(){function t(){e.handleResize(),e.didResize=!1}var e=this;this.adapter.on("resize.waypoints",function(){e.didResize||(e.didResize=!0,n.requestAnimationFrame(t))})},e.prototype.createThrottledScrollHandler=function(){function t(){e.handleScroll(),e.didScroll=!1}var e=this;this.adapter.on("scroll.waypoints",function(){(!e.didScroll||n.isTouch)&&(e.didScroll=!0,n.requestAnimationFrame(t))})},e.prototype.handleResize=function(){n.Context.refreshAll()},e.prototype.handleScroll=function(){var t={},e={horizontal:{newScroll:this.adapter.scrollLeft(),oldScroll:this.oldScroll.x,forward:"right",backward:"left"},vertical:{newScroll:this.adapter.scrollTop(),oldScroll:this.oldScroll.y,forward:"down",backward:"up"}};for(var i in e){var o=e[i],n=o.newScroll>o.oldScroll,r=n?o.forward:o.backward;for(var s in this.waypoints[i]){var a=this.waypoints[i][s],l=o.oldScroll<a.triggerPoint,h=o.newScroll>=a.triggerPoint,p=l&&h,u=!l&&!h;(p||u)&&(a.queueTrigger(r),t[a.group.id]=a.group)}}for(var c in t)t[c].flushTriggers();this.oldScroll={x:e.horizontal.newScroll,y:e.vertical.newScroll}},e.prototype.innerHeight=function(){return this.element==this.element.window?n.viewportHeight():this.adapter.innerHeight()},e.prototype.remove=function(t){delete this.waypoints[t.axis][t.key],this.checkEmpty()},e.prototype.innerWidth=function(){return this.element==this.element.window?n.viewportWidth():this.adapter.innerWidth()},e.prototype.destroy=function(){var t=[];for(var e in this.waypoints)for(var i in this.waypoints[e])t.push(this.waypoints[e][i]);for(var o=0,n=t.length;n>o;o++)t[o].destroy()},e.prototype.refresh=function(){var t,e=this.element==this.element.window,i=e?void 0:this.adapter.offset(),o={};this.handleScroll(),t={horizontal:{contextOffset:e?0:i.left,contextScroll:e?0:this.oldScroll.x,contextDimension:this.innerWidth(),oldScroll:this.oldScroll.x,forward:"right",backward:"left",offsetProp:"left"},vertical:{contextOffset:e?0:i.top,contextScroll:e?0:this.oldScroll.y,contextDimension:this.innerHeight(),oldScroll:this.oldScroll.y,forward:"down",backward:"up",offsetProp:"top"}};for(var r in t){var s=t[r];for(var a in this.waypoints[r]){var l,h,p,u,c,d=this.waypoints[r][a],f=d.options.offset,w=d.triggerPoint,y=0,g=null==w;d.element!==d.element.window&&(y=d.adapter.offset()[s.offsetProp]),"function"==typeof f?f=f.apply(d):"string"==typeof f&&(f=parseFloat(f),d.options.offset.indexOf("%")>-1&&(f=Math.ceil(s.contextDimension*f/100))),l=s.contextScroll-s.contextOffset,d.triggerPoint=y+l-f,h=w<s.oldScroll,p=d.triggerPoint>=s.oldScroll,u=h&&p,c=!h&&!p,!g&&u?(d.queueTrigger(s.backward),o[d.group.id]=d.group):!g&&c?(d.queueTrigger(s.forward),o[d.group.id]=d.group):g&&s.oldScroll>=d.triggerPoint&&(d.queueTrigger(s.forward),o[d.group.id]=d.group)}}return n.requestAnimationFrame(function(){for(var t in o)o[t].flushTriggers()}),this},e.findOrCreateByElement=function(t){return e.findByElement(t)||new e(t)},e.refreshAll=function(){for(var t in o)o[t].refresh()},e.findByElement=function(t){return o[t.waypointContextKey]},window.onload=function(){r&&r(),e.refreshAll()},n.requestAnimationFrame=function(e){var i=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||t;i.call(window,e)},n.Context=e}(),function(){"use strict";function t(t,e){return t.triggerPoint-e.triggerPoint}function e(t,e){return e.triggerPoint-t.triggerPoint}function i(t){this.name=t.name,this.axis=t.axis,this.id=this.name+"-"+this.axis,this.waypoints=[],this.clearTriggerQueues(),o[this.axis][this.name]=this}var o={vertical:{},horizontal:{}},n=window.Waypoint;i.prototype.add=function(t){this.waypoints.push(t)},i.prototype.clearTriggerQueues=function(){this.triggerQueues={up:[],down:[],left:[],r
3254ight:[]}},i.prototype.flushTriggers=function(){for(var i in this.triggerQueues){var o=this.triggerQueues[i],n="up"===i||"left"===i;o.sort(n?e:t);for(var r=0,s=o.length;s>r;r+=1){var a=o[r];(a.options.continuous||r===o.length-1)&&a.trigger([i])}}this.clearTriggerQueues()},i.prototype.next=function(e){this.waypoints.sort(t);var i=n.Adapter.inArray(e,this.waypoints),o=i===this.waypoints.length-1;return o?null:this.waypoints[i+1]},i.prototype.previous=function(e){this.waypoints.sort(t);var i=n.Adapter.inArray(e,this.waypoints);return i?this.waypoints[i-1]:null},i.prototype.queueTrigger=function(t,e){this.triggerQueues[e].push(t)},i.prototype.remove=function(t){var e=n.Adapter.inArray(t,this.waypoints);e>-1&&this.waypoints.splice(e,1)},i.prototype.first=function(){return this.waypoints[0]},i.prototype.last=function(){return this.waypoints[this.waypoints.length-1]},i.findOrCreate=function(t){return o[t.axis][t.name]||new i(t)},n.Group=i}(),function(){"use strict";function t(t){this.$element=e(t)}var e=window.jQuery,i=window.Waypoint;e.each(["innerHeight","innerWidth","off","offset","on","outerHeight","outerWidth","scrollLeft","scrollTop"],function(e,i){t.prototype[i]=function(){var t=Array.prototype.slice.call(arguments);return this.$element[i].apply(this.$element,t)}}),e.each(["extend","inArray","isEmptyObject"],function(i,o){t[o]=e[o]}),i.adapters.push({name:"jquery",Adapter:t}),i.Adapter=t}(),function(){"use strict";function t(t){return function(){var i=[],o=arguments[0];return t.isFunction(arguments[0])&&(o=t.extend({},arguments[1]),o.handler=arguments[0]),this.each(function(){var n=t.extend({},o,{element:this});"string"==typeof n.context&&(n.context=t(this).closest(n.context)[0]),i.push(new e(n))}),i}}var e=window.Waypoint;window.jQuery&&(window.jQuery.fn.waypoint=t(window.jQuery)),window.Zepto&&(window.Zepto.fn.waypoint=t(window.Zepto))}();
3255/* End */
3256;
3257; /* Start:"a:4:{s:4:"full";s:62:"/bitrix/templates/aib_flex/js/jquery.countTo.js?17253514833760";s:6:"source";s:47:"/bitrix/templates/aib_flex/js/jquery.countTo.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/
3258(function (factory) {
3259    if (typeof define === 'function' && define.amd) {
3260        // AMD
3261        define(['jquery'], factory);
3262    } else if (typeof exports === 'object') {
3263        // CommonJS
3264        factory(require('jquery'));
3265    } else {
3266        // Browser globals
3267        factory(jQuery);
3268    }
3269}(function ($) {
3270  var CountTo = function (element, options) {
3271    this.$element = $(element);
3272    this.options  = $.extend({}, CountTo.DEFAULTS, this.dataOptions(), options);
3273    this.init();
3274  };
3275
3276  CountTo.DEFAULTS = {
3277    from: 0,               // the number the element should start at
3278    to: 0,                 // the number the element should end at
3279    speed: 1000,           // how long it should take to count between the target numbers
3280    refreshInterval: 100,  // how often the element should be updated
3281    decimals: 0,           // the number of decimal places to show
3282    formatter: formatter,  // handler for formatting the value before rendering
3283    onUpdate: null,        // callback method for every time the element is updated
3284    onComplete: null       // callback method for when the element finishes updating
3285  };
3286
3287  CountTo.prototype.init = function () {
3288    this.value     = this.options.from;
3289    this.loops     = Math.ceil(this.options.speed / this.options.refreshInterval);
3290    this.loopCount = 0;
3291    this.increment = (this.options.to - this.options.from) / this.loops;
3292  };
3293
3294  CountTo.prototype.dataOptions = function () {
3295    var options = {
3296      from:            this.$element.data('from'),
3297      to:              this.$element.data('to'),
3298      speed:           this.$element.data('speed'),
3299      refreshInterval: this.$element.data('refresh-interval'),
3300      decimals:        this.$element.data('decimals')
3301    };
3302
3303    var keys = Object.keys(options);
3304
3305    for (var i in keys) {
3306      var key = keys[i];
3307
3308      if (typeof(options[key]) === 'undefined') {
3309        delete options[key];
3310      }
3311    }
3312
3313    return options;
3314  };
3315
3316  CountTo.prototype.update = function () {
3317    this.value += this.increment;
3318    this.loopCount++;
3319
3320    this.render();
3321
3322    if (typeof(this.options.onUpdate) == 'function') {
3323      this.options.onUpdate.call(this.$element, this.value);
3324    }
3325
3326    if (this.loopCount >= this.loops) {
3327      clearInterval(this.interval);
3328      this.value = this.options.to;
3329
3330      if (typeof(this.options.onComplete) == 'function') {
3331        this.options.onComplete.call(this.$element, this.value);
3332      }
3333    }
3334  };
3335
3336  CountTo.prototype.render = function () {
3337    var formattedValue = this.options.formatter.call(this.$element, this.value, this.options);
3338    this.$element.text(formattedValue);
3339  };
3340
3341  CountTo.prototype.restart = function () {
3342    this.stop();
3343    this.init();
3344    this.start();
3345  };
3346
3347  CountTo.prototype.start = function () {
3348    this.stop();
3349    this.render();
3350    this.interval = setInterval(this.update.bind(this), this.options.refreshInterval);
3351  };
3352
3353  CountTo.prototype.stop = function () {
3354    if (this.interval) {
3355      clearInterval(this.interval);
3356    }
3357  };
3358
3359  CountTo.prototype.toggle = function () {
3360    if (this.interval) {
3361      this.stop();
3362    } else {
3363      this.start();
3364    }
3365  };
3366
3367  function formatter(value, options) {
3368    return value.toFixed(options.decimals);
3369  }
3370
3371  $.fn.countTo = function (option) {
3372    return this.each(function () {
3373      var $this   = $(this);
3374      var data    = $this.data('countTo');
3375      var init    = !data || typeof(option) === 'object';
3376      var options = typeof(option) === 'object' ? option : {};
3377      var method  = typeof(option) === 'string' ? option : 'start';
3378
3379      if (init) {
3380        if (data) data.stop();
3381        $this.data('countTo', data = new CountTo(this, options));
3382      }
3383
3384      data[method].call(data);
3385    });
3386  };
3387}));
3388/* End */
3389;
3390; /* Start:"a:4:{s:4:"full";s:57:"/bitrix/templates/aib_flex/js/noty.min.js?172535148330991";s:6:"source";s:41:"/bitrix/templates/aib_flex/js/noty.min.js";s:3:"min";s:41:"/bitrix/templates/aib_flex/js/noty.min.js";s:3:"map";
3390s:45:"/bitrix/templates/aib_flex/js/noty.min.js.map";}"*/
3391/* 
3392  @package NOTY - Dependency-free notification library 
3393  @version version: 3.1.4 
3394  @contributors https://github.com/needim/noty/graphs/contributors 
3395  @documentation Examples and Documentation - http://needim.github.com/noty 
3396  @license Licensed under the MIT licenses: http://www.opensource.org/licenses/mit-license.php 
3397*/
3398�
vendor: 15,489 bytes, lines 3398-3406
3398
3399!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Noty",[],e):"object"==typeof exports?exports.Noty=e():t.Noty=e()}(this,function(){return function(t){function e(o){if(n[o])return n[o].exports;var i=n[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=6)}([function(t,e,n){"use strict";function o(t,e,n){var o=void 0;if(!n){for(o in e)if(e.hasOwnProperty(o)&&e[o]===t)return!0}else for(o in e)if(e.hasOwnProperty(o)&&e[o]===t)return!0;return!1}function i(t){t=t||window.event,void 0!==t.stopPropagation?t.stopPropagation():t.cancelBubble=!0}function r(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e="noty_"+t+"_";return e+="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}function s(t){var e=t.offsetHeight,n=window.getComputedStyle(t);return e+=parseInt(n.marginTop)+parseInt(n.marginBottom)}function u(t,e,n){var o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];e=e.split(" ");for(var i=0;i<e.length;i++)document.addEventListener?t.addEventListener(e[i],n,o):document.attachEvent&&t.attachEvent("on"+e[i],n)}function a(t,e){return("string"==typeof t?t:f(t)).indexOf(" "+e+" ")>=0}function c(t,e){var n=f(t),o=n+e;a(n,e)||(t.className=o.substring(1))}function l(t,e){var n=f(t),o=void 0;a(t,e)&&(o=n.replace(" "+e+" "," "),t.className=o.substring(1,o.length-1))}function d(t){t.parentNode&&t.parentNode.removeChild(t)}function f(t){return(" "+(t&&t.className||"")+" ").replace(/\s+/gi," ")}function h(){function t(){b.PageHidden=document[s],o()}function e(){b.PageHidden=!0,o()}function n(){b.PageHidden=!1,o()}function o(){b.PageHidden?i():r()}function i(){setTimeout(function(){Object.keys(b.Store).forEach(function(t){b.Store.hasOwnProperty(t)&&b.Store[t].options.visibilityControl&&b.Store[t].stop()})},100)}function r(){setTimeout(function(){Object.keys(b.Store).forEach(function(t){b.Store.hasOwnProperty(t)&&b.Store[t].options.visibilityControl&&b.Store[t].resume()}),b.queueRenderAll()},100)}var s=void 0,a=void 0;void 0!==document.hidden?(s="hidden",a="visibilitychange"):void 0!==document.msHidden?(s="msHidden",a="msvisibilitychange"):void 0!==document.webkitHidden&&(s="webkitHidden",a="webkitvisibilitychange"),a&&u(document,a,t),u(window,"blur",e),u(window,"focus",n)}function p(t){if(t.hasSound){var e=document.createElement("audio");t.options.sounds.sources.forEach(function(t){var n=document.createElement("source");n.src=t,n.type="audio/"+m(t),e.appendChild(n)}),t.barDom?t.barDom.appendChild(e):document.querySelector("body").appendChild(e),e.volume=t.options.sounds.volume,t.soundPlayed||(e.play(),t.soundPlayed=!0),e.onended=function(){d(e)}}}function m(t){return t.match(/\.([^.]+)$/)[1]}Object.defineProperty(e,"__esModule",{value:!0}),e.css=e.deepExtend=e.animationEndEvents=void 0;var v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};e.inArray=o,e.stopPropagation=i,e.generateID=r,e.outerHeight=s,e.addListener=u,e.hasClass=a,e.addClass=c,e.removeClass=l,e.remove=d,e.classList=f,e.visibilityChangeFlow=h,e.createAudioElements=p;var y=n(1),b=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(y);e.animationEndEvents="webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend",e.deepExtend=function t(e){e=e||{};for(var n=1;n<arguments.length;n++){var o=arguments[n];if(o)for(var i in o)o.hasOwnProperty(i)&&(Array.isArray(o[i])?e[i]=o[i]:"object"===v(o[i])&&null!==o[i]?e[i]=t(e[i],o[i]):e[i]=o[i])}return e},e.css=function(){function t(t){return t.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,function(t,e){return e.toUpperCase()})}function e(t){var e=document.body.style;if(t in e)return t;for(var n=i.length,o=t.charAt(0).toUpperCase()+t.slice(1),r=void 0;n--;)if((r=i[n]+o)in e)return r;return t}function n(n){return n=t(n),r[n]||(r[n]=e(n))}function o(t,e,o){e=n(e),t.style[e]=o}var i=["Webkit","O","Moz","ms"],r={};return function(t,e){var n=arguments,i=void 0,r=void 0;if(2===n.length)for(i in e)e.hasOwnProperty(i)&&void 0!==(r=e[i])&&e.hasOwnProperty(i)&&o(t,i,r);else o(t,n[1],n[2])}}()},function(t,e,n){"use strict";function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"global",e=0,n=x;return E.hasOwnProperty(t)&&(n=E[t].maxVisible,Object.keys(P).forEach(function(n){P[n].options.queue!==t||P[n].closed||e++})),{current:e,maxVisible:n}}function i(t){E.hasOwnProperty(t.options.queue)||(E[t.options.queue]={maxVisible:x,queue:[]}),E[t.options.queue].queue.push(t)}function r(t){if(E.hasOwnProperty(t.options.queue)){var e=[];Object.keys(E[t.options.queue].queue).forEach(function(n){E[t.options.queue].queue[n].id!==t.id&&e.push(E[t.options.queue].queue[n])}),E[t.options.queue].queue=e}}function s(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"global";if(E.hasOwnProperty(t)){var e=E[t].queue.shift();e&&e.show()}}function u(){Object.keys(E).forEach(function(t){s(t)})}function a(t){var e=k.generateID("ghost"),n=document.createElement("div");n.setAttribute("id",e),k.css(n,{height:k.outerHeight(t.barDom)+"px"}),t.barDom.insertAdjacentHTML("afterend",n.outerHTML),k.remove(t.barDom),n=document.getElementById(e),k.addClass(n,"noty_fix_effects_height"),k.addListener(n,k.animationEndEvents,function(){k.remove(n)})}function c(t){m(t);var e='<div class="noty_body">'+t.options.text+"</div>"+d(t)+'<div class="noty_progressbar"></div>';t.barDom=document.createElement("div"),t.barDom.setAttribute("id",t.id),k.addClass(t.barDom,"noty_bar noty_type__"+t.options.type+" noty_theme__"+t.options.theme),t.barDom.innerHTML=e,b(t,"onTemplate")}function l(t){return!(!t.options.buttons||!Object.keys(t.options.buttons).length)}function d(t){if(l(t)){var e=document.createElement("div");return k.addClass(e,"noty_buttons"),Object.keys(t.options.buttons).forEach(function(n){e.appendChild(t.options.buttons[n].dom)}),t.options.buttons.forEach(function(t){e.appendChild(t.dom)}),e.outerHTML}return""}function f(t){t.options.modal&&(0===C&&p(),e.DocModalCount=C+=1)}function h(t){if(t.options.modal&&C>0&&(e.DocModalCount=C-=1,C<=0)){var n=document.querySelector(".noty_modal");n&&(k.removeClass(n,"noty_modal_open"),k.addClass(n,"noty_modal_close"),k.addListener(n,k.animationEndEvents,function(){k.remove(n)}))}}function p(){var t=document.querySelector("body"),e=document.createElement("div");k.addClass(e,"noty_modal"),t.insertBefore(e,t.firstChild),k.addClass(e,"noty_modal_open"),k.addListener(e,k.animationEndEvents,function(){k.removeClass(e,"noty_modal_open")})}function m(t){if(t.options.container)return void(t.layoutDom=document.querySelector(t.options.container));var e="noty_layout__"+t.options.layout;t.layoutDom=document.querySelector("div#"+e),t.layoutDom||(t.layoutDom=document.createElement("div"),t.layoutDom.setAttribute("id",e),t.layoutDom.setAttribute("role","alert"),t.layoutDom.setAttribute("aria-live","polite"),k.addClass(t.layoutDom,"noty_layout"),document.querySelector("body").appendChild(t.layoutDom))}function v(t){t.options.timeout&&(t.options.progressBar&&t.progressDom&&k.css(t.progressDom,{transition:"width "+t.options.timeout+"ms linear",width:"0%"}),clearTimeout(t.closeTimer),t.closeTimer=setTimeout(function(){t.close()},t.options.timeout))}function y(t){t.options.timeout&&t.closeTimer&&(clearTimeout(t.closeTimer),t.closeTimer=-1,t.options.progressBar&&t.progressDom&&k.css(t.progressDom,{transition:"width 0ms linear",width:"100%"}))}function b(t,e){t.listeners.hasOwnProperty(e)&&t.listeners[e].forEach(function(e){"function"==typeof e&&e.apply(t)})}function w(t){b(t,"afterShow"),v(t),k.addListener(t.barDom,"mouseenter",function(){y(t)}),k.addListener(t.barDom,"mouseleave",function(){v(t)})}function g(t){delete P[t.id],t.closing=!1,b(t,"afterClose"),k.remove(t.barDom),0!==t.layoutDom.querySelectorAll(".noty_bar").length||t.options.container||k.remove(t.layoutDom),(k.inArray("docVisible",t.options.titleCount.conditions)||k.inArray("docHidden",t.options.titleCount.conditions))&&D.decrement(),s(t.options.queue)}Object.defineProperty(e,"__esModule",{value:!0}),e.Defaults=e.Store=e.Queues=e.DefaultMaxVisible=e.docTitle=e.DocModalCount=e.PageHidden=void 0,e.getQueueCounts=o,e.addToQueue=i,e.removeFromQueue=r,e.queueRender=s,e.queueRenderAll=u,e.ghostFix=a,e.build=c,e.hasButtons=l,e.handleModal=f,e.handleModalClose=h,e.queueClose=v,e.dequeueClose=y,e.fire=b,e.openFlow=w,e.closeFlow=g;var _=n(0),k=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(_),C=(e.PageHidden=!1,e.DocModalCount=0),S={originalTitle:null,count:0,changed:!1,timer:-1},D=e.docTitle={increment:function(){S.count++,D._update()},decrement:function(){if(--S.count<=0)return void D._clear();D._update()},_update:function(){var t=document.title;S.changed?document.title="("+S.count+") "+S.originalTitle:(S.originalTitle=t,document.title="("+S.count+") "+t,S.changed=!0)},_clear:function(){S.changed&&(S.count=0,document.title=S.originalTitle,S.changed=!1)}},x=e.DefaultMaxVisible=5,E=e.Queues={global:{maxVisible:x,queue:[]}},P=e.Store={};e.Defaults={type:"alert",layout:"topRight",theme:"mint",text:"",timeout:!1,progressBar:!0,closeWith:["click"],animation:{open:"noty_effects_open",close:"noty_effects_close"},id:!1,force:!1,killer:!1,queue:"global",container:!1,buttons:[],callbacks:{beforeShow:null,onShow:null,afterShow:null,onClose:null,afterClose:null,onClick:null,onHover:null,onTemplate:null},sounds:{sources:[],volume:1,conditions:[]},titleCount:{conditions:[]},modal:!1,visibilityControl:!1}},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0}),e.NotyButton=void 0;var i=n(0),r=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(i);e.NotyButton=function t(e,n,i){var s=this,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return o(this,t),this.dom=document.createElement("button"),this.dom.innerHTML=e,this.id=u.id=u.id||r.generateID("button"),this.cb=i,Object.keys(u).forEach(function(t){s.dom.setAttribute(t,u[t])}),r.addClass(this.dom,n||"noty_btn"),this}},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}();e.Push=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"/service-worker.js";return o(this,t),this.subData={},this.workerPath=e,this.listeners={onPermissionGranted:[],onPermissionDenied:[],onSubscriptionSuccess:[],onSubscriptionCancel:[],onWorkerError:[],onWorkerSuccess:[],onWorkerNotSupported:[]},this}return i(t,[{key:"on",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){};return"function"==typeof e&&this.listeners.hasOwnProperty(t)&&this.listeners[t].push(e),this}},{key:"fire",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];this.listeners.hasOwnProperty(t)&&this.listeners[t].forEach(function(t){"function"==typeof t&&t.apply(e,n)})}},{key:"create",value:function(){console.log("NOT IMPLEMENTED YET")}},{key:"isSupported",value:function(){var t=!1;try{t=window.Notification||window.webkitNotifications||navigator.mozNotification||window.external&&void 0!==window.external.msIsSiteMode()}catch(t){}return t}},{key:"getPermissionStatus",value:function(){var t="default";if(window.Notification&&window.Notification.permissionLevel)t=window.Notification.permissionLevel;else if(window.webkitNotifications&&window.webkitNotifications.checkPermission)switch(window.webkitNotifications.checkPermission()){case 1:t="default";break;case 0:t="granted";break;default:t="denied"}else window.Notification&&window.Notification.permission?t=window.Notification.permission:navigator.mozNotification?t="granted":window.external&&void 0!==window.external.msIsSiteMode()&&(t=window.external.msIsSiteMode()?"granted":"default");return t.toString().toLowerCase()}},{key:"getEndpoint",value:function(t){var e=t.endpoint,n=t.subscriptionId;return n&&-1===e.indexOf(n)&&(e+="/"+n),e}},{key:"isSWRegistered",value:function(){try{return"activated"===navigator.serviceWorker.controller.state}catch(t){return!1}}},{key:"unregisterWorker",value:function(){var t=this;"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(function(e){var n=!0,o=!1,i=void 0;try{for(var r,s=e[Symbol.iterator]();!(n=(r=s.next()).done);n=!0){r.value.unregister(),t.fire("onSubscriptionCancel")}}catch(t){o=!0,i=t}finally{try{!n&&s.return&&s.return()}finally{if(o)throw i}}})}},{key:"requestSubscription",value:function(){var t=this,e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=this,o=this.getPermissionStatus(),i=function(o){"granted"===o?(t.fire("onPermissionGranted"),"serviceWorker"in navigator?navigator.serviceWorker.register(t.workerPath).then(function(){navigator.serviceWorker.ready.then(function(t){n.fire("onWorkerSuccess"),t.pushManager.subscribe({userVisibleOnly:e}).then(function(t){var e=t.getKey("p256dh"),o=t.getKey("auth");n.subData={endpoint:n.getEndpoint(t),p256dh:e?window.btoa(String.fromCharCode.apply(null,new Uint8Array(e))):null,auth:o?window.btoa(String.fromCharCode.apply(null,new Uint8Array(o))):null},n.fire("onSubscriptionSuccess",[n.subData])}).catch(function(t){n.fire("onWorkerError",[t])})})}):n.fire("onWorkerNotSupported")):"denied"===o&&(t.fire("onPermissionDenied"),t.unregisterWorker())};"default"===o?window.Notification&&window.Notification.requestPermission?window.Notification.requestPermission(i):window.webkitNotifications&&window.webkitNotifications.checkPermission&&window.webkitNotifications.requestPermission(i):i(o)}}]),t}()},function(t,e,n){(function(e,o){/*!
3400 * @overview es6-promise - a tiny implementation of Promises/A+.
3401 * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
3402 * @license   Licensed under MIT license
3403 *            See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
3404 * @version   4.1.1
3405 */
3406!function(e,n){t.exports=n()}(0,function(){"use strict";function t(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}function i(t){return"function"==typeof t}function r(t){z=t}function s(t){U=t}function u(){return void 0!==R?function(){R(c)}:a()}function a(){var t=setTimeout;return function(){return t(c,1)}}function c(){for(var t=0;t<
vendor: 1,207 bytes, line 3406
3406Q;t+=2){(0,X[t])(X[t+1]),X[t]=void 0,X[t+1]=void 0}Q=0}function l(t,e){var n=arguments,o=this,i=new this.constructor(f);void 0===i[tt]&&A(i);var r=o._state;return r?function(){var t=n[r-1];U(function(){return P(r,i,t,o._result)})}():S(o,i,t,e),i}function d(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var n=new e(f);return g(n,t),n}function f(){}function h(){return new TypeError("You cannot resolve a promise with itself")}function p(){return new TypeError("A promises callback cannot return that same promise.")}function m(t){try{return t.then}catch(t){return it.error=t,it}}function v(t,e,n,o){try{t.call(e,n,o)}catch(t){return t}}function y(t,e,n){U(function(t){var o=!1,i=v(n,e,function(n){o||(o=!0,e!==n?g(t,n):k(t,n))},function(e){o||(o=!0,C(t,e))},"Settle: "+(t._label||" unknown promise"));!o&&i&&(o=!0,C(t,i))},t)}function b(t,e){e._state===nt?k(t,e._result):e._state===ot?C(t,e._result):S(e,void 0,function(e){return g(t,e)},function(e){return C(t,e)})}function w(t,e,n){e.constructor===t.constructor&&n===l&&e.constructor.resolve===d?b(t,e):n===it?(C(t,it.error),it.error=null):void 0===n?k(t,e):i(n)?y(t,e,n):k(t,e)}function g(e,n){e===n?C(e,h()):t(n)?w(e,n,m(n)):k(e,n)}
vendor: 1,953 bytes, line 3406
3406function _(t){t._onerror&&t._onerror(t._result),D(t)}function k(t,e){t._state===et&&(t._result=e,t._state=nt,0!==t._subscribers.length&&U(D,t))}function C(t,e){t._state===et&&(t._state=ot,t._result=e,U(_,t))}function S(t,e,n,o){var i=t._subscribers,r=i.length;t._onerror=null,i[r]=e,i[r+nt]=n,i[r+ot]=o,0===r&&t._state&&U(D,t)}function D(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var o=void 0,i=void 0,r=t._result,s=0;s<e.length;s+=3)o=e[s],i=e[s+n],o?P(n,o,i,r):i(r);t._subscribers.length=0}}function x(){this.error=null}function E(t,e){try{return t(e)}catch(t){return rt.error=t,rt}}function P(t,e,n,o){var r=i(n),s=void 0,u=void 0,a=void 0,c=void 0;if(r){if(s=E(n,o),s===rt?(c=!0,u=s.error,s.error=null):a=!0,e===s)return void C(e,p())}else s=o,a=!0;e._state!==et||(r&&a?g(e,s):c?C(e,u):t===nt?k(e,s):t===ot&&C(e,s))}function T(t,e){try{e(function(e){g(t,e)},function(e){C(t,e)})}catch(e){C(t,e)}}function O(){return st++}function A(t){t[tt]=st++,t._state=void 0,t._result=void 0,t._subscribers=[]}function M(t,e){this._instanceConstructor=t,this.promise=new t(f),this.promise[tt]||A(this.promise),I(e)?(this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?k(this.promise,this._result):(this.length=this.length||0,this._enumerate(e),0===this._remaining&&k(this.promise,this._result))):C(this.promise,q())}function q(){return new Error("Array Methods must be provided an Array")}function j(t){return new M(this,t).promise}function N(t){var e=this;return new e(I(t)?function(n,o){for(var i=t.length,r=0;r<i;r++)e.resolve(t[r]).then(n,o)}:function(t,e){return e(new TypeError("You must pass an array to race."))})}function L(t){var e=this,n=new e(f);return C(n,t),n}function H(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function W(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object c
3406onstructor cannot be called as a function.")}function V(t){this[tt]=O(),this._result=this._state=void 0,this._subscribers=[],f!==t&&("function"!=typeof t&&H(),this instanceof V?T(this,t):W())}function B(){var t=void 0;if(void 0!==o)t=o;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var e=t.Promise;if(e){var n=null;try{n=Object.prototype.toString.call(e.resolve())}catch(t){}if("[object Promise]"===n&&!e.cast)return}t.Promise=V}var F=void 0;F=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var I=F,Q=0,R=void 0,z=void 0,U=function(t,e){X[Q]=t,X[Q+1]=e,2===(Q+=2)&&(z?z(c):Z())},Y="undefined"!=typeof window?window:void 0,K=Y||{},G=K.MutationObserver||K.WebKitMutationObserver,$="undefined"==typeof self&&void 0!==e&&"[object process]"==={}.toString.call(e),J="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,X=new Array(1e3),Z=void 0;Z=$?function(){return function(){return e.nextTick(c)}}():G?function(){var t=0,e=new G(c),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}():J?function(){var t=new MessageChannel;return t.port1.onmessage=c,function(){return t.port2.postMessage(0)}}():void 0===Y?function(){try{var t=n(9);return R=t.runOnLoop||t.runOnContext,u()}catch(t){return a()}}():a();var tt=Math.random().toString(36).substring(16),et=void 0,nt=1,ot=2,it=new x,rt=new x,st=0;return M.prototype._enumerate=function(t){for(var e=0;this._state===et&&e<t.length;e++)this._eachEntry(t[e],e)},M.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,o=n.resolve;if(o===d){var i=m(t);if(i===l&&t._state!==et)this._settledAt(t._state,e,t._result);else if("function"!=typeof i)this._remaining--,this._result[e]=t;else if(n===V){var r=new n(f);w(r,t,i),this._willSettleAt(r,e)}else this._willSettleAt(new n(function(e){return e(t)}),e)}else this._willSettleAt(o(t),e)},M.prototype._settledAt=function(t,e,n){var o=this.promise;o._state===et&&(this._remaining--,t===ot?C(o,n):this._result[e]=n),0===this._remaining&&k(o,this._result)},M.prototype._willSettleAt=function(t,e){var n=this;S(t,void 0,function(t){return n._settledAt(nt,e,t)},function(t){return n._settledAt(ot,e,t)})},V.all=j,V.race=N,V.resolve=d,V.reject=L,V._setScheduler=r,V._setAsap=s,V._asap=U,V.prototype={constructor:V,then:l,catch:function(t){return this.then(null,t)}},V.polyfill=B,V.Promise=V,V})}).call(e,n(7),n(8))},function(t,e){},function(t,e,n){"use strict";function o(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}();n(5);var s=n(4),u=function(t){return t&&t.__esModule?t:{default:t}}(s),a=n(0),c=o(a),l=n(1),d=o(l),f=n(2),h=n(3),p=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i(this,t),this.options=c.deepExtend({},d.Defaults,e),this.id=this.options.id||c.generateID("bar"),this.closeTimer=-1,this.barDom=null,this.layoutDom=null,this.progressDom=null,this.showing=!1,this.shown=!1,this.closed=!1,this.closing=!1,this.killable=this.options.timeout||this.options.closeWith.length>0,this.hasSound=this.options.sounds.sources.length>0,this.soundPlayed=!1,this.listeners={beforeShow:[],onShow:[],afterShow:[],onClose:[],afterClose:[],onClick:[],onHover:[],onTemplate:[]},this.promises={show:null,close:null},this.on("beforeShow",this.options.callbacks.beforeShow),this.on("onShow",this.options.callbacks.onShow),this.on("afterShow",this.options.callbacks.afterShow),this.on("onClose",this.options.callbacks.onClose),this.on("afterClose",this.options.callbacks.afterClose),this.on("onClick",this.options.callbacks.onClick),this.on("onHover",this.options.callbacks.onHover),this.on("onTemplate",this.options.callbacks.onTemplate),this}return r(t,[{key:"on",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){};return"function"==typeof e&&this.listeners.hasOwnProperty(t)&&this.listeners[t].push(e),this}},{key:"show",value:function(){var e=this;!0===this.options.killer?t.closeAll():"string"==typeof this.options.killer&&t.closeAll(this.options.killer);var n=d.getQueueCounts(this.options.queue);
vendor: 7,975 bytes, lines 3406-3419
3406if(n.current>=n.maxVisible||d.PageHidden&&this.options.visibilityControl)return d.addToQueue(this),d.PageHidden&&this.hasSound&&c.inArray("docHidden",this.options.sounds.conditions)&&c.createAudioElements(this),d.PageHidden&&c.inArray("docHidden",this.options.titleCount.conditions)&&d.docTitle.increment(),this;if(d.Store[this.id]=this,d.fire(this,"beforeShow"),this.showing=!0,this.closing)return this.showing=!1,this;if(d.build(this),d.handleModal(this),this.options.force?this.layoutDom.insertBefore(this.barDom,this.layoutDom.firstChild):this.layoutDom.appendChild(this.barDom),this.hasSound&&!this.soundPlayed&&c.inArray("docVisible",this.options.sounds.conditions)&&c.createAudioElements(this),c.inArray("docVisible",this.options.titleCount.conditions)&&d.docTitle.increment(),this.shown=!0,this.closed=!1,d.hasButtons(this)&&Object.keys(this.options.buttons).forEach(function(t){var n=e.barDom.querySelector("#"+e.options.buttons[t].id);c.addListener(n,"click",function(n){c.stopPropagation(n),e.options.buttons[t].cb()})}),this.progressDom=this.barDom.querySelector(".noty_progressbar"),c.inArray("click",this.options.closeWith)&&(c.addClass(this.barDom,"noty_close_with_click"),c.addListener(this.barDom,"click",function(t){c.stopPropagation(t),d.fire(e,"onClick"),e.close()},!1)),c.addListener(this.barDom,"mouseenter",function(){d.fire(e,"onHover")},!1),this.options.timeout&&c.addClass(this.barDom,"noty_has_timeout"),this.options.progressBar&&c.addClass(this.barDom,"noty_has_progressbar"),c.inArray("button",this.options.closeWith)){c.addClass(this.barDom,"noty_close_with_button");var o=document.createElement("div");c.addClass(o,"noty_close_button"),o.innerHTML="×",this.barDom.appendChild(o),c.addListener(o,"click",function(t){c.stopPropagation(t),e.close()},!1)}return d.fire(this,"onShow"),null===this.options.animation.open?this.promises.show=new u.default(function(t){t()}):"function"==typeof this.options.animation.open?this.promises.show=new u.default(this.options.animation.open.bind(this)):(c.addClass(this.barDom,this.options.animation.open),this.promises.show=new u.default(function(t){c.addListener(e.barDom,c.animationEndEvents,function(){c.removeClass(e.barDom,e.options.animation.open),t()})})),this.promises.show.then(function(){var t=e;setTimeout(function(){d.openFlow(t)},100)}),this}},{key:"stop",value:function(){return d.dequeueClose(this),this}},{key:"resume",value:function(){return d.queueClose(this),this}},{key:"setTimeout",value:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}(function(t){if(this.stop(),this.options.timeout=t,this.barDom){this.options.timeout?c.addClass(this.barDom,"noty_has_timeout"):c.removeClass(this.barDom,"noty_has_timeout");var e=this;setTimeout(function(){e.resume()},100)}return this})},{key:"setText",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.barDom&&(this.barDom.querySelector(".noty_body").innerHTML=t),e&&(this.options.text=t),this}},{key:"setType",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.barDom){c.classList(this.barDom).split(" ").forEach(function(t){"noty_type__"===t.substring(0,11)&&c.removeClass(e.barDom,t)}),c.addClass(this.barDom,"noty_type__"+t)}return n&&(this.options.type=t),this}},{key:"setTheme",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.barDom){c.classList(this.barDom).split(" ").forEach(function(t){"noty_theme__"===t.substring(0,12)&&c.removeClass(e.barDom,t)}),c.addClass(this.barDom,"noty_theme__"+t)}return n&&(this.options.theme=t),this}},{key:"close",value:function(){var t=this;return this.closed?this:this.shown?(d.fire(this,"onClose"),this.closing=!0,null===this.options.animation.close?this.promises.close=new u.default(function(t){t()}):"function"==typeof this.options.animation.close?this.promises.close=new u.default(this.options.animation.close.bind(this)):(c.addClass(this.barDom,this.options.animation.close),this.promises.close=new u.default(function(e){c.addListener(t.barDom,c.animationEndEvents,function(){t.options.force?c.remove(t.barDom):d.ghostFix(t),e()})})),this.promises.close.then(function(){d.closeFlow(t),d.handleModalClose(t)}),this.closed=!0,this):(d.removeFromQueue(this),this)}}],[{key:"closeAll",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Object.keys(d.Store).forEach(function(e){t?d.Store[e].options.queue===t&&d.Store[e].killable&&d.Store[e].close():d.Store[e].killable&&d.Store[e].close()}),this}},{key:"overrideDefaults",value:function(t){return d.Defaults=c.deepExtend({},d.Defaults,t),this}},{key:"setMaxVisible",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d.DefaultMaxVisible,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"global";return d.Queues.hasOwnProperty(e)||(d.Queues[e]={maxVisible:t,queue:[]}),d.Queues[e].maxVisible=t,this}},{key:"button",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new f.NotyButton(t,e,n,o)}},{key:"version",value:function(){return"3.1.4"}},{key:"Push",value:function(t){return new h.Push(t)}}]),t}();e.default=p,c.visibilityChangeFlow(),t.exports=e.default},function(t,e){function n(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function i(t){if(l===setTimeout)return setTimeout(t,0);if((l===n||!l)&&setTimeout)return l=setTimeout,setTimeout(t,0);try{return l(t,0)}catch(e){try{return l.call(null,t,0)}catch(e){return l.call(this,t,0)}}}function r(t){if(d===clearTimeout)return clearTimeout(t);if((d===o||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(t);try{return d(t)}catch(e){try{return d.call(null,t)}catch(e){return d.call(this,t)}}}function s(){m&&h&&(m=!1,h.length?p=h.concat(p):v=-1,p.length&&u())}function u(){if(!m){var t=i(s);m=!0;for(var e=p.length;e;){for(h=p,p=[];++v<e;)h&&h[v].run();v=-1,e=p.length}h=null,m=!1,r(t)}}function a(t,e){this.fun=t,this.array=e}function c(){}var l,d,f=t.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:n}catch(t){l=n}try{d="function"==typeof clearTimeout?clearTimeout:o}catch(t){d=o}}();var h,p=[],m=!1,v=-1;f.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];p.push(new a(t,e)),1!==p.length||m||i(u)},a.prototype.run=function(){this.fun.apply(null,this.array)},f.title="browser",f.browser=!0,f.env={},f.argv=[],f.version="",f.versions={},f.on=c,f.addListener=c,f.once=c,f.off=c,f.removeListener=c,f.removeAllListeners=c,f.emit=c,f.prependListener=c,f.prependOnceListener=c,f.listeners=function(t){return[]},f.binding=function(t){throw new Error("process.binding is not supported")},f.cwd=function(){return"/"},f.chdir=function(t){throw new Error("process.chdir is not supported")},f.umask=function(){return 0}},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e){}])});
3407/* End */
3408;; /* /bitrix/templates/aib_flex/js/jquery.mCustomScrollbar.js?172535148392949*/
3409; /* /bitrix/templates/aib_flex/js/grasp.js?17253514833433*/
3410; /* /bitrix/templates/aib_flex/js/jquery.vide.js?172535148311713*/
3411; /* /bitrix/templates/aib_flex/js/wow.min.js?17253514838183*/
3412; /* /bitrix/templates/aib_flex/js/main.js?17348499926773*/
3413; /* /bitrix/templates/aib_flex/js/front.js?17347656941677*/
3414; /* /bitrix/templates/aib_flex/js/lazysizes.min.js?17253514837771*/
3415; /* /bitrix/templates/aib_flex/js/jquery.waypoints.min.js?17253514838835*/
3416; /* /bitrix/templates/aib_flex/js/jquery.countTo.js?17253514833760*/
3417; /* /bitrix/templates/aib_flex/js/noty.min.js?172535148330991*/
3418
3419//# sourceMappingURL=template_c4b6104dbcff31ff0399b5138ab4be62.map.js

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.