PageSourceSearch

https://www.sencelles.cat/wp-content/themes/enfold/js/avia.js?ver=5.4.1

js sencelles.cat collected 2026-09-24 10:02:32 UTC 54,448 bytes, 1,790 lines download raw bytes

1/**
2 * Polyfill for older browsers https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
3 *
4 * @since 4.8
5 * @return boolean
6 */
7if ( ! Array.isArray )
8{
9	Array.isArray = function( arg )
10	{
11		return Object.prototype.toString.call( arg ) === '[object Array]';
12	};
13}
14
15(function($)
16{
17	"use strict";
18
19	$( function()
20	{
21		$.avia_utilities = $.avia_utilities || {};
22
23		AviaBrowserDetection( 'html' );
24		AviaDeviceDetection( 'html' );
25
26		//show scroll top but1ton
27		avia_scroll_top_fade();
28
29		//calculate width of content
30		aviaCalcContentWidth();
31
32		//creates search tooltip
33		new $.AviaTooltip({
34					"class": 'avia-search-tooltip',
35					data: 'avia-search-tooltip',
36					event: 'click',
37					position: 'bottom',
38					scope: "body",
39					attach: 'element',
40					within_screen: true,
41					close_keys: 27
42				});
43
44        //creates relate posts tooltip
45        new $.AviaTooltip({
46					"class": 'avia-related-tooltip',
47					data: 'avia-related-tooltip',
48					scope: ".related_posts, .av-share-box",
49					attach: 'element',
50					delay: 0
51				});
52
53        //creates ajax search
54        new $.AviaAjaxSearch({scope:'#header, .avia_search_element'});
55
56		// actiavte portfolio sorting
57		if( $.fn.avia_iso_sort )
58		{
59			$('.grid-sort-container').avia_iso_sort();
60		}
61
62		// Checks height of content and sidebar and applies shadow class to the higher one
63        AviaSidebarShadowHelper();
64
65        $.avia_utilities.avia_ajax_call();
66
67    });
68
69	$.avia_utilities = $.avia_utilities || {};
70
71	$.avia_utilities.avia_ajax_call = function(container)
72	{
73		if( typeof container == 'undefined' )
74		{
75			container = 'body';
76		};
77
78		$('a.avianolink').on('click', function(e){ e.preventDefault(); });
79        $('a.aviablank').attr('target', '_blank');
80
81        //activates the prettyphoto lightbox
82        if($.fn.avia_activate_lightbox)
83		{
84        	$(container).avia_activate_lightbox();
85        }
86
87        //scrollspy for main menu. must be located before smoothscrolling
88		if( $.fn.avia_scrollspy )
89		{
90			if(container == 'body')
91			{
92				$('body').avia_scrollspy({target:'.main_menu .menu li > a'});
93			}
94			else
95			{
96				$('body').avia_scrollspy('refresh');
97			}
98		}
99
100
101
102		//smooth scrooling
103		if( $.fn.avia_smoothscroll )
104		{
105			$('a[href*="#"]', container).avia_smoothscroll(container);
106		}
107
108		avia_small_fixes(container);
109
110		avia_hover_effect(container);
111
112		avia_iframe_fix(container);
113
114		//activate html5 video player
115		if( $.fn.avia_html5_activation && $.fn.mediaelementplayer )
116		{
117			$(".avia_video, .avia_audio", container).avia_html5_activation({ratio:'16:9'});
118		}
119
120	};
121
122	// -------------------------------------------------------------------------------------------
123	// Error log helper
124	// -------------------------------------------------------------------------------------------
125	$.avia_utilities.log = function( text, type, extra )
126	{
127		if( typeof console == 'undefined' )
128		{
129			return;
130		}
131
132		if( typeof type == 'undefined' )
133		{
134			type = "log";
135		}
136
137		type = "AVIA-" + type.toUpperCase();
138
139		console.log( "["+type+"] "+text );
140
141		if( typeof extra != 'undefined' )
142		{
143			console.log( extra );
144		}
145	};
146
147
148
149	// -------------------------------------------------------------------------------------------
150	// keep track of the browser and content width
151	// -------------------------------------------------------------------------------------------
152
153
154
155	function aviaCalcContentWidth()
156	{
157
158	var win			= $(window),
159		width_select= $('html').is('.html_header_sidebar') ? "#main" : "#header",
160		outer		= $(width_select),
161		outerParent = outer.parents('div').eq( 0 ),
162		the_main	= $(width_select + ' .container').first(),
163		css_block	= "",
164		calc_dimensions = function()
165		{
166			var css			= "",
167				w_12 		= Math.round( the_main.width() ),
168				w_outer		= Math.round( outer.width() ),
169				w_inner		= Math.round( outerParent.width() );
170
171			//css rules for mega menu
172			css += " #header .three.units{width:"	+ ( w_12 * 0.25)+	"px;}";
173			css += " #header .six.units{width:"		+ ( w_12 * 0.50)+	"px;}";
174			css += " #header .nine.units{width:"	+ ( w_12 * 0.75)+	"px;}";
175			css += " #header .twelve.units{width:"	+( w_12 )		+	"px;}";
176
177			//css rules for tab sections
178			css += " .av-framed-box .av-layout-tab-inner .container{width:"	+( w_inner )+	"px;}";
179			css += " .html_header_sidebar .av-layout-tab-inner .container{width:"	+( w_outer )+	"px;}";
180			css += " .boxed .av-layout-tab-inner .container{width:"	+( w_outer )+	"px;}";
181
182			//css rules for submenu container
183			css += " .av-framed-box#top .av-submenu-container{width:"	+( w_inner )+	"px;}";
184
185			//ie8 needs different insert method
186			try{
187				css_block.text(css);
188			}
189			catch(err){
190				css_block.remove();
191				var headFirst = $( 'head' ).first();
192				css_block = $("<style type='text/css' id='av-browser-width-calc'>"+css+"</style>").appendTo( headFirst );
193			}
194
195		};
196
197
198
199		if($('.avia_mega_div').length > 0 || $('.av-layout-tab-inner').length > 0 || $('.av-submenu-container').length > 0)
200		{
201			var headFirst = $( 'head' ).first();
202			css_block = $("<style type='text/css' id='av-browser-width-calc'></style>").appendTo( headFirst );
203			win.on( 'debouncedresize', calc_dimensions);
204			calc_dimensions();
205		}
206	}
207
208
209    // -------------------------------------------------------------------------------------------
210    // Tiny helper for sidebar shadow
211    // -------------------------------------------------------------------------------------------
212
213	function AviaSidebarShadowHelper()
214	{
215		var $sidebar_container = $('.sidebar_shadow#top #main .sidebar');
216		var $content_container = $('.sidebar_shadow .content');
217
218		if( $sidebar_container.height() >= $content_container.height() )
219		{
220			$sidebar_container.addClass('av-enable-shadow');
221		}
222		else
223		{
224			$content_container.addClass('av-enable-shadow');
225		}
226	}
227
228
229	// -------------------------------------------------------------------------------------------
230	// modified SCROLLSPY by bootstrap
231	// -------------------------------------------------------------------------------------------
232
233
234	  function AviaScrollSpy(element, options)
235	  {
236		var self = this;
237
238		var process = self.process.bind( self ),
239			refresh = self.refresh.bind( self ),
240			$element = $(element).is('body') ? $(window) : $(element),
241			href;
242
243		    self.$body = $('body');
244		    self.$win = $(window);
245		    self.options = $.extend({}, $.fn.avia_scrollspy.defaults, options);
246		    self.selector = (self.options.target
247		      || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
248		      || '');
249
250		   	self.activation_true = false;
251
252		    if(self.$body.find(self.selector + "[href*='#']").length)
253		    {
254		    	self.$scrollElement = $element.on('scroll.scroll-spy.data-api', process);
255		    	self.$win.on('av-height-change', refresh);
256		    	self.$body.on('av_resize_finished', refresh);
257		    	self.activation_true = true;
258		    	self.checkFirst();
259
260		    	setTimeout(function()
261	  			{
262		    		self.refresh();
263		    		self.process();
264
265		    	},100);
266		    }
267
268	  }
269
270	  AviaScrollSpy.prototype = {
271
272	      constructor: AviaScrollSpy
273		, checkFirst: function () {
274
275			var current = window.location.href.split('#')[0],
276				matching_link = this.$body.find(this.selector + "[href='"+current+"']").attr('href',current+'#top');
277		}
278	    , refresh: function () {
279
280	    if(!this.activation_true) return;
281
282	        var self = this
283	          , $targets;
284
285	        this.offsets = $([]);
286	        this.targets = $([]);
287
288	        $targets = this.$body
289	          .find(this.selector)
290	          .map(function () {
291	            var $el = $(this)
292	              , href = $el.data('target') || $el.attr('href')
293	              , hash = this.hash
294	              , hash = hash.replace(/\//g, "")
295	              , $href = /^#\w/.test(hash) && $(hash);
296
297				//	$.isWindow deprecated 3.3 https://api.jquery.com/jquery.iswindow/
298				var obj = self.$scrollElement.get(0);
299				var isWindow = obj != null && obj === obj.window;
300
301	            return ( $href
302	              && $href.length
303	              && [[ $href.position().top + ( ! isWindow && self.$scrollElement.scrollTop() ), href ]] ) || null;
304	          })
305	          .sort(function (a, b) { return a[0] - b[0]; })
306	          .each(function () {
307	            self.offsets.push(this[0]);
308	            self.targets.push(this[1]);
309	          });
310
311	      }
312
313	    , process: function () {
314
315	    	if(!this.offsets) return;
316	    	if(isNaN(this.options.offset)) this.options.offset = 0;
317
318	        var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
319	          , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
320	          , maxScroll = scrollHeight - this.$scrollElement.height()
321	          , offsets = this.offsets
322	          , targets = this.targets
323	          , activeTarget = this.activeTarget
324	          , i;
325
326	        if (scrollTop >= maxScroll) {
327	          return activeTarget != (i = targets.last()[0])
328	            && this.activate ( i );
329	        }
330
331	        for (i = offsets.length; i--;) {
332	          activeTarget != targets[i]
333	            && scrollTop >= offsets[i]
334	            && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
335	            && this.activate( targets[i] );
336	        }
337	      }
338
339	    , activate: function (target) {
340	        var active
341	          , selector;
342
343	        this.activeTarget = target;
344
345	        $(this.selector)
346	          .parent('.' + this.options.applyClass)
347	          .removeClass(this.options.applyClass);
348
349	        selector = this.selector
350	          + '[data-target="' + target + '"],'
351	          + this.selector + '[href="' + target + '"]';
352
353
354
355	        active = $(selector)
356	          .parent('li')
357	          .addClass(this.options.applyClass);
358
359	        if (active.parent('.sub-menu').length)  {
360	          active = active.closest('li.dropdown_ul_available').addClass(this.options.applyClass);
361	        }
362
363	        active.trigger('activate');
364	      }
365
366	  };
367
368
369	 /* AviaScrollSpy PLUGIN DEFINITION
370	  * =========================== */
371
372	  $.fn.avia_scrollspy = function (option) {
373	    return this.each(function () {
374	      var $this = $(this)
375	        , data = $this.data('scrollspy')
376	        , options = typeof option == 'object' && option;
377	      if (!data) $this.data('scrollspy', (data = new AviaScrollSpy(this, options)));
378	      if (typeof option == 'string') data[option]();
379	    });
380	  };
381
382	  $.fn.avia_scrollspy.Constructor = AviaScrollSpy;
383
384	  $.fn.avia_scrollspy.calc_offset = function()
385	  {
386		  var 	offset_1 = (parseInt($('.html_header_sticky #main').data('scroll-offset'), 10)) || 0,
387		  		offset_2 = ($(".html_header_sticky:not(.html_top_nav_header) #header_main_alternate").outerHeight()) || 0,
388		  		offset_3 = ($(".html_header_sticky.html_header_unstick_top_disabled #header_meta").outerHeight()) || 0,
389		  		offset_4 =  1,
390		  		offset_5 = parseInt($('html').css('margin-top'),10) || 0,
391		  		offset_6 = parseInt($('.av-frame-top ').outerHeight(),10) || 0;
392
393		  return offset_1 + offset_2 + offset_3 + offset_4 + offset_5 + offset_6;
394	  };
395
396	  $.fn.avia_scrollspy.defaults =
397	  {
398	    offset: $.fn.avia_scrollspy.calc_offset(),
399	    applyClass: 'current-menu-item'
400	  };
401
402
403    // -------------------------------------------------------------------------------------------
404    // detect browser and add class to body
405    // -------------------------------------------------------------------------------------------
406    function AviaBrowserDetection(outputClassElement)
407    {
408	    //code from the old jquery migrate plugin
409	    var current_browser = {},
410
411	    	uaMatch = function( ua )
412			{
413				ua = ua.toLowerCase();
414
415				var match = /(edge)\/([\w.]+)/.exec( ua ) ||
416				/(opr)[\/]([\w.]+)/.exec( ua ) ||
417				/(chrome)[ \/]([\w.]+)/.exec( ua ) ||
418				/(iemobile)[\/]([\w.]+)/.exec( ua ) ||
419				/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) ||
420				/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) ||
421				/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
422				/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
423				/(msie) ([\w.]+)/.exec( ua ) ||
424				ua.indexOf("trident") >= 0 && /(rv)(?::| )([\w.]+)/.exec( ua ) ||
425				ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
426				[];
427
428				return {
429					  browser: match[ 5 ] || match[ 3 ] || match[ 1 ] || "",
430					  version: match[ 2 ] || match[ 4 ] || "0",
431					  versionNumber: match[ 4 ] || match[ 2 ] || "0"
432					};
433			};
434
435		var matched = uaMatch( navigator.userAgent );
436
437		if( matched.browser )
438		{
439			current_browser.browser = matched.browser;
440			current_browser[ matched.browser ] = true;
441			current_browser.version = matched.version;
442		}
443
444		// Chrome is Webkit, but Webkit is also Safari.
445		if ( current_browser.chrome ) {
446			current_browser.webkit = true;
447		} else if ( current_browser.webkit ) {
448			current_browser.safari = true;
449		}
450
451        if(typeof(current_browser) !== 'undefined')
452        {
453            var bodyclass = '',
454				version = current_browser.version ? parseInt(current_browser.version) : "";
455
456            if(current_browser.msie || current_browser.rv || current_browser.iemobile){
457                bodyclass += 'avia-msie';
458            }else if(current_browser.webkit){
459                bodyclass += 'avia-webkit';
460            }else if(current_browser.mozilla){
461                bodyclass += 'avia-mozilla';
462            }
463
464            if(current_browser.version) bodyclass += ' ' + bodyclass + '-' + version + ' ';
465            if(current_browser.browser) bodyclass += ' avia-' + current_browser.browser + ' avia-' +current_browser.browser +'-' + version + ' ';
466        }
467
468        if( outputClassElement )
469		{
470			$(outputClassElement).addClass( bodyclass );
471		}
472
473        return bodyclass;
474    }
475
476	/**
477	 * Detect device features and add a class to body
478	 */
479	function AviaDeviceDetection( outputClassElement )
480	{
481		var classes = [];
482
483		//	https://stackoverflow.com/questions/14439903/how-can-i-detect-device-touch-support-in-javascript
484		$.avia_utilities.isTouchDevice = 'ontouchstart' in window ||
485				window.DocumentTouch && document instanceof window.DocumentTouch ||
486				navigator.maxTouchPoints > 0 ||
487				window.navigator.msMaxTouchPoints > 0;
488
489		classes.push( $.avia_utilities.isTouchDevice ? 'touch-device' : 'no-touch-device' );
490
491		$.avia_utilities.pointerDevices = [];
492
493		//	https://stackdiary.com/detect-mobile-browser-javascript/
494		if( typeof window.matchMedia != 'function' )
495		{
496			$.avia_utilities.pointerDevices.push( 'undefined' );
497			classes.push( 'pointer-device-undefined' );
498		}
499		else
500		{
501			var pointer_fine = false;
502
503			if( window.matchMedia( '(any-pointer: fine)' ) )
504			{
505				classes.push( 'pointer-device-fine' );
506				$.avia_utilities.pointerDevices.push( 'fine' );
507				pointer_fine = true;
508			}
509
510			if( window.matchMedia( '(any-pointer: coarse)' ) )
511			{
512				classes.push( 'pointer-device-coarse' );
513				$.avia_utilities.pointerDevices.push( 'coarse' );
514
515				if( ! pointer_fine )
516				{
517					classes.push( 'pointer-device-coarse-only' );
518				}
519			}
520
521			if( ! $.avia_utilities.pointerDevices.length )
522			{
523				classes.push( 'pointer-device-none' );
524				$.avia_utilities.pointerDevices.push( 'none' );
525			}
526		}
527
528		if( 'undefined' == typeof $.avia_utilities.isMobile )
529		{
530			if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && 'ontouchstart' in document.documentElement)
531			{
532				$.avia_utilities.isMobile = true;
533			}
534			else
535			{
536				$.avia_utilities.isMobile = false;
537			}
538		}
539
540		$( outputClassElement ).addClass( classes.join( ' ') );
541	}
542
543    // -------------------------------------------------------------------------------------------
544	// html 5 videos
545	// -------------------------------------------------------------------------------------------
546    $.fn.avia_html5_activation = function( options )
547	{
548		var defaults =
549		{
550			ratio: '16:9'
551		};
552
553		var options = $.extend( defaults, options );
554
555//			isMobile = $.avia_utilities.isMobile;
556//			if(isMobile) return;
557
558		this.each( function()
559		{
560			var fv = $(this),
561				id_to_apply = '#' + fv.attr('id'),
562				posterImg = fv.attr('poster'),
563				features = [ 'playpause', 'progress', 'current', 'duration', 'tracks', 'volume' ],
564				container = fv.closest( '.avia-video' );
565
566			if( container.length > 0 && container.hasClass( 'av-html5-fullscreen-btn' ) )
567			{
568				features.push( 'fullscreen' );
569			}
570
571			fv.mediaelementplayer(
572			{
573				// if the <video width> is not specified, this is the default
574				defaultVideoWidth: 480,
575				// if the <video height> is not specified, this is the default
576				defaultVideoHeight: 270,
577				// if set, overrides <video width>
578				videoWidth: -1,
579				// if set, overrides <video height>
580				videoHeight: -1,
581				// width of audio player
582				audioWidth: 400,
583				// height of audio player
584				audioHeight: 30,
585				// initial volume when the player starts
586				startVolume: 0.8,
587				// useful for <audio> player loops
588				loop: false,
589				// enables Flash and Silverlight to resize to content size
590				enableAutosize: false,
591				// the order of controls you want on the control bar (and other plugins below)
592				features: features,
593				// Hide controls when playing and mouse is not over the video
594				alwaysShowControls: false,
595				// force iPad's native controls
596				iPadUseNativeControls: false,
597				// force iPhone's native controls
598				iPhoneUseNativeControls: false,
599				// force Android's native controls
600				AndroidUseNativeControls: false,
601				// forces the hour marker (##:00:00)
602				alwaysShowHours: false,
603				// show framecount in timecode (##:00:00:00)
604				showTimecodeFrameCount: false,
605				// used when showTimecodeFrameCount is set to true
606				framesPerSecond: 25,
607				// turns keyboard support on and off for this instance
608				enableKeyboard: true,
609				// when this player starts, it will pause other players
610				pauseOtherPlayers: false,
611				poster: posterImg,
612				success: function( mediaElement, domObject, instance )
613				{
614					//make the medialement instance accesible by storing it. usually not necessary but safari has problems since wp version 4.9
615					$.AviaVideoAPI.players[ fv.attr('id').replace( /_html5/,'' ) ] = instance;
616
617					setTimeout(function()
618					{
619						if( mediaElement.pluginType == 'flash' )
620						{
621							mediaElement.addEventListener('canplay', function() { fv.trigger('av-mediajs-loaded'); }, false);
622						}
623						else
624						{
625							fv.trigger('av-mediajs-loaded').addClass('av-mediajs-loaded');
626						}
627
628						mediaElement.addEventListener('ended', function() {  fv.trigger('av-mediajs-ended'); }, false);
629
630						var html5MediaElement = document.getElementById( $(mediaElement).attr('id') + '_html5' );
631						if( html5MediaElement && html5MediaElement !== mediaElement )
632						{
633							mediaElement.addEventListener( "ended", function()
634							{
635								$( html5MediaElement ).trigger( 'av-mediajs-ended' );
636							});
637						}
638					}, 10 );
639
640				},
641				// fires when a problem is detected
642				error: function()
643				{
644
645				},
646				// array of keyboard commands
647				keyActions: []
648			});
649		});
650	};
651
652 	// -------------------------------------------------------------------------------------------
653	// hover effect for images
654	// -------------------------------------------------------------------------------------------
655    function avia_hover_effect( container )
656    {
657    	//hover overlay for mobile device doesnt really make sense. in addition it often slows down the click event
658    	if( $.avia_utilities.isMobile )
659		{
660			return;
661		}
662
663		if( $('body').hasClass( 'av-disable-avia-hover-effect' ) )
664		{
665			return;
666		}
667
668		var overlay = "",
669			cssTrans = $.avia_utilities.supports('transition');
670
671		if(container == 'body')
672    	{
673    		var elements = $('#main a img').parents('a').not('.noLightbox, .noLightbox a, .avia-gallery-thumb a, .ls-wp-container a, .noHover, .noHover a, .av-logo-container .logo a').add('#main .avia-hover-fx');
674    	}
675    	else
676    	{
677    		var elements = $('a img', container).parents('a').not('.noLightbox, .noLightbox a, .avia-gallery-thumb a, .ls-wp-container a, .noHover, .noHover a, .av-logo-container .logo a').add('.avia-hover-fx', container);
678    	}
679
680	   elements.each( function(e)
681       {
682            var link = $(this),
683            	current = link.find('img').first();
684
685            if(current.hasClass('alignleft')) link.addClass('alignleft').css({float:'left', margin:0, padding:0});
686            if(current.hasClass('alignright')) link.addClass('alignright').css({float:'right', margin:0, padding:0});
687            if(current.hasClass('aligncenter')) link.addClass('aligncenter').css({float:'none','text-align':'center', margin:0, padding:0});
688
689            if(current.hasClass('alignnone'))
690            {
691               link.addClass('alignnone').css({margin:0, padding:0});;
692               if(!link.css('display') || link.css('display') == 'inline') { link.css({display:'inline-block'}); }
693            }
694
695            if(!link.css('position') || link.css('position') == 'static') { link.css({position:'relative', overflow:'hidden'}); }
696
697            var url		 	= link.attr('href'),
698				span_class	= "overlay-type-video",
699				opa			= link.data('opacity') || 0.7,
700				overlay_offset = 5,
701				overlay 	= link.find('.image-overlay');
702
703            	if(url)
704				{
705					if( url.match(/(jpg|gif|jpeg|png|tif)/) ) span_class = "overlay-type-image";
706					if(!url.match(/(jpg|gif|jpeg|png|\.tif|\.mov|\.swf|vimeo\.com|youtube\.com)/) ) span_class = "overlay-type-extern";
707				}
708
709				if(!overlay.length)
710				{
711					overlay = $("<span class='image-overlay "+span_class+"'><span class='image-overlay-inside'></span></span>").appendTo(link);
712				}
713
714            	link.on('mouseenter', function(e)
715				{
716					var current = link.find('img').first(),
717						_self	= current.get(0),
718						outerH 	= current.outerHeight(),
719						outerW 	= current.outerWidth(),
720						pos		= current.position(),
721						linkCss = link.css('display'),
722						overlay = link.find('.image-overlay');
723
724					if(outerH > 100)
725					{
726
727						if(!overlay.length)
728						{
729							overlay = $("<span class='image-overlay "+span_class+"'><span class='image-overlay-inside'></span></span>").appendTo(link);
730
731						}
732						//can be wrapped into if !overlay.length statement if chrome fixes fade in problem
733						if(link.height() == 0) { link.addClass(_self.className); _self.className = ""; }
734						if(!linkCss || linkCss == 'inline') { link.css({display:'block'}); }
735						//end wrap
736
737						overlay.css({left:(pos.left - overlay_offset) + parseInt(current.css("margin-left"),10), top:pos.top + parseInt(current.css("margin-top"),10)})
738							   .css({overflow:'hidden',display:'block','height':outerH,'width':(outerW + (2*overlay_offset))});
739
740						if(cssTrans === false ) overlay.stop().animate({opacity:opa}, 400);
741					}
742					else
743					{
744						overlay.css({display:"none"});
745					}
746
747				}).on('mouseleave', elements, function(){
748
749					if(overlay.length)
750					{
751						if(cssTrans === false ) overlay.stop().animate({opacity:0}
751, 400);
752					}
753				});
754        });
755    }
756
757
758// -------------------------------------------------------------------------------------------
759// Smooth scrooling when clicking on anchor links
760// todo: maybe use https://github.com/ryanburnette/scrollToBySpeed/blob/master/src/scrolltobyspeed.jquery.js in the future
761// -------------------------------------------------------------------------------------------
762
763	(function($)
764	{
765		$.fn.avia_smoothscroll = function( apply_to_container )
766		{
767			if( ! this.length )
768			{
769				return;
770			}
771
772			var the_win = $(window),
773				$header = $('#header'),
774				$main 	= $('.html_header_top.html_header_sticky #main').not('.page-template-template-blank-php #main'),
775				$meta 	= $('.html_header_top.html_header_unstick_top_disabled #header_meta'),
776				$alt  	= $('.html_header_top:not(.html_top_nav_header) #header_main_alternate'),
777				menu_above_logo = $('.html_header_top.html_top_nav_header'),
778				shrink	= $('.html_header_top.html_header_shrinking').length,
779				frame	= $('.av-frame-top'),
780				fixedMainPadding = 0,
781				isMobile = $.avia_utilities.isMobile,
782				sticky_sub = $('.sticky_placeholder').first(),
783				calc_main_padding = function()
784				{
785					if( $header.css('position') == "fixed" )
786					{
787						var tempPadding = parseInt($main.data('scroll-offset'),10) || 0,
788							non_shrinking = parseInt($meta.outerHeight(),10) || 0,
789							non_shrinking2 = parseInt($alt.outerHeight(),10) || 0;
790
791						if( tempPadding > 0 && shrink )
792						{
793							tempPadding = (tempPadding / 2 ) + non_shrinking + non_shrinking2;
794						}
795						else
796						{
797							tempPadding = tempPadding + non_shrinking + non_shrinking2;
798						}
799
800						tempPadding += parseInt($('html').css('margin-top'),10);
801						fixedMainPadding = tempPadding;
802					}
803					else
804					{
805						fixedMainPadding = parseInt($('html').css('margin-top'),10);
806					}
807
808					if( frame.length )
809					{
810						fixedMainPadding += frame.height();
811					}
812
813					if( menu_above_logo.length )
814					{
815						//if menu is above logo and we got a sticky height header
816						fixedMainPadding = $('.html_header_sticky #header_main_alternate').height() + parseInt($('html').css('margin-top'),10);
817					}
818
819					if( isMobile )
820					{
821						fixedMainPadding = 0;
822					}
823
824				};
825
826			if( isMobile )
827			{
828				shrink = false;
829			}
830
831			calc_main_padding();
832			the_win.on( "debouncedresize av-height-change", calc_main_padding );
833
834			var hash = window.location.hash.replace(/\//g, "");
835
836			//if a scroll event occurs at pageload and an anchor is set and a coresponding element exists apply the offset to the event
837			if( fixedMainPadding > 0 && hash && apply_to_container == 'body' && hash.charAt(1) != "!" && hash.indexOf("=") === -1 )
838			{
839				var scroll_to_el = $(hash), modifier = 0;
840
841				if( scroll_to_el.length )
842				{
843					the_win.on('scroll.avia_first_scroll', function()
844					{
845						setTimeout( function()		//small delay so other scripts can perform necessary resizing
846						{
847							if( sticky_sub.length && scroll_to_el.offset().top > sticky_sub.offset().top )
848							{
849								modifier = sticky_sub.outerHeight() - 3;
850							}
851
852							the_win.off( 'scroll.avia_first_scroll' ).scrollTop( scroll_to_el.offset().top - fixedMainPadding - modifier );
853						},10);
854				    });
855			    }
856			}
857
858			return this.each(function()
859			{
860				$(this).on('click', function(e)
861				{
862					var newHash = this.hash.replace(/\//g, ""),
863						clicked = $(this),
864						data = clicked.data();
865
866					if( newHash != '' && newHash != '#' && newHash != '#prev' && newHash != '#next' && !clicked.is('.comment-reply-link, #cancel-comment-reply-link, .no-scroll'))
867					{
868						var container = "",
869							originHash = "";
870
871						if( '#next-section' == newHash )
872						{
873							originHash = newHash;
874
875							//	@since 4.8.3 check to scroll to visible sections only (e.g. sections could be hidden on different devices
876							var next_containers = clicked.parents('.container_wrap').eq( 0 ).nextAll('.container_wrap');
877							next_containers.each( function()
878							{
879							   var cont = $( this );
880
881							   if( cont.css( 'display' ) == 'none' || cont.css( 'visibility' ) == 'hidden' )
882							   {
883								   return;
884							   }
885
886							   container = cont;
887							   return false;
888							});
889
890							if( 'object' == typeof container && container.length > 0 )
891							{
892								newHash = '#' + container.attr('id') ;
893							}
894						}
895						else
896						{
897							 container = $( this.hash.replace(/\//g, "") );
898						}
899
900						if( container.length )
901						{
902							var cur_offset = the_win.scrollTop(),
903								container_offset = container.offset().top,
904								target =  container_offset - fixedMainPadding,
905								hash = window.location.hash,
906								hash = hash.replace(/\//g, ""),
907								oldLocation = window.location.href.replace(hash, ''),
908								newLocation = this,
909								duration = data.duration || 1200,
910								easing = data.easing || 'easeInOutQuint';
911
912							if( sticky_sub.length && container_offset > sticky_sub.offset().top )
913							{
914								target -= sticky_sub.outerHeight() - 3;
915							}
916
917							// make sure it's the same location
918							if( oldLocation+newHash == newLocation || originHash )
919							{
920								if( cur_offset != target ) // if current pos and target are the same dont scroll
921								{
922									if( ! ( cur_offset == 0 && target <= 0 ) ) // if we are at the top dont try to scroll to top or above
923									{
924										the_win.trigger('avia_smooth_scroll_start');
925
926										// animate to target and set the hash to the window.location after the animation
927										$('html:not(:animated),body:not(:animated)').animate({ scrollTop: target }, duration, easing, function()
928										{
929											// add new hash to the browser location
930											//window.location.href=newLocation;
931											if( window.history.replaceState )
932											{
933												window.history.replaceState( "", "", newHash );
934											}
935										});
936									}
937								}
938
939								// cancel default click action
940								e.preventDefault();
941							}
942						}
943					}
944				});
945			});
946		};
947	})(jQuery);
948
949
950	// -------------------------------------------------------------------------------------------
951	// iframe fix for firefox and ie so they get proper z index
952	// -------------------------------------------------------------------------------------------
953	function avia_iframe_fix(container)
954	{
955		var iframe 	= jQuery('iframe[src*="youtube.com"]:not(.av_youtube_frame)', container),
956			youtubeEmbed = jQuery('iframe[src*="youtube.com"]:not(.av_youtube_frame) object, iframe[src*="youtube.com"]:not(.av_youtube_frame) embed', container).attr('wmode','opaque');
957
958			iframe.each(function()
959			{
960				var current = jQuery(this),
961					src 	= current.attr('src');
962
963				if(src)
964				{
965					if(src.indexOf('?') !== -1)
966					{
967						src += "&wmode=opaque&rel=0";
968					}
969					else
970					{
971						src += "?wmode=opaque&rel=0";
972					}
973
974					current.attr('src', src);
975				}
976			});
977	}
978
979	// -------------------------------------------------------------------------------------------
980	// small js fixes for pixel perfection :)
981	// -------------------------------------------------------------------------------------------
982	function avia_small_fixes(container)
983	{
984		if(!container) container = document;
985
986		//make sure that iframes do resize correctly. uses css padding bottom iframe trick
987		var win		= jQuery(window),
988			iframes = jQuery('.avia-iframe-wrap iframe:not(.avia-slideshow iframe):not( iframe.no_resize):not(.avia-video iframe)', container),
989			adjust_iframes = function()
990			{
991				iframes.each(function(){
992
993					var iframe = jQuery(this), parent = iframe.parent(), proportions = 56.25;
994
995					if(this.width && this.height)
996					{
997						proportions = (100/ this.width) * this.height;
998						parent.css({"padding-bottom":proportions+"%"});
999					}
1000				});
1001			};
1002
1003			adjust_iframes();
1004
1005	}
1006
1007   function avia_scroll_top_fade()
1008   {
1009   		 var win 		= $(window),
1010   		 	 timeo = false,
1011   		 	 scroll_top = $('#scroll-top-link'),
1012   		 	 set_status = function()
1013             {
1014             	var st = win.scrollTop();
1015
1016             	if(st < 500)
1017             	{
1018             		scroll_top.removeClass('avia_pop_class');
1019             	}
1020             	else if(!scroll_top.is('.avia_pop_class'))
1021             	{
1022             		scroll_top.addClass('avia_pop_class');
1023             	}
1024             };
1025
1026   		 win.on( 'scroll',  function(){ window.requestAnimationFrame( set_status ); } );
1027         set_status();
1028	}
1029
1030	$.AviaAjaxSearch = function( options )
1031	{
1032		var defaults = {
1033			delay: 300,                //delay in ms until the user stops typing.
1034			minChars: 3,               //dont start searching before we got at least that much characters
1035			scope: 'body'
1036		};
1037
1038		this.options = $.extend({}, defaults, options);
1039		this.scope   = $(this.options.scope);
1040		this.timer   = false;
1041		this.lastVal = "";
1042
1043		this.bind_events();
1044	};
1045
1046	$.AviaAjaxSearch.prototype =
1047    {
1048        bind_events: function()
1049        {
1050            this.scope.on( 'keyup', '#s:not(".av_disable_ajax_search #s")', this.try_search.bind( this ) );
1051            this.scope.on( 'click', '#s.av-results-parked', this.reset.bind( this ) );
1052        },
1053
1054        try_search: function(e)
1055        {
1056            var form = $(e.currentTarget).parents('form').eq( 0 ),
1057                resultscontainer = form.find('.ajax_search_response');
1058
1059            clearTimeout(this.timer);
1060
1061			// clear on ESC
1062            if( e.keyCode === 27 )
1063			{
1064                this.reset(e);
1065				return;
1066			}
1067
1068            //only execute search if chars are at least "minChars" and search differs from last one
1069            if(e.currentTarget.value.length >= this.options.minChars && this.lastVal != e.currentTarget.value.trim() )
1070            {
1071                //wait at least "delay" milliseconds to execute ajax. if user types again during that time dont execute
1072                this.timer = setTimeout( this.do_search.bind( this, e ), this.options.delay );
1073            }
1074            //remove the results container if the input field has been emptied
1075            else if ( e.currentTarget.value.length == 0 )
1076			{
1077                this.timer = setTimeout( this.reset.bind( this, e ), this.options.delay );
1078			}
1079        },
1080
1081		reset: function(e)
1082		{
1083            var form = $(e.currentTarget).parents('form').eq( 0 ),
1084				resultscontainer = form.find('.ajax_search_response'),
1085				alternative_resultscontainer = $(form.attr('data-ajaxcontainer')).find('.ajax_search_response'),
1086				searchInput = $(e.currentTarget);
1087
1088            // bring back results that were hidden when user clicked outside the form element
1089            if ($(e.currentTarget).hasClass('av-results-parked')) {
1090                resultscontainer.show();
1091                alternative_resultscontainer.show();
1092
1093                // in case results container is attached to body
1094                $('body > .ajax_search_response').show();
1095			}
1096			else {
1097                // remove results and delete the input value
1098                resultscontainer.remove();
1099                alternative_resultscontainer.remove();
1100                searchInput.val('');
1101
1102                // in case results container is attached to body
1103                $('body > .ajax_search_response').remove();
1104			}
1105
1106
1107		},
1108
1109        do_search: function(e)
1110        {
1111            var obj = this,
1112                currentField = $(e.currentTarget).attr( "autocomplete", "off" ),
1113				currentFieldWrapper = $(e.currentTarget).parents('.av_searchform_wrapper').eq( 0 ),
1114                currentField_position = currentFieldWrapper.offset(),
1115                currentField_width = currentFieldWrapper.outerWidth(),
1116                currentField_height = currentFieldWrapper.outerHeight(),
1117				form = currentField.parents('form').eq( 0 ),
1118				submitbtn = form.find('#searchsubmit'),
1119                resultscontainer = form,
1120                results = resultscontainer.find('.ajax_search_response'),
1121                loading = $('<div class="ajax_load"><span class="ajax_load_inner"></span></div>'),
1122                action = form.attr('action'),
1123                values = form.serialize(),
1124				elementID = form.data('element_id'),
1125				custom_color = form.data('custom_color');
1126
1127			values += '&action=avia_ajax_search';
1128
1129
1130            // define results div if not found
1131            if( ! results.length )
1132			{
1133                results = $('<div class="ajax_search_response" style="display:none;"></div>');
1134            }
1135
1136			if( 'undefined' != typeof elementID )
1137			{
1138				results.addClass( elementID );
1139			}
1140
1141			if( 'undefined' != typeof custom_color && custom_color != '' )
1142			{
1143				results.addClass( 'av_has_custom_color' );
1144			}
1145
1146            // add class to differentiate betweeen search element and header search
1147			if( form.attr('id') == 'searchform_element')
1148			{
1149				results.addClass('av_searchform_element_results');
1150			}
1151
1152            //check if the form got get parameters applied and also apply them
1153           	if(action.indexOf('?') != -1)
1154           	{
1155           		action  = action.split('?');
1156           		values += "&" + action[1];
1157           	}
1158
1159           	//check if there is a results container defined
1160			if( form.attr('data-ajaxcontainer') )
1161			{
1162                var rescon = form.attr('data-ajaxcontainer');
1163
1164                // check if defined container exists
1165                if ($(rescon).length)
1166				{
1167                	// remove previous search results
1168					$(rescon).find('.ajax_search_response').remove();
1169
1170                    resultscontainer = $(rescon);
1171				}
1172			}
1173
1174			/*
1175			 * For the placement option: "Under the search form - overlay other content",
1176			 * we have to attach the results to the body in order to overlay the other content,
1177			 * and we calculate it's position using the search field
1178			 */
1179
1180            results_css = {};
1181
1182			if( form.hasClass('av_results_container_fixed') )
1183			{
1184				// remove previous search results
1185				$('body').find('.ajax_search_response').remove();
1186
1187				resultscontainer = $('body');
1188
1189				// add class and position to results if defined above
1190				var results_css = {
1191								top: currentField_position.top + currentField_height,
1192								left: currentField_position.left,
1193								width: currentField_width
1194							};
1195
1196				// make sure default stylesheet is applied
1197				results.addClass('main_color');
1198
1199				// remove results and reset if window is resized
1200				$( window ).resize( function()
1201				{
1202					results.remove();
1203					this.reset.bind( this );
1204					currentField.val('');
1205				});
1206			}
1207
1208            // add additional styles - for backwards comp. only. Attribute has been removed in 4.8.7 with header styles
1209            if ( form.attr('data-results_style') )
1210			{
1211                var results_style = JSON.parse(form.attr('data-results_style'));
1212                results_css = Object.assign(results_css, results_style);
1213
1214                // add class if font color is applied, so we can use color: inherit
1215                if( "color" in results_css )
1216				{
1217                    results.addClass('av_has_custom_color');
1218                }
1219            }
1220
1221            // apply inline styles
1222            results.css(results_css);
1223
1224            // add .container class if resultscontainer in a color section
1225			if( resultscontainer.hasClass('avia-section') )
1226			{
1227				results.addClass('container');
1228			}
1229
1230            // append results to defined container
1231            results.appendTo(resultscontainer);
1232
1233
1234			//return if we already hit a no result and user is still typing
1235			if(results.find('.ajax_not_found').length && e.currentTarget.value.indexOf(this.lastVal) != -1)
1236			{
1237				return;
1238			}
1239
1240			this.lastVal = e.currentTarget.value;
1241
1242			$.ajax({
1243				url: avia_framework_globals.ajaxurl,
1244				type: "POST",
1245				data:values,
1246				beforeSend: function()
1247				{
1248					// add loader after submit button
1249					loading.insertAfter(submitbtn);
1250					form.addClass('ajax_loading_now');
1251				},
1252				success: function(response)
1253				{
1254					if(response == 0)
1255					{
1256						response = "";
1257					}
1258
1259					results.html(response).show();
1260				},
1261				complete: function()
1262				{
1263					loading.remove();
1264					form.removeClass('ajax_loading_now');
1265				}
1266			});
1267
1268            // Hide search resuls if user clicks anywhere outside the form element
1269			$(document).on('click',function(e)
1270			{
1271				if(!$(e.target).closest(form).length)
1272				{
1273					if($(results).is(":visible"))
1274					{
1275						$(results).hide();
1276						currentField.addClass('av-results-parked');
1277					}
1278				}
1279			});
1280		}
1281	};
1282
1283
1284	$.AviaTooltip = function( options )
1285	{
1286	   var defaults = {
1287            delay: 1500,                //delay in ms until the tooltip appears
1288            delayOut: 300,             	//delay in ms when instant showing should stop
1289            delayHide: 0,             	//delay hiding of tooltip in ms
1290            "class": "avia-tooltip",   	//tooltip classname for css styling and alignment
1291            scope: "body",             	//area the tooltip should be applied to
1292            data:  "avia-tooltip",     	//data attribute that contains the tooltip text
1293            attach: "body",          	//either attach the tooltip to the "mouse" or to the "element" // todo: implement mouse, make sure that it doesnt overlap with screen borders
1294            event: 'mouseenter',       	//mousenter and leave or click and leave
1295            position: 'top',             //top or bottom
1296            extraClass: 'avia-tooltip-class', //extra class that is defined by a tooltip element data attribute
1297            permanent: false, 			// always display the tooltip?
1298            within_screen: false,		// if the tooltip is displayed outside the screen adjust its position
1299            close_keys: null			// string|[] of keyCodes to close the tooltip (there is no check for empty value !! )
1300        };
1301
1302        this.options = $.extend({}, defaults, options);
1303
1304		var close_keys = '';
1305		if( this.options.close_keys != null )
1306		{
1307			if( ! Array.isArray( this.options.close_keys ) )
1308			{
1309				this.options.close_keys = [ this.options.close_keys ];
1310			}
1311			close_keys = ' data-close-keys="' + this.options.close_keys.join( ',' ) + '" ';
1312		}
1313
1314        this.body    = $('body');
1315        this.scope   = $(this.options.scope);
1316		this.tooltip = $( '<div class="' + this.options['class'] + ' avia-tt"' + close_keys + '><span class="avia-arrow-wrap"><span class="avia-arrow"></span></span></div>' );
1317        this.inner   = $( '<div class="inner_tooltip"></div>').prependTo(this.tooltip);
1318        this.open    = false;
1319        this.timer   = false;
1320        this.active  = false;
1321
1322        this.bind_events();
1323	};
1324
1325	$.AviaTooltip.openTTs = [];
1326	$.AviaTooltip.openTT_Elements = [];
1327
1328    $.AviaTooltip.prototype =
1329    {
1330        bind_events: function()
1331        {
1332	        var perma_tooltips		= '.av-permanent-tooltip [data-'+this.options.data+']',
1333	        	default_tooltips	= '[data-'+this.options.data+']:not( .av-permanent-tooltip [data-'+this.options.data+'])';
1334
1335	        this.scope.on( 'av_permanent_show', perma_tooltips, this.display_tooltip.bind( this ) );
1336	        $(perma_tooltips).addClass('av-perma-tooltip').trigger('av_permanent_show');
1337
1338
1339			this.scope.on( this.options.event + ' mouseleave', default_tooltips, this.start_countdown.bind( this ) );
1340
1341            if(this.options.event != 'click')
1342            {
1343                this.scope.on( 'mouseleave', default_tooltips, this.hide_tooltip.bind( this ) );
1344				this.scope.on( 'click', default_tooltips, this.hide_on_click_tooltip.bind( this ) );
1345            }
1346            else
1347            {
1348                this.body.on( 'mousedown', this.hide_tooltip.bind( this ) );
1349            }
1350
1351			if( this.options.close_keys != null )
1352			{
1353				this.body.on( 'keyup', this.close_on_keyup.bind( this ) );
1354			}
1355        },
1356
1357        start_countdown: function(e)
1358        {
1359            clearTimeout(this.timer);
1360
1361			var target 		= this.options.event == "click" ? e.target : e.currentTarget,
1362            	element 	= $(target);
1363
1364            if( e.type == this.options.event )
1365            {
1366                var delay = this.options.event == 'click' ? 0 : this.open ? 0 : this.options.delay;
1367
1368                this.timer = setTimeout( this.display_tooltip.bind( this, e ), delay );
1369            }
1370            else if( e.type == 'mouseleave' )
1371            {
1372				if( ! element.hasClass( 'av-close-on-click-tooltip' ) )
1373				{
1374					this.timer = setTimeout( this.stop_instant_open.bind( this, e ), this.options.delayOut);
1375				}
1376            }
1377            e.preventDefault();
1378        },
1379
1380        reset_countdown: function(e)
1381        {
1382            clearTimeout( this.timer );
1383            this.timer = false;
1384        },
1385
1386        display_tooltip: function(e)
1387        {
1388            var _self		= this,
1389            	target 		= this.options.event == "click" ? e.target : e.currentTarget,
1390            	element 	= $(target),
1391                text    	= element.data(this.options.data),
1392                tip_index  	= element.data('avia-created-tooltip'),
1393            	extraClass 	= element.data('avia-tooltip-class'),
1394                attach  	= this.options.attach == 'element' ? element : this.body,
1395                offset  	= this.options.attach == 'element' ? element.position() : element.offset(),
1396                position	= element.data('avia-tooltip-position'),
1397                align		= element.data('avia-tooltip-alignment'),
1398                force_append= false,
1399				newTip		= false,
1400				is_new_tip	= false;
1401
1402            text = 'string' == typeof text ? text.trim() : '';
1403
1404            if(element.is('.av-perma-tooltip'))
1405            {
1406	            offset = {top:0, left:0 };
1407	        	attach = element;
1408				force_append = true;
1409            }
1410
1411			if( text == "" )
1412			{
1413				return;
1414			}
1415			if( position == "" || typeof position == 'undefined' )
1416			{
1417				position = this.options.position;
1418			}
1419			if( align == "" || typeof align == 'undefined' )
1420			{
1421				align = 'center';
1422			}
1423
1424			if( typeof tip_index != 'undefined' )
1425			{
1426				newTip = $.AviaTooltip.openTTs[tip_index];
1427			}
1428			else
1429			{
1430				this.inner.html(text);
1431				newTip = this.tooltip.clone();
1432				is_new_tip = true;
1433
1434				if( this.options.attach == 'element' && force_append !== true )
1435				{
1436					newTip.insertAfter(attach);
1437				}
1438				else
1439				{
1440					newTip.appendTo(attach);
1441				}
1442
1443                if(extraClass != "")
1444				{
1445					newTip.addClass(extraClass);
1446				}
1447			}
1448
1449			if( this.open && this.active == newTip )
1450			{
1451				return;
1452			}
1453
1454			if( element.hasClass( 'av-close-on-click-tooltip' ) )
1455			{
1456				this.hide_all_tooltips();
1457			}
1458
1459            this.open = true;
1460            this.active = newTip;
1461
1462            if( ( newTip.is(':animated:visible') && e.type == 'click' ) || element.is( '.' + this.options['class'] ) || element.parents( '.' + this.options['class'] ).length != 0 )
1463			{
1464				return;
1465			}
1466
1467            var animate1 = {},
1468				animate2 = {},
1469				pos1 = "",
1470				pos2 = "";
1471
1472			if( position == "top" || position == "bottom" )
1473			{
1474				switch(align)
1475				{
1476					case "left":
1477						pos2 = offset.left;
1478						break;
1479					case "right":
1480						pos2 = offset.left + element.outerWidth() - newTip.outerWidth();
1481						break;
1482					default:
1483						pos2 = ( offset.left + ( element.outerWidth() / 2 ) ) - ( newTip.outerWidth() / 2 );
1484						break;
1485				}
1486
1487				if(_self.options.within_screen) //used to keep search field inside screen
1488				{
1489					var boundary = element.offset().left + (element.outerWidth() / 2) - (newTip.outerWidth() / 2) + parseInt(newTip.css('margin-left'),10);
1490					if(boundary < 0)
1491					{
1492						pos2 = pos2 - boundary;
1493					}
1494				}
1495			}
1496			else
1497			{
1498				switch(align)
1499				{
1500					case "top":
1501						pos1 = offset.top;
1502						break;
1503					case "bottom":
1504						pos1 = offset.top + element.outerHeight() - newTip.outerHeight();
1505						break;
1506					default:
1507						pos1 = ( offset.top + (element.outerHeight() / 2 ) ) - ( newTip.outerHeight() / 2 );
1508						break;
1509				}
1510			}
1511
1512			switch(position)
1513			{
1514				case "top":
1515					pos1 = offset.top - newTip.outerHeight();
1516					animate1 = {top: pos1 - 10, left: pos2};
1517					animate2 = {top: pos1};
1518					break;
1519				case "bottom":
1520					pos1 = offset.top + element.outerHeight();
1521					animate1 = {top: pos1 + 10, left: pos2};
1522					animate2 = {top: pos1};
1523					break;
1524				case "left":
1525					pos2 = offset.left  - newTip.outerWidth();
1526					animate1 = {top: pos1, left: pos2 -10};
1527					animate2 = {left: pos2};
1528					break;
1529				case "right":
1530					pos2 = offset.left + element.outerWidth();
1531					animate1 = {top: pos1, left: pos2 + 10};
1532					animate2 = {left: pos2};
1533					break;
1534			}
1535
1536			animate1['display'] = "block";
1537			animate1['opacity'] = 0;
1538			animate2['opacity'] = 1;
1539
1540            newTip.css(animate1).stop().animate(animate2,200);
1541
1542            newTip.find('input, textarea').trigger('focus');
1543			if( is_new_tip )
1544			{
1545				$.AviaTooltip.openTTs.push(newTip);
1546				$.AviaTooltip.openTT_Elements.push(element);
1547				element.data('avia-created-tooltip', $.AviaTooltip.openTTs.length - 1);
1548			}
1549        },
1550
1551		hide_on_click_tooltip: function(e)
1552		{
1553			if( this.options.event == "click" )
1554			{
1555				return;
1556			}
1557
1558			var element = $( e.currentTarget );
1559
1560			if( ! element.hasClass('av-close-on-click-tooltip') )
1561			{
1562				return;
1563			}
1564
1565			if( ! element.find( 'a' ) )
1566			{
1567				e.preventDefault();
1568			}
1569
1570			//	Default behaviour when using mouse - click on active tooltip closes it (moving mouse to another tooltip close others automatically
1571			//	On mobile devices or when using touchscreen we show element on click (= old behaviour) and hide when same element
1572			var ttip_index = element.data('avia-created-tooltip');
1573
1574			if( 'undefined' != typeof ttip_index )
1575			{
1576				var current = $.AviaTooltip.openTTs[ttip_index];
1577				if( 'undefined' != typeof current && current == this.active )
1578				{
1579					this.hide_all_tooltips();
1580				}
1581			}
1582
1583		},
1584
1585		close_on_keyup: function( e )
1586		{
1587			if( this.options.close_keys == null )
1588			{
1589				return;
1590			}
1591
1592			if( $.inArray( e.keyCode, this.options.close_keys ) < 0 )
1593			{
1594				return;
1595			}
1596
1597			this.hide_all_tooltips( e.keyCode );
1598		},
1599
1600		hide_all_tooltips: function( keyCode )
1601		{
1602			var ttip,
1603				position,
1604				element,
1605				keyCodeCheck = 'undefined' != typeof keyCode ? keyCode + '' : null;
1606
1607			for( var index = 0; index < $.AviaTooltip.openTTs.length; ++index )
1608			{
1609				ttip = $.AviaTooltip.openTTs[index];
1610				element = $.AviaTooltip.openTT_Elements[index];
1611				position = element.data('avia-tooltip-position');
1612
1613				//	check if tooltip can be closed on keyup
1614				if( keyCodeCheck != null )
1615				{
1616					var keys = ttip.data( 'close-keys' );
1617					if( 'undefined' == typeof keys )
1618					{
1619						continue;
1620					}
1621
1622					keys = keys + '';
1623					keys = keys.split( ',' );
1624					if( $.inArray( keyCodeCheck, keys ) < 0 )
1625					{
1626						continue;
1627					}
1628				}
1629
1630				this.animate_hide_tooltip( ttip, position );
1631			}
1632
1633			this.open = false;
1634			this.active  = false;
1635		},
1636
1637        hide_tooltip: function(e)
1638        {
1639            var element 	= $(e.currentTarget) , newTip, animateTo,
1640            	position	= element.data('avia-tooltip-position'),
1641                align		= element.data('avia-tooltip-alignment'),
1642				newTip		= false;
1643
1644            if( position == "" || typeof position == 'undefined' )
1645			{
1646				position = this.options.position;
1647			}
1648
1649			if( align == "" || typeof align == 'undefined' )
1650			{
1651				align = 'center';
1652			}
1653
1654            if( this.options.event == 'click' )
1655            {
1656                element = $(e.target);
1657
1658                if( ! element.is( '.' + this.options['class'] ) && element.parents( '.' + this.options['class'] ).length == 0 )
1659                {
1660                    if( this.active.length )
1661					{
1662						newTip = this.active;
1663						this.active = false;
1664					}
1665                }
1666            }
1667            else
1668            {
1669				if( ! element.hasClass( 'av-close-on-click-tooltip' ) )
1670				{
1671					newTip = element.data('avia-created-tooltip');
1672					newTip = typeof newTip != 'undefined' ? $.AviaTooltip.openTTs[newTip] : false;
1673				}
1674            }
1675
1676            this.animate_hide_tooltip( newTip, position );
1677        },
1678
1679		animate_hide_tooltip: function( ttip, position )
1680		{
1681			if(ttip)
1682            {
1683            	var animate = {opacity:0};
1684
1685            	switch(position)
1686            	{
1687            		case "top":
1688						animate['top'] = parseInt(ttip.css('top'),10) - 10;
1689						break;
1690					case "bottom":
1691						animate['top'] = parseInt(ttip.css('top'),10) + 10;
1692						break;
1693					case "left":
1694						animate['left'] = parseInt(ttip.css('left'), 10) - 10;
1695						break;
1696					case "right":
1697						animate['left'] = parseInt(ttip.css('left'), 10) + 10;
1698						break;
1699            	}
1700
1701                ttip.animate( animate, 200, function()
1702                {
1703                    ttip.css({display:'none'});
1704                });
1705			}
1706		},
1707
1708        stop_instant_open: function(e)
1709        {
1710            this.open = false;
1711        }
1712    };
1713
1714})( jQuery );
1715
1716
1717(function($)
1718{
1719	"use strict";
1720
1721	$( function()
1722	{
1723		/**
1724		 * Performance fix to pass pagespeed test
1725		 *
1726		 * https://stackoverflow.com/questions/60357083/does-not-use-passive-listeners-to-improve-scrolling-performance-lighthouse-repo#62177358
1727		 * @since 5.4
1728		 */
1729		$.event.special.touchstart = {
1730							setup: function( _, ns, handle )
1731							{
1732								this.addEventListener( "touchstart", handle, { passive: !ns.includes("noPreventDefault") } );
1733							}
1734						};
1735
1736		$.event.special.touchmove = {
1737							setup: function( _, ns, handle )
1738							{
1739								this.addEventListener( "touchmove", handle, { passive: !ns.includes("noPreventDefault") } );
1740							}
1741						};
1742
1743		$.event.special.wheel = {
1744							setup: function( _, ns, handle )
1745							{
1746								this.addEventListener( "wheel", handle, { passive: true } );
1747							}
1748						};
1749
1750		$.event.special.mousewheel = {
1751							setup: function( _, ns, handle )
1752							{
1753								this.addEventListener( "mousewheel", handle, { passive: true } );
1754							}
1755						};
1756
1757	});
1758
1759})( jQuery );
1760
1761
1762/**
1763 * Waypoints - 4.0.2
1764 * Copyright © 2011-2016 Caleb Troughton (up to 4.0.1)
1765 * Licensed under the MIT license.
1766 * https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
1767 *
1768 * @since 5.2   moved to own folder /waypoints
1769 */
1770
1771
1772// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ + http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
1773// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel. can be removed if IE9 is no longer supported or all parallax scripts are gone
1774// MIT license
1775(function(){var lastTime=0;var vendors=['ms','moz','webkit','o'];for(var x=0;x<vendors.length&&!window.requestAnimationFrame;++x){window.requestAnimationFrame=window[vendors[x]+'RequestAnimationFrame'];window.cancelAnimationFrame=window[vendors[x]+'CancelAnimationFrame']||window[vendors[x]+'CancelRequestAnimationFrame']}if(!window.requestAnimationFrame)window.requestAnimationFrame=function(callback,element){var currTime=new Date().getTime();var timeToCall=Math.max(0,16-(currTime-lastTime));var id=window.setTimeout(function(){callback(currTime+timeToCall)},timeToCall);lastTime=currTime+timeToCall;return id};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=function(id){clearTimeout(id)}}());
1776
1777jQuery.expr.pseudos.regex = function(elem, index, match)
1778{
1779    var matchParams = match[3].split(','),
1780        validLabels = /^(data|css):/,
1781        attr = {
1782            method: matchParams[0].match(validLabels) ? matchParams[0].split(':')[0] : 'attr',
1783            property: matchParams.shift().replace(validLabels,'')
1784        },
1785        regexFlags = 'ig',
1786        regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
1787
1788    return regex.test(jQuery(elem)[attr.method](attr.property));
1789};
1790

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.