// source --> https://axhotelsmalta.com/wp-content/themes/enfold/js/avia.js?ver=5.1.2 
/**
 * Polyfill for older browsers https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
 *
 * @since 4.8
 * @retrun boolean
 */
if ( ! Array.isArray )
{
	Array.isArray = function( arg )
	{
		return Object.prototype.toString.call( arg ) === '[object Array]';
	};
}

(function($)
{
	"use strict";

	$( function()
	{
		$.avia_utilities = $.avia_utilities || {};

		AviaBrowserDetection( 'html' );
		AviaDeviceDetection( 'html' );

		//show scroll top but1ton
		avia_scroll_top_fade();

		//calculate width of content
		aviaCalcContentWidth();

		//creates search tooltip
		new $.AviaTooltip({
					"class": 'avia-search-tooltip',
					data: 'avia-search-tooltip',
					event: 'click',
					position: 'bottom',
					scope: "body",
					attach: 'element',
					within_screen: true,
					close_keys: 27
				});

        //creates relate posts tooltip
        new $.AviaTooltip({
					"class": 'avia-related-tooltip',
					data: 'avia-related-tooltip',
					scope: ".related_posts, .av-share-box",
					attach: 'element',
					delay: 0
				});

        //creates ajax search
        new $.AviaAjaxSearch({scope:'#header, .avia_search_element'});

		// actiavte portfolio sorting
		if( $.fn.avia_iso_sort )
		{
			$('.grid-sort-container').avia_iso_sort();
		}

		// Checks height of content and sidebar and applies shadow class to the higher one
        AviaSidebarShadowHelper();

        $.avia_utilities.avia_ajax_call();

    });

	$.avia_utilities = $.avia_utilities || {};

	$.avia_utilities.avia_ajax_call = function(container)
	{
		if( typeof container == 'undefined' )
		{
			container = 'body';
		};

		$('a.avianolink').on('click', function(e){ e.preventDefault(); });
        $('a.aviablank').attr('target', '_blank');

        //activates the prettyphoto lightbox
        if($.fn.avia_activate_lightbox)
		{
        	$(container).avia_activate_lightbox();
        }

        //scrollspy for main menu. must be located before smoothscrolling
		if( $.fn.avia_scrollspy )
		{
			if(container == 'body')
			{
				$('body').avia_scrollspy({target:'.main_menu .menu li > a'});
			}
			else
			{
				$('body').avia_scrollspy('refresh');
			}
		}



		//smooth scrooling
		if( $.fn.avia_smoothscroll )
		{
			if ( !is_page(5310) ){
				$('a[href*="#"]', container).avia_smoothscroll(container);
			}		
		}

		avia_small_fixes(container);

		avia_hover_effect(container);

		avia_iframe_fix(container);

		//activate html5 video player
		if( $.fn.avia_html5_activation && $.fn.mediaelementplayer )
		{
			$(".avia_video, .avia_audio", container).avia_html5_activation({ratio:'16:9'});
		}

	};

	// -------------------------------------------------------------------------------------------
	// Error log helper
	// -------------------------------------------------------------------------------------------
	$.avia_utilities.log = function( text, type, extra )
	{
		if( typeof console == 'undefined' )
		{
			return;
		}

		if( typeof type == 'undefined' )
		{
			type = "log";
		}

		type = "AVIA-" + type.toUpperCase();

		console.log( "["+type+"] "+text );

		if( typeof extra != 'undefined' )
		{
			console.log( extra );
		}
	};



	// -------------------------------------------------------------------------------------------
	// keep track of the browser and content width
	// -------------------------------------------------------------------------------------------



	function aviaCalcContentWidth()
	{

	var win			= $(window),
		width_select= $('html').is('.html_header_sidebar') ? "#main" : "#header",
		outer		= $(width_select),
		outerParent = outer.parents('div').eq( 0 ),
		the_main	= $(width_select + ' .container').first(),
		css_block	= "",
		calc_dimensions = function()
		{
			var css			= "",
				w_12 		= Math.round( the_main.width() ),
				w_outer		= Math.round( outer.width() ),
				w_inner		= Math.round( outerParent.width() );

			//css rules for mega menu
			css += " #header .three.units{width:"	+ ( w_12 * 0.25)+	"px;}";
			css += " #header .six.units{width:"		+ ( w_12 * 0.50)+	"px;}";
			css += " #header .nine.units{width:"	+ ( w_12 * 0.75)+	"px;}";
			css += " #header .twelve.units{width:"	+( w_12 )		+	"px;}";

			//css rules for tab sections
			css += " .av-framed-box .av-layout-tab-inner .container{width:"	+( w_inner )+	"px;}";
			css += " .html_header_sidebar .av-layout-tab-inner .container{width:"	+( w_outer )+	"px;}";
			css += " .boxed .av-layout-tab-inner .container{width:"	+( w_outer )+	"px;}";

			//css rules for submenu container
			css += " .av-framed-box#top .av-submenu-container{width:"	+( w_inner )+	"px;}";

			//ie8 needs different insert method
			try{
				css_block.text(css);
			}
			catch(err){
				css_block.remove();
				var headFirst = $( 'head' ).first();
				css_block = $("<style type='text/css' id='av-browser-width-calc'>"+css+"</style>").appendTo( headFirst );
			}

		};



		if($('.avia_mega_div').length > 0 || $('.av-layout-tab-inner').length > 0 || $('.av-submenu-container').length > 0)
		{
			var headFirst = $( 'head' ).first();
			css_block = $("<style type='text/css' id='av-browser-width-calc'></style>").appendTo( headFirst );
			win.on( 'debouncedresize', calc_dimensions);
			calc_dimensions();
		}
	}


    // -------------------------------------------------------------------------------------------
    // Tiny helper for sidebar shadow
    // -------------------------------------------------------------------------------------------

	function AviaSidebarShadowHelper()
	{
		var $sidebar_container = $('.sidebar_shadow#top #main .sidebar');
		var $content_container = $('.sidebar_shadow .content');

		if( $sidebar_container.height() >= $content_container.height() )
		{
			$sidebar_container.addClass('av-enable-shadow');
		}
		else
		{
			$content_container.addClass('av-enable-shadow');
		}
	}


	// -------------------------------------------------------------------------------------------
	// modified SCROLLSPY by bootstrap
	// -------------------------------------------------------------------------------------------


	  function AviaScrollSpy(element, options)
	  {
		var self = this;

		var process = self.process.bind( self ),
			refresh = self.refresh.bind( self ),
			$element = $(element).is('body') ? $(window) : $(element),
			href;

		    self.$body = $('body');
		    self.$win = $(window);
		    self.options = $.extend({}, $.fn.avia_scrollspy.defaults, options);
		    self.selector = (self.options.target
		      || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
		      || '');

		   	self.activation_true = false;

		    if(self.$body.find(self.selector + "[href*='#']").length)
		    {
		    	self.$scrollElement = $element.on('scroll.scroll-spy.data-api', process);
		    	self.$win.on('av-height-change', refresh);
		    	self.$body.on('av_resize_finished', refresh);
		    	self.activation_true = true;
		    	self.checkFirst();

		    	setTimeout(function()
	  			{
		    		self.refresh();
		    		self.process();

		    	},100);
		    }

	  }

	  AviaScrollSpy.prototype = {

	      constructor: AviaScrollSpy
		, checkFirst: function () {

			var current = window.location.href.split('#')[0],
				matching_link = this.$body.find(this.selector + "[href='"+current+"']").attr('href',current+'#top');
		}
	    , refresh: function () {

	    if(!this.activation_true) return;

	        var self = this
	          , $targets;

	        this.offsets = $([]);
	        this.targets = $([]);

	        $targets = this.$body
	          .find(this.selector)
	          .map(function () {
	            var $el = $(this)
	              , href = $el.data('target') || $el.attr('href')
	              , hash = this.hash
	              , hash = hash.replace(/\//g, "")
	              , $href = /^#\w/.test(hash) && $(hash);

				//	$.isWindow deprecated 3.3 https://api.jquery.com/jquery.iswindow/
				var obj = self.$scrollElement.get(0);
				var isWindow = obj != null && obj === obj.window;

	            return ( $href
	              && $href.length
	              && [[ $href.position().top + ( ! isWindow && self.$scrollElement.scrollTop() ), href ]] ) || null;
	          })
	          .sort(function (a, b) { return a[0] - b[0]; })
	          .each(function () {
	            self.offsets.push(this[0]);
	            self.targets.push(this[1]);
	          });

	      }

	    , process: function () {

	    	if(!this.offsets) return;
	    	if(isNaN(this.options.offset)) this.options.offset = 0;

	        var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
	          , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
	          , maxScroll = scrollHeight - this.$scrollElement.height()
	          , offsets = this.offsets
	          , targets = this.targets
	          , activeTarget = this.activeTarget
	          , i;

	        if (scrollTop >= maxScroll) {
	          return activeTarget != (i = targets.last()[0])
	            && this.activate ( i );
	        }

	        for (i = offsets.length; i--;) {
	          activeTarget != targets[i]
	            && scrollTop >= offsets[i]
	            && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
	            && this.activate( targets[i] );
	        }
	      }

	    , activate: function (target) {
	        var active
	          , selector;

	        this.activeTarget = target;

	        $(this.selector)
	          .parent('.' + this.options.applyClass)
	          .removeClass(this.options.applyClass);

	        selector = this.selector
	          + '[data-target="' + target + '"],'
	          + this.selector + '[href="' + target + '"]';



	        active = $(selector)
	          .parent('li')
	          .addClass(this.options.applyClass);

	        if (active.parent('.sub-menu').length)  {
	          active = active.closest('li.dropdown_ul_available').addClass(this.options.applyClass);
	        }

	        active.trigger('activate');
	      }

	  };


	 /* AviaScrollSpy PLUGIN DEFINITION
	  * =========================== */

	  $.fn.avia_scrollspy = function (option) {
	    return this.each(function () {
	      var $this = $(this)
	        , data = $this.data('scrollspy')
	        , options = typeof option == 'object' && option;
	      if (!data) $this.data('scrollspy', (data = new AviaScrollSpy(this, options)));
	      if (typeof option == 'string') data[option]();
	    });
	  };

	  $.fn.avia_scrollspy.Constructor = AviaScrollSpy;

	  $.fn.avia_scrollspy.calc_offset = function()
	  {
		  var 	offset_1 = (parseInt($('.html_header_sticky #main').data('scroll-offset'), 10)) || 0,
		  		offset_2 = ($(".html_header_sticky:not(.html_top_nav_header) #header_main_alternate").outerHeight()) || 0,
		  		offset_3 = ($(".html_header_sticky.html_header_unstick_top_disabled #header_meta").outerHeight()) || 0,
		  		offset_4 =  1,
		  		offset_5 = parseInt($('html').css('margin-top'),10) || 0,
		  		offset_6 = parseInt($('.av-frame-top ').outerHeight(),10) || 0;

		  return offset_1 + offset_2 + offset_3 + offset_4 + offset_5 + offset_6;
	  };

	  $.fn.avia_scrollspy.defaults =
	  {
	    offset: $.fn.avia_scrollspy.calc_offset(),
	    applyClass: 'current-menu-item'
	  };


    // -------------------------------------------------------------------------------------------
    // detect browser and add class to body
    // -------------------------------------------------------------------------------------------
    function AviaBrowserDetection(outputClassElement)
    {
	    //code from the old jquery migrate plugin
	    var current_browser = {},

	    	uaMatch = function( ua )
			{
				ua = ua.toLowerCase();

				var match = /(edge)\/([\w.]+)/.exec( ua ) ||
				/(opr)[\/]([\w.]+)/.exec( ua ) ||
				/(chrome)[ \/]([\w.]+)/.exec( ua ) ||
				/(iemobile)[\/]([\w.]+)/.exec( ua ) ||
				/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) ||
				/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) ||
				/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
				/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
				/(msie) ([\w.]+)/.exec( ua ) ||
				ua.indexOf("trident") >= 0 && /(rv)(?::| )([\w.]+)/.exec( ua ) ||
				ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
				[];

				return {
					  browser: match[ 5 ] || match[ 3 ] || match[ 1 ] || "",
					  version: match[ 2 ] || match[ 4 ] || "0",
					  versionNumber: match[ 4 ] || match[ 2 ] || "0"
					};
			};

		var matched = uaMatch( navigator.userAgent );

		if( matched.browser )
		{
			current_browser.browser = matched.browser;
			current_browser[ matched.browser ] = true;
			current_browser.version = matched.version;
		}

		// Chrome is Webkit, but Webkit is also Safari.
		if ( current_browser.chrome ) {
			current_browser.webkit = true;
		} else if ( current_browser.webkit ) {
			current_browser.safari = true;
		}

        if(typeof(current_browser) !== 'undefined')
        {
            var bodyclass = '',
				version = current_browser.version ? parseInt(current_browser.version) : "";

            if(current_browser.msie || current_browser.rv || current_browser.iemobile){
                bodyclass += 'avia-msie';
            }else if(current_browser.webkit){
                bodyclass += 'avia-webkit';
            }else if(current_browser.mozilla){
                bodyclass += 'avia-mozilla';
            }

            if(current_browser.version) bodyclass += ' ' + bodyclass + '-' + version + ' ';
            if(current_browser.browser) bodyclass += ' avia-' + current_browser.browser + ' avia-' +current_browser.browser +'-' + version + ' ';
        }

        if( outputClassElement )
		{
			$(outputClassElement).addClass( bodyclass );
		}

        return bodyclass;
    }

	/**
	 * Detect device features and add a class to body
	 */
	function AviaDeviceDetection( outputClassElement )
	{
		var classes = [];

		//	https://stackoverflow.com/questions/14439903/how-can-i-detect-device-touch-support-in-javascript
		$.avia_utilities.isTouchDevice = 'ontouchstart' in window ||
				window.DocumentTouch && document instanceof window.DocumentTouch ||
				navigator.maxTouchPoints > 0 ||
				window.navigator.msMaxTouchPoints > 0;

		classes.push( $.avia_utilities.isTouchDevice ? 'touch-device' : 'no-touch-device' );

		$.avia_utilities.pointerDevices = [];

		//	https://stackdiary.com/detect-mobile-browser-javascript/
		if( typeof window.matchMedia != 'function' )
		{
			$.avia_utilities.pointerDevices.push( 'undefined' );
			classes.push( 'pointer-device-undefined' );
		}
		else
		{
			var pointer_fine = false;

			if( window.matchMedia( '(any-pointer: fine)' ) )
			{
				classes.push( 'pointer-device-fine' );
				$.avia_utilities.pointerDevices.push( 'fine' );
				pointer_fine = true;
			}

			if( window.matchMedia( '(any-pointer: coarse)' ) )
			{
				classes.push( 'pointer-device-coarse' );
				$.avia_utilities.pointerDevices.push( 'coarse' );

				if( ! pointer_fine )
				{
					classes.push( 'pointer-device-coarse-only' );
				}
			}

			if( ! $.avia_utilities.pointerDevices.length )
			{
				classes.push( 'pointer-device-none' );
				$.avia_utilities.pointerDevices.push( 'none' );
			}
		}

		if( 'undefined' == typeof $.avia_utilities.isMobile )
		{
			if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && 'ontouchstart' in document.documentElement)
			{
				$.avia_utilities.isMobile = true;
			}
			else
			{
				$.avia_utilities.isMobile = false;
			}
		}

		$( outputClassElement ).addClass( classes.join( ' ') );
	}

    // -------------------------------------------------------------------------------------------
	// html 5 videos
	// -------------------------------------------------------------------------------------------
    $.fn.avia_html5_activation = function( options )
	{
		var defaults =
		{
			ratio: '16:9'
		};

		var options = $.extend( defaults, options );

//			isMobile = $.avia_utilities.isMobile;
//			if(isMobile) return;

		this.each( function()
		{
			var fv = $(this),
				id_to_apply = '#' + fv.attr('id'),
				posterImg = fv.attr('poster'),
				features = [ 'playpause', 'progress', 'current', 'duration', 'tracks', 'volume' ],
				container = fv.closest( '.avia-video' );

			if( container.length > 0 && container.hasClass( 'av-html5-fullscreen-btn' ) )
			{
				features.push( 'fullscreen' );
			}

			fv.mediaelementplayer(
			{
				// if the <video width> is not specified, this is the default
				defaultVideoWidth: 480,
				// if the <video height> is not specified, this is the default
				defaultVideoHeight: 270,
				// if set, overrides <video width>
				videoWidth: -1,
				// if set, overrides <video height>
				videoHeight: -1,
				// width of audio player
				audioWidth: 400,
				// height of audio player
				audioHeight: 30,
				// initial volume when the player starts
				startVolume: 0.8,
				// useful for <audio> player loops
				loop: false,
				// enables Flash and Silverlight to resize to content size
				enableAutosize: false,
				// the order of controls you want on the control bar (and other plugins below)
				features: features,
				// Hide controls when playing and mouse is not over the video
				alwaysShowControls: false,
				// force iPad's native controls
				iPadUseNativeControls: false,
				// force iPhone's native controls
				iPhoneUseNativeControls: false,
				// force Android's native controls
				AndroidUseNativeControls: false,
				// forces the hour marker (##:00:00)
				alwaysShowHours: false,
				// show framecount in timecode (##:00:00:00)
				showTimecodeFrameCount: false,
				// used when showTimecodeFrameCount is set to true
				framesPerSecond: 25,
				// turns keyboard support on and off for this instance
				enableKeyboard: true,
				// when this player starts, it will pause other players
				pauseOtherPlayers: false,
				poster: posterImg,
				success: function( mediaElement, domObject, instance )
				{
					//make the medialement instance accesible by storing it. usually not necessary but safari has problems since wp version 4.9
					$.AviaVideoAPI.players[ fv.attr('id').replace( /_html5/,'' ) ] = instance;

					setTimeout(function()
					{
						if( mediaElement.pluginType == 'flash' )
						{
							mediaElement.addEventListener('canplay', function() { fv.trigger('av-mediajs-loaded'); }, false);
						}
						else
						{
							fv.trigger('av-mediajs-loaded').addClass('av-mediajs-loaded');
						}

						mediaElement.addEventListener('ended', function() {  fv.trigger('av-mediajs-ended'); }, false);

						var html5MediaElement = document.getElementById( $(mediaElement).attr('id') + '_html5' );
						if( html5MediaElement && html5MediaElement !== mediaElement )
						{
							mediaElement.addEventListener( "ended", function()
							{
								$( html5MediaElement ).trigger( 'av-mediajs-ended' );
							});
						}
					}, 10 );

				},
				// fires when a problem is detected
				error: function()
				{

				},
				// array of keyboard commands
				keyActions: []
			});
		});
	};

 	// -------------------------------------------------------------------------------------------
	// hover effect for images
	// -------------------------------------------------------------------------------------------
    function avia_hover_effect( container )
    {
    	//hover overlay for mobile device doesnt really make sense. in addition it often slows down the click event
    	if( $.avia_utilities.isMobile )
		{
			return;
		}

		if( $('body').hasClass( 'av-disable-avia-hover-effect' ) )
		{
			return;
		}

		var overlay = "",
			cssTrans = $.avia_utilities.supports('transition');

		if(container == 'body')
    	{
    		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');
    	}
    	else
    	{
    		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);
    	}

	   elements.each( function(e)
       {
            var link = $(this),
            	current = link.find('img').first();

            if(current.hasClass('alignleft')) link.addClass('alignleft').css({float:'left', margin:0, padding:0});
            if(current.hasClass('alignright')) link.addClass('alignright').css({float:'right', margin:0, padding:0});
            if(current.hasClass('aligncenter')) link.addClass('aligncenter').css({float:'none','text-align':'center', margin:0, padding:0});

            if(current.hasClass('alignnone'))
            {
               link.addClass('alignnone').css({margin:0, padding:0});;
               if(!link.css('display') || link.css('display') == 'inline') { link.css({display:'inline-block'}); }
            }

            if(!link.css('position') || link.css('position') == 'static') { link.css({position:'relative', overflow:'hidden'}); }

            var url		 	= link.attr('href'),
				span_class	= "overlay-type-video",
				opa			= link.data('opacity') || 0.7,
				overlay_offset = 5,
				overlay 	= link.find('.image-overlay');

            	if(url)
				{
					if( url.match(/(jpg|gif|jpeg|png|tif)/) ) span_class = "overlay-type-image";
					if(!url.match(/(jpg|gif|jpeg|png|\.tif|\.mov|\.swf|vimeo\.com|youtube\.com)/) ) span_class = "overlay-type-extern";
				}

				if(!overlay.length)
				{
					overlay = $("<span class='image-overlay "+span_class+"'><span class='image-overlay-inside'></span></span>").appendTo(link);
				}

            	link.on('mouseenter', function(e)
				{
					var current = link.find('img').first(),
						_self	= current.get(0),
						outerH 	= current.outerHeight(),
						outerW 	= current.outerWidth(),
						pos		= current.position(),
						linkCss = link.css('display'),
						overlay = link.find('.image-overlay');

					if(outerH > 100)
					{

						if(!overlay.length)
						{
							overlay = $("<span class='image-overlay "+span_class+"'><span class='image-overlay-inside'></span></span>").appendTo(link);

						}
						//can be wrapped into if !overlay.length statement if chrome fixes fade in problem
						if(link.height() == 0) { link.addClass(_self.className); _self.className = ""; }
						if(!linkCss || linkCss == 'inline') { link.css({display:'block'}); }
						//end wrap

						overlay.css({left:(pos.left - overlay_offset) + parseInt(current.css("margin-left"),10), top:pos.top + parseInt(current.css("margin-top"),10)})
							   .css({overflow:'hidden',display:'block','height':outerH,'width':(outerW + (2*overlay_offset))});

						if(cssTrans === false ) overlay.stop().animate({opacity:opa}, 400);
					}
					else
					{
						overlay.css({display:"none"});
					}

				}).on('mouseleave', elements, function(){

					if(overlay.length)
					{
						if(cssTrans === false ) overlay.stop().animate({opacity:0}, 400);
					}
				});
        });
    }


// -------------------------------------------------------------------------------------------
// Smooth scrooling when clicking on anchor links
// todo: maybe use https://github.com/ryanburnette/scrollToBySpeed/blob/master/src/scrolltobyspeed.jquery.js in the future
// -------------------------------------------------------------------------------------------

	(function($)
	{
		$.fn.avia_smoothscroll = function( apply_to_container )
		{
			if( ! this.length )
			{
				return;
			}

			var the_win = $(window),
				$header = $('#header'),
				$main 	= $('.html_header_top.html_header_sticky #main').not('.page-template-template-blank-php #main'),
				$meta 	= $('.html_header_top.html_header_unstick_top_disabled #header_meta'),
				$alt  	= $('.html_header_top:not(.html_top_nav_header) #header_main_alternate'),
				menu_above_logo = $('.html_header_top.html_top_nav_header'),
				shrink	= $('.html_header_top.html_header_shrinking').length,
				frame	= $('.av-frame-top'),
				fixedMainPadding = 0,
				isMobile = $.avia_utilities.isMobile,
				sticky_sub = $('.sticky_placeholder').first(),
				calc_main_padding = function()
				{
					if( $header.css('position') == "fixed" )
					{
						var tempPadding = parseInt($main.data('scroll-offset'),10) || 0,
							non_shrinking = parseInt($meta.outerHeight(),10) || 0,
							non_shrinking2 = parseInt($alt.outerHeight(),10) || 0;

						if( tempPadding > 0 && shrink )
						{
							tempPadding = (tempPadding / 2 ) + non_shrinking + non_shrinking2;
						}
						else
						{
							tempPadding = tempPadding + non_shrinking + non_shrinking2;
						}

						tempPadding += parseInt($('html').css('margin-top'),10);
						fixedMainPadding = tempPadding;
					}
					else
					{
						fixedMainPadding = parseInt($('html').css('margin-top'),10);
					}

					if( frame.length )
					{
						fixedMainPadding += frame.height();
					}

					if( menu_above_logo.length )
					{
						//if menu is above logo and we got a sticky height header
						fixedMainPadding = $('.html_header_sticky #header_main_alternate').height() + parseInt($('html').css('margin-top'),10);
					}

					if( isMobile )
					{
						fixedMainPadding = 0;
					}

				};

			if( isMobile )
			{
				shrink = false;
			}

			calc_main_padding();
			the_win.on( "debouncedresize av-height-change", calc_main_padding );

			var hash = window.location.hash.replace(/\//g, "");

			//if a scroll event occurs at pageload and an anchor is set and a coresponding element exists apply the offset to the event
			if( fixedMainPadding > 0 && hash && apply_to_container == 'body' && hash.charAt(1) != "!" && hash.indexOf("=") === -1 )
			{
				var scroll_to_el = $(hash), modifier = 0;

				if( scroll_to_el.length )
				{
					the_win.on('scroll.avia_first_scroll', function()
					{
						setTimeout( function()		//small delay so other scripts can perform necessary resizing
						{
							if( sticky_sub.length && scroll_to_el.offset().top > sticky_sub.offset().top )
							{
								modifier = sticky_sub.outerHeight() - 3;
							}

							the_win.off( 'scroll.avia_first_scroll' ).scrollTop( scroll_to_el.offset().top - fixedMainPadding - modifier );
						},10);
				    });
			    }
			}

			return this.each(function()
			{
				$(this).on('click', function(e)
				{
					var newHash = this.hash.replace(/\//g, ""),
						clicked = $(this),
						data = clicked.data();

					if( newHash != '' && newHash != '#' && newHash != '#prev' && newHash != '#next' && !clicked.is('.comment-reply-link, #cancel-comment-reply-link, .no-scroll'))
					{
						var container = "",
							originHash = "";

						if( '#next-section' == newHash )
						{
							originHash = newHash;

							//	@since 4.8.3 check to scroll to visible sections only (e.g. sections could be hidden on different devices
							var next_containers = clicked.parents('.container_wrap').eq( 0 ).nextAll('.container_wrap');
							next_containers.each( function()
							{
							   var cont = $( this );

							   if( cont.css( 'display' ) == 'none' || cont.css( 'visibility' ) == 'hidden' )
							   {
								   return;
							   }

							   container = cont;
							   return false;
							});

							if( 'object' == typeof container && container.length > 0 )
							{
								newHash = '#' + container.attr('id') ;
							}
						}
						else
						{
							 container = $( this.hash.replace(/\//g, "") );
						}

						if( container.length )
						{
							var cur_offset = the_win.scrollTop(),
								container_offset = container.offset().top - 100,
								target =  container_offset - fixedMainPadding,
								hash = window.location.hash,
								hash = hash.replace(/\//g, ""),
								oldLocation = window.location.href.replace(hash, ''),
								newLocation = this,
								duration = data.duration || 1200,
								easing = data.easing || 'easeInOutQuint';

							if( sticky_sub.length && container_offset > sticky_sub.offset().top )
							{
								target -= sticky_sub.outerHeight() - 3;
							}

							// make sure it's the same location
							if( oldLocation+newHash == newLocation || originHash )
							{
								if( cur_offset != target ) // if current pos and target are the same dont scroll
								{
									if( ! ( cur_offset == 0 && target <= 0 ) ) // if we are at the top dont try to scroll to top or above
									{
										the_win.trigger('avia_smooth_scroll_start');

										// animate to target and set the hash to the window.location after the animation
										$('html:not(:animated),body:not(:animated)').animate({ scrollTop: target }, duration, easing, function()
										{
											// add new hash to the browser location
											//window.location.href=newLocation;
											if( window.history.replaceState )
											{
												window.history.replaceState( "", "", newHash );
											}
										});
									}
								}

								// cancel default click action
								e.preventDefault();
							}
						}
					}
				});
			});
		};
	})(jQuery);


	// -------------------------------------------------------------------------------------------
	// iframe fix for firefox and ie so they get proper z index
	// -------------------------------------------------------------------------------------------
	function avia_iframe_fix(container)
	{
		var iframe 	= jQuery('iframe[src*="youtube.com"]:not(.av_youtube_frame)', container),
			youtubeEmbed = jQuery('iframe[src*="youtube.com"]:not(.av_youtube_frame) object, iframe[src*="youtube.com"]:not(.av_youtube_frame) embed', container).attr('wmode','opaque');

			iframe.each(function()
			{
				var current = jQuery(this),
					src 	= current.attr('src');

				if(src)
				{
					if(src.indexOf('?') !== -1)
					{
						src += "&wmode=opaque&rel=0";
					}
					else
					{
						src += "?wmode=opaque&rel=0";
					}

					current.attr('src', src);
				}
			});
	}

	// -------------------------------------------------------------------------------------------
	// small js fixes for pixel perfection :)
	// -------------------------------------------------------------------------------------------
	function avia_small_fixes(container)
	{
		if(!container) container = document;

		//make sure that iframes do resize correctly. uses css padding bottom iframe trick
		var win		= jQuery(window),
			iframes = jQuery('.avia-iframe-wrap iframe:not(.avia-slideshow iframe):not( iframe.no_resize):not(.avia-video iframe)', container),
			adjust_iframes = function()
			{
				iframes.each(function(){

					var iframe = jQuery(this), parent = iframe.parent(), proportions = 56.25;

					if(this.width && this.height)
					{
						proportions = (100/ this.width) * this.height;
						parent.css({"padding-bottom":proportions+"%"});
					}
				});
			};

			adjust_iframes();

	}

   function avia_scroll_top_fade()
   {
   		 var win 		= $(window),
   		 	 timeo = false,
   		 	 scroll_top = $('#scroll-top-link'),
   		 	 set_status = function()
             {
             	var st = win.scrollTop();

             	if(st < 500)
             	{
             		scroll_top.removeClass('avia_pop_class');
             	}
             	else if(!scroll_top.is('.avia_pop_class'))
             	{
             		scroll_top.addClass('avia_pop_class');
             	}
             };

   		 win.on( 'scroll',  function(){ window.requestAnimationFrame( set_status ); } );
         set_status();
	}




	$.AviaAjaxSearch = function( options )
	{
		var defaults = {
			delay: 300,                //delay in ms until the user stops typing.
			minChars: 3,               //dont start searching before we got at least that much characters
			scope: 'body'
		};

		this.options = $.extend({}, defaults, options);
		this.scope   = $(this.options.scope);
		this.timer   = false;
		this.lastVal = "";

		this.bind_events();
	};

	$.AviaAjaxSearch.prototype =
    {
        bind_events: function()
        {
            this.scope.on( 'keyup', '#s:not(".av_disable_ajax_search #s")', this.try_search.bind( this ) );
            this.scope.on( 'click', '#s.av-results-parked', this.reset.bind( this ) );
        },

        try_search: function(e)
        {
            var form = $(e.currentTarget).parents('form').eq( 0 ),
                resultscontainer = form.find('.ajax_search_response');

            clearTimeout(this.timer);

			// clear on ESC
            if( e.keyCode === 27 )
			{
                this.reset(e);
				return;
			}

            //only execute search if chars are at least "minChars" and search differs from last one
            if(e.currentTarget.value.length >= this.options.minChars && this.lastVal != e.currentTarget.value.trim() )
            {
                //wait at least "delay" milliseconds to execute ajax. if user types again during that time dont execute
                this.timer = setTimeout( this.do_search.bind( this, e ), this.options.delay );
            }
            //remove the results container if the input field has been emptied
            else if ( e.currentTarget.value.length == 0 )
			{
                this.timer = setTimeout( this.reset.bind( this, e ), this.options.delay );
			}
        },

		reset: function(e){
            var form = $(e.currentTarget).parents('form').eq( 0 ),
				resultscontainer = form.find('.ajax_search_response'),
				alternative_resultscontainer = $(form.attr('data-ajaxcontainer')).find('.ajax_search_response'),
				searchInput = $(e.currentTarget);

            // bring back results that were hidden when user clicked outside the form element
            if ($(e.currentTarget).hasClass('av-results-parked')) {
                resultscontainer.show();
                alternative_resultscontainer.show();

                // in case results container is attached to body
                $('body > .ajax_search_response').show();
			}
			else {
                // remove results and delete the input value
                resultscontainer.remove();
                alternative_resultscontainer.remove();
                searchInput.val('');

                // in case results container is attached to body
                $('body > .ajax_search_response').remove();
			}


		},

        do_search: function(e)
        {
            var obj = this,
                currentField = $(e.currentTarget).attr( "autocomplete", "off" ),
				currentFieldWrapper = $(e.currentTarget).parents('.av_searchform_wrapper').eq( 0 ),
                currentField_position = currentFieldWrapper.offset(),
                currentField_width = currentFieldWrapper.outerWidth(),
                currentField_height = currentFieldWrapper.outerHeight(),
				form = currentField.parents('form').eq( 0 ),
				submitbtn = form.find('#searchsubmit'),
                resultscontainer = form,
                results = resultscontainer.find('.ajax_search_response'),
                loading = $('<div class="ajax_load"><span class="ajax_load_inner"></span></div>'),
                action = form.attr('action'),
                values = form.serialize(),
				elementID = form.data('element_id'),
				custom_color = form.data('custom_color');

			values += '&action=avia_ajax_search';


            // define results div if not found
            if( ! results.length )
			{
                results = $('<div class="ajax_search_response" style="display:none;"></div>');
            }

			if( 'undefined' != typeof elementID )
			{
				results.addClass( elementID );
			}

			if( 'undefined' != typeof custom_color && custom_color != '' )
			{
				results.addClass( 'av_has_custom_color' );
			}

            // add class to differentiate betweeen search element and header search
			if( form.attr('id') == 'searchform_element')
			{
				results.addClass('av_searchform_element_results');
			}

            //check if the form got get parameters applied and also apply them
           	if(action.indexOf('?') != -1)
           	{
           		action  = action.split('?');
           		values += "&" + action[1];
           	}

           	//check if there is a results container defined
			if( form.attr('data-ajaxcontainer') )
			{
                var rescon = form.attr('data-ajaxcontainer');

                // check if defined container exists
                if ($(rescon).length)
				{
                	// remove previous search results
					$(rescon).find('.ajax_search_response').remove();

                    resultscontainer = $(rescon);
				}
			}

			/*
			 * For the placement option: "Under the search form - overlay other content",
			 * we have to attach the results to the body in order to overlay the other content,
			 * and we calculate it's position using the search field
			 */

            results_css = {};

			if( form.hasClass('av_results_container_fixed') )
			{
				// remove previous search results
				$('body').find('.ajax_search_response').remove();

				resultscontainer = $('body');

				// add class and position to results if defined above
				var results_css = {
								top: currentField_position.top + currentField_height,
								left: currentField_position.left,
								width: currentField_width
							};

				// make sure default stylesheet is applied
				results.addClass('main_color');

				// remove results and reset if window is resized
				$( window ).resize( function()
				{
					results.remove();
					this.reset.bind( this );
					currentField.val('');
				});
			}

            // add additional styles - for backwards comp. only. Attribute has been removed in 4.8.7 with header styles
            if ( form.attr('data-results_style') )
			{
                var results_style = JSON.parse(form.attr('data-results_style'));
                results_css = Object.assign(results_css, results_style);

                // add class if font color is applied, so we can use color: inherit
                if( "color" in results_css )
				{
                    results.addClass('av_has_custom_color');
                }
            }

            // apply inline styles
            results.css(results_css);

            // add .container class if resultscontainer in a color section
			if( resultscontainer.hasClass('avia-section') )
			{
				results.addClass('container');
			}

            // append results to defined container
            results.appendTo(resultscontainer);


			//return if we already hit a no result and user is still typing
			if(results.find('.ajax_not_found').length && e.currentTarget.value.indexOf(this.lastVal) != -1)
			{
				return;
			}

			this.lastVal = e.currentTarget.value;

			$.ajax({
				url: avia_framework_globals.ajaxurl,
				type: "POST",
				data:values,
				beforeSend: function()
				{
					// add loader after submit button
					loading.insertAfter(submitbtn);
					form.addClass('ajax_loading_now');
				},
				success: function(response)
				{
					if(response == 0)
					{
						response = "";
					}

					results.html(response).show();
				},
				complete: function()
				{
					loading.remove();
					form.removeClass('ajax_loading_now');
				}
			});

            // Hide search resuls if user clicks anywhere outside the form element
			$(document).on('click',function(e)
			{
				if(!$(e.target).closest(form).length)
				{
					if($(results).is(":visible"))
					{
						$(results).hide();
						currentField.addClass('av-results-parked');
					}
				}
			});
		}
	};


	$.AviaTooltip = function( options )
	{
	   var defaults = {
            delay: 1500,                //delay in ms until the tooltip appears
            delayOut: 300,             	//delay in ms when instant showing should stop
            delayHide: 0,             	//delay hiding of tooltip in ms
            "class": "avia-tooltip",   	//tooltip classname for css styling and alignment
            scope: "body",             	//area the tooltip should be applied to
            data:  "avia-tooltip",     	//data attribute that contains the tooltip text
            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
            event: 'mouseenter',       	//mousenter and leave or click and leave
            position: 'top',             //top or bottom
            extraClass: 'avia-tooltip-class', //extra class that is defined by a tooltip element data attribute
            permanent: false, 			// always display the tooltip?
            within_screen: false,		// if the tooltip is displayed outside the screen adjust its position
            close_keys: null			// string|[] of keyCodes to close the tooltip (there is no check for empty value !! )
        };

        this.options = $.extend({}, defaults, options);

		var close_keys = '';
		if( this.options.close_keys != null )
		{
			if( ! Array.isArray( this.options.close_keys ) )
			{
				this.options.close_keys = [ this.options.close_keys ];
			}
			close_keys = ' data-close-keys="' + this.options.close_keys.join( ',' ) + '" ';
		}

        this.body    = $('body');
        this.scope   = $(this.options.scope);
		this.tooltip = $( '<div class="' + this.options['class'] + ' avia-tt"' + close_keys + '><span class="avia-arrow-wrap"><span class="avia-arrow"></span></span></div>' );
        this.inner   = $( '<div class="inner_tooltip"></div>').prependTo(this.tooltip);
        this.open    = false;
        this.timer   = false;
        this.active  = false;

        this.bind_events();
	};

	$.AviaTooltip.openTTs = [];
	$.AviaTooltip.openTT_Elements = [];

    $.AviaTooltip.prototype =
    {
        bind_events: function()
        {
	        var perma_tooltips		= '.av-permanent-tooltip [data-'+this.options.data+']',
	        	default_tooltips	= '[data-'+this.options.data+']:not( .av-permanent-tooltip [data-'+this.options.data+'])';

	        this.scope.on( 'av_permanent_show', perma_tooltips, this.display_tooltip.bind( this ) );
	        $(perma_tooltips).addClass('av-perma-tooltip').trigger('av_permanent_show');


			this.scope.on( this.options.event + ' mouseleave', default_tooltips, this.start_countdown.bind( this ) );

            if(this.options.event != 'click')
            {
                this.scope.on( 'mouseleave', default_tooltips, this.hide_tooltip.bind( this ) );
				this.scope.on( 'click', default_tooltips, this.hide_on_click_tooltip.bind( this ) );
            }
            else
            {
                this.body.on( 'mousedown', this.hide_tooltip.bind( this ) );
            }

			if( this.options.close_keys != null )
			{
				this.body.on( 'keyup', this.close_on_keyup.bind( this ) );
			}
        },

        start_countdown: function(e)
        {
            clearTimeout(this.timer);

			var target 		= this.options.event == "click" ? e.target : e.currentTarget,
            	element 	= $(target);

            if( e.type == this.options.event )
            {
                var delay = this.options.event == 'click' ? 0 : this.open ? 0 : this.options.delay;

                this.timer = setTimeout( this.display_tooltip.bind( this, e ), delay );
            }
            else if( e.type == 'mouseleave' )
            {
				if( ! element.hasClass( 'av-close-on-click-tooltip' ) )
				{
					this.timer = setTimeout( this.stop_instant_open.bind( this, e ), this.options.delayOut);
				}
            }
            e.preventDefault();
        },

        reset_countdown: function(e)
        {
            clearTimeout( this.timer );
            this.timer = false;
        },

        display_tooltip: function(e)
        {
            var _self		= this,
            	target 		= this.options.event == "click" ? e.target : e.currentTarget,
            	element 	= $(target),
                text    	= element.data(this.options.data),
                tip_index  	= element.data('avia-created-tooltip'),
            	extraClass 	= element.data('avia-tooltip-class'),
                attach  	= this.options.attach == 'element' ? element : this.body,
                offset  	= this.options.attach == 'element' ? element.position() : element.offset(),
                position	= element.data('avia-tooltip-position'),
                align		= element.data('avia-tooltip-alignment'),
                force_append= false,
				newTip		= false,
				is_new_tip	= false;

            text = 'string' == typeof text ? text.trim() : '';

            if(element.is('.av-perma-tooltip'))
            {
	            offset = {top:0, left:0 };
	        	attach = element;
				force_append = true;
            }

			if( text == "" )
			{
				return;
			}
			if( position == "" || typeof position == 'undefined' )
			{
				position = this.options.position;
			}
			if( align == "" || typeof align == 'undefined' )
			{
				align = 'center';
			}

			if( typeof tip_index != 'undefined' )
			{
				newTip = $.AviaTooltip.openTTs[tip_index];
			}
			else
			{
				this.inner.html(text);
				newTip = this.tooltip.clone();
				is_new_tip = true;

				if( this.options.attach == 'element' && force_append !== true )
				{
					newTip.insertAfter(attach);
				}
				else
				{
					newTip.appendTo(attach);
				}

                if(extraClass != "")
				{
					newTip.addClass(extraClass);
				}
			}

			if( this.open && this.active == newTip )
			{
				return;
			}

			if( element.hasClass( 'av-close-on-click-tooltip' ) )
			{
				this.hide_all_tooltips();
			}

            this.open = true;
            this.active = newTip;

            if( ( newTip.is(':animated:visible') && e.type == 'click' ) || element.is( '.' + this.options['class'] ) || element.parents( '.' + this.options['class'] ).length != 0 )
			{
				return;
			}

            var animate1 = {},
				animate2 = {},
				pos1 = "",
				pos2 = "";

			if( position == "top" || position == "bottom" )
			{
				switch(align)
				{
					case "left":
						pos2 = offset.left;
						break;
					case "right":
						pos2 = offset.left + element.outerWidth() - newTip.outerWidth();
						break;
					default:
						pos2 = ( offset.left + ( element.outerWidth() / 2 ) ) - ( newTip.outerWidth() / 2 );
						break;
				}

				if(_self.options.within_screen) //used to keep search field inside screen
				{
					var boundary = element.offset().left + (element.outerWidth() / 2) - (newTip.outerWidth() / 2) + parseInt(newTip.css('margin-left'),10);
					if(boundary < 0)
					{
						pos2 = pos2 - boundary;
					}
				}
			}
			else
			{
				switch(align)
				{
					case "top":
						pos1 = offset.top;
						break;
					case "bottom":
						pos1 = offset.top + element.outerHeight() - newTip.outerHeight();
						break;
					default:
						pos1 = ( offset.top + (element.outerHeight() / 2 ) ) - ( newTip.outerHeight() / 2 );
						break;
				}
			}

			switch(position)
			{
				case "top":
					pos1 = offset.top - newTip.outerHeight();
					animate1 = {top: pos1 - 10, left: pos2};
					animate2 = {top: pos1};
					break;
				case "bottom":
					pos1 = offset.top + element.outerHeight();
					animate1 = {top: pos1 + 10, left: pos2};
					animate2 = {top: pos1};
					break;
				case "left":
					pos2 = offset.left  - newTip.outerWidth();
					animate1 = {top: pos1, left: pos2 -10};
					animate2 = {left: pos2};
					break;
				case "right":
					pos2 = offset.left + element.outerWidth();
					animate1 = {top: pos1, left: pos2 + 10};
					animate2 = {left: pos2};
					break;
			}

			animate1['display'] = "block";
			animate1['opacity'] = 0;
			animate2['opacity'] = 1;

            newTip.css(animate1).stop().animate(animate2,200);

            newTip.find('input, textarea').trigger('focus');
			if( is_new_tip )
			{
				$.AviaTooltip.openTTs.push(newTip);
				$.AviaTooltip.openTT_Elements.push(element);
				element.data('avia-created-tooltip', $.AviaTooltip.openTTs.length - 1);
			}
        },

		hide_on_click_tooltip: function(e)
		{
			if( this.options.event == "click" )
			{
				return;
			}

			var element = $( e.currentTarget );

			if( ! element.hasClass('av-close-on-click-tooltip') )
			{
				return;
			}

			if( ! element.find( 'a' ) )
			{
				e.preventDefault();
			}

			//	Default behaviour when using mouse - click on active tooltip closes it (moving mouse to another tooltip close others automatically
			//	On mobile devices or when using touchscreen we show element on click (= old behaviour) and hide when same element
			var ttip_index = element.data('avia-created-tooltip');

			if( 'undefined' != typeof ttip_index )
			{
				var current = $.AviaTooltip.openTTs[ttip_index];
				if( 'undefined' != typeof current && current == this.active )
				{
					this.hide_all_tooltips();
				}
			}

		},

		close_on_keyup: function( e )
		{
			if( this.options.close_keys == null )
			{
				return;
			}

			if( $.inArray( e.keyCode, this.options.close_keys ) < 0 )
			{
				return;
			}

			this.hide_all_tooltips( e.keyCode );
		},

		hide_all_tooltips: function( keyCode )
		{
			var ttip,
				position,
				element,
				keyCodeCheck = 'undefined' != typeof keyCode ? keyCode + '' : null;

			for( var index = 0; index < $.AviaTooltip.openTTs.length; ++index )
			{
				ttip = $.AviaTooltip.openTTs[index];
				element = $.AviaTooltip.openTT_Elements[index];
				position = element.data('avia-tooltip-position');

				//	check if tooltip can be closed on keyup
				if( keyCodeCheck != null )
				{
					var keys = ttip.data( 'close-keys' );
					if( 'undefined' == typeof keys )
					{
						continue;
					}

					keys = keys + '';
					keys = keys.split( ',' );
					if( $.inArray( keyCodeCheck, keys ) < 0 )
					{
						continue;
					}
				}

				this.animate_hide_tooltip( ttip, position );
			}

			this.open = false;
			this.active  = false;
		},

        hide_tooltip: function(e)
        {
            var element 	= $(e.currentTarget) , newTip, animateTo,
            	position	= element.data('avia-tooltip-position'),
                align		= element.data('avia-tooltip-alignment'),
				newTip		= false;

            if( position == "" || typeof position == 'undefined' )
			{
				position = this.options.position;
			}

			if( align == "" || typeof align == 'undefined' )
			{
				align = 'center';
			}

            if( this.options.event == 'click' )
            {
                element = $(e.target);

                if( ! element.is( '.' + this.options['class'] ) && element.parents( '.' + this.options['class'] ).length == 0 )
                {
                    if( this.active.length )
					{
						newTip = this.active;
						this.active = false;
					}
                }
            }
            else
            {
				if( ! element.hasClass( 'av-close-on-click-tooltip' ) )
				{
					newTip = element.data('avia-created-tooltip');
					newTip = typeof newTip != 'undefined' ? $.AviaTooltip.openTTs[newTip] : false;
				}
            }

            this.animate_hide_tooltip( newTip, position );
        },

		animate_hide_tooltip: function( ttip, position )
		{
			if(ttip)
            {
            	var animate = {opacity:0};

            	switch(position)
            	{
            		case "top":
						animate['top'] = parseInt(ttip.css('top'),10) - 10;
						break;
					case "bottom":
						animate['top'] = parseInt(ttip.css('top'),10) + 10;
						break;
					case "left":
						animate['left'] = parseInt(ttip.css('left'), 10) - 10;
						break;
					case "right":
						animate['left'] = parseInt(ttip.css('left'), 10) + 10;
						break;
            	}

                ttip.animate( animate, 200, function()
                {
                    ttip.css({display:'none'});
                });
			}
		},

        stop_instant_open: function(e)
        {
            this.open = false;
        }
    };

})( jQuery );


/*!
Waypoints - 4.0.2
Copyright © 2011-2016 Caleb Troughton (up to 4.0.1)
Licensed under the MIT license.
https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
*/
!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");this.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.Context.refreshAll();for(var e in i)i[e].enabled=!0;return this},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,n.windowContext||(n.windowContext=!0,n.windowContext=new e(window)),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),i=this.element==this.element.window;t&&e&&!i&&(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];if(null!==a.triggerPoint){var 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=Math.floor(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:[],right:[]}},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 'function'===typeof 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))}();



// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ + http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// 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
// MIT license
(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)}}());

jQuery.expr.pseudos.regex = function(elem, index, match) {
    var matchParams = match[3].split(','),
        validLabels = /^(data|css):/,
        attr = {
            method: matchParams[0].match(validLabels) ?
                        matchParams[0].split(':')[0] : 'attr',
            property: matchParams.shift().replace(validLabels,'')
        },
        regexFlags = 'ig',
        regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
    return regex.test(jQuery(elem)[attr.method](attr.property));
};
// source --> https://axhotelsmalta.com/wp-content/themes/enfold/js/shortcodes.js?ver=5.1.2 
(function($)
{
	"use strict";

	$( function()
	{
		//global variables that are used on several ocassions
		$.avia_utilities = $.avia_utilities || {};

		if( 'undefined' == typeof $.avia_utilities.isMobile )
		{
			if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && 'ontouchstart' in document.documentElement)
			{
				$.avia_utilities.isMobile = true;
			}
			else
			{
				$.avia_utilities.isMobile = false;
			}
		}

		//activate fixed bg fallback for mobile
		if( $.fn.avia_mobile_fixed )
		{
			$( '.avia-bg-style-fixed' ).avia_mobile_fixed();
		}

		//calculate the browser height and append a css rule to the head
		if( $.fn.avia_browser_height )
		{
			$( '.av-minimum-height, .avia-fullscreen-slider, .av-cell-min-height' ).avia_browser_height();
		}

		//calculate the element height in a layout container
		if( $.fn.avia_container_height )
		{
			$( '.av-column-min-height-pc' ).avia_container_height();
		}

		//calculate the height of each video section
		if( $.fn.avia_video_section )
		{
			$( '.av-section-with-video-bg' ).avia_video_section();
		}

		//creates team social icon tooltip
		new $.AviaTooltip({'class': "avia-tooltip", data: "avia-tooltip", delay:0, scope: "body"});

		//creates icon element tooltip
		new $.AviaTooltip({'class': "avia-tooltip avia-icon-tooltip", data: "avia-icon-tooltip", delay:0, scope: "body"});

		$.avia_utilities.activate_shortcode_scripts();

		//layer slider height helper
		if( $.fn.layer_slider_height_helper )
		{
			$( '.avia-layerslider' ).layer_slider_height_helper();
		}

		//"ajax" portfolio
		if( $.fn.avia_portfolio_preview )
		{
			$( '.grid-links-ajax' ).avia_portfolio_preview();
		}

		// activate the masonry script: sorting/loading/etc
		if( $.fn.avia_masonry )
		{
			$( '.av-masonry' ).avia_masonry();
		}

		//activate the accordion
		if( $.fn.aviaccordion )
		{
			$( '.aviaccordion' ).aviaccordion();
		}


		//activate the accordion
		if( $.fn.avia_textrotator )
		{
			$( '.av-rotator-container' ).avia_textrotator();
		}

		//activates the tab section and slideshow section shortcode
		if( $.fn.avia_sc_tab_section )
		{
			$( '.av-tab-section-container' ).avia_sc_tab_section();
		}

		//activates the hor gallery  shortcode
		if( $.fn.avia_hor_gallery )
		{
			$( '.av-horizontal-gallery' ).avia_hor_gallery();
		}

		//	activate columns and cells with a link
		if( $.fn.avia_link_column )
		{
			$( '.avia-link-column' ).avia_link_column();
		}

		if( $.fn.avia_delayed_animation_in_container )
		{
			$( '.av-animation-delay-container' ).avia_delayed_animation_in_container();
		}
	});


// -------------------------------------------------------------------------------------------
// ACTIVATE ALL SHORTCODES
// -------------------------------------------------------------------------------------------

	$.avia_utilities = $.avia_utilities || {};
	$.avia_utilities.activate_shortcode_scripts = function( container )
	{
		if( typeof container == 'undefined' )
		{
			container = 'body';
		}

		//activates the form shortcode
		if( $.fn.avia_ajax_form )
		{
			$( '.avia_ajax_form:not( .avia-disable-default-ajax )', container ).avia_ajax_form();
		}

		activate_waypoints( container );

		//activate the video api
		if( $.fn.aviaVideoApi )
		{
			$( '.avia-slideshow iframe[src*="youtube.com"], .av_youtube_frame, .av_vimeo_frame, .avia-slideshow video' ).aviaVideoApi({}, 'li');
		}

	    //activates the toggle shortcode
		if( $.fn.avia_sc_toggle )
		{
			$( '.togglecontainer', container ).avia_sc_toggle();
		}

		//activates the tabs shortcode
		if( $.fn.avia_sc_tabs )
		{
			$( '.top_tab', container ).avia_sc_tabs();
			$( '.sidebar_tab', container ).avia_sc_tabs({sidebar:true});
		}

		//activates behavior and animation for gallery
		if( $.fn.avia_sc_gallery )
		{
			$( '.avia-gallery', container ).avia_sc_gallery();
		}

		//activates animated number shortcode
		if( $.fn.avia_sc_animated_number )
		{
			$( '.avia-animated-number', container ).avia_sc_animated_number();
		}

		//animation for elements that are not connected like icon shortcode
		if( $.fn.avia_sc_animation_delayed )
		{
			$( '.av_font_icon', container ).avia_sc_animation_delayed({delay:100});
			$( '.avia-image-container', container ).avia_sc_animation_delayed({delay:100});
			$( '.av-hotspot-image-container', container ).avia_sc_animation_delayed({delay:100});
			$( '.av-animated-generic', container ).avia_sc_animation_delayed({delay:100});

			//	@since 5.0 - avoid conflict with already existing classes
			$( '.av-animated-when-visible', container ).avia_sc_animation_delayed({delay:100});
			$( '.av-animated-when-almost-visible', container ).avia_sc_animation_delayed({delay:100});
			$( '.av-animated-when-visible-95', container ).avia_sc_animation_delayed({delay:100});
		}

		//activates animation for iconlist
		if( $.fn.avia_sc_iconlist )
		{
			$( '.avia-icon-list.av-iconlist-big.avia-iconlist-animate', container ).avia_sc_iconlist();
		}

		//activates animation for progress bar
		if( $.fn.avia_sc_progressbar )
		{
			$( '.avia-progress-bar-container', container ).avia_sc_progressbar();
		}

		//activates animation for testimonial
		if( $.fn.avia_sc_testimonial )
		{
			$( '.avia-testimonial-wrapper', container ).avia_sc_testimonial();
		}

		//activate the fullscreen slider
		if( $.fn.aviaFullscreenSlider )
		{
			$( '.avia-slideshow.av_fullscreen', container ).aviaFullscreenSlider();
		}

		//activate the aviaslider
		if( $.fn.aviaSlider )
		{
			$( '.avia-slideshow:not(.av_fullscreen)', container ).aviaSlider();

			//content slider
        	$( '.avia-content-slider-active', container ).aviaSlider({wrapElement: '.avia-content-slider-inner', slideElement: '.slide-entry-wrap', fullfade: true});

			//testimonial slider
			$( '.avia-slider-testimonials', container ).aviaSlider({wrapElement: '.avia-testimonial-row', slideElement: '.avia-testimonial', fullfade: true});
        }

		//load magazine sorting
		if( $.fn.aviaMagazine )
		{
			$( '.av-magazine-tabs-active', container ).aviaMagazine();
		}

		//load image hotspot
		if( $.fn.aviaHotspots )
		{
			$( '.av-hotspot-image-container', container ).aviaHotspots();
		}

		//load countdown
		if( $.fn.aviaCountdown )
		{
			$( '.av-countdown-timer', container ).aviaCountdown();
		}

		//load audio player
		if( $.fn.aviaPlayer )
		{
			$( '.av-player', container ).aviaPlayer();
		}

		//	load icon circles
		if( $.fn.aviaIconCircles )
		{
			$('.av-icon-circles-container').aviaIconCircles();
		}

		//	load icon grid
		if( $.fn.avia_sc_icongrid )
		{
			$('.avia-icon-grid-container').avia_sc_icongrid();
		}
    };


	function activate_waypoints( container )
	{
		//activates simple css animations of the content once the user scrolls to an elements
		if( $.fn.avia_waypoints )
		{
			if( typeof container == 'undefined' )
			{
				container = 'body';
			}

			$( '.avia_animate_when_visible', container ).avia_waypoints();
			$( '.avia_animate_when_almost_visible', container ).avia_waypoints( { offset: '80%'} );

			//	@since 5.0 - avoid conflict with already existing classes
			$( '.av-animated-when-visible', container ).avia_waypoints();
			$( '.av-animated-when-almost-visible', container ).avia_waypoints( { offset: '80%'} );
			$( '.av-animated-when-visible-95', container ).avia_waypoints( { offset: '95%'} );

			var disable_mobile = $( 'body' ).hasClass( 'avia-mobile-no-animations' );

			if( container == 'body' && disable_mobile )
			{
				container = '.avia_desktop body';
			}

			$( '.av-animated-generic', container ).avia_waypoints( { offset: '95%'} );
		}
	};


// -------------------------------------------------------------------------------------------



	// -------------------------------------------------------------------------------------------
	// Helper to allow fixed bgs on mobile
	// -------------------------------------------------------------------------------------------
	$.fn.avia_mobile_fixed = function(options)
	{
		var isMobile = $.avia_utilities.isMobile;

		if( ! isMobile )
		{
			return;
		}

		return this.each( function()
		{
			var current				= $(this).addClass('av-parallax-section'),
				$background 		= current.attr('style'),
				$attachment_class 	= current.data('section-bg-repeat'),
				template			= "";

				if($attachment_class == 'stretch' || $attachment_class == 'no-repeat' )
				{
					$attachment_class = " avia-full-stretch";
				}
				else
				{
					$attachment_class = "";
				}

				template = "<div class='av-parallax " + $attachment_class + "' data-avia-parallax-ratio='0.0' style = '" + $background + "' ></div>";

				current.prepend(template);
				current.attr('style','');
		});
	};



	// -------------------------------------------------------------------------------------------
	//  shortcode javascript for delayed animation even when non connected elements are used
	// -------------------------------------------------------------------------------------------
	$.fn.avia_sc_animation_delayed = function(options)
	{
		var global_timer = 0,
			delay = options.delay || 50,
			max_timer = 10,
			new_max = setTimeout( function(){ max_timer = 20; }, 500);

		return this.each(function()
		{
			var elements = $(this);

			//trigger displaying of thumbnails
			elements.on( 'avia_start_animation', function()
			{
				var element = $(this);

				if( global_timer < max_timer )
				{
					global_timer ++;
				}

				setTimeout( function()
				{
					element.addClass('avia_start_delayed_animation');
					if( global_timer > 0 )
					{
						global_timer --;
					}

				}, ( global_timer * delay ) );

			});
		});
	};

	/*delayd animations when used within tab sections or similar elements. this way they get animated each new time a tab is shown*/
	$.fn.avia_delayed_animation_in_container = function( options )
	{
		return this.each( function()
		{
			var elements = $(this);

			elements.on( 'avia_start_animation_if_current_slide_is_active', function()
			{
				var current = $(this),
					animate = current.find( '.avia_start_animation_when_active' );

				animate.addClass( 'avia_start_animation' ).trigger( 'avia_start_animation' );
			});

			elements.on( 'avia_remove_animation', function()
			{
				var current = $(this),
					animate = current.find( '.avia_start_animation_when_active, .avia_start_animation' );

				animate.removeClass( 'avia_start_animation avia_start_delayed_animation' );
			});
		});
	};


	// -------------------------------------------------------------------------------------------
	// Section Height Helper
	// -------------------------------------------------------------------------------------------
	$.fn.avia_browser_height = function()
	{
		if( ! this.length )
		{
			return this;
		}

		var win			= $(window),
			html_el		= $('html'),
			headFirst	= $( 'head' ).first(),
			subtract	= $('#wpadminbar, #header.av_header_top:not(.html_header_transparency #header), #main>.title_container'),
			css_block	= $("<style type='text/css' id='av-browser-height'></style>").appendTo( headFirst ),
			sidebar_menu= $('.html_header_sidebar #top #header_main'),
			full_slider	= $('.html_header_sidebar .avia-fullscreen-slider.avia-builder-el-0.avia-builder-el-no-sibling').addClass('av-solo-full'),
			pc_heights	= [ 25, 50, 75 ],
			calc_height = function()
			{
				var css			= '',
					wh100 		= win.height(),
					ww100 		= win.width(),
					wh100_mod 	= wh100,
					whCover		= (wh100 / 9) * 16,
					wwCover		= (ww100 / 16) * 9,
					solo		= 0;

				if( sidebar_menu.length )
				{
					solo = sidebar_menu.height();
				}

				subtract.each( function()
				{
					wh100_mod -= this.offsetHeight - 1;
				});

				var whCoverMod = ( wh100_mod / 9 ) * 16;

				//fade in of section content with minimum height once the height has been calculated
				css += ".avia-section.av-minimum-height .container{opacity: 1; }\n";

				//various section heights (100-25% as well as 100% - header/adminbar in case its the first builder element)
				css += ".av-minimum-height-100:not(.av-slideshow-section) .container, .avia-fullscreen-slider .avia-slideshow, #top.avia-blank .av-minimum-height-100 .container, .av-cell-min-height-100 > .flex_cell{height:" + wh100 + "px;}\n";

				css += ".av-minimum-height-100.av-slideshow-section .container { height:unset; }\n";
				css += ".av-minimum-height-100.av-slideshow-section {min-height:" + wh100 + "px;}\n";


				$.each( pc_heights, function( index, value )
				{
					var wh = Math.round( wh100 * ( value / 100.0 ) );
					css += ".av-minimum-height-" + value + ":not(.av-slideshow-section) .container, .av-cell-min-height-" + value + " > .flex_cell	{height:" + wh + "px;}\n";
					css += ".av-minimum-height-" + value + ".av-slideshow-section {min-height:" + wh + "px;}\n";
				});

				css += ".avia-builder-el-0.av-minimum-height-100:not(.av-slideshow-section) .container, .avia-builder-el-0.avia-fullscreen-slider .avia-slideshow, .avia-builder-el-0.av-cell-min-height-100 > .flex_cell{height:" + wh100_mod + "px;}\n";

				css += "#top .av-solo-full .avia-slideshow {min-height:" + solo + "px;}\n";

				//fullscreen video calculations
				if( ww100 / wh100 < 16 / 9 )
				{
					css += "#top .av-element-cover iframe, #top .av-element-cover embed, #top .av-element-cover object, #top .av-element-cover video{width:" + whCover + "px; left: -" + ( whCover - ww100 ) / 2 + "px;}\n";
				}
				else
				{
					css += "#top .av-element-cover iframe, #top .av-element-cover embed, #top .av-element-cover object, #top .av-element-cover video{height:" + wwCover + "px; top: -"+( wwCover - wh100 ) / 2 + "px;}\n";
				}

				if( ww100 / wh100_mod < 16 / 9 )
				{
					css += "#top .avia-builder-el-0 .av-element-cover iframe, #top .avia-builder-el-0 .av-element-cover embed, #top .avia-builder-el-0 .av-element-cover object, #top .avia-builder-el-0 .av-element-cover video{width:" + whCoverMod + "px; left: -" + ( whCoverMod - ww100 ) / 2 + "px;}\n";
				}
				else
				{
					css += "#top .avia-builder-el-0 .av-element-cover iframe, #top .avia-builder-el-0 .av-element-cover embed, #top .avia-builder-el-0 .av-element-cover object, #top .avia-builder-el-0 .av-element-cover video{height:" + wwCover + "px; top: -" + ( wwCover - wh100_mod ) / 2 + "px;}\n";
				}

				//ie8 needs different insert method
				try
				{
					css_block.text( css );
				}
				catch(err)
				{
					css_block.remove();
					css_block = $( "<style type='text/css' id='av-browser-height'>" + css + "</style>" ).appendTo( headFirst );
				}

				setTimeout(function()
				{
					win.trigger( 'av-height-change' ); /*broadcast the height change*/
				}, 100 );
			};

		this.each( function( index )
		{
			var height = $( this ).data( 'av_minimum_height_pc' );
			if( 'number' != typeof height )
			{
				return this;
			}

			height = parseInt( height );

			if( ( -1 == $.inArray( height, pc_heights ) ) && ( height != 100 ) )
			{
				pc_heights.push( height );
			}

			return this;
		});

		win.on( 'debouncedresize', calc_height );
		calc_height();
	};

	// -------------------------------------------------------------------------------------------
	// Layout container height helper
	// -------------------------------------------------------------------------------------------
	$.fn.avia_container_height = function()
	{
		if( ! this.length )
		{
			return this;
		}

		var win = $( window ),
			calc_height = function()
			{
				var column = $( this ),
					jsonHeight = column.data( 'av-column-min-height' ),
					minHeight = parseInt( jsonHeight['column-min-pc'], 10 ),
					container = null,
					containerHeight = 0,
					columMinHeight = 0;

				if( isNaN( minHeight ) || minHeight == 0 )
				{
					return;
				}

				//	try to find a layout container, else take browser height
				container = column.closest( '.avia-section' );
				if( ! container.length )
				{
					container = column.closest( '.av-gridrow-cell' );
				}
				if( ! container.length )
				{
					//	tab section and slideshow section
					container = column.closest( '.av-layout-tab' );
				}

				containerHeight = container.length ? container.outerHeight() : win.height();

				columMinHeight = containerHeight * ( minHeight / 100.0 );

				if( ! jsonHeight['column-equal-height'] )
				{
					column.css( 'min-height', columMinHeight + 'px');
					column.css( 'height', 'auto');
				}
				else
				{
					column.css( 'height', columMinHeight + 'px');
				}

				setTimeout( function()
				{
					win.trigger( 'av-height-change' ); /*broadcast the height change*/
				}, 100 );
			};

		this.each( function( index )
		{
			var column = $( this ),
				jsonHeight = column.data( 'av-column-min-height' );

			if( 'object' != typeof jsonHeight )
			{
				return this;
			}

			win.on( 'debouncedresize', calc_height.bind( column ) );
			calc_height.call( column );

			return this;
		});

	};

	// -------------------------------------------------------------------------------------------
	// Video Section helper
	// -------------------------------------------------------------------------------------------
	$.fn.avia_video_section = function()
	{
		if(!this.length) return;

		var elements	= this.length, content = "",
			win			= $(window),
			headFirst	= $( 'head' ).first(),
			css_block	= $("<style type='text/css' id='av-section-height'></style>").appendTo( headFirst ),
			calc_height = function(section, counter)
			{
				if(counter === 0) { content = "";}

				var css			= "",
					the_id		= '#' +section.attr('id'),
					wh100 		= section.height(),
					ww100 		= section.width(),
					aspect		= section.data('sectionVideoRatio').split(':'),
					video_w		= aspect[0],
					video_h		= aspect[1],
					whCover		= (wh100 / video_h ) * video_w,
					wwCover		= (ww100 / video_w ) * video_h;

				//fullscreen video calculations
				if(ww100/wh100 < video_w/video_h)
				{
					css += "#top "+the_id+" .av-section-video-bg iframe, #top "+the_id+" .av-section-video-bg embed, #top "+the_id+" .av-section-video-bg object, #top "+the_id+" .av-section-video-bg video{width:"+whCover+"px; left: -"+(whCover - ww100)/2+"px;}\n";
				}
				else
				{
					css += "#top "+the_id+" .av-section-video-bg iframe, #top "+the_id+" .av-section-video-bg embed, #top "+the_id+" .av-section-video-bg object, #top "+the_id+" .av-section-video-bg video{height:"+wwCover+"px; top: -"+(wwCover - wh100)/2+"px;}\n";
				}

				content = content + css;

				if(elements == counter + 1)
				{
					//ie8 needs different insert method
					try{
						css_block.text(content);
					}
					catch(err){
						css_block.remove();
						css_block = $("<style type='text/css' id='av-section-height'>"+content+"</style>").appendTo( headFirst );
					}
				}
			};


		return this.each(function(i)
		{
			var self = $(this);

			win.on( 'debouncedresize', function(){ calc_height(self, i); });
			calc_height(self, i);
		});

	};


	/**
	 * Column or cell with a link
	 *
	 * @returns {jQuery}
	 */
	$.fn.avia_link_column = function()
	{
		return this.each( function()
		{
			$(this).on( 'click', function(e)
			{
				//	if event is bubbled from an <a> link, do not activate link of column/cell
				if( 'undefined' !== typeof e.target && 'undefined' !== typeof e.target.href )
				{
					return;
				}

				var	column = $(this),
					url = column.data('link-column-url'),
					target = column.data('link-column-target'),
					link = window.location.hostname+window.location.pathname;

				if( 'undefined' === typeof url || 'string' !== typeof url )
				{
					return;
				}

				if( 'undefined' !== typeof target || '_blank' == target )
				{
//					in FF and other browsers this opens a new window and not only a new tab
//					window.open( url, '_blank', 'noopener noreferrer' );
					var a = document.createElement('a');
					a.href = url;
					a.target = '_blank';
					a.rel = 'noopener noreferrer';
					a.click();
					return false;
				}
				else
				{
					//	allow smoothscroll feature when on same page and hash exists - trigger only works for current page
					if( column.hasClass('av-cell-link') || column.hasClass('av-column-link') )
					{
						var reader = column.hasClass('av-cell-link') ? column.prev('a.av-screen-reader-only').first() : column.find('a.av-screen-reader-only').first();

						url = url.trim();
						if( ( 0 == url.indexOf("#") ) || ( ( url.indexOf( link ) >= 0 ) && ( url.indexOf("#") > 0 ) ) )
						{
							reader.trigger('click');

							//	fix a bug with tabsection not changeing tab
							if( 'undefined' == typeof target || '_blank' != target )
							{
								window.location.href = url;
							}

							return;
						}
					}

					window.location.href = url;
				}

				e.preventDefault();
				return;
			});
		});
	};


	// -------------------------------------------------------------------------------------------
	// HELPER FUNCTIONS
	// -------------------------------------------------------------------------------------------


	//waipoint script when something comes into viewport
	$.fn.avia_waypoints = function( options_passed )
	{
		if( ! $('html').is('.avia_transform') )
		{
			return;
		}

		var defaults = {
					offset: 'bottom-in-view',
					triggerOnce: true
				},
			options  = $.extend( {}, defaults, options_passed ),
			isMobile = $.avia_utilities.isMobile;

		return this.each( function()
		{
			var element = $(this),
				force_animate = element.hasClass( 'animate-all-devices' ),
				mobile_no_animations = $( 'body' ).hasClass( 'avia-mobile-no-animations' );

			setTimeout( function()
			{
				if( isMobile && mobile_no_animations && ! force_animate )
				{
					element.addClass( 'avia_start_animation' ).trigger('avia_start_animation');
				}
				else
				{
					element.waypoint( function( direction )
					{
						var current = $(this.element),
							parent = current.parents('.av-animation-delay-container').eq( 0 );

						if( parent.length )
						{
							current.addClass( 'avia_start_animation_when_active' ).trigger( 'avia_start_animation_when_active' );
						}

						if( ! parent.length || ( parent.length && parent.is( '.__av_init_open' ) ) || ( parent.length && parent.is( '.av-active-tab-content' ) ) )
						{
							current.addClass( 'avia_start_animation' ).trigger( 'avia_start_animation' );
						}
					}, options );
				}
			}, 100 );

		});
	};


	// window resize script
	var $event = $.event, $special, resizeTimeout;

	$special = $event.special.debouncedresize = {
		setup: function() {
			$( this ).on( "resize", $special.handler );
		},
		teardown: function() {
			$( this ).off( "resize", $special.handler );
		},
		handler: function( event, execAsap ) {
			// Save the context
			var context = this,
				args = arguments,
				dispatch = function() {
					// set correct event type
					event.type = "debouncedresize";
					$event.dispatch.apply( context, args );
				};

			if ( resizeTimeout ) {
				clearTimeout( resizeTimeout );
			}

			execAsap ?
				dispatch() :
				resizeTimeout = setTimeout( dispatch, $special.threshold );
		},
		threshold: 150
	};

})( jQuery );



/*utility functions*/


(function($)
{
	"use strict";

	$.avia_utilities = $.avia_utilities || {};

	/************************************************************************
	gloabl loading function
	*************************************************************************/
	$.avia_utilities.loading = function(attach_to, delay){

		var loader = {

			active: false,

			show: function()
			{
				if(loader.active === false)
				{
					loader.active = true;
					loader.loading_item.css({display:'block', opacity:0});
				}

				loader.loading_item.stop().animate({opacity:1});
			},

			hide: function()
			{
				if(typeof delay === 'undefined'){ delay = 600; }

				loader.loading_item.stop().delay( delay ).animate({opacity:0}, function()
				{
					loader.loading_item.css({display:'none'});
					loader.active = false;
				});
			},

			attach: function()
			{
				if(typeof attach_to === 'undefined'){ attach_to = 'body';}

				loader.loading_item = $('<div class="avia_loading_icon"><div class="av-siteloader"></div></div>').css({display:"none"}).appendTo(attach_to);
			}
		};

		loader.attach();
		return loader;
	};

	/************************************************************************
	gloabl play/pause visualizer function
	*************************************************************************/
	$.avia_utilities.playpause = function(attach_to, delay){

		var pp = {

			active: false,
			to1: "",
			to2: "",
			set: function(status)
			{
				pp.loading_item.removeClass('av-play av-pause');
				pp.to1 = setTimeout(function(){ pp.loading_item.addClass('av-' + status); },10);
				pp.to2 = setTimeout(function(){ pp.loading_item.removeClass('av-' + status); },1500);
			},

			attach: function()
			{
				if(typeof attach_to === 'undefined'){ attach_to = 'body';}

				pp.loading_item = $('<div class="avia_playpause_icon"></div>').css({display:"none"}).appendTo(attach_to);
			}
		};

		pp.attach();
		return pp;
	};



	/************************************************************************
	preload images, as soon as all are loaded trigger a special load ready event
	*************************************************************************/
	$.avia_utilities.preload = function(options_passed)
	{
		new $.AviaPreloader(options_passed);
	};

	$.AviaPreloader  =  function(options)
	{
	    this.win 		= $(window);
	    this.defaults	=
		{
			container:			'body',
			maxLoops:			10,
			trigger_single:		true,
			single_callback:	function(){},
			global_callback:	function(){}

		};
		this.options 	= $.extend({}, this.defaults, options);
		this.preload_images = 0;

		this.load_images();
	};

	$.AviaPreloader.prototype  =
	{
		load_images: function()
		{
			var _self = this;

			if(typeof _self.options.container === 'string'){ _self.options.container = $(_self.options.container); }

			_self.options.container.each(function()
			{
				var container		= $(this);

				container.images	= container.find('img');
				container.allImages	= container.images;

				_self.preload_images += container.images.length;
				setTimeout(function(){ _self.checkImage(container); }, 10);
			});
		},

		checkImage: function(container)
		{
			var _self = this;

			container.images.each(function()
			{
				if(this.complete === true)
				{
					container.images = container.images.not(this);
					_self.preload_images -= 1;
				}
			});

			if(container.images.length && _self.options.maxLoops >= 0)
			{
				_self.options.maxLoops-=1;
				setTimeout( function(){ _self.checkImage( container ); }, 500 );
			}
			else
			{
				_self.preload_images = _self.preload_images - container.images.length;
				_self.trigger_loaded(container);
			}
		},

		trigger_loaded: function(container)
		{
			var _self = this;

			if(_self.options.trigger_single !== false)
			{
				_self.win.trigger('avia_images_loaded_single', [container]);
				_self.options.single_callback.call(container);
			}

			if(_self.preload_images === 0)
			{
				_self.win.trigger('avia_images_loaded');
				_self.options.global_callback.call();
			}

		}
	};

	/************************************************************************
	CSS Easing transformation table
	*************************************************************************/
	/*
	Easing transform table from jquery.animate-enhanced plugin
	http://github.com/benbarnett/jQuery-Animate-Enhanced
	*/
	$.avia_utilities.css_easings = {
			linear:			'linear',
			swing:			'ease-in-out',
			bounce:			'cubic-bezier(0.0, 0.35, .5, 1.3)',
			easeInQuad:     'cubic-bezier(0.550, 0.085, 0.680, 0.530)' ,
			easeInCubic:    'cubic-bezier(0.550, 0.055, 0.675, 0.190)' ,
			easeInQuart:    'cubic-bezier(0.895, 0.030, 0.685, 0.220)' ,
			easeInQuint:    'cubic-bezier(0.755, 0.050, 0.855, 0.060)' ,
			easeInSine:     'cubic-bezier(0.470, 0.000, 0.745, 0.715)' ,
			easeInExpo:     'cubic-bezier(0.950, 0.050, 0.795, 0.035)' ,
			easeInCirc:     'cubic-bezier(0.600, 0.040, 0.980, 0.335)' ,
			easeInBack:     'cubic-bezier(0.600, -0.280, 0.735, 0.04)' ,
			easeOutQuad:    'cubic-bezier(0.250, 0.460, 0.450, 0.940)' ,
			easeOutCubic:   'cubic-bezier(0.215, 0.610, 0.355, 1.000)' ,
			easeOutQuart:   'cubic-bezier(0.165, 0.840, 0.440, 1.000)' ,
			easeOutQuint:   'cubic-bezier(0.230, 1.000, 0.320, 1.000)' ,
			easeOutSine:    'cubic-bezier(0.390, 0.575, 0.565, 1.000)' ,
			easeOutExpo:    'cubic-bezier(0.190, 1.000, 0.220, 1.000)' ,
			easeOutCirc:    'cubic-bezier(0.075, 0.820, 0.165, 1.000)' ,
			easeOutBack:    'cubic-bezier(0.175, 0.885, 0.320, 1.275)' ,
			easeInOutQuad:  'cubic-bezier(0.455, 0.030, 0.515, 0.955)' ,
			easeInOutCubic: 'cubic-bezier(0.645, 0.045, 0.355, 1.000)' ,
			easeInOutQuart: 'cubic-bezier(0.770, 0.000, 0.175, 1.000)' ,
			easeInOutQuint: 'cubic-bezier(0.860, 0.000, 0.070, 1.000)' ,
			easeInOutSine:  'cubic-bezier(0.445, 0.050, 0.550, 0.950)' ,
			easeInOutExpo:  'cubic-bezier(1.000, 0.000, 0.000, 1.000)' ,
			easeInOutCirc:  'cubic-bezier(0.785, 0.135, 0.150, 0.860)' ,
			easeInOutBack:  'cubic-bezier(0.680, -0.550, 0.265, 1.55)' ,
			easeInOutBounce:'cubic-bezier(0.580, -0.365, 0.490, 1.365)',
			easeOutBounce:	'cubic-bezier(0.760, 0.085, 0.490, 1.365)'
		};

	/************************************************************************
	check if a css feature is supported and save it to the supported array
	*************************************************************************/
	$.avia_utilities.supported	= {};
	$.avia_utilities.supports	= (function()
	{
		var div		= document.createElement('div'),
			vendors	= ['Khtml', 'Ms','Moz','Webkit'];  // vendors	= ['Khtml', 'Ms','Moz','Webkit','O'];

		return function(prop, vendor_overwrite)
		{
			if ( div.style[prop] !== undefined  ) { return ""; }
			if (vendor_overwrite !== undefined) { vendors = vendor_overwrite; }

			prop = prop.replace(/^[a-z]/, function(val)
			{
				return val.toUpperCase();
			});

			var len	= vendors.length;
			while(len--)
			{
				if ( div.style[vendors[len] + prop] !== undefined )
				{
					return "-" + vendors[len].toLowerCase() + "-";
				}
			}

			return false;
		};

	}());

	/************************************************************************
	animation function
	*************************************************************************/
	$.fn.avia_animate = function(prop, speed, easing, callback)
	{
		if(typeof speed === 'function') {callback = speed; speed = false; }
		if(typeof easing === 'function'){callback = easing; easing = false;}
		if(typeof speed === 'string'){easing = speed; speed = false;}

		if(callback === undefined || callback === false){ callback = function(){}; }
		if(easing === undefined || easing === false)	{ easing = 'easeInQuad'; }
		if(speed === undefined || speed === false)		{ speed = 400; }

		if($.avia_utilities.supported.transition === undefined)
		{
			$.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
		}



		if($.avia_utilities.supported.transition !== false )
		{
			var prefix		= $.avia_utilities.supported.transition + 'transition',
				cssRule		= {},
				cssProp		= {},
				thisStyle	= document.body.style,
				end			= (thisStyle.WebkitTransition !== undefined) ? 'webkitTransitionEnd' : (thisStyle.OTransition !== undefined) ? 'oTransitionEnd' : 'transitionend';

			//translate easing into css easing
			easing = $.avia_utilities.css_easings[easing];

			//create css transformation rule
			cssRule[prefix]	=  'all '+(speed/1000)+'s '+easing;
			//add namespace to the transition end trigger
			end = end + ".avia_animate";

			//since jquery 1.10 the items passed need to be {} and not [] so make sure they are converted properly
			for (var rule in prop)
			{
				if (prop.hasOwnProperty(rule)) { cssProp[rule] = prop[rule]; }
			}
			prop = cssProp;



			this.each(function()
			{
				var element	= $(this), css_difference = false, rule, current_css;

				for (rule in prop)
				{
					if (prop.hasOwnProperty(rule))
					{
						current_css = element.css(rule);

						if(prop[rule] != current_css && prop[rule] != current_css.replace(/px|%/g,""))
						{
							css_difference = true;
							break;
						}
					}
				}

				if(css_difference)
				{
					//if no transform property is set set a 3d translate to enable hardware acceleration
					if(!($.avia_utilities.supported.transition+"transform" in prop))
					{
						prop[$.avia_utilities.supported.transition+"transform"] = "translateZ(0)";
					}

					var endTriggered = false;

					element.on(end,  function(event)
					{
						if(event.target != event.currentTarget) return false;

						if(endTriggered == true) return false;
						endTriggered = true;

						cssRule[prefix] = "none";

						element.off(end);
						element.css(cssRule);
						setTimeout(function(){ callback.call(element); });
					});


					//desktop safari fallback if we are in another tab to trigger the end event
					setTimeout(function(){
						if(!endTriggered && !avia_is_mobile && $('html').is('.avia-safari') ) {
							element.trigger(end);
							$.avia_utilities.log('Safari Fallback '+end+' trigger');
						}
					}, speed + 100);

					setTimeout(function(){ element.css(cssRule);},10);
					setTimeout(function(){ element.css(prop);	},20);
				}
				else
				{
					setTimeout(function(){ callback.call(element); });
				}

			});
		}
		else // if css animation is not available use default JS animation
		{
			this.animate(prop, speed, easing, callback);
		}

		return this;
	};

})( jQuery );



// -------------------------------------------------------------------------------------------
// keyboard controls
// -------------------------------------------------------------------------------------------

(function($)
{
	"use strict";

	/************************************************************************
	keyboard arrow nav
	*************************************************************************/
	$.fn.avia_keyboard_controls = function(options_passed)
	{
		var defaults	=
		{
			37: '.prev-slide',	// prev
			39: '.next-slide'	// next
		},

		methods		= {

			mousebind: function(slider)
			{
				slider.on('mouseenter', function(){
					slider.mouseover	= true;  })
				.on('mouseleave', function(){
					slider.mouseover	= false; }
				);
			},

			keybind: function(slider)
			{
				$(document).on('keydown', function(e)
				{
					if(slider.mouseover && typeof slider.options[e.keyCode] !== 'undefined')
					{
						var item;

						if(typeof slider.options[e.keyCode] === 'string')
						{
							item = slider.find(slider.options[e.keyCode]);
						}
						else
						{
							item = slider.options[e.keyCode];
						}

						if(item.length)
						{
							item.trigger('click', ['keypress']);
							return false;
						}
					}
				});
			}
		};


		return this.each(function()
		{
			var slider			= $(this);
			slider.options		= $.extend({}, defaults, options_passed);
			slider.mouseover	= false;

			methods.mousebind(slider);
			methods.keybind(slider);

		});
	};


	/************************************************************************
	swipe nav
	*************************************************************************/
	$.fn.avia_swipe_trigger = function( passed_options )
	{
		var win = $(window),
			isMobile = $.avia_utilities.isMobile,
			isTouchDevice = $.avia_utilities.isTouchDevice,
			defaults =
			{
				prev: '.prev-slide',
				next: '.next-slide',
				event: {
					prev: 'click',
					next: 'click'
				}
			},

			methods =
			{
				activate_touch_control: function(slider)
				{
					var i,
						differenceX,
						differenceY;

					slider.touchPos = {};
					slider.hasMoved = false;

					slider.on( 'touchstart', function(event)
					{
						slider.touchPos.X = event.originalEvent.touches[0].clientX;
						slider.touchPos.Y = event.originalEvent.touches[0].clientY;
					});

					slider.on( 'touchend', function(event)
					{
						slider.touchPos = {};

						if( slider.hasMoved )
						{
							event.preventDefault();
						}

						slider.hasMoved = false;
					});

					slider.on( 'touchmove', function(event)
					{
						if( ! slider.touchPos.X )
						{
							slider.touchPos.X = event.originalEvent.touches[0].clientX;
							slider.touchPos.Y = event.originalEvent.touches[0].clientY;
						}
						else
						{
							differenceX = event.originalEvent.touches[0].clientX - slider.touchPos.X;
							differenceY = event.originalEvent.touches[0].clientY - slider.touchPos.Y;

							//check if user is scrolling the window or moving the slider
							if( Math.abs( differenceX ) > Math.abs( differenceY ) )
							{
								event.preventDefault();

								if( slider.touchPos !== event.originalEvent.touches[0].clientX )
								{
									if( Math.abs(differenceX) > 50 )
									{
										i = differenceX > 0 ? 'prev' : 'next';

										if( typeof slider.options[i] === 'string' )
										{
											slider.find( slider.options[i] ).trigger( slider.options.event[i], ['swipe'] );
										}
										else
										{
											slider.options[i].trigger( slider.options.event[i], ['swipe'] );
										}

										slider.hasMoved = true;
										slider.touchPos = {};
										return false;
									}
								}
							}
						}
					});

				}
			};

		return this.each( function()
		{
			if( isMobile || isTouchDevice )
			{
				var slider = $(this);
				slider.options = $.extend( {}, defaults, passed_options );
				methods.activate_touch_control( slider );
			}
		});
	};

}(jQuery));

/**
 * jQuery 3.x:  JQMIGRATE: easing function “jQuery.easing.swing” should use only first argument
 * https://stackoverflow.com/questions/39355019/jqmigrate-easing-function-jquery-easing-swing-should-use-only-first-argument
 * https://github.com/gdsmith/jquery.easing/blob/master/jquery.easing.js
 *
 * @since 4.8.4
 * @param {jQuery} $
 */
(function($)
{
	// Preserve the original jQuery "swing" easing as "jswing"
	if (typeof $.easing !== 'undefined') {
		$.easing['jswing'] = $.easing['swing'];
	}

	var pow = Math.pow,
		sqrt = Math.sqrt,
		sin = Math.sin,
		cos = Math.cos,
		PI = Math.PI,
		c1 = 1.70158,
		c2 = c1 * 1.525,
		c3 = c1 + 1,
		c4 = ( 2 * PI ) / 3,
		c5 = ( 2 * PI ) / 4.5;

	// x is the fraction of animation progress, in the range 0..1
	function bounceOut(x) {
		var n1 = 7.5625,
			d1 = 2.75;
		if ( x < 1/d1 ) {
			return n1*x*x;
		} else if ( x < 2/d1 ) {
			return n1*(x-=(1.5/d1))*x + .75;
		} else if ( x < 2.5/d1 ) {
			return n1*(x-=(2.25/d1))*x + .9375;
		} else {
			return n1*(x-=(2.625/d1))*x + .984375;
		}
	}

	$.extend( $.easing,
	{
		def: 'easeOutQuad',
		swing: function (x) {
			return $.easing[$.easing.def](x);
		},
		easeInQuad: function (x) {
			return x * x;
		},
		easeOutQuad: function (x) {
			return 1 - ( 1 - x ) * ( 1 - x );
		},
		easeInOutQuad: function (x) {
			return x < 0.5 ?
				2 * x * x :
				1 - pow( -2 * x + 2, 2 ) / 2;
		},
		easeInCubic: function (x) {
			return x * x * x;
		},
		easeOutCubic: function (x) {
			return 1 - pow( 1 - x, 3 );
		},
		easeInOutCubic: function (x) {
			return x < 0.5 ?
				4 * x * x * x :
				1 - pow( -2 * x + 2, 3 ) / 2;
		},
		easeInQuart: function (x) {
			return x * x * x * x;
		},
		easeOutQuart: function (x) {
			return 1 - pow( 1 - x, 4 );
		},
		easeInOutQuart: function (x) {
			return x < 0.5 ?
				8 * x * x * x * x :
				1 - pow( -2 * x + 2, 4 ) / 2;
		},
		easeInQuint: function (x) {
			return x * x * x * x * x;
		},
		easeOutQuint: function (x) {
			return 1 - pow( 1 - x, 5 );
		},
		easeInOutQuint: function (x) {
			return x < 0.5 ?
				16 * x * x * x * x * x :
				1 - pow( -2 * x + 2, 5 ) / 2;
		},
		easeInSine: function (x) {
			return 1 - cos( x * PI/2 );
		},
		easeOutSine: function (x) {
			return sin( x * PI/2 );
		},
		easeInOutSine: function (x) {
			return -( cos( PI * x ) - 1 ) / 2;
		},
		easeInExpo: function (x) {
			return x === 0 ? 0 : pow( 2, 10 * x - 10 );
		},
		easeOutExpo: function (x) {
			return x === 1 ? 1 : 1 - pow( 2, -10 * x );
		},
		easeInOutExpo: function (x) {
			return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ?
				pow( 2, 20 * x - 10 ) / 2 :
				( 2 - pow( 2, -20 * x + 10 ) ) / 2;
		},
		easeInCirc: function (x) {
			return 1 - sqrt( 1 - pow( x, 2 ) );
		},
		easeOutCirc: function (x) {
			return sqrt( 1 - pow( x - 1, 2 ) );
		},
		easeInOutCirc: function (x) {
			return x < 0.5 ?
				( 1 - sqrt( 1 - pow( 2 * x, 2 ) ) ) / 2 :
				( sqrt( 1 - pow( -2 * x + 2, 2 ) ) + 1 ) / 2;
		},
		easeInElastic: function (x) {
			return x === 0 ? 0 : x === 1 ? 1 :
				-pow( 2, 10 * x - 10 ) * sin( ( x * 10 - 10.75 ) * c4 );
		},
		easeOutElastic: function (x) {
			return x === 0 ? 0 : x === 1 ? 1 :
				pow( 2, -10 * x ) * sin( ( x * 10 - 0.75 ) * c4 ) + 1;
		},
		easeInOutElastic: function (x) {
			return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ?
				-( pow( 2, 20 * x - 10 ) * sin( ( 20 * x - 11.125 ) * c5 )) / 2 :
				pow( 2, -20 * x + 10 ) * sin( ( 20 * x - 11.125 ) * c5 ) / 2 + 1;
		},
		easeInBack: function (x) {
			return c3 * x * x * x - c1 * x * x;
		},
		easeOutBack: function (x) {
			return 1 + c3 * pow( x - 1, 3 ) + c1 * pow( x - 1, 2 );
		},
		easeInOutBack: function (x) {
			return x < 0.5 ?
				( pow( 2 * x, 2 ) * ( ( c2 + 1 ) * 2 * x - c2 ) ) / 2 :
				( pow( 2 * x - 2, 2 ) *( ( c2 + 1 ) * ( x * 2 - 2 ) + c2 ) + 2 ) / 2;
		},
		easeInBounce: function (x) {
			return 1 - bounceOut( 1 - x );
		},
		easeOutBounce: bounceOut,
		easeInOutBounce: function (x) {
			return x < 0.5 ?
				( 1 - bounceOut( 1 - 2 * x ) ) / 2 :
				( 1 + bounceOut( 2 * x - 1 ) ) / 2;
		}
	});

}(jQuery));
// source --> https://axhotelsmalta.com/wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/iconlist/iconlist.js?ver=6.8.5 
(function($)
{
	"use strict";

	// -------------------------------------------------------------------------------------------
	// Iconlist shortcode javascript
	// -------------------------------------------------------------------------------------------

	$.fn.avia_sc_iconlist = function(options)
	{
		return this.each( function()
		{
			var iconlist = $(this),
				elements = iconlist.find('>li');


			//trigger displaying of thumbnails
			iconlist.on('avia_start_animation', function()
			{
				elements.each( function(i)
				{
					var element = $(this);
					setTimeout( function(){ element.addClass('avia_start_animation'); }, ( i * 350 ) );
				});
			});
		});
	};


}(jQuery));
// source --> https://axhotelsmalta.com/wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/gallery/gallery.js?ver=6.8.5 
(function($)
{
	'use strict';

	// -------------------------------------------------------------------------------------------
	// Gallery shortcode javascript
	// -------------------------------------------------------------------------------------------

	$.fn.avia_sc_gallery = function(options)
	{
		return this.each(function()
		{
			var gallery = $(this),
				images = gallery.find('img'),
				big_prev = gallery.find('.avia-gallery-big');


			//trigger displaying of thumbnails
			gallery.on( 'avia_start_animation', function()
			{
				images.each(function(i)
				{
					var image = $(this);
					setTimeout( function(){ image.addClass('avia_start_animation') }, (i * 110) );
				});
			});

			if( gallery.hasClass('deactivate_avia_lazyload') )
			{
				gallery.trigger('avia_start_animation');
			}

			//trigger thumbnail hover and big prev image change
			if( big_prev.length )
			{
				gallery.on( 'mouseenter','.avia-gallery-thumb a', function()
				{
					var _self = $(this),
						newImgSrc = _self.attr('data-prev-img'),
						oldImg = big_prev.find('img'),
						oldImgSrc = oldImg.attr('src');

					if( newImgSrc == oldImgSrc )
					{
						return;
					}

					big_prev.height( big_prev.height() );

					big_prev.attr('data-onclick', _self.attr('data-onclick'));
					big_prev.attr('href', _self.attr('href'));
					big_prev.attr('title', _self.attr('title'));

					//	copy lightbox attributes
					if( 'undefined' == typeof _self.data('srcset') )
					{
						big_prev.removeAttr('data-srcset');
						big_prev.removeData('srcset');
					}
					else
					{
						big_prev.data('srcset', _self.data('srcset'));
						big_prev.attr('data-srcset', _self.data('srcset'));
					}

					if( 'undefined' == typeof _self.data('sizes') )
					{
						big_prev.removeAttr('data-sizes');
						big_prev.removeData('sizes');
					}
					else
					{
						big_prev.data('sizes', _self.data('sizes'));
						big_prev.attr('data-sizes', _self.data('sizes'));
					}

					//	since 4.8.8.2 we have a hidden img to support scrset and sizes - fallback to old version if missing
					var newPrev = _self.find( '.big-prev-fake img' ).clone( true );
					if( newPrev.length == 0 )
					{
						var next_img = new Image();
						next_img.src = newImgSrc;
						newPrev = $(next_img);
					}

					if( big_prev.hasClass( 'avia-gallery-big-no-crop-thumb' ) )
					{
						newPrev.css( {'height':big_prev.height(),'width':'auto'} );
					}

					big_prev.stop().animate( {opacity:0}, function()
					{
						newPrev.insertAfter( oldImg );
						oldImg.remove();
						big_prev.animate( {opacity:1} );
					});

				});

				big_prev.on( 'click', function()
				{
					var imagelink = gallery.find('.avia-gallery-thumb a').eq( this.getAttribute('data-onclick') - 1 );

					if( imagelink && ! imagelink.hasClass('aviaopeninbrowser') )
					{
						imagelink.trigger('click');
					}
					else if( imagelink )
					{
						var imgurl = imagelink.attr('href');
						var secure = imagelink.hasClass( 'custom_link' ) ? 'noopener,noreferrer' : '';

						if( imagelink.hasClass('aviablank') && imgurl != '' )
						{
							window.open( imgurl, '_blank', secure );
						}
						else if( imgurl != '' )
						{
							window.open( imgurl, '_self', secure );
						}
					}
					return false;
				});


				$(window).on( 'debouncedresize', function()
				{
				  	big_prev.height('auto');
				});
			}
		});
	};

}(jQuery));
// source --> https://axhotelsmalta.com/wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/numbers/numbers.js?ver=6.8.5 
// -------------------------------------------------------------------------------------------
// Big Number animation shortcode javascript
// -------------------------------------------------------------------------------------------

(function($)
{
	// options.simple_up = dont prepend leading zeros, options.instant_start = trigger counting instantly, options.start_timer = delay when to start counting
	$.fn.avia_sc_animated_number = function(options)
	{
		if(!this.length) return;
		if(this.is('.avia_sc_animated_number_active')) return;

		this.addClass('avia_sc_animated_number_active');

		var simple_upcount 	= (options && options.simple_up) ? true : false,
			start_timer 	= (options && options.start_timer) ? options.start_timer : 300,

			format_number = function( number, number_format, final_number )
			{
				var prepend = '',
					addZeros = final_number.toString().length - number.toString().length;

				//if the number has less digits than the final number some zeros where omitted. add them to the front
				for(var i = addZeros; i > 0; i--)
				{
					prepend += '0';
				}

				number = ( simple_upcount ) ? number.toString() : prepend + number.toString();

				if( '' == number_format )
				{
					return number;
				}

				return number.split( /(?=(?:...)*$)/ ).join( number_format );
			},

			start_count = function(element, countTo, increment, current, fakeCountTo, number_format)
			{
				//calculate the new number
				var newCount = current + increment,
					final = '';

				//if the number is bigger than our final number set the number and finish
				if(newCount >= fakeCountTo)
				{
					final = format_number( countTo, number_format, countTo );
					element.text( final ); //exit
				}
				else
				{
					final = format_number( newCount, number_format, countTo );
					element.text(final);

					window.requestAnimationFrame(function(){ start_count(element, countTo, increment, newCount, fakeCountTo, number_format); });
				}
			};

		return this.each(function()
		{
			var number_container = $(this),
				elements = number_container.find('.__av-single-number'),
				countTimer = number_container.data('timer') || 3000;

			//prepare elements
			elements.each(function(i)
			{
				var element = $(this),
					text = element.text();

				if(window.addEventListener) element.text( text.replace(/./g, "0")); /*https://github.com/AviaThemes/wp-themes/issues/812*/
			});

			//trigger number animation
			number_container.addClass('number_prepared').on('avia_start_animation', function()
			{
				if(number_container.is('.avia_animation_done')) return;
				number_container.addClass('avia_animation_done');

				elements.each(function(i)
				{
					var element = $(this),
						countTo = element.data('number'),
						fakeCountTo = countTo,
						current = parseInt(element.text(),10),
						zeroOnly = /^0+$/.test(countTo),
						increment = 0,
						number_format = '';

					if( 'undefined' != typeof element.data('start_from') )
					{
						current = element.data('start_from');
					}

					if( 'undefined' != typeof element.data('number_format') )
					{
						number_format = element.data('number_format');
					}

					//fallback for decimals like 00 or 000
					if( zeroOnly && countTo !== 0 )
					{
						fakeCountTo = countTo.replace( /0/g, '9' );
					}

					increment = Math.round( fakeCountTo * 32 / countTimer);
					if(increment == 0 || increment % 10 == 0) increment += 1;

					setTimeout( function(){ start_count(element, countTo, increment, current, fakeCountTo, number_format);}, start_timer);
				});
			});

			if(options && options.instant_start == true)
			{
				number_container.trigger('avia_start_animation');
			}


		});
	};
})(jQuery);
// source --> https://axhotelsmalta.com/wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/slideshow/slideshow.js?ver=6.8.5 
/* ======================================================================================================================================================
Avia Slideshow
======================================================================================================================================================
*/

(function($)
{
    "use strict";

	$.AviaSlider = function( options, slider )
	{
		var self = this;

		this.$win = $( window );
		this.$slider = $( slider );

		this.isMobile = $.avia_utilities.isMobile;
		this.isTouchDevice = $.avia_utilities.isTouchDevice,

		this._prepareSlides(options);

		//default preload images then init slideshow
	    $.avia_utilities.preload({
			container: this.$slider,
			single_callback: function(){ self._init( options ); }
		});
	};

	$.AviaSlider.defaults =
	{
		//interval between autorotation switches
		interval: 5,

		//start autorotation active or not
		autoplay: false,

		//stop on last slide - shortcut for stopinfiniteloop - kept for backwards comp. With 5.0 added extended support also for manual rotation
		autoplay_stopper: false,

		// @since 5.0		'endless' | 'once'
		loop_autoplay: 'once',

		// @since 5.0		'manual-endless' | 'manual-once'
		loop_manual: 'manual-endless',

		//set if the loop will stop at the last/first slide or if the slides will loop infinite
		//set to false for infinite loop, "last" to stop at the last slide or "first" to stop at the first slide
		stopinfiniteloop: false,

		//	true to ignore all user navigation
		noNavigation: false,

		//fade or slide animation
		animation: 'slide',

		//transition speed when switching slide
		transitionSpeed: 900,

		//easing method for the transition
		easing: 'easeInOutQuart',

		//slide wrapper
		wrapElement: '>ul',

		//slide element
		slideElement: '>li',

		//pause if mouse cursor is above item
		hoverpause: false,

		//attach images as background
		bg_slider: false,

		//delay of milliseconds to wait before showing the next slide
		show_slide_delay: 0,

		//if slider animation is set to "fade" the fullfade property sets the crossfade behaviour
		fullfade: false,

		//set to true to keep padding (e.g. for featured image slideshow, carousel slideshow
		keep_padding: false,

        //enable carousel mode with multiple visible slides
		carousel: 'no',

		// how many slides are displayed at once in the carousel
        carouselSlidesToShow: 3,

		// TODO: how many slides are scrolled in the carousel
		carouselSlidesToScroll: 1,

		// responsive carousel
		carouselResponsive: new Array()

	};

  	$.AviaSlider.prototype =
    {
    	_init: function( options )
    	{
            // set slider options
			this.options = this._setOptions( options );

			//slidewrap
			this.$sliderUl = this.$slider.find(this.options.wrapElement);

			// slide elements
			this.$slides = this.$sliderUl.find(this.options.slideElement);

			//	slide navigaton arrows wrap
			this.slide_arrows = this.$slider.find( '.avia-slideshow-arrows' );

			// goto dots
			this.gotoButtons = this.$slider.find( '.avia-slideshow-dots a' );

			//perma caption
			this.permaCaption = this.$slider.find( '>.av-slideshow-caption' );

			// slide count
			this.itemsCount = this.$slides.length;

			// current image index
			this.current = 0;

			// current carousel index
			this.currentCarousel = 0;

			// carousel slide width
			this.slideWidthCarousel = '240';

			//loop count
			this.loopCount = 0;

			// control if the slicebox is animating
			this.isAnimating = false;

			// css browser prefix like -webkit-, -moz-
			this.browserPrefix = $.avia_utilities.supports('transition');

			// css3 animation?
			this.cssActive = this.browserPrefix !== false ? true : false;

			// css3D animation?
			this.css3DActive = document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;

			//if we have a bg slider no images were preloaded yet. in that case start preloading and attaching images
			if( this.options.bg_slider == true )
			{
				//create array that holds all image urls to preload
				this.imageUrls = [];

				//create a preloader icon to indicate loading
				this.loader = $.avia_utilities.loading( this.$slider );

				//preload the images ony by one
				this._bgPreloadImages();

			}
			else //if it was a default slider all images are already loaded and we can start showing the slider
			{
				//kickoff the slider: bind functions, show first slide, if active start the autorotation timer
				this._kickOff();
			}

			if( this.options.carousel === 'yes' )
			{
				this.options.animation = 'carouselslide';
			}
    	},

    	//set the slider options by first merging the default options and the passed options, then checking the slider element if any data attributes overwrite the option set
    	_setOptions: function( options )
		{
			var jsonOptions = this.$slider.data( 'slideshow-options' );

			//	since 5.0 - render options via json to clean up html - $.data returns parsed object
			if( 'object' == typeof jsonOptions )
			{
				var newOptions = $.extend( {}, $.AviaSlider.defaults, options, jsonOptions );

				if( 'undefined' != typeof newOptions.transition_speed )
				{
					newOptions.transitionSpeed = newOptions.transition_speed;
				}

				return newOptions;
			}

			var newOptions = $.extend( true, {}, $.AviaSlider.defaults, options ),
				htmlData = this.$slider.data();

			//overwrite passed option set with any data properties on the html element
			for( var i in htmlData )
			{
				//	data attribute is transformed to lower case, but js is case sensitive - transform key
				var key = ( 'transition_speed' != i ) ? i :'transitionSpeed';

				if( typeof htmlData[ i ] === "string" || typeof htmlData[ i ] === "number" || typeof htmlData[ i ] === "boolean" )
				{
					newOptions[ key ] = htmlData[ i ];
				}

				if( 'undefined' != typeof newOptions.autoplay_stopper && newOptions.autoplay_stopper == 1 )
				{
					newOptions.autoplay_stopper = true;
				}
			}

			return newOptions;
		},

		_prepareSlides: function(options)
		{
			//if its a mobile device find all video slides that need to be altered
			if( this.isMobile )
			{
				var alter = this.$slider.find('.av-mobile-fallback-image');
				alter.each(function()
				{
					var current  = $(this).removeClass('av-video-slide').data({'avia_video_events': true, 'video-ratio':0}),
						fallback = current.data('mobile-img'),
						fallback_link = current.data('fallback-link'),
						appendTo = current.find('.avia-slide-wrap');

					current.find('.av-click-overlay, .mejs-mediaelement, .mejs-container').remove();

					if(!fallback)
					{
						$('<p class="av-fallback-message"><span>Please set a mobile device fallback image for this video in your wordpress backend</span></p>').appendTo(appendTo);
					}

					if(options && options.bg_slider)
					{
						current.data('img-url', fallback);

						//if we got a fallback link we need to either replace the default link on mobile devices, or if there is no default link change the wrapping <div> to an <a>
						if(fallback_link != "")
						{
							if(appendTo.is('a'))
							{
								appendTo.attr('href', fallback_link);
							}
							else
							{
								appendTo.find('a').remove();
								appendTo.replaceWith(function(){
									var cur_slide = $(this);
								    return $("<a>").attr({'data-rel': cur_slide.data('rel'), 'class': cur_slide.attr('class'), 'href': fallback_link} ).append( $(this).contents() );
								});

								appendTo = current.find('.avia-slide-wrap');
							}

							if($.fn.avia_activate_lightbox)
							{
								current.parents('#main').avia_activate_lightbox();
							}
						}
					}
					else
					{
						var image = '<img src="'+fallback+'" alt="" title="" />';
						var lightbox = false;

						if( 'string' == typeof fallback_link && fallback_link.trim() != '' )
						{
							if( appendTo.is('a') )
							{
								appendTo.attr('href', fallback_link);
							}
							else
							{
								var rel = fallback_link.match(/\.(jpg|jpeg|gif|png)$/i) != null ? ' rel="lightbox" ' : '';
								image = '<a href="' + fallback_link.trim() + '"' + rel + '>' + image + '</a>';
							}
							lightbox = true;
						}

						current.find('.avia-slide-wrap').append(image);

						if( lightbox && $.fn.avia_activate_lightbox)
						{
							current.parents('#main').avia_activate_lightbox();
						}
					}

				});
			}
			
			if ($('html').is('.pointer-device-fine'))
            {   
                if( $('body').is('.avia-slider-video-controls-fix-support'))
                {
                    avia_slider_video_controls_fix(this);
                }
            }
		},

		//start preloading the background images
		_bgPreloadImages: function(callback)
    	{
    		this._getImageURLS();

    		this._preloadSingle(0, function()
    		{
    			this._kickOff();
				this._preloadNext(1);
    		});
    	},

    	//if we are using a background image slider, fetch the images from a data attribute and preload them one by one
    	_getImageURLS: function()
    	{
    		var _self = this;

    		//collect url strings of the images to preload
			this.$slides.each( function(i)
			{
				_self.imageUrls[i] = [];
				_self.imageUrls[i]['url'] = $(this).data("img-url");

				//if no image is passed we can set the slide to loaded
				if(typeof _self.imageUrls[i]['url'] == 'string')
				{
					_self.imageUrls[i]['status'] = false;
				}
				else
				{
					_self.imageUrls[i]['status'] = true;
				}
			});
    	},

    	_preloadSingle: function(key, callback)
		{
			var _self = this,
				objImage = new Image();

			if( typeof _self.imageUrls[key]['url'] == 'string' )
			{
				$(objImage).on('load error', function()
				{
					_self.imageUrls[key]['status'] = true;
					_self.$slides.eq(key).css('background-image','url(' + _self.imageUrls[key]['url'] + ')');

					if( typeof callback == 'function' )
					{
						callback.apply( _self, [objImage, key] );
					}
				});

				if(_self.imageUrls[key]['url'] != "")
				{
					objImage.src = _self.imageUrls[key]['url'];
				}
				else
				{
					$(objImage).trigger('error');
				}
			}
			else
			{
				if( typeof callback == 'function' )
				{
					callback.apply( _self, [objImage, key] );
				}
			}
		},

		_preloadNext: function(key)
		{
			if(typeof this.imageUrls[key] != "undefined")
    		{
				this._preloadSingle(key, function()
	    		{
					this._preloadNext(key + 1);
	    		});
    		}
		},


    	//bind click events of slide controlls to the public functions
    	_bindEvents: function()
    	{
    		var self = this,
    			win  = $( window );

    		this.$slider.on( 'click', '.next-slide', this.next.bind( this ) );
    		this.$slider.on( 'click', '.prev-slide', this.previous.bind( this ) );
    		this.$slider.on( 'click', '.goto-slide', this.go2.bind( this ) );

    		if( this.options.hoverpause )
    		{
    			this.$slider.on( 'mouseenter', this.pause.bind( this ) );
    			this.$slider.on( 'mouseleave', this.resume.bind( this ) );
    		}

			//	activate permanent caption link of image
			if( this.permaCaption.length )
			{
				this.permaCaption.on( 'click', this._routePermaCaptionClick );
				this.$slider.on( 'avia_slider_first_slide avia_slider_last_slide avia_slider_navigate_slide', this._setPermaCaptionPointer.bind( this ) );
			}

			if( this.options.stopinfiniteloop && this.options.autoplay )
			{
				if( this.options.stopinfiniteloop == 'last' )
				{
					this.$slider.on( 'avia_slider_last_slide', this._stopSlideshow.bind( this ) );
				}
				else if( this.options.stopinfiniteloop == 'first' )
				{
					this.$slider.on( 'avia_slider_first_slide', this._stopSlideshow.bind( this ) );
				}
			}

			if( this.options.carousel === 'yes' )
			{
				// recalculate carousel dimensions on viewport size change
				// use on desktop only, debouncedresize fires on scroll on mobile
				if( ! this.isMobile )
				{
					win.on( 'debouncedresize', this._buildCarousel.bind( this ) );
				}
			}
			else
			{
                win.on( 'debouncedresize.aviaSlider', this._setSize.bind( this ) );
			}

			if( ! this.options.noNavigation )
			{
				//if its a desktop browser add arrow navigation, otherwise add touch nav (also for touch devices)
				if( ! this.isMobile )
				{
					this.$slider.avia_keyboard_controls();
				}

				if( this.isMobile || this.isTouchDevice )
				{
					this.$slider.avia_swipe_trigger();
				}
			}

			self._attach_video_events();
    	},

    	//kickoff the slider by binding all functions to slides and buttons, show the first slide and start autoplay
    	_kickOff: function()
    	{
    		var self = this,
    			first_slide = self.$slides.eq(0),
    			video = first_slide.data('video-ratio');

    		// bind events to to the controll buttons
			self._bindEvents();
			self._set_slide_arrows_visibility();

    		this.$slider.removeClass('av-default-height-applied');

    		//show the first slide. if its a video set the correct size, otherwise make sure to remove the % padding
    		if( video )
    		{
    			self._setSize( true );
    		}
    		else
    		{
	    		if( this.options.keep_padding != true )
	    		{
    				self.$sliderUl.css('padding',0);
					self.$win.trigger('av-height-change');
				}
    		}

    		self._setCenter();

    		if( this.options.carousel === 'no' )
			{
				first_slide.addClass( 'next-active-slide' );
                first_slide.css( {visibility:'visible', opacity:0} ).avia_animate( {opacity:1}, function()
                {
                    var current = $(this).addClass( 'active-slide' );

                    if( self.permaCaption.length )
                    {
                        self.permaCaption.addClass( 'active-slide' );
                    }
                });
			}

			self.$slider.trigger( 'avia_slider_first_slide' );


    		// start autoplay if active
			if( self.options.autoplay )
			{
				self._startSlideshow();
			}

			// prepare carousel if active
			if( self.options.carousel === 'yes' )
			{
				self._buildCarousel();
			}

			self.$slider.trigger( '_kickOff' );
    	},

		_set_slide_arrows_visibility: function()
		{
			//	special use case - hardcoded as only used in timeline
			if( this.options.carousel == 'yes' )
			{
				if( 0 == this.currentCarousel )
				{
					this.slide_arrows.removeClass( 'av-visible-prev' );
					this.slide_arrows.addClass( 'av-visible-next' );
				}
				else if( this.currentCarousel + this.options.carouselSlidesToShow >= this.itemsCount )
				{
					this.slide_arrows.addClass( 'av-visible-prev' );
					this.slide_arrows.removeClass( 'av-visible-next' );
				}
				else
				{
					this.slide_arrows.addClass( 'av-visible-prev' );
					this.slide_arrows.addClass( 'av-visible-next' );
				}

				return;
			}

			if( 'endless' == this.options.loop_autoplay || 'manual-endless' == this.options.loop_manual )
			{
				this.slide_arrows.addClass( 'av-visible-prev' );
				this.slide_arrows.addClass( 'av-visible-next' );
			}
			else if( 0 == this.current )
			{
				this.slide_arrows.removeClass( 'av-visible-prev' );
				this.slide_arrows.addClass( 'av-visible-next' );
			}
			else if( this.current + 1 >= this.itemsCount )
			{
				this.slide_arrows.addClass( 'av-visible-prev' );
				this.slide_arrows.removeClass( 'av-visible-next' );
			}
			else
			{
				this.slide_arrows.addClass( 'av-visible-prev' );
				this.slide_arrows.addClass( 'av-visible-next' );
			}
		},

		_buildCarousel: function()
		{
            var self = this,
    		stageWidth = this.$slider.outerWidth(),
    		slidesWidth = parseInt(stageWidth / this.options.carouselSlidesToShow),
            windowWidth = window.innerWidth || $(window).width();

			// responsive carousel
			if( this.options.carouselResponsive &&
                this.options.carouselResponsive.length &&
                this.options.carouselResponsive !== null )
			{

				for( var breakpoint in this.options.carouselResponsive )
				{
					var breakpointValue = this.options.carouselResponsive[breakpoint]['breakpoint'];
					var newSlidesToShow = this.options.carouselResponsive[breakpoint]['settings']['carouselSlidesToShow'];

					if( breakpointValue >= windowWidth )
					{
                        slidesWidth = parseInt(stageWidth / newSlidesToShow);
                        this.options.carouselSlidesToShow = newSlidesToShow;
					}
				}
			}

            // set width and height for each slide
            this.slideWidthCarousel = slidesWidth;

            this.$slides.each(function(i)
			{
                $(this).width(slidesWidth);
            });

            // set width for the UL
			var slideTrackWidth = slidesWidth * this.itemsCount;
			this.$sliderUl.width(slideTrackWidth).css( 'transform', 'translateX(0px)' );

			// hide nav if not needed
			if( this.options.carouselSlidesToShow >= this.itemsCount )
			{
				this.$slider.find('.av-timeline-nav').hide();
			}
		},

    	//calculate which slide should be displayed next and call the executing transition function
    	_navigate: function( dir, pos )
		{
			if( this.isAnimating || this.itemsCount < 2 || ! this.$slider.is( ':visible' ) )
			{
				return false;
			}

			this.isAnimating = true;

			// current item's index
			this.prev = this.current;

			// if position is passed
			if( pos !== undefined )
			{
				this.current = pos;
				dir = this.current > this.prev ? 'next' : 'prev';
			}

            // if not check the boundaries
			else if( dir === 'next' )
			{
				this.current = this.current < this.itemsCount - 1 ? this.current + 1 : 0;

				if( this.current === 0 && this.options.autoplay_stopper && this.options.autoplay )
				{
					this.isAnimating = false;
					this.current = this.prev;
					this._stopSlideshow();
					return false;
				}

				//	check if we can rotate
				if( 0 === this.current )
				{
					if( 'endless' != this.options.loop_autoplay && 'manual-endless' != this.options.loop_manual )
					{
						this.isAnimating = false;
						this.current = this.prev;
						return false;
					}
				}
			}
			else if( dir === 'prev' )
			{
				this.current = this.current > 0 ? this.current - 1 : this.itemsCount - 1;

				//	check if we can rotate
				if( this.itemsCount - 1 === this.current )
				{
					if( 'endless' != this.options.loop_autoplay && 'manual-endless' != this.options.loop_manual )
					{
						this.isAnimating = false;
						this.current = this.prev;
						return false;
					}
				}
			}

			//set goto button
			this.gotoButtons.removeClass( 'active' ).eq( this.current ).addClass( 'active' );
			this._set_slide_arrows_visibility();

			//set slideshow size if carousel not in use
            if( this.options.carousel === 'no' )
			{
                this._setSize();
			}

            //if we are using a background slider make sure that the image is loaded. if not preload it, then show the slide
			if( this.options.bg_slider == true )
			{
				if( this.imageUrls[this.current]['status'] == true )
				{
					this['_' + this.options.animation].call(this, dir);
				}
				else
				{
					this.loader.show();
					this._preloadSingle(this.current, function()
    				{
    					this['_' + this.options.animation].call( this, dir );
    					this.loader.hide();
    				});
				}
			}
			else //no background loader -> images are already loaded
			{
				//call the executing function. for example _slide, or _fade. since the function call is absed on a var we can easily extend the slider with new animations
				this['_' + this.options.animation].call( this, dir );
			}

			if( this.current == 0 )
			{
				this.loopCount++;
				this.$slider.trigger( 'avia_slider_first_slide' );
			}
			else if( this.current == this.itemsCount - 1 )
			{
				this.$slider.trigger( 'avia_slider_last_slide' );
			}
			else
			{
				this.$slider.trigger( 'avia_slider_navigate_slide' );
			}
		},

		//if the next slide has a different height than the current change the slideshow height
		_setSize: function(instant)
		{
			//if images are attached as bg images the slider has a fixed height
			if( this.options.bg_slider == true )
			{
				return;
			}

			var self    		= this,
				slide 			= this.$slides.eq(this.current),
				img 			= slide.find('img'),
				current			= Math.floor(this.$sliderUl.height()),
				ratio			= slide.data('video-ratio'),
				setTo   		= ratio ? this.$sliderUl.width() / ratio : Math.floor(slide.height()),
				video_height 	= slide.data('video-height'), //forced video height %. needs to be set only once
				video_toppos 	= slide.data('video-toppos'); //forced video top position

			this.$sliderUl.height(current).css('padding',0); //make sure to set the slideheight to an actual value

			if(setTo != current)
			{
				if(instant == true)
				{
					this.$sliderUl.css({height:setTo});
					this.$win.trigger('av-height-change');
				}
				else
				{
					this.$sliderUl.avia_animate({height:setTo}, function()
					{
						self.$win.trigger('av-height-change');
					});
				}
			}

			this._setCenter();

			if(video_height && video_height!= "set")
			{
				slide.find('iframe, embed, video, object, .av_youtube_frame').css({height: video_height + '%', top: video_toppos + '%'});
				slide.data('video-height','set');
			}
		},

		_setCenter: function()
		{
			//if the image has a min width and is larger than the slider center it
			//positon img based on caption. right caption->left pos, left caption -> right pos
			var slide 		= this.$slides.eq(this.current),
				img 		= slide.find('img'),
				min_width 	= parseInt(img.css('min-width'),10),
				slide_width	= slide.width(),
				caption		= slide.find('.av-slideshow-caption'),
				css_left 	= ((slide_width - min_width) / 2);

			if(caption.length)
			{
				if(caption.is('.caption_left'))
				{
					css_left = ((slide_width - min_width) / 1.5);
				}
				else if(caption.is('.caption_right'))
				{
					css_left = ((slide_width - min_width) / 2.5);
				}
			}

			if(slide_width >= min_width)
			{
				css_left = 0;
			}

			img.css({left:css_left});
		},

		_carouselmove : function(){

        //    var offset = (this.options.carouselSlidesToScroll*this.slideWidthCarousel)*this.currentCarousel;
			var offset = this.slideWidthCarousel * this.currentCarousel;
            this.$sliderUl.css('transform', 'translateX(-' + offset + 'px)');
		},

		_carouselslide: function(dir)
		{
			console.log( '_carouselslide:', dir, this.currentCarousel );

    		if( dir === 'next' )
			{
				if (this.options.carouselSlidesToShow + this.currentCarousel < this.itemsCount)
				{
                    this.currentCarousel++;
                    this._carouselmove();
				}
			}
			else if( dir === 'prev' )
			{
    			if( this.currentCarousel > 0 )
				{
                    this.currentCarousel--;
                    this._carouselmove();
				}
			}

			this._set_slide_arrows_visibility();

            this.isAnimating = false;
		},

		_slide: function(dir)
		{
			var dynamic			= false, //todo: pass by option if a slider is dynamic
				modifier		= dynamic == true ? 2 : 1,
				sliderWidth		= this.$slider.width(),
				direction		= dir === 'next' ? -1 : 1,
				property  		= this.browserPrefix + 'transform',
				reset			= {},
				transition = {},
				transition2 = {},
				trans_val 		= ( sliderWidth * direction * -1 ),
				trans_val2 		= ( sliderWidth * direction ) / modifier;

			//do a css3 animation
			if(this.cssActive)
			{
				property = this.browserPrefix + 'transform';

				//do a translate 3d transformation if available, since it uses hardware acceleration
				if(this.css3DActive)
				{
					reset[property]  = "translate3d(" + trans_val + "px, 0, 0)";
					transition[property]  = "translate3d(" + trans_val2 + "px, 0, 0)";
					transition2[property] = "translate3d(0,0,0)";
				}
				else //do a 2d transform. still faster than a position "left" change
				{
					reset[property]  = "translate(" + trans_val + "px,0)";
					transition[property]  = "translate(" + trans_val2 + "px,0)";
					transition2[property] = "translate(0,0)";
				}
			}
			else
			{
				reset.left = trans_val;
				transition.left = trans_val2;
				transition2.left = 0;
			}

			if(dynamic)
			{
				transition['z-index']  = "1";
				transition2['z-index']  = "2";
			}

			this._slide_animate(reset, transition, transition2);
		},

		_slide_up: function(dir)
		{
			var dynamic			= true, //todo: pass by option if a slider is dynamic
				modifier		= dynamic == true ? 2 : 1,
				sliderHeight	= this.$slider.height(),
				direction		= dir === 'next' ? -1 : 1,
				property  		= this.browserPrefix + 'transform',
				reset			= {},
				transition = {},
				transition2 = {},
				trans_val 		= ( sliderHeight * direction * -1),
				trans_val2 		= ( sliderHeight * direction) / modifier;

			//do a css3 animation
			if(this.cssActive)
			{
				property  = this.browserPrefix + 'transform';

				//do a translate 3d transformation if available, since it uses hardware acceleration
				if(this.css3DActive)
				{
					reset[property]  = "translate3d( 0," + trans_val + "px, 0)";
					transition[property]  = "translate3d( 0," + trans_val2 + "px, 0)";
					transition2[property] = "translate3d(0,0,0)";
				}
				else //do a 2d transform. still faster than a position "left" change
				{
					reset[property]  = "translate( 0," + trans_val + "px)";
					transition[property]  = "translate( 0," + trans_val2 + "px)";
					transition2[property] = "translate(0,0)";					}
			}
			else
			{
				reset.top = trans_val;
				transition.top = trans_val2;
				transition2.top = 0;
			}

			if(dynamic)
			{
				transition['z-index']  = "1";
				transition2['z-index']  = "2";
			}
			this._slide_animate(reset, transition, transition2);
		},


		//slide animation: do a slide transition by css3 transform if possible. if not simply do a position left transition
		_slide_animate: function( reset , transition , transition2 )
		{
			var self			= this,
				displaySlide 	= this.$slides.eq(this.current),
				hideSlide		= this.$slides.eq(this.prev);

			hideSlide.trigger('pause');
			if( ! displaySlide.data('disableAutoplay') )
			{
				if(displaySlide.hasClass('av-video-lazyload') && !displaySlide.hasClass('av-video-lazyload-complete'))
				{
					displaySlide.find('.av-click-to-play-overlay').trigger('click');
				}
				else
				{
					displaySlide.trigger('play');
				}
			}

			displaySlide.css({visibility:'visible', zIndex:4, opacity:1, left:0, top:0});
			displaySlide.css(reset);

			hideSlide.avia_animate(transition, this.options.transitionSpeed, this.options.easing);

			var after_slide = function()
			{
				self.isAnimating = false;
				displaySlide.addClass( 'active-slide' );
				hideSlide.css( {visibility:'hidden'} ).removeClass( 'active-slide next-active-slide' );
				self.$slider.trigger( 'avia-transition-done' );
			};

			if( self.options.show_slide_delay > 0 )
			{
				setTimeout( function()
				{
					displaySlide.addClass( 'next-active-slide' );
					displaySlide.avia_animate( transition2, self.options.transitionSpeed, self.options.easing, after_slide );
				}, self.options.show_slide_delay );
			}
			else
			{
				displaySlide.addClass( 'next-active-slide' );
				displaySlide.avia_animate( transition2, self.options.transitionSpeed, self.options.easing, after_slide );
			}
		},

		//simple fade transition of the slideshow
		_fade: function()
		{
			var self			= this,
				displaySlide 	= this.$slides.eq(this.current),
				hideSlide		= this.$slides.eq(this.prev),
				properties		= {visibility:'visible', zIndex:3, opacity:0},
				fadeCallback 	= function()
				{
					self.isAnimating = false;
					displaySlide.addClass( 'active-slide' );
					hideSlide.css({visibility:'hidden', zIndex:2}).removeClass( 'active-slide next-active-slide' );
					self.$slider.trigger( 'avia-transition-done' );
				};

			hideSlide.trigger('pause');

			if( ! displaySlide.data('disableAutoplay') )
			{
				if(displaySlide.hasClass('av-video-lazyload') && ! displaySlide.hasClass('av-video-lazyload-complete'))
				{
					displaySlide.find('.av-click-to-play-overlay').trigger('click');
				}
				else
				{
					displaySlide.trigger('play');
				}
			}

			displaySlide.addClass( 'next-active-slide' );

			if( self.options.fullfade == true )
			{
				hideSlide.avia_animate( {opacity:0}, 200, 'linear', function()
				{
					displaySlide.css( properties ).avia_animate( {opacity:1}, self.options.transitionSpeed, 'linear', fadeCallback );
				});
			}
			else
			{
				if( self.current === 0 )
				{
					hideSlide.avia_animate( {opacity:0}, self.options.transitionSpeed/2, 'linear' );
					displaySlide.css(properties).avia_animate( {opacity:1}, self.options.transitionSpeed/2, 'linear', fadeCallback );
				}
				else
				{
					displaySlide.css(properties).avia_animate( {opacity:1}, self.options.transitionSpeed/2, 'linear', function()
					{
						hideSlide.avia_animate({opacity:0}, 200, 'linear', fadeCallback );
					});
				}
			}
		},

		/************************************************************************
		Video functions
		*************************************************************************/

		//bind events to the video that tell the slider to autorotate once a video has been played
		_attach_video_events: function()
		{
			var self = this,
				$html = $('html');

			self.$slides.each( function(i)
			{
				var currentSlide 	= $(this),
					caption			= currentSlide.find('.caption_fullwidth, .av-click-overlay'),
					mejs			= currentSlide.find('.mejs-mediaelement'),
					lazyload		= currentSlide.hasClass('av-video-lazyload') ? true : false;


				if( currentSlide.data('avia_video_events') != true )
				{
					currentSlide.data('avia_video_events', true);

					currentSlide.on('av-video-events-bound', { slide: currentSlide, wrap: mejs , iteration: i , self: self, lazyload: lazyload }, onReady);

					currentSlide.on('av-video-ended', { slide: currentSlide , self: self}, onFinish);

					currentSlide.on('av-video-play-executed', function(){ setTimeout( function(){  self.pause(); }, 100 ); } );

					caption.on('click', { slide: currentSlide }, toggle);

					// also if the player was loaded before the _bindEvents function was bound trigger it manually
					if( currentSlide.is('.av-video-events-bound') )
					{
						currentSlide.trigger('av-video-events-bound');
					}

					//if we are on the first slide and autoplay is enabled and lazy loading is enabled we need to simulate a click event to the lazy load container
					if( lazyload && i === 0 && ! currentSlide.data('disableAutoplay') )
					{
						currentSlide.find('.av-click-to-play-overlay').trigger('click');
					}
				}
			});


			//function that takes care of events once the video is loaded for the first time.
			//needs to take into account 2 different scenarios: normally embedded videos or lazyloaded videos that start on user interaction/autoplay
			function onReady( event )
			{
				//autostart for first slide
				if(event.data.iteration === 0)
				{
					event.data.wrap.css('opacity',0);

					if( ! event.data.self.isMobile && ! event.data.slide.data('disableAutoplay') )
					{
						event.data.slide.trigger('play');
					} 

					setTimeout( function(){ event.data.wrap.avia_animate({opacity:1}, 400); }, 50 );
				}
				else if( $html.is('.avia-msie') && ! event.data.slide.is('.av-video-service-html5') )
				{
					/*
					* Internet Explorer fires the ready event for external videos once they become visible
					* as oposed to other browsers which always fire immediately.
					*/
					if( ! event.data.slide.data('disableAutoplay') )
					{
						event.data.slide.trigger('play');
					}
				}


				//make sure that the html5 element does not play if autoply is enabled but its not the first slide.
				//the autoplay attribute on the video element might cause this
				if( event.data.slide.is('.av-video-service-html5') && event.data.iteration !== 0 )
				{
					event.data.slide.trigger('pause');
				}

				//make sure that lazyloaded videos always get started once a user clicks them
				if( event.data.lazyload)
				{
					event.data.slide.addClass('av-video-lazyload-complete');
					event.data.slide.trigger('play');
				}
			}

			function onFinish( event )
			{
				//if the video is not looped resume the slideshow
				if( ! event.data.slide.is('.av-single-slide') && ! event.data.slide.is('.av-loop-video') )
				{
					event.data.slide.trigger('reset');
					self._navigate( 'next' );
					self.resume();
				}

				//safari 8 workaround for self hosted videos which wont loop by default
				if( event.data.slide.is('.av-loop-video') && event.data.slide.is('.av-video-service-html5') )
				{
					if( $html.is('.avia-safari-8') )
					{
						setTimeout( function()
						{
							event.data.slide.trigger('play');
						}, 1 );
					}
				}
			}

			function toggle( event )
			{
				if( event.target.tagName != "A" )
				{
					event.data.slide.trigger('toggle');
				}
			}
		},


		/************************************************************************
		Slideshow control functions
		*************************************************************************/

		_timer: function(callback, delay, first)
		{
		    var self = this,
				start,
				remaining = delay;

			self.timerId = 0;

		    this.pause = function()
			{
		        window.clearTimeout(self.timerId);
		        remaining -= new Date() - start;
		    };

		    this.resume = function()
			{
		        start = new Date();
		        self.timerId = window.setTimeout(callback, remaining);
		    };

		    this.destroy = function()
		    {
		    	window.clearTimeout(self.timerId);
		    };

		    this.resume(true);
		},

		//start autorotation
		_startSlideshow: function()
		{
			var self = this;

			this.isPlaying = true;

			this.slideshow = new this._timer( function()
			{
				self._navigate( 'next' );

				if( self.options.autoplay )
				{
					self._startSlideshow();
				}
			}, ( this.options.interval * 1000 ) );
		},

		//stop autorotation
		_stopSlideshow: function()
		{
			if( this.options.autoplay )
			{
				this.slideshow.destroy();
				this.isPlaying = false;
				this.options.autoplay = false;
			}

			this.options.autoplay = false;
			this.options.loop_autoplay = 'once';
			this.$slider.removeClass( 'av-slideshow-autoplay' ).addClass( 'av-slideshow-manual' );
			this.$slider.removeClass( 'av-loop-endless' ).addClass( 'av-loop-once' );
		},

		//	check if we have a link for the image and set cursor
		_setPermaCaptionPointer: function( e )
		{
			if( ! this.permaCaption.length )
			{
				return;
			}

			var withLink = $( this.$slides[this.current] ).find( 'a' ).length;
			this.permaCaption.css( 'cursor', withLink ? 'pointer' : 'default' );
		},

		//	route perma caption to actual link of image, else allow bubble (e.g. for buttons)
		_routePermaCaptionClick: function( e )
		{
			var active_slide_link = $(this).siblings( '.avia-slideshow-inner' ).find( '>.active-slide a' );

			if( active_slide_link.length )
			{
				e.preventDefault();

				//	jQuery trigger does not work !!!
				active_slide_link[0].click();
			}
		},

		// public method: shows next image
		next: function(e)
		{
			e.preventDefault();
			this._stopSlideshow();
			this._navigate( 'next' );
		},

		// public method: shows previous image
		previous: function(e)
		{
			e.preventDefault();
			this._stopSlideshow();
			this._navigate( 'prev' );
		},

		// public method: goes to a specific image
		go2: function( pos )
		{
			//if we didnt pass a number directly lets asume someone clicked on a link that triggered the goto transition
			if(isNaN(pos))
			{
				//in that case prevent the default link behavior and set the slide number to the links hash
				pos.preventDefault();
				pos = pos.currentTarget.hash.replace('#','');
			}

			pos -= 1;

			if( pos === this.current || pos >= this.itemsCount || pos < 0 )
			{
				return false;
			}

			this._stopSlideshow();
			this._navigate( false, pos );

		},

		// public method: starts the slideshow
		// any call to next(), previous() or goto() will stop the slideshow autoplay
		play: function()
		{
			if( !this.isPlaying )
			{
				this.isPlaying = true;

				this._navigate( 'next' );
				this.options.autoplay = true;
				this._startSlideshow();
			}

		},

		// public methos: pauses the slideshow
		pause: function()
		{
			if( this.isPlaying )
			{
				this.slideshow.pause();
			}
		},

		// publiccmethos: resumes the slideshow
		resume: function()
		{
			if( this.isPlaying )
			{
				this.slideshow.resume();
			}
		},

		// public methos: destroys the instance
		destroy: function( callback )
		{
			this.slideshow.destroy( callback );
		}
    };

    //simple wrapper to call the slideshow. makes sure that the slide data is not applied twice
    $.fn.aviaSlider = function( options )
    {
    	return this.each(function()
    	{
    		var self = $.data( this, 'aviaSlider' );

    		if( ! self )
    		{
    			self = $.data( this, 'aviaSlider', new $.AviaSlider( options, this ) );
    		}
    	});
    };

})( jQuery );
// source --> https://axhotelsmalta.com/wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/slideshow/slideshow-video.js?ver=6.8.5 
// -------------------------------------------------------------------------------------------
//
// AVIA VIDEO API - make sure that youtube, vimeo and html 5 use the same interface
//
// requires froogaloop vimeo library and youtube iframe api (yt can be loaded async)
//
// -------------------------------------------------------------------------------------------


(function($)
{
    "use strict";

	$.AviaVideoAPI  =  function(options, video, option_container)
	{
		this.videoElement = video;

		// actual video element. either iframe or video
		this.$video	= $( video );

		// container where the AviaVideoAPI object will be stored as data, and that can receive events like play, pause etc
		// also the container that allows to overwrite javacript options by adding html data- attributes
		this.$option_container = option_container ? $( option_container ) : this.$video;

		// button to click to actually start the loading process of the video
		this.load_btn = this.$option_container.find('.av-click-to-play-overlay');

		// contains video list
		this.video_wrapper = this.$video.parents('ul').eq(0);

		//check if we should load immediately or on click
		this.lazy_load = this.video_wrapper.hasClass('av-show-video-on-click') ? true : false;

		//mobile device?
		this.isMobile = $.avia_utilities.isMobile;

		//iamge fallback use
		this.fallback = this.isMobile ? this.$option_container.is('.av-mobile-fallback-image') : false;

		if( this.fallback )
		{
			return;
		}

		// set up the whole api object
		this._init( options );
	};

	$.AviaVideoAPI.defaults  = {

		loop: false,
		mute: false,
		controls: false,
		events: 'play pause mute unmute loop toggle reset unload'

	};

	$.AviaVideoAPI.apiFiles =
    {
    	youtube : {loaded: false, src: 'https://www.youtube.com/iframe_api' }
    };

    $.AviaVideoAPI.players =
    {

    };

  	$.AviaVideoAPI.prototype =
    {
    	_init: function( options )
    	{
			// set slider options
			this.options = this._setOptions(options);

			// info which video service we are using: html5, vimeo or youtube
			this.type = this._getPlayerType();

			this.player = false;

			// store the player object to the this.player variable created by one of the APIs (mediaelement, youtube, vimeo)
			this._bind_player();

			// set to true once the events are bound so it doesnt happen a second time by accident or racing condition
			this.eventsBound = false;

			// info if the video is playing
			this.playing = false;

			//set css class that video is currently not playing
			this.$option_container.addClass('av-video-paused');

			//play pause indicator
			this.pp = $.avia_utilities.playpause(this.$option_container);
    	},


    	//set the video options by first merging the default options and the passed options, then checking the video element if any data attributes overwrite the option set
    	_setOptions: function(options)
		{
			var newOptions 	= $.extend( true, {}, $.AviaVideoAPI.defaults, options ),
				htmlData 	= this.$option_container.data(),
				i 			= "";

			//overwritte passed option set with any data properties on the html element
			for( i in htmlData )
			{
				if( htmlData.hasOwnProperty(i) && (typeof htmlData[i] === "string" || typeof htmlData[i] === "number" || typeof htmlData[i] === "boolean") )
				{
					newOptions[i] = htmlData[i];
				}
			}

			return newOptions;
		},

		//get the player type
		_getPlayerType: function()
		{
			var vid_src = this.$video.get(0).src || this.$video.data('src');

			if( this.$video.is('video') )
			{
				return 'html5';
			}

			if( this.$video.is('.av_youtube_frame') )
			{
				return 'youtube';
			}

			if( vid_src.indexOf('vimeo.com') != -1 )
			{
				return 'vimeo';
			}
			if( vid_src.indexOf('youtube.com') != -1)
			{
				return 'youtube';
			}
		},

		_bind_player: function()
		{
			var _self = this;

			//	check if videos are disabled by user setting via cookie - or user must opt in.
			var cookie_check = $('html').hasClass('av-cookies-needs-opt-in') || $('html').hasClass('av-cookies-can-opt-out');
			var allow_continue = true;
			var silent_accept_cookie = $('html').hasClass('av-cookies-user-silent-accept');
			var self_hosted = 'html5' == this.type;

			if( cookie_check && ! silent_accept_cookie && ! self_hosted )
			{
				if( ! document.cookie.match(/aviaCookieConsent/) || $('html').hasClass('av-cookies-session-refused') )
				{
					allow_continue = false;
				}
				else
				{
					if( ! document.cookie.match(/aviaPrivacyRefuseCookiesHideBar/) )
					{
						allow_continue = false;
					}
					else if( ! document.cookie.match(/aviaPrivacyEssentialCookiesEnabled/) )
					{
						allow_continue = false;
					}
					else if( document.cookie.match(/aviaPrivacyVideoEmbedsDisabled/) )
					{
						allow_continue = false;
					}
				}
			}

			if( ! allow_continue )
			{
				this._use_external_link();
				return;
			}

			if(this.lazy_load && this.load_btn.length && this.type != "html5")
			{
				this.$option_container.addClass('av-video-lazyload');

				this.load_btn.on('click', function()
				{
					_self.load_btn.remove();
					_self._setPlayer();
				});
			}
			else
			{
				this.lazy_load = false;
				this._setPlayer();
			}
		},

		//if the user has disabled video slides via cookie a click event will open the video externally
		_use_external_link: function()
		{
			//display the play button no matter what
			this.$option_container.addClass('av-video-lazyload');

			this.load_btn.on('click', function(e)
			{
				if (e.originalEvent === undefined) return; //human click only

				var src_url = $(this).parents('.avia-slide-wrap').find('div[data-original_url]').data('original_url');
				if( src_url ) window.open(src_url , '_blank');
			});
		},

		//get the player object
		_setPlayer: function()
		{
			var _self = this;

			switch( this.type )
			{
				case "html5":

					this.player = this.$video.data('mediaelementplayer');

					//apply fallback. sometimes needed for safari
					if( ! this.player )
					{
						this.$video.data('mediaelementplayer', $.AviaVideoAPI.players[ this.$video.attr('id').replace(/_html5/,'') ] );
						this.player = this.$video.data('mediaelementplayer');
					}

					this._playerReady();
					break;

				case "vimeo":

					//we need to create an iframe and append it to the html first
					var ifrm 	= document.createElement("iframe");
					var $ifrm	= $( ifrm );

					//note: unmuted vimeo videos in chrome do often times not work due to chrome blocking them
					ifrm.onload = function()
					{
						_self.player = Froogaloop( ifrm );
						_self._playerReady();
						_self.$option_container.trigger('av-video-loaded');
					};

					ifrm.setAttribute("src", this.$video.data('src') );

					//we replace the old html structure with the iframe
					$ifrm.insertAfter( this.$video );
					this.$video.remove();
					this.$video = ifrm;
					break;

				case "youtube":

					this._getAPI(this.type);
					$('body').on('av-youtube-iframe-api-loaded', function(){ _self._playerReady(); });
					break;
			}
		},

		_getAPI: function( api )
		{
			//make sure the api file is loaded only once
			if($.AviaVideoAPI.apiFiles[api].loaded === false)
			{
				$.AviaVideoAPI.apiFiles[api].loaded = true;
				//load the file async
				var tag		= document.createElement('script'),
					first	= document.getElementsByTagName('script')[0];

				tag.src = $.AviaVideoAPI.apiFiles[api].src;
      			first.parentNode.insertBefore(tag, first);
			}
		},

		//wait for player to be ready, then bind events
		_playerReady: function()
		{
			var _self = this;

			this.$option_container.on('av-video-loaded', function(){ _self._bindEvents(); });

			switch(this.type)
			{
				case "html5":
					this.$video.on( 'av-mediajs-loaded', function(){ _self.$option_container.trigger('av-video-loaded'); } );
					this.$video.on( 'av-mediajs-ended' , function(){ _self.$option_container.trigger('av-video-ended');  } );
					break;
				case "vimeo":
					//finish event must be applied after ready event for firefox
					_self.player.addEvent('ready',  function()
					{
						_self.$option_container.trigger('av-video-loaded');
						_self.player.addEvent('finish', function(){ _self.$option_container.trigger('av-video-ended');  });
					});
					break;

				case "youtube":

					var params = _self.$video.data();

					if( _self._supports_video() )
					{
						params.html5 = 1;
					}

					_self.player = new YT.Player(_self.$video.attr('id'),
					{
						videoId: params.videoid,
						height: _self.$video.attr('height'),
						width: _self.$video.attr('width'),
						playerVars: params,
						events: {
						'onReady': function(){ _self.$option_container.trigger('av-video-loaded'); },
						'onError': function(player){ $.avia_utilities.log('YOUTUBE ERROR:', 'error', player); },
						'onStateChange': function(event){
							if (event.data === YT.PlayerState.ENDED)
							{
								var command = _self.options.loop != false ? 'loop' : 'av-video-ended';
								_self.$option_container.trigger(command);
							}
						  }
						}
					});
					break;
			}

			//fallback always trigger after 2 seconds
			setTimeout(function()
			{
				if(_self.eventsBound == true || typeof _self.eventsBound == 'undefined' || _self.type == 'youtube' )
				{
					return;
				}

				$.avia_utilities.log('Fallback Video Trigger "' + _self.type + '":', 'log', _self );

				_self.$option_container.trigger('av-video-loaded');

			}, 2000 );
		},

		//bind events we should listen to, to the player
		_bindEvents: function()
		{
			if( this.eventsBound == true || typeof this.eventsBound == 'undefined')
			{
				return;
			}

			var _self = this, volume = 'unmute';

			this.eventsBound = true;

			this.$option_container.on(this.options.events, function(e)
			{
				_self.api(e.type);
			});

			if( !_self.isMobile )
			{
				//set up initial options
				if( this.options.mute != false )
				{
					volume = "mute";
				}

				if( this.options.loop != false )
				{
					_self.api('loop');
				}

				_self.api(volume);
			}

			//set timeout to prevent racing conditions with other scripts
			setTimeout( function()
			{
				_self.$option_container.trigger('av-video-events-bound').addClass('av-video-events-bound');
			}, 50 );
		},


		_supports_video: function()
		{
		  return !!document.createElement('video').canPlayType;
		},


		/************************************************************************
		PUBLIC Methods
		*************************************************************************/


		api: function( action )
		{
			//commands on mobile can not be executed if the player was not started manually
			if(this.isMobile && !this.was_started()) return;

			// prevent calling of unbound function
			if(this.options.events.indexOf(action) === -1) return;

			// broadcast that the command was executed
			this.$option_container.trigger('av-video-'+action+'-executed');

			// console.log("video player api action: " + action);

			// calls the function based on action. eg: _html5_play()
			if(typeof this[ '_' + this.type + '_' + action] == 'function')
			{
				this[ '_' + this.type + '_' + action].call(this);
			}

			//call generic function eg: _toggle() or _play()
			if(typeof this[ '_' + action] == 'function')
			{
				this[ '_' + action].call(this);
			}
		},

		was_started: function()
		{
			if(!this.player) return false;

			switch(this.type)
			{
				case "html5":
					if( this.player.getCurrentTime() > 0 )
					{
						return true;
					}
					break;

				case "vimeo":
					if( this.player.api('getCurrentTime') > 0 )
					{
						return true;
					}
					break;

				case "youtube":
					if( this.player.getPlayerState() !== -1 )
					{
						return true;
					}
					break;
			}

			return false;
		},

		/************************************************************************
		Generic Methods, are always executed and usually set variables
		*************************************************************************/
		_play: function()
		{
			this.playing = true;
			this.$option_container.addClass('av-video-playing').removeClass('av-video-paused');
		},

		_pause: function()
		{
			this.playing = false;
			this.$option_container.removeClass('av-video-playing').addClass('av-video-paused');
		},

		_loop: function()
		{
			this.options.loop = true;
		},

		_toggle: function( )
		{
			var command = this.playing == true ? 'pause' : 'play';

			this.api(command);
			this.pp.set(command);
		},


		/************************************************************************
		VIMEO Methods
		*************************************************************************/

		_vimeo_play: function( )
		{
			this.player.api('play');
		},

		_vimeo_pause: function( )
		{
			this.player.api('pause');
		},

		_vimeo_mute: function( )
		{
			this.player.api('setVolume', 0);
		},

		_vimeo_unmute: function( )
		{
			this.player.api('setVolume', 0.7);
		},

		_vimeo_loop: function( )
		{
			// currently throws error, must be set in iframe
			// this.player.api('setLoop', true);
		},

		_vimeo_reset: function( )
		{
			this.player.api('seekTo',0);
		},

		_vimeo_unload: function()
		{
			this.player.api('unload');
		},

		/************************************************************************
		YOUTUBE Methods
		*************************************************************************/

		_youtube_play: function( )
		{
			this.player.playVideo();
		},

		_youtube_pause: function( )
		{
			this.player.pauseVideo();
		},

		_youtube_mute: function( )
		{
			this.player.mute();
		},

		_youtube_unmute: function( )
		{
			this.player.unMute();
		},

		_youtube_loop: function( )
		{
			// does not work properly with iframe api. needs to manual loop on "end" event
			// this.player.setLoop(true);
			if(this.playing == true) this.player.seekTo(0);
		},

		_youtube_reset: function( )
		{
			this.player.stopVideo();
		},

		_youtube_unload: function()
		{
			this.player.clearVideo();
		},

		/************************************************************************
		HTML5 Methods
		*************************************************************************/

		_html5_play: function( )
		{
			//disable stoping of other videos in case the user wants to run section bgs
			if(this.player)
			{
				this.player.options.pauseOtherPlayers = false;
				this.player.play();
			}

		},

		_html5_pause: function( )
		{
			if(this.player) this.player.pause();
		},

		_html5_mute: function( )
		{
			if(this.player) this.player.setMuted(true);
		},

		_html5_unmute: function( )
		{
			if(this.player) this.player.setVolume(0.7);
		},

		_html5_loop: function( )
		{
			if(this.player) this.player.options.loop = true;
		},

		_html5_reset: function( )
		{
			if(this.player) this.player.setCurrentTime(0);
		},

		_html5_unload: function()
		{
			this._html5_pause();
			this._html5_reset();
		}
    };

    //simple wrapper to call the api. makes sure that the api data is not applied twice
    $.fn.aviaVideoApi = function( options , apply_to_parent)
    {
    	return this.each( function()
    	{
    		// by default save the object as data to the initial video.
    		// in the case of slideshows its more benefitial to save it to a parent element (eg: the slide)
    		var applyTo = this;

    		if( apply_to_parent )
    		{
    			applyTo = $(this).parents(apply_to_parent).get(0);
    		}

    		var self = $.data( applyTo, 'aviaVideoApi' );

    		if( ! self )
    		{
    			self = $.data( applyTo, 'aviaVideoApi', new $.AviaVideoAPI( options, this, applyTo ) );
    		}
    	});
    };

})( jQuery );

window.onYouTubeIframeAPIReady = function(){ jQuery('body').trigger('av-youtube-iframe-api-loaded'); };


// Init style shamelessly stolen from jQuery http://jquery.com
// min version: https://f.vimeocdn.com/js/froogaloop2.min.js
var Froogaloop = (function(){
    // Define a local copy of Froogaloop
    function Froogaloop(iframe) {
        // The Froogaloop object is actually just the init constructor
        return new Froogaloop.fn.init(iframe);
    }

    var eventCallbacks = {},
        hasWindowEvent = false,
        isReady = false,
        slice = Array.prototype.slice,
        playerOrigin = '*';

    Froogaloop.fn = Froogaloop.prototype = {
        element: null,

        init: function(iframe) {
            if (typeof iframe === "string") {
                iframe = document.getElementById(iframe);
            }

            this.element = iframe;

            return this;
        },

        /*
         * Calls a function to act upon the player.
         *
         * @param {string} method The name of the Javascript API method to call. Eg: 'play'.
         * @param {Array|Function} valueOrCallback params Array of parameters to pass when calling an API method
         *                                or callback function when the method returns a value.
         */
        api: function(method, valueOrCallback) {
            if (!this.element || !method) {
                return false;
            }

            var self = this,
                element = self.element,
                target_id = element.id !== '' ? element.id : null,
                params = !isFunction(valueOrCallback) ? valueOrCallback : null,
                callback = isFunction(valueOrCallback) ? valueOrCallback : null;

            // Store the callback for get functions
            if (callback) {
                storeCallback(method, callback, target_id);
            }

            postMessage(method, params, element);
            return self;
        },

        /*
         * Registers an event listener and a callback function that gets called when the event fires.
         *
         * @param eventName (String): Name of the event to listen for.
         * @param callback (Function): Function that should be called when the event fires.
         */
        addEvent: function(eventName, callback) {
            if (!this.element) {
                return false;
            }

            var self = this,
                element = self.element,
                target_id = element.id !== '' ? element.id : null;


            storeCallback(eventName, callback, target_id);

            // The ready event is not registered via postMessage. It fires regardless.
            if (eventName != 'ready') {
                postMessage('addEventListener', eventName, element);
            }
            else if (eventName == 'ready' && isReady) {
                callback.call(null, target_id);
            }

            return self;
        },

        /*
         * Unregisters an event listener that gets called when the event fires.
         *
         * @param eventName (String): Name of the event to stop listening for.
         */
        removeEvent: function(eventName) {
            if (!this.element) {
                return false;
            }

            var self = this,
                element = self.element,
                target_id = element.id !== '' ? element.id : null,
                removed = removeCallback(eventName, target_id);

            // The ready event is not registered
            if (eventName != 'ready' && removed) {
                postMessage('removeEventListener', eventName, element);
            }
        }
    };

    /**
     * Handles posting a message to the parent window.
     *
     * @param method (String): name of the method to call inside the player. For api calls
     * this is the name of the api method (api_play or api_pause) while for events this method
     * is api_addEventListener.
     * @param params (Object or Array): List of parameters to submit to the method. Can be either
     * a single param or an array list of parameters.
     * @param target (HTMLElement): Target iframe to post the message to.
     */
    function postMessage(method, params, target) {
        if (!target.contentWindow.postMessage) {
            return false;
        }

        var data = JSON.stringify({
            method: method,
            value: params
        });

        target.contentWindow.postMessage(data, playerOrigin);
    }

    /**
     * Event that fires whenever the window receives a message from its parent
     * via window.postMessage.
     */
    function onMessageReceived(event)
	{

        var data, method;

        try {
            data = JSON.parse(event.data);
            method = data.event || data.method;
        }
        catch(e)  {
            //fail silently... like a ninja!
        }

        if (method == 'ready' && !isReady) {
            isReady = true;
        }

        // Handles messages from the vimeo player only
        if (!(/^https?:\/\/player.vimeo.com/).test(event.origin)) {
            return false;
        }

        if (playerOrigin === '*') {
            playerOrigin = event.origin;
        }
        var value = data.value,
            eventData = data.data,
            target_id = target_id === '' ? null : data.player_id,

            callback = getCallback(method, target_id),
            params = [];

        if (!callback) {
            return false;
        }

        if (value !== undefined) {
            params.push(value);
        }

        if (eventData) {
            params.push(eventData);
        }

        if (target_id) {
            params.push(target_id);
        }

        return params.length > 0 ? callback.apply(null, params) : callback.call();
    }


    /**
     * Stores submitted callbacks for each iframe being tracked and each
     * event for that iframe.
     *
     * @param eventName (String): Name of the event. Eg. api_onPlay
     * @param callback (Function): Function that should get executed when the
     * event is fired.
     * @param target_id (String) [Optional]: If handling more than one iframe then
     * it stores the different callbacks for different iframes based on the iframe's
     * id.
     */
    function storeCallback(eventName, callback, target_id) {
        if (target_id) {
            if (!eventCallbacks[target_id]) {
                eventCallbacks[target_id] = {};
            }
            eventCallbacks[target_id][eventName] = callback;
        }
        else {
            eventCallbacks[eventName] = callback;
        }
    }

    /**
     * Retrieves stored callbacks.
     */
    function getCallback(eventName, target_id) {

	    /*modified by kriesi - removing this will result in a js error. */
        if (target_id && eventCallbacks[target_id] && eventCallbacks[target_id][eventName])
		{
            return eventCallbacks[target_id][eventName];
        }
        else
		{
            return eventCallbacks[eventName];
        }
    }

    function removeCallback(eventName, target_id) {
        if (target_id && eventCallbacks[target_id]) {
            if (!eventCallbacks[target_id][eventName]) {
                return false;
            }
            eventCallbacks[target_id][eventName] = null;
        }
        else {
            if (!eventCallbacks[eventName]) {
                return false;
            }
            eventCallbacks[eventName] = null;
        }

        return true;
    }

    function isFunction(obj) {
        return !!(obj && obj.constructor && obj.call && obj.apply);
    }

    function isArray(obj) {
        return toString.call(obj) === '[object Array]';
    }

    // Give the init function the Froogaloop prototype for later instantiation
    Froogaloop.fn.init.prototype = Froogaloop.fn;

    // Listens for the message event.
    // W3C
    if (window.addEventListener) {
        window.addEventListener('message', onMessageReceived, false);
    }
    // IE
    else {
        window.attachEvent('onmessage', onMessageReceived);
    }

    // Expose froogaloop to the global object
    return (window.Froogaloop = window.$f = Froogaloop);

})();
// source --> https://axhotelsmalta.com/wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/tabs/tabs.js?ver=6.8.5 
// -------------------------------------------------------------------------------------------
// Tab Shortcode
// -------------------------------------------------------------------------------------------

(function($)
{
	"use strict";

	$.fn.avia_sc_tabs = function(options)
	{
		var defaults =
		{
			heading: '.tab',
			content:'.tab_content',
			active:'active_tab',
			sidebar: false
		};

		var win = $(window),
			options = $.extend(defaults, options);

		return this.each(function()
		{
			var container 	= $(this),
				tab_titles 	= $('<div class="tab_titles"></div>').prependTo(container),
				tabs 		= $(options.heading, container),
				content 	= $(options.content, container),
				newtabs 	= false,
				oldtabs 	= false;

			newtabs = tabs.clone();
			oldtabs = tabs.addClass('fullsize-tab').attr('aria-hidden', true );
			tabs = newtabs;

			tabs.prependTo(tab_titles).each(function(i)
			{
				var tab = $(this),
					the_oldtab = false;

				if(newtabs)
				{
					the_oldtab = oldtabs.eq( i );
				}

				tab.addClass('tab_counter_'+i).on('click', function()
				{
					open_content(tab, i, the_oldtab);
					return false;
				});

				tab.on('keydown', function(objEvent)
				{
					if (objEvent.keyCode === 13)  // if user presses 'enter'
					{
						tab.trigger('click');
					}
				});

				if(newtabs)
				{
					the_oldtab.on('click', function()
					{
						open_content(the_oldtab, i, tab);
						return false;
					});

					the_oldtab.on('keydown', function(objEvent)
					{
						if (objEvent.keyCode === 13)  // if user presses 'enter'
						{
							the_oldtab.trigger('click');
						}
					});
				}
			});

			set_size();
			trigger_default_open(false);
			win.on("debouncedresize", set_size);

	        $('a').on('click',function(){
	            var hash = $(this).attr('href');
	            if(typeof hash != "undefined" && hash)
	            {
	                hash = hash.replace(/^.*?#/,'');
	                trigger_default_open('#'+hash);
	            }
	        });

			function set_size()
			{
				if( ! options.sidebar)
				{
					return;
				}

				content.css({'min-height': tab_titles.outerHeight() + 1});
			}

			function open_content(tab, i, alternate_tab)
			{
				if(!tab.is('.'+options.active))
				{
					$('.'+options.active, container).removeClass(options.active);
					$('.'+options.active+'_content', container).attr('aria-hidden', true).removeClass(options.active+'_content');

					tab.addClass(options.active);

					var new_loc = tab.data('fake-id');
					if( typeof new_loc == 'string' )
					{
						window.location.replace( new_loc );
					}

					if( alternate_tab )
					{
						alternate_tab.addClass(options.active);
					}

					var active_c = content.eq( i ).addClass(options.active+'_content').attr('aria-hidden', false);

					if(typeof click_container != 'undefined' && click_container.length)
					{
						sidebar_shadow.height(active_c.outerHeight());
					}

					//check if tab title is in viewport. if not scroll up
					var el_offset = active_c.offset().top,
						scoll_target = el_offset - 50 - parseInt($('html').css('margin-top'),10);

					if(win.scrollTop() > el_offset)
					{
						$('html:not(:animated),body:not(:animated)').scrollTop(scoll_target);
					}
				}

				win.trigger( 'av-content-el-height-changed', tab );
			}

			function trigger_default_open(hash)
			{
				if( ! hash && window.location.hash )
				{
					hash = window.location.hash;
				}

				if( ! hash )
				{
					return;
				}

				var open = tabs.filter('[data-fake-id="'+hash+'"]');

				if(open.length)
				{
					if( ! open.is('.active_tab') )
					{
						open.trigger('click');
					}

					window.scrollTo(0, container.offset().top - 70);
				}
			}

		});
	};


}(jQuery));
// source --> https://axhotelsmalta.com/wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/video/video.js?ver=6.8.5 
(function($)
{
	"use strict";


	$('body').on( 'click', '.av-lazyload-video-embed .av-click-to-play-overlay', function(e)
	{
		var clicked = $(this);

		//	check if videos are disabled by user setting via cookie - or user must opt in.
		var cookie_check = $('html').hasClass('av-cookies-needs-opt-in') || $('html').hasClass('av-cookies-can-opt-out');
		var allow_continue = true;
		var silent_accept_cookie = $('html').hasClass('av-cookies-user-silent-accept');

		if( cookie_check && ! silent_accept_cookie )
		{
			if( ! document.cookie.match(/aviaCookieConsent/) || $('html').hasClass('av-cookies-session-refused') )
			{
				allow_continue = false;
			}
			else
			{
				if( ! document.cookie.match(/aviaPrivacyRefuseCookiesHideBar/) )
				{
					allow_continue = false;
				}
				else if( ! document.cookie.match(/aviaPrivacyEssentialCookiesEnabled/) )
				{
					allow_continue = false;
				}
				else if( document.cookie.match(/aviaPrivacyVideoEmbedsDisabled/) )
				{
					allow_continue = false;
				}
			}
		}

		var container = clicked.parents( '.av-lazyload-video-embed' );
		if( container.hasClass( 'avia-video-lightbox' ) && container.hasClass( 'avia-video-standard-html' ) )
		{
			allow_continue = true;
		}

		if( ! allow_continue )
		{
			if( typeof e.originalEvent == 'undefined' ) { return; } //human click only

			var src_url = container.data('original_url');
			if( src_url ) window.open( src_url , '_blank', 'noreferrer noopener' );

			return;
		}


		var video = container.find('.av-video-tmpl').html();
		var link = '';

		if( container.hasClass( 'avia-video-lightbox' ) )
		{
			link = container.find( 'a.lightbox-link' );
			if( link.length == 0 )
			{
				container.append( video );

				// DOM not ready
				setTimeout(function(){
							link = container.find( 'a.lightbox-link' );
							if( $( 'html' ).hasClass( 'av-default-lightbox' ) )
							{
								link.addClass( 'lightbox-added' ).magnificPopup( $.avia_utilities.av_popup );
								link.trigger( 'click' );
							}
							else
							{
								link.trigger( 'avia-open-video-in-lightbox' );
							}
					}, 100 );
			}
			else
			{
				link.trigger( 'click' );
			}
		}
		else
		{
			container.html( video );
		}

	});

	$('.av-lazyload-immediate .av-click-to-play-overlay').trigger('click');

}(jQuery));
// source --> https://axhotelsmalta.com/wp-content/themes/enfold-child/main.js?ver=2.2.74 
jQuery(document).ready(function ($) {
	$(".main_video_cont").each(function (){
			
		
				$(this).on("click", function (){
					var video_src = $(this).find('video').find('Source:first').attr('src');
					var full_video_src = $(this).find('video').find('Source:first').attr('data-fullvideo');
					$("#popup_holder").show();
					if($('#top').hasClass('page-id-27137')){
					   $("#popup_inner").html('<div class="popup_video_cont"><i class="close_icon bg_contain bg_center bg_no_repeat"></i>\
										   <video class="popup_video" width="1320" height="auto" autoplay playsinline webkit-playsinline controls>\
												  <source src="'+ (full_video_src ? full_video_src : video_src) +'" type="video/mp4">\
												</video></div>');
					   } else {
						   $("#popup_inner").html('<div class="popup_video_cont"><i class="close_icon bg_contain bg_center bg_no_repeat"></i>\
										   <video class="popup_video" width="1320" height="auto" autoplay muted playsinline webkit-playsinline controls>\
												  <source src="'+ (full_video_src ? full_video_src : video_src) +'" type="video/mp4">\
												</video></div>');
					   }
					
					$("#popup_holder").addClass('above_all');
					
					$('.wedding_fair_sticky_box').addClass('wedding_fair_sticky_box_move_up');
				});
			
	});
	
		$(document).on("click", ".gallery_tour_link_cont" , function() {
			$(this).closest('.avia-section').addClass('iframe_active');
			$('body, html').addClass('scroll-disabled');	
		});
	
		$(document).on("click", ".iframe_gallery_cont .close_icon" , function() {
			$(this).closest('.avia-section').removeClass('iframe_active');
			$('body, html').removeClass('scroll-disabled');
		});
	
		$(document).on("click", ".close_icon" , function() {
            $("#popup_holder").hide();
			$("#popup_holder").removeClass('above_all');
			if($(this).parent().hasClass("popup_video_cont")){
				var video = $(".popup_video").get(0);
				if ( video.paused ) {
					video.play();
				} else {
					video.pause();
				}
			}
			
			$('.wedding_fair_sticky_box').removeClass('wedding_fair_sticky_box_move_up');
        });
	
	$('.popup_video').each(function(){
		$(this).on('contextmenu', function(e) {
		  e.preventDefault();
		});
	});
	
	$(".ax_tab_title").each(function (){
		$(this).on('click', function (){
			$(".ax_tab_title").each(function (){
				$(this).removeClass("ax_tab_title_active");
			});
			
			$(this).addClass("ax_tab_title_active");
			
			$(".swiper_title_content").each(function (){
				$(this).toggleClass("hide_swiper");
			});
			
		});
	});
	
	function addIconsToTitles() {
		
		 $('.main_cards_inner, .awards_cards_inner').each(function(){
							   $(this).css("opacity", 1);
						   });
			}
	
		addIconsToTitles();			  
	
		$('.single_filter_cont, .single_mob_filter').each(function(){
				$(this).on('click', function(e){	
					setTimeout(
					  function() 
					  {
						addIconsToTitles();
					  }, 1100);
				});
			});
	
	$(document).on("click", ".load_more_btn_cont" , function() {
            $("#popup_holder").hide();
        });
	
	var mouseX = 0, mouseY = 0;
		  var xp = 0, yp = 0;

		 
		
	$(document).on("mouseenter", ".single_img_hover_cont, .hotelchildpage .timeline_single_img, .explore_mouse .timeline_single_img, .page-id-27966 .timeline_single_img", function() {
		
		 $(document).mousemove(function(e){
			mouseX = e.pageX - 20;
			mouseY = e.pageY - 20; 
		  });

		   setInterval(function(){
			xp += ((mouseX - xp)/3);
			yp += ((mouseY - yp)/3);
			$("#hover_mouse_cont").css('transform', 'translate(' + xp + 'px, ' + yp + 'px)');
			}, 20);
		
		if(!$(this).parent().hasClass("no_explore_hover")){
		   $("#hover_mouse_cont").addClass("show_cursor");
		}
	});
	
	$(document).on("mouseleave", ".single_img_hover_cont, .hotelchildpage .timeline_single_img, .explore_mouse .timeline_single_img, .page-id-27966 .timeline_single_img", function() {
		 $("#hover_mouse_cont").removeClass("show_cursor");
	});
	
	$("#mobile_back_to_top").click(function() {
	  window.scrollTo({ top: 0, behavior: 'smooth' });
	});
	
	if ($(window).width() <= 600) {
	   $("#hover_mouse_cont").remove();
		
		$(window).on('scroll', function() {
		  var targetDiv = $('#mobile_back_to_top, #mobile_book_btn, #mobile_book_btn_alt, #mobile_book_btn_alt_sub');
		  var targetDivOffset = targetDiv.offset().top - 100;
		  var targetDivHeight = targetDiv.height();

		  var targetDivTop = targetDivOffset;
		  var targetDivBottom = targetDivOffset + targetDivHeight;
		  var isOverlapping = false;

		  $('.ax_bg_black, #footer, #socket').each(function() {
			 var greyBgOffset = $(this).offset().top;
			var greyBgHeight = $(this).height();

			var greyBgTop = greyBgOffset;
			var greyBgBottom = greyBgOffset + greyBgHeight;
			greyBgBottom = greyBgBottom - 100;
			if (targetDivTop < greyBgBottom && targetDivBottom > greyBgTop) {
			  isOverlapping = true;
			  return false;
			}
		  });
			
			if (isOverlapping) {
				targetDiv.addClass('white_back_to_top');
			  } else {
				targetDiv.removeClass('white_back_to_top');
			  }
		});
		
	}
	
	$(".copy_code_btn").each(function(){
		$(this).on('click', function() {
			var textToCopy = $(this).attr("data-code");
			var textarea = $('<textarea>').val(textToCopy).appendTo('body').select();
			document.execCommand('copy');
			textarea.remove();
			$(this).addClass("copied");
			$(this).text("COPIED!");
		  });
	});

	  if(!$(".booking_form_menu_cont").hasClass("single_hotel_main_menu_cont")){
	  		checkScrollPosition();
	  }	 

	  $(window).scroll(function() {
		  if(!$(".booking_form_menu_cont").hasClass("single_hotel_main_menu_cont")){
			 checkScrollPosition();
		  }	  
	  });

	  function checkScrollPosition() {
		var scrollTop = $(window).scrollTop();

		if (scrollTop > 0) {
		  $(".booking_form_menu_cont").addClass("show_scroll_menu");
	
		} else {			
			$(".booking_form_menu_cont").removeClass("show_scroll_menu");	
			
		  	if($("#top").hasClass("home")){
			   if (screen.width <= 767) {
					if($(".sticky_burger_menu_items_cont").hasClass("active_inner_sticky_burger_menu")){
					   $(".booking_form_menu_cont").addClass("show_scroll_menu");	
					}			
				}
			}
		
			if (screen.width > 767) {				
				$("#sticky_burger_menu").removeClass("active_sticky_burger_menu");
				$(".sticky_burger_menu_items_cont").removeClass("active_inner_sticky_burger_menu");
			}		  		  
			 $(".rooms_guests_cont").removeClass("active_rooms_guests_cont");
		}
	  }
	
	$("#sticky_burger_menu, .single_hotel_full_menu_inner_open").on("click",function(evt) {
		evt.stopImmediatePropagation();
		$(".hi-widget-container").toggleClass("chat_box_hide");
		$("#sticky_burger_menu").toggleClass("active_sticky_burger_menu");
		$('.single_hotel_full_menu_inner_open').toggleClass('single_hotel_full_menu_inner_open_active');
		$(".sticky_burger_menu_items_cont").toggleClass("active_inner_sticky_burger_menu");
		$(".rooms_guests_cont").removeClass("active_rooms_guests_cont");
		$("#desktop_contact_us_popup").hide();	
		 if (screen.width <= 767) {
			 $("#mob_burger_menu_back_btn").parent().addClass("burger_menu_hide");
			 $(".sticky_burger_menu_items_side").removeClass("burger_menu_hide");
		 }
		if($("#top").hasClass("home")){
		   if (screen.width <= 767) {
				var scrollTop = $(window).scrollTop();
				if(scrollTop <= 0){
				   $(".booking_form_menu_cont").toggleClass("show_scroll_menu");
				}			
			}
		}
		if (screen.width <= 767) {
			$('.close_room_details_cont').toggleClass('close_room_details_cont_hide');
			$('body, html').toggleClass('scroll-disabled');	
			$('.booking_form_menu_cont').toggleClass('mobile_scroll_menu');	
			$('#mobile_booking_cont').removeClass('mobile_booking_cont_active');
		}
	});
	
	$("#book_rooms_guests_cont").on("click",function() {
		$("#rooms_guests_cont").toggleClass("active_rooms_guests_cont");
		var get_children_number = $("#children_number").val();
		if(get_children_number > 0){
		   $("#children_guests_cont").toggleClass("active_rooms_guests_cont");
		}
		$("#sticky_burger_menu").removeClass("active_sticky_burger_menu");
		$(".sticky_burger_menu_items_cont").removeClass("active_inner_sticky_burger_menu");
	});
	
	$(".increment_icon").each(function(){
		$(this).on("click", function(){
			$(this).parent().find("input").val( function(i, oldval) {
				var get_max = $(this).attr("data-max");
				
				if(oldval == get_max){
				   return oldval;
				} else {
					return ++oldval;
				}			
			});
		});
	});
	
	$(".decrement_icon").each(function(){
		$(this).on("click", function(){
			$(this).parent().find("input").val( function(i, oldval) {
				var get_min = $(this).attr("data-min");
				
				if(oldval == get_min){
				   return oldval;
				} else {
					return --oldval;
				}			
			});
		});
	});
	
	$("#children_number_cont .increment_icon").each(function(){
		$(this).on("click", function(){
			$(this).parent().find("input").val( function(i, oldval) {								
				$("#children_guests_cont").addClass("active_rooms_guests_cont");
				$("#children_age_" + oldval + "_cont").removeClass("children_age_hidden");				
				return oldval;
			});
		});
	});
	
	$("#children_number_cont .decrement_icon").each(function(){
		$(this).on("click", function(){
			$(this).parent().find("input").val( function(i, oldval) {				
				if(oldval == 0){
				   $("#children_guests_cont").removeClass("active_rooms_guests_cont");
				} else {			
				   $("#children_guests_cont").addClass("active_rooms_guests_cont");
					var val = parseInt(oldval) + 1;
					$("#children_age_" + val + "_cont").addClass("children_age_hidden");
				}
				return oldval;
			});
		});
	});
	
	$("#rooms_number_cont i").each(function(){
		$(this).on("click", function(){
			$(this).parent().find("input").val( function(i, oldval) {					
				if(oldval == 1){
				   $("#room_label").text(oldval + " Room,");
				} else {
				   $("#room_label").text(oldval + " Rooms,");
				}
				
				return oldval;
			});
		});
	});
	
	$("#adults_number_cont i, #children_number_cont i").each(function(){
		$(this).on("click", function(){
			$(this).parent().find("input").val( function(i, oldval) {					
				var get_adult_val = parseInt($("#adults_number").val());
				var get_children_val = parseInt($("#children_number").val());
				var total_guests = get_adult_val + get_children_val;
				
				if(total_guests == 1){
				   $("#guests_label").text(total_guests + " "+lbl_guest);
				} else {
				   $("#guests_label").text(total_guests + " "+lbl_guests);
				}
				
				return oldval;
			});
		});
	});
	
	function format_date(date_to_format) {
		var dd = date_to_format.getDate();
		var mm = date_to_format.getMonth() + 1;
		var yyyy = date_to_format.getFullYear();

		if (dd < 10) {
			dd = '0' + dd;
		}

		if (mm < 10) {
			mm = '0' + mm;
		}
		
		var formattedDate = date_to_format.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric' });
		
		return formattedDate;
	}	
	
	var today = new Date();
	var today_formatted_date = format_date(today);
	
	var isVerdalaClass = $('html').hasClass('verdala-wellness');
	var isHeightsResidencesClass = $('html').hasClass('ax-the-heights-residences');
	var isExcludedPage = $('#top').hasClass('page-id-32219');

	var dropsValue = (isVerdalaClass && !isExcludedPage) ? 'up' : 'down';

	if(isVerdalaClass || isExcludedPage){
	   //today = new Date('2025-08-01');
	   //today_formatted_date = format_date(today);
	}
	
	/*if(isHeightsResidencesClass){
	   today = new Date('2025-10-01');
	   today_formatted_date = format_date(today);
	}*/
	
	if(isVerdalaClass){
		setInterval(function() {
			$('.verdala_floating_book_btn').toggleClass('verdala_floating_book_btn_active');
			$('.verdala_floating_offer_btn').toggleClass('verdala_floating_offer_btn_active');
		}, 2000);
		
		if (screen.width <= 767) {
			$('.sticky_burger_menu_items_side .ax_burger_menu_item_single_hover_bg').each(function() {
				const randomRotation = Math.floor(Math.random() * 360);
				$(this).css('transform', `rotate(${randomRotation}deg)`);
			});
			
			$('.booking_form_menu_logo_cont img').attr('src', '/wp-content/uploads/2025/07/Verdala-Wellness-Hotel-Logo-Mobile.svg');
		}
		
		function handleHijiffyIcon() {
			if ($(window).scrollTop() >= 600) {
				$('.hi-widget-container').addClass('hi-widget-container-show');
			}
		}
		$(window).on('scroll', handleHijiffyIcon);
		
		if ($(window).scrollTop() >= 600) {
			$('.hi-widget-container').addClass('hi-widget-container-show');
		}
	}
	
    var adddays = today.setDate(today.getDate() + 1);
	var new_date = new Date(adddays);
	var end_date_formatted_date = format_date(new_date);
	var add_year = today.setFullYear(today.getFullYear() + 1);
	var date_add_year = new Date(add_year);
	
	var dateRangePicker = $('#date_range_picker').daterangepicker({
			startDate: today_formatted_date,
			endDate: end_date_formatted_date,
			minDate: today_formatted_date,
			maxDate: date_add_year,
			locale: {
				format: 'ddd, MMM D'
			},
			autoApply: true,
			drops: dropsValue
		}).data('daterangepicker');
	
	dateRangePicker.hide();
	
	var first_click = true;
  $('#date_range_picker').on('click', function() {
	  if(first_click != true){
		 var current_display = $('.daterangepicker').css('display');
		
		  if (current_display === 'block') {
			$('#date_range_picker').data('daterangepicker').hide();
		  } else {
			$('#date_range_picker').data('daterangepicker').show();
		  }
 		}
	 
    });
	
	$(window).scroll(function() {    
		$('#date_range_picker').data('daterangepicker').hide();
	});
	
	var startdate_picker = "";
	var enddate_picker = "";
	
	$('#date_range_picker').on('show.daterangepicker', function(ev, picker) {
		setTimeout(function() {
			first_click = false;
		  }, 100);	
	});
	
	
	$('#date_range_picker').on('hide.daterangepicker', function(ev, picker) {
		startdate_picker = moment(picker.startDate.format('YYYY-MM-DD'));
		enddate_picker = moment(picker.endDate.format('YYYY-MM-DD'));
		first_click = true;
	 	var nights = enddate_picker.diff(startdate_picker, 'days');		
		if(nights == 1){
			if($(".pagetranslated").hasClass("IT")){
			   $("#number_of_nights").text(nights + " Notte");
			} else if($(".pagetranslated").hasClass("FR")){
				$("#number_of_nights").text(nights + " Nuit");  
			} else if($(".pagetranslated").hasClass("PL")){
			 $("#number_of_nights").text(nights + " Noc");  
			} else if($(".pagetranslated").hasClass("DE")){
				$("#number_of_nights").text(nights + " Nacht");	  
			} else {
				$("#number_of_nights").text(nights + " Night");
			}		   
		} else {
			if($(".pagetranslated").hasClass("IT")){
			   $("#number_of_nights").text(nights + " Notti");
			} else if($(".pagetranslated").hasClass("FR")){
				$("#number_of_nights").text(nights + " Nuits");  
			} else if($(".pagetranslated").hasClass("PL")){
			 $("#number_of_nights").text(nights + " Noce");  
			} else if($(".pagetranslated").hasClass("DE")){
				$("#number_of_nights").text(nights + " Nächte");	  
			} else {
				$("#number_of_nights").text(nights + " Nights");
			}		
		}
	});
	
	function change_date_format_for_url(the_date){
		var date_format = new Date(the_date);
		var today = new Date();

        var year = date_format.getFullYear();
        var month = String(date_format.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed
        var day = String(date_format.getDate()).padStart(2, '0');
        var outputDateStr = year + "-" + month + "-" + day;
		
		return outputDateStr;
	}
	
	var if_promo_clicked = false;
	var if_date_changed = false;
	
	$('#date_range_picker').on('change', function() {
		if_date_changed = true;
    });
	
	$("#booking_form_btn").on("click", function (){
		var get_dates = $("#date_range_picker").val();
		var dates_array = get_dates.split(" - ");
		
		if(if_date_changed == true){
		   if(startdate_picker == ''){
				startdate_picker = moment($('#date_range_picker').data('daterangepicker').startDate.format('YYYY-MM-DD'));
				enddate_picker = moment($('#date_range_picker').data('daterangepicker').endDate.format('YYYY-MM-DD'));
			}
			var from_date = change_date_format_for_url(startdate_picker);
			var end_date = change_date_format_for_url(enddate_picker);
		} else {
			/*if(isVerdalaClass || isExcludedPage){
			    var start_verdala_day = new Date('2025-08-01');
				var from_date = change_date_format_for_url(start_verdala_day);
			    var start_verdala_day_formatted_date = format_date(start_verdala_day);			
				var adddays = start_verdala_day.setDate(start_verdala_day.getDate() + 1);
				var new_date = new Date(adddays);
				
				
				var end_date = change_date_format_for_url(new_date);	
				if_date_changed = true;
			} else {
				var from_date = '';
				var end_date = '';	
			}	*/	
			
			/*if(isHeightsResidencesClass){
				var start_verdala_day = new Date('2025-10-01');
					var from_date = change_date_format_for_url(start_verdala_day);
					var start_verdala_day_formatted_date = format_date(start_verdala_day);			
					var adddays = start_verdala_day.setDate(start_verdala_day.getDate() + 1);
					var new_date = new Date(adddays);


					var end_date = change_date_format_for_url(new_date);	
					if_date_changed = true;
			} else {
				var from_date = '';
				var end_date = '';
			}	*/
			
			var from_date = '';
			var end_date = '';
		}	

		var rooms = $("#room_number").val();
		var adult = $("#adults_number").val();
		var child = $("#children_number").val();
		var config = $(this).attr("data-config");
		var hotel = $(this).attr("data-hotel");
		var lang = $(this).attr("data-lang");
		var locale = $(this).attr("data-locale");
		var theme = $(this).attr("data-theme");
		if(if_promo_clicked == true){
		   var promo_code = 'UNLOCK25';
		 } else {
		   var promo_code = $("#promo_code").val();
		 }
		
		var child_ages = [];
			for (var i = 1; i <= child; i++) {
				var age = $("#children_age_"+ i +"_number").val();
			if (age) {
				child_ages.push(age);
			}
		}

		var url_with_child_age = '&childages=' + child_ages.join('%7C');
		
		if(theme == "axhotels"){
		   if(promo_code != ""){
			   if(if_date_changed == true){
				   window.location.href = 'https://secure.axhotelsmalta.com/?Lang='+ lang +'&adult='+ adult +'&arrive='+ from_date +'&brand=AX-HOTELS&brand=AX-HOTELS&chain=19159&child='+ child +'&config='+ config +'&currency=EUR&depart='+ end_date +'&level=chain&locale='+ locale +'&rooms='+ rooms +'&theme='+ theme +'&promo=' + promo_code + url_with_child_age, '_blank';
			   } else {
				    window.location.href = 'https://secure.axhotelsmalta.com/?Lang='+ lang +'&adult='+ adult +'&brand=AX-HOTELS&brand=AX-HOTELS&chain=19159&child='+ child +'&config='+ config +'&currency=EUR&level=chain&locale='+ locale +'&rooms='+ rooms +'&theme='+ theme +'&promo=' + promo_code + url_with_child_age, '_blank';
			   }
		   } else {			  
			   if(if_date_changed == true){
				   window.location.href = 'https://secure.axhotelsmalta.com/?Lang='+ lang +'&adult='+ adult +'&arrive='+ from_date +'&brand=AX-HOTELS&brand=AX-HOTELS&chain=19159&child='+ child +'&config='+ config +'&currency=EUR&depart='+ end_date +'&level=chain&locale='+ locale +'&rooms='+ rooms +'&theme='+ theme + url_with_child_age, '_blank';
			   } else {
				    window.location.href = 'https://secure.axhotelsmalta.com/?Lang='+ lang +'&adult='+ adult +'&brand=AX-HOTELS&brand=AX-HOTELS&chain=19159&child='+ child +'&config='+ config +'&currency=EUR&level=chain&locale='+ locale +'&rooms='+ rooms +'&theme='+ theme + url_with_child_age, '_blank';
			   }
		   }
		} else {
			if(promo_code != ""){
				if(if_date_changed == true){
				   window.location.href = 'https://secure.axhotelsmalta.com/?Lang='+ lang +'&adult='+ adult +'&arrive='+ from_date +'&brand=AX-HOTELS&chain=19159&child='+ child +'&config='+ config +'&currency=EUR&hotel='+ hotel +'&depart='+ end_date +'&level=hotel&locale='+ locale +'&rooms='+ rooms +'&theme='+ theme +'&promo=' + promo_code + url_with_child_age, '_blank';
			   } else {
				    window.location.href = 'https://secure.axhotelsmalta.com/?Lang='+ lang +'&adult='+ adult +'&brand=AX-HOTELS&chain=19159&child='+ child +'&config='+ config +'&currency=EUR&hotel='+ hotel +'&level=hotel&locale='+ locale +'&rooms='+ rooms +'&theme='+ theme +'&promo=' + promo_code + url_with_child_age, '_blank';
			   }
		   } else {			   
		   		if(if_date_changed == true){
				   window.location.href = 'https://secure.axhotelsmalta.com/?Lang='+ lang +'&adult='+ adult +'&arrive='+ from_date +'&brand=AX-HOTELS&chain=19159&child='+ child +'&config='+ config +'&currency=EUR&hotel='+ hotel +'&depart='+ end_date +'&level=hotel&locale='+ locale +'&rooms='+ rooms +'&theme='+ theme + url_with_child_age, '_blank';
			   } else {
				    window.location.href = 'https://secure.axhotelsmalta.com/?Lang='+ lang +'&adult='+ adult +'&brand=AX-HOTELS&chain=19159&child='+ child +'&config='+ config +'&currency=EUR&hotel='+ hotel +'&level=hotel&locale='+ locale +'&rooms='+ rooms +'&theme='+ theme + url_with_child_age, '_blank';
			   }
		   }
		}
	});
	
	$(".black_friday_bar_book_cont, .black_friday_bar_mobile_booking_bar").each(function(){
		$(this).on("click", function (){	
			if_promo_clicked = true;
			if ($(window).width() <= 600) {
				if(!$(".responsive").hasClass("pagetranslated")){
					window.location.href = '/hotel-deals/';
				} else {
					$('#booking_form_btn').trigger('click');
				}
			} else {
				$('#booking_form_btn').trigger('click');
			}				
		});
	});
	
	var mob_startdate_picker = '';
	var mob_enddate_picker = '';
	
	$('#mobile_menu_date_range_picker').on('hide.daterangepicker', function(ev, picker) {
		mob_startdate_picker = moment(picker.startDate.format('YYYY-MM-DD'));
		mob_enddate_picker = moment(picker.endDate.format('YYYY-MM-DD'));
	});
	
	$(".mobile_booking_search_cont").each(function(){
		$(this).on("click", function (){
			var get_dates = $("#mobile_menu_date_range_picker").val();
			var dates_array = get_dates.split(" - ");
			
			if(mob_startdate_picker == ''){
			   mob_startdate_picker = moment($('#mobile_menu_date_range_picker').data('daterangepicker').startDate.format('YYYY-MM-DD'));
			   mob_enddate_picker = moment($('#mobile_menu_date_range_picker').data('daterangepicker').endDate.format('YYYY-MM-DD'));
			}
			
			if(if_date_changed == true){
		   if(startdate_picker == ''){
				startdate_picker = moment($('#mobile_menu_date_range_picker').data('daterangepicker').startDate.format('YYYY-MM-DD'));
				enddate_picker = moment($('#mobile_menu_date_range_picker').data('daterangepicker').endDate.format('YYYY-MM-DD'));
			}
			var from_date = change_date_format_for_url(startdate_picker);
			var end_date = change_date_format_for_url(enddate_picker);
		} else {
			if(isVerdalaClass || isExcludedPage){
			    var start_verdala_day = new Date('2025-08-01');
			    var start_verdala_day_formatted_date = format_date(start_verdala_day);			
				var adddays = start_verdala_day.setDate(start_verdala_day.getDate() + 1);
				var new_date = new Date(adddays);
				
				var from_date = change_date_format_for_url(start_verdala_day);
				var end_date = change_date_format_for_url(new_date);	
				if_date_changed = true;
			} if(isHeightsResidencesClass){
			    var start_verdala_day = new Date('2025-08-15');
			    var start_verdala_day_formatted_date = format_date(start_verdala_day);		
				var from_date = change_date_format_for_url(start_verdala_day);
				var adddays = start_verdala_day.setDate(start_verdala_day.getDate() + 1);
				var new_date = new Date(adddays);
							
				var end_date = change_date_format_for_url(new_date);	
				if_date_changed = true;
			} else {
				var from_date = '';
				var end_date = '';	
			}	
		}	
			
			var rooms = 1;
			var adult = $("#num_adults").val();
			var child = $("#num_children").val();
			
			var child_ages = [];
			for (var i = 1; i <= child; i++) {
				var age = $("#num_children_age_" + i).val();
				if (age) {
					child_ages.push(age);
				}
			}

			var url_with_child_age = '&childages=' + child_ages.join('%7C');
						
			var config = $(this).attr("data-config");
			var hotel = $(this).attr("data-hotel");
			var lang = $(this).attr("data-lang");
			var locale = $(this).attr("data-locale");
			var theme = $(this).attr("data-theme");
			var promo_code = $("#mobile_promo_input").val();
			if ($(window).width() <= 600) {
					if(theme == "axhotels"){
						
						if(if_date_changed == true){
				  window.location.href = 'https://secure.axhotelsmalta.com/?Lang='+ lang +'&adult='+ adult +'&arrive='+ from_date +'&brand=AX-HOTELS&brand=AX-HOTELS&chain=19159&child='+ child + url_with_child_age +'&config='+ config +'&currency=EUR&depart='+ end_date +'&level=chain&locale='+ locale +'&rooms='+ rooms +'&theme='+ theme +'&promo=' + promo_code;
			   } else {
				    window.location.href = 'https://secure.axhotelsmalta.com/?Lang='+ lang +'&adult='+ adult +'&brand=AX-HOTELS&brand=AX-HOTELS&chain=19159&child='+ child + url_with_child_age +'&config='+ config +'&currency=EUR&level=chain&locale='+ locale +'&rooms='+ rooms +'&theme='+ theme +'&promo=' + promo_code;
			   }
					} else {
						
						if(if_date_changed == true){
				  window.location.href = 'https://secure.axhotelsmalta.com/?Lang='+ lang +'&adult='+ adult +'&arrive='+ from_date +'&brand=AX-HOTELS&chain=19159&child='+ child + url_with_child_age +'&config='+ config +'&currency=EUR&hotel='+ hotel +'&depart='+ end_date +'&level=hotel&locale='+ locale +'&rooms='+ rooms +'&theme='+ theme +'&promo=' + promo_code;
			   } else {
				    window.location.href = 'https://secure.axhotelsmalta.com/?Lang='+ lang +'&adult='+ adult +'&brand=AX-HOTELS&chain=19159&child='+ child + url_with_child_age +'&config='+ config +'&currency=EUR&hotel='+ hotel +'&level=hotel&locale='+ locale +'&rooms='+ rooms +'&theme='+ theme +'&promo=' + promo_code;
			   }
					}
			}
		});
	});
	
	$("#promo_remove").on("click", function(){
		$("#promo_code").val("").focus();
	});
	
	$(".single_hotel_main_menu_footer_inner .sub_menu, .sticky_burger_menu_items_footer .sub_menu").each(function(){
		$(this).parent().addClass("hide_hover_border");
		$(this).parent().addClass("enable_hover_sub_menu");
	});
	
	$(".single_hotel_main_menu_footer_inner .sub_menu, .sticky_burger_menu_items_footer .sub_menu").each(function(){
		$(this).mouseover(function(){
			$(this).parent().parent().addClass("show_overlay");
		});
	});
	
	$(".enable_hover_sub_menu").each(function(){
		$(this).mouseover(function(){
			$(this).parent().addClass("show_overlay");
		});
	});
	
	$(".single_hotel_main_menu_footer_inner .sub_menu, .sticky_burger_menu_items_footer .sub_menu").each(function(){
		$(this).mouseout(function(){
			$(this).parent().parent().removeClass("show_overlay");
		});
	});
	
	$(".enable_hover_sub_menu").each(function(){
		$(this).mouseout(function(){
			$(this).parent().removeClass("show_overlay");
		});
	});
	
		$(document).on("click", ".mob_filter_selected" , function(evt) {
			evt.stopImmediatePropagation();
			$(this).toggleClass("active_select");
			$(this).parent().parent().find(".mob_filter_options_cont").toggleClass("show_dropdown");
		});
	
		$(document).on("scroll", function (evt) {
				$(".mob_filter_selected").removeClass("active_select");
				$(".mob_filter_options_cont").removeClass("show_dropdown");
		});
	
		$(document).on("click", ".mob_filter_options_cont .single_mob_filter" , function() {
			var get_text = $(this).html();
			$(".mob_filter_options_cont .single_mob_filter").each(function(){
				$(this).removeClass("selected_mob_filter");
			});
			if(!$('#top').hasClass('single-news')){
				$(this).addClass("selected_mob_filter");	
			    $(this).parent().parent().find(".mob_filter_selected span").html(get_text);
				$(this).parent().parent().find(".mob_filter_selected").removeClass("active_select");	
			}			
			$(this).parent().toggleClass('show_dropdown');
		});
	
	$(".mob_lang_nav").on("click",function(evt){
		evt.stopImmediatePropagation();
		$(this).toggleClass("mob_active_sub_menu");
	});
	
	$(window).scroll(function() {    
		$(".mob_lang_nav").removeClass("mob_active_sub_menu");
	});
	
	$("#mob_burger_menu_more_btn").on("click",function(){
		$(this).parent().addClass("burger_menu_hide");
		$(".sticky_burger_menu_items_inner").removeClass("burger_menu_hide");
	});
	
	$("#mob_burger_menu_back_btn").on("click",function(){
		$(this).parent().addClass("burger_menu_hide");
		$(".sticky_burger_menu_items_side").removeClass("burger_menu_hide");
	});
	
	if ($(window).width() <= 767) {
		$(".ax_burger_menu_item_single").each(function (){
			$(this).on("click", function (evt){
				evt.stopImmediatePropagation();
				$(this).closest(".sticky_burger_menu_items_cont").removeClass("active_inner_sticky_burger_menu");
				$("#sticky_burger_menu").removeClass("active_sticky_burger_menu");
				$(".booking_form_menu_cont").removeClass("mobile_scroll_menu");
				$('body, html').removeClass("scroll-disabled");		
			});
		});
	}
	
	$(".single_hotel_main_menu_mob_dropdown_cont").on("click",function(evt){
		evt.stopImmediatePropagation();
		$(this).find(".sub_single_hotel_menu").toggleClass("burger_menu_hide");
	});
	
	var lastScrollTop = 0;
	var offsetThreshold = 100;
	
            $(window).scroll(function(event) {
                var st = $(this).scrollTop();
				if ($(window).scrollTop() < offsetThreshold) {
				   $('.single_hotel_main_menu_cont').removeClass("mob_menu_down");
						$('#mobile_book_btn').removeClass("mobile_book_btn_show");
						$('.mobile_book_btn_alt_cont').removeClass("mobile_book_btn_show");
						$('#top.page-id-32219').removeClass("transparent_menu_anim");
						$('#top.page-id-34969').removeClass("transparent_menu_anim");
				} else {
					if (st > lastScrollTop){			
						$('#top.page-id-32219').addClass("transparent_menu_anim");
						$('#top.page-id-34969').addClass("transparent_menu_anim");
						$('.single_hotel_main_menu_cont').addClass("mob_menu_down");
						if(!$("#sticky_burger_menu").hasClass("active_sticky_burger_menu")){
							if(!$(".responsive").hasClass("hotelchildpage")){
								if(!$(".responsive").hasClass("pagetranslated")){
						   			$('.booking_form_menu_cont').addClass("mob_menu_up");
								}
							}
						}		
						   $('#mobile_book_btn').addClass("mobile_book_btn_show");
							$('.mobile_book_btn_alt_cont').addClass("mobile_book_btn_show");
					} else {					
						$('.single_hotel_main_menu_cont').removeClass("mob_menu_down");
						$('.single_hotel_main_menu_cont').removeClass("mob_menu_down");
						if(!$(".responsive").hasClass("hotelchildpage")){
							if(!$(".responsive").hasClass("pagetranslated")){
						   		$('.booking_form_menu_cont').removeClass("mob_menu_up");
							}
						 }
						
					}
				}

                lastScrollTop = st;
            });
	
	
	
	$('.avia_codeblock:contains("[avia_codeblock_placeholder uid=”0″]")').css('display', 'none');
	
	$(".mob_filter_cont").each(function(){
		$(this).closest('.avia-section').addClass("mob_z_index");
	});
	
	$(window).scroll(function () {
		var documentHeight = $(document).height();
		var scrollPosition = $(window).scrollTop();
		var halfPage = documentHeight / 5;

		if (scrollPosition > halfPage) {
		  $("#mobile_back_to_top").addClass("show_back_to_top");
		} else {
		  $("#mobile_back_to_top").removeClass("show_back_to_top");
		}
	  });
	
	$(document).on("click", function (e) {
		if(!$(e.target).closest("#sticky_burger_menu").is("#sticky_burger_menu")){
		   if(!$(e.target).is(".sticky_burger_menu_items_wrapper, .sticky_burger_menu_items_footer, #mob_burger_menu_more_btn, #mob_burger_menu_more_btn .btn_icon, #mob_burger_menu_back_btn, #mob_burger_menu_back_btn .btn_icon")){
			   $(".sticky_burger_menu_items_cont").removeClass("active_inner_sticky_burger_menu");
				$("#sticky_burger_menu").removeClass("active_sticky_burger_menu");		
			}
		} 
    });
	
		$(document).on("click","#contact_popup, #christmas_cards_contact_inline", function(){
			$("#desktop_contact_us_popup").show();		
		});
	
	if (screen.width <= 767) {
		$(document).on("click",".mob_christmas_main_cards", function(){
			 $(".mob_main_sections").each(function (){
				   $(this).hide();
			   });
			$("#christmas_discover").addClass("mob_bg_grey");
			if($(this).hasClass("qawra")){
				$(".mob_christmas_location").each(function(){
					if($(this).hasClass("qawra")){
					   $(this).addClass("show_christmas_location");
					   $(this).addClass("show_christmas_location_bg_white");		   
					}
				});				   
			} else if($(this).hasClass("sliema")){
			   $(".mob_christmas_location").each(function(){
					if($(this).hasClass("sliema")){
					   $(this).addClass("show_christmas_location");
					   $(this).addClass("show_christmas_location_bg_white");
					}
				});	
			} else if($(this).hasClass("valletta")){
			  $(".mob_christmas_location").each(function(){
					if($(this).hasClass("valletta")){
					   $(this).addClass("show_christmas_location");
					   $(this).addClass("show_christmas_location_bg_white");
					}
				});	
			} else if($(this).hasClass("gift_vouchers")){
			  $(".mob_christmas_location").each(function(){
					if($(this).hasClass("gift_vouchers")){
					    $(this).addClass("show_christmas_location");
						$("#christmas_discover").addClass("mob_onclick_white_bg");
						$("#christmas_discover").removeClass("mob_bg_grey");
						$(".mob_on_click_white").each(function(){
							$(this).addClass("mob_bg_white");
						});
					}
				});	
			}
			$(window).scrollTop(0);	
		});
		
		$(document).on("click",".christmas_single_location_mob_back_btn", function(){
				$(".show_christmas_location").addClass("close_christmas_location");
				  setTimeout(
				  function() 
				  {
					$(".show_christmas_location").removeClass("show_christmas_location");			 
					$(".show_christmas_location").removeClass("show_christmas_location_bg_white");
					$("#christmas_discover").removeClass("mob_onclick_white_bg");
					$("#christmas_discover").removeClass("mob_bg_grey");
					$(".mob_main_sections").each(function (){
					   $(this).show();
					});
				  }, 800);
		});
		
		$(document).on("click","#christmas_contact_us", function(){
			$('.mob_christmas_location').removeClass("close_christmas_location");
			$(".mob_main_sections").each(function (){
				$(this).hide();
			});
			$("#christmas_discover").addClass("mob_bg_grey");
			$(".mob_christmas_location").each(function(){
				$(this).removeClass("show_christmas_location");
				$(this).removeClass("show_christmas_location_bg_white");
				$("#christmas_discover").removeClass("mob_onclick_white_bg");
				if($(this).hasClass("christmas_contact_us_sect")){
					$(this).addClass("show_christmas_location");
					$(this).addClass("show_christmas_location_bg_white");
				}
			});	
			$(this).hide();
			$(window).scrollTop(0);	
		});
		
		$(document).on("click",".christmas_single_location_mob_back_btn_contact", function(){
			$("#christmas_contact_us").css("display","grid");
		});
	}
	
	$(window).scroll(function () {
		var documentChristmasHeight = $(document).height();
		var scrollChristmasPosition = $(window).scrollTop();
		var halfChristmasPage = 500;

		if (scrollChristmasPosition > halfChristmasPage) {
			$("#christmas_page_btn").addClass("show_christmas_page_btn");
		} else {
		    $("#christmas_page_btn").removeClass("show_christmas_page_btn");
		}
	  });
	
	if($("#top").hasClass("page-id-21514")){
		$("#mobile_back_to_top, #mobile_book_btn").remove();   
	}
	
	$(document).on('click', function (event) {
      var activeRoomsDiv = $('#rooms_guests_cont');
      var childrenGuestsDiv = $('#children_guests_cont');
		var noRemovalDiv = $('#book_rooms_guests_cont');
		if(activeRoomsDiv.hasClass("active_rooms_guests_cont")){
		    // Check if the clicked element is not within activeRoomsDiv or its children (except childrenGuestsDiv)
      if (!activeRoomsDiv.is(event.target) && activeRoomsDiv.has(event.target).length === 0 &&
            !childrenGuestsDiv.is(event.target) && childrenGuestsDiv.has(event.target).length === 0 &&
            !noRemovalDiv.is(event.target) && noRemovalDiv.has(event.target).length === 0) {
          activeRoomsDiv.removeClass('active_rooms_guests_cont');
		  childrenGuestsDiv.removeClass('active_rooms_guests_cont');
        }
		   }
	});
	
	/*$(document).on("click", ".hotel_accordian_header_wrapper" , function() {
		$(this).closest(".av-layout-tab-inner").css("height", "fit-content");
		$(this).closest(".av-tab-section-outer-container").css("max-height", "fit-content");
		$(this).closest(".av-tab-section-outer-container").css("height", "fit-content");
		setTimeout(function() {
			var get_inner_height = $('#top .av-active-tab-content .av-layout-tab-inner').height() + 126;
			$('#top .ax_axhotels_faqs_search .av-tab-section-outer-container').attr('style', 'height: '+ get_inner_height +'px !important');
		}, 1000);
	});
	
	$(document).on("click", ".av-section-tab-title" , function() {
		var get_height = $('.av-active-tab-content').find(".av-layout-tab-inner").height();
		$('.av-active-tab-content').find(".av-tab-section-outer-container").css("height", get_height + 88);
		$('.av-active-tab-content').find(".av-tab-section-outer-container").css("max-height", get_height + 88);
	});*/
	
	$('.mob_filter_cont_with_search .search_filter_btn_posts').on('click', function(){
		if(!$(this).hasClass('search_filter_btn_active')){
		   $(this).parent().find('.mob_filter_selected .single_mob_filter').toggleClass('single_mob_filter_active_search');
		}		
	});
	
	$('#share_button').on('click', function(){
		$(this).parent().find('.share_icons_cont').toggleClass('share_icons_cont_active');
	});
	
	if (screen.width <= 600) {	
		function toggleClasses() {
			const mainBtn = document.getElementById('mobile_book_btn_alt');
			const subBtn = document.getElementById('mobile_book_btn_alt_sub');
			if (mainBtn.classList.contains('pt-page-rotateCubeTopOut')) {
				mainBtn.classList.remove('pt-page-rotateCubeTopOut');
				mainBtn.classList.add('pt-page-rotateCubeTopIn');
			  } else {
				mainBtn.classList.remove('pt-page-rotateCubeTopIn');
				mainBtn.classList.add('pt-page-rotateCubeTopOut');
			  }

			  if (subBtn.classList.contains('pt-page-rotateCubeTopOut')) {
				subBtn.classList.remove('pt-page-rotateCubeTopOut');
				subBtn.classList.add('pt-page-rotateCubeTopIn');
			  } else {
				subBtn.classList.remove('pt-page-rotateCubeTopIn');
				subBtn.classList.add('pt-page-rotateCubeTopOut');
			  }
		  }

		  setInterval(toggleClasses, 5000);
		
		$(".clear_promo_input").on("click", function (){
			$("#mobile_promo_input").val("");
			$(".promo_code_btn").removeClass("promo_code_applied");
			var get_translated_main_text = $(".promo_code_btn").attr("data-main-applied");
			$(".promo_code_btn").text(get_translated_main_text);
		});
		
		$(".promo_code_btn").on("click", function (){
			$(this).addClass("promo_code_applied");
			$(this).text("PROMO APPLIED!");
			var get_code = $(this).attr('data-code');
			$("#mobile_promo_input").val(get_code);
			var get_translated_text = $(".promo_code_btn").attr("data-applied");
			$(this).text(get_translated_text);
		});
		
		$("#mobile_children_select .single_mobile_input_number_plus, .mobile_booking_ages_cont .single_mobile_input_inner_cont .single_mobile_input_number_plus, #single_mobile_input_number_plus_adults").each(function(){
			$(this).on("click", function(){
				$(this).parent().find("input").val( function(i, oldval) {
					var get_max = $(this).attr("max");

					if(oldval == get_max){
					   return oldval;
					} else {
						return ++oldval;
					}			
				});
			});
		});

		$("#mobile_children_select .single_mobile_input_number_minus, .mobile_booking_ages_cont .single_mobile_input_inner_cont .single_mobile_input_number_minus, #single_mobile_input_number_minus_adults").each(function(){
			$(this).on("click", function(){
				$(this).parent().find("input").val( function(i, oldval) {
					var get_min = $(this).attr("min");

					if(oldval == get_min){
					   return oldval;
					} else {
						return --oldval;
					}			
				});
			});
		});
		
		$("#mobile_children_select .single_mobile_input_number_plus").each(function(){
			$(this).on("click", function(){
				$(this).parent().find("input").val( function(i, oldval) {	
					$(".mobile_booking_age_" + oldval).addClass("age_child_input_active");				
					return oldval;
				});
			});
		});

		$("#mobile_children_select .single_mobile_input_number_minus").each(function(){
			$(this).on("click", function(){
				$(this).parent().find("input").val( function(i, oldval) {			
					var val = parseInt(oldval) + 1;
					$(".mobile_booking_age_" + val).removeClass("age_child_input_active");
					return oldval;
				});
			});
		});
		
		var dateRangePickerMobile = $('#mobile_menu_date_range_picker').daterangepicker({
			startDate: today_formatted_date,
			endDate: end_date_formatted_date,
			minDate: today_formatted_date,
			maxDate: date_add_year,		
			parentEl: ".mobile_inputs_date_section_cont",
			locale: {
				format: 'ddd, MMM D',
				monthNames: moment.months(),
				daysOfWeek: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
			}
		}).data('daterangepicker');
		
		setTimeout(
			function() 
			 {
		/*$('.mobile_inputs_date_section_cont .drp-calendar.right').hide();*/
  		$('.mobile_inputs_date_section_cont .drp-calendar.left').addClass('single');
		/*$('.mobile_inputs_date_section_cont .calendar-table').on('DOMSubtreeModified', function() {		
			var el = $(".mobile_inputs_date_section_cont .month").parent().children().last();
			console.log('test');
			if (el.hasClass('next available')) {
			  return;
			}
			el.addClass('next available');
			el.append('<span></span>');
		  });*/
		 }, 500);
		
		
		$("#mobile_menu_date_range_picker").on("click", function(){
			$('.mobile_inputs_date_section_cont').addClass("mobile_inputs_date_section_cont_active");
			$('.mobile_inputs_date_section_cont .cancelBtn').text("Clear");
			$('.mobile_inputs_date_section_cont .applyBtn').text("Confirm Dates");
		});
		
		$(".mobile_inputs_date_section_close, .mobile_inputs_date_section_cont .applyBtn").on("click", function(){
			$('.mobile_inputs_date_section_cont').removeClass("mobile_inputs_date_section_cont_active");
		});
		
		$('#mobile_menu_date_range_picker').on('cancel.daterangepicker', function(ev, picker) {
			ev.preventDefault();
			$('.mobile_inputs_date_section_cont .daterangepicker').addClass('keep_visible');
			$('#mobile_menu_date_range_picker').data('daterangepicker').setStartDate(today_formatted_date);
			$('#mobile_menu_date_range_picker').data('daterangepicker').setEndDate(end_date_formatted_date);
			$('#mobile_menu_date_range_picker').trigger("click");
		});
		
		$("#mobile_book_btn_alt, #mobile_book_btn_alt_sub, .verdala_floating_offer_btn, .verdala_floating_book_btn, .verdala_btn_room_check_availability").on("click", function(){
			$("#mobile_booking_cont").addClass("mobile_booking_cont_active");
			setTimeout(
			function() 
			 {
				$('#mobile_booking_cont').addClass('mobile_booking_cont_left_active');
			 }, 500);
			$('body, html').addClass('scroll-disabled');
			$('.booking_form_menu_cont').removeClass('mob_menu_up');
		});
		
		$('.mobile_booking_bar_cont_mobile').on("click", function(){
			$('#mobile_book_btn_alt').trigger('click');
			$('.booking_form_menu_cont').addClass('show_scroll_menu');
		});
		
		$(".close_mobile_booking").on("click", function(){		
			$('#mobile_booking_cont').removeClass('mobile_booking_cont_left_active');
			setTimeout(
			  function() 
			  {
				$("#mobile_booking_cont").removeClass("mobile_booking_cont_active");
			  }, 1000);
			if ($(window).scrollTop() === 0 && $('#top').hasClass('home')) {
				$('.booking_form_menu_cont').removeClass('show_scroll_menu');
			}
			$('body, html').removeClass('scroll-disabled');
		});
		
	}
	
	$('.gfield--type-text input, .gfield--type-email input, .gfield--type-textarea textarea').each(function() {
        if ($(this).val().trim() !== '') {
            $(this).closest('.gfield').addClass('focused_input focused_input_border');
        }
    });
	
	$('.newsletter_dob_cont .ginput_container_date input').each(function() {
		var value = $(this).val();
		if (value.indexOf('/') !== -1) {
			$(this).closest('.gfield').addClass('focused_input focused_input_border');
		}
    });
	
	$(document).on('focus', '.gfield--type-text input, .gfield--type-email input, .gfield--type-textarea textarea', function() {
        $(this).closest('.gfield').addClass('focused_input');
		$(this).closest('.gfield').addClass('focused_input_border');
    });
	
	$(document).on('focus', '.gfield--type-date input', function() {
        $(this).closest('.gfield').addClass('focused_input');
		$(this).closest('.gfield').addClass('focused_input_border');
		if($(this).val() == ''){
			if(isVerdalaClass){
				$(this).val('Select The Date');
			} else {
				$(this).val('Select a Date');
			}
		}	
    });
	
    $(document).on('blur', '.gfield--type-text input, .gfield--type-email input, .gfield--type-textarea textarea', function() {
        if ($(this).val().trim() === '') {
            $(this).closest('.gfield').removeClass('focused_input');
			$(this).closest('.gfield').removeClass('focused_input_border');
        }	
    });
	
	$(document).on('click', '.gform_button', function() {
		setTimeout(
			  function() 
			  {
		$('.gfield').each(function() {
			if ($(this).hasClass('gfield_error') && $(this).find('input, textarea').val() != '') {
				$(this).addClass('focused_input');
			} else if($(this).find('input, textarea').val() != '') {
				$(this).addClass('focused_input focused_input_border');
			}
		});
				  }, 1000);
	});
	 
		if ($('.swiper-main-slider').length) {
        function isInViewport(element) {
            var elementTop = element.offset().top;
            var elementBottom = elementTop + element.outerHeight();
            var viewportTop = $(window).scrollTop();
            var viewportBottom = viewportTop + $(window).height();
            return elementBottom > viewportTop && elementTop < viewportBottom;
        }

        function checkVisibility() {
            if (isInViewport($('.swiper-main-slider'))) {
                $('#weddings_page_btn').addClass('hide_wedding_fair');
				$('.gift_vouchers_btn_cont').addClass('hide_gift_btn');
            } else {
                $('#weddings_page_btn').removeClass('hide_wedding_fair');
				$('.gift_vouchers_btn_cont').addClass('hide_gift_btn');
            }
        }

        $(window).on('scroll resize', function() {
            checkVisibility();
        });

        // Initial check on page load
        checkVisibility();
    }
	
	$('.read_more_button').on('click', function() {
         $('.read_more_text').slideToggle();
         var buttonText = $(this).text().trim() === 'Read More' ? 'Read Less' : 'Read More';
         $(this).find('span').text(buttonText);
         $(this).toggleClass('rotated');
    });
	
	$(document).on("click",".close_room_details_cont, .close_room_details_cont *", function(){
			if (screen.width <= 767) {
				$('.burger_menu_cont').removeClass('burger_menu_cont_hide');
			}
	  });
	
	$(document).on("click",".main_newsletter_form_cont .newsletter_accordion_cont .gfield_label", function(){
		$(this).parent().find('.ginput_container_checkbox').slideToggle();
		$(this).parent().toggleClass('newsletter_accordion_active');
	});
	
	if($('#top').hasClass('page-id-30534')){
		$('.main_newsletter_form_cont .newsletter_accordion_cont_hotels .gfield_label').trigger('click');  
		
		$('#input_41_12').datepicker({
			dateFormat: 'dd/mm/yy',
												changeMonth: true,
											changeYear: true,
											yearRange: "-100:+0",
											maxDate: new Date(),
											monthNamesShort: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
											showOtherMonths: true, // Display dates of other months
											selectOtherMonths: false, 
												beforeShow: function(input, inst) {
													$(inst.dpDiv).addClass('gform-theme-datepicker gravity-theme');
												}
											});
	}
	
	$('#choice_41_2_8').change(function() {
        $('.newsletter_accordion_cont_hotels input[type="checkbox"]').not(this).prop('checked', this.checked);
    });
	
	$('#choice_41_13_12').change(function() {
        $('.newsletter_accordion_cont_restaurants input[type="checkbox"]').not(this).prop('checked', this.checked);
    });
	
	$(document).on("click", "#send_another_message, #send_another_message_mobile" , function(e) {
			e.preventDefault();
			var baseUrl = window.location.origin + window.location.pathname;
			var paramKey = "popup";
			var paramValue = "send-new-message";
			var newUrl = baseUrl + "?" + paramKey + '=' + paramValue;
			window.location.href = newUrl;	
	});
	
	var currentUrl = window.location.href;

    var urlParams = new URLSearchParams(window.location.search);
    if (urlParams.has('popup') && urlParams.get('popup') === 'send-new-message') {
		if (screen.width <= 767) {
			$("#christmas_contact_us").trigger('click');			
		} else {
			$("#desktop_contact_us_popup").show();
		}	
    }
	
	$('.single_hotel_full_menu_inner_offer').mouseover(function(){
		$('.global_bar_sale_dropdown_cont').addClass('hover_offer_active');
	});
	
	$('.single_hotel_full_menu_inner_offer').mouseout(function(){
		$('.global_bar_sale_dropdown_cont').removeClass('hover_offer_active');
	});
	
	$('#mobile_menu_date_range_picker').on('change', function() {
		if (!if_date_changed) {
			if_date_changed = false;
		} else {
			if_date_changed = true; 
		}
		if_date_changed = true;
	});
	
	$(window).on('scroll', function() {
		var scrollPosition = $(window).scrollTop();
		var offset = 150; 
		if (screen.width > 767) {
			if ($('.single_hotels_christmas_sect').length > 0) {
				var christmasSectionTop = $('.single_hotels_christmas_sect').offset().top - offset;
			}
			
			if (scrollPosition >= christmasSectionTop) {
				$('.single_hotel_full_menu_cont').addClass('single_hotel_full_menu_cont_show');
				$('.global_bar_cont').addClass('global_bar_cont_hide');
				$('.single_hotel_main_menu_cont').addClass('single_hotel_main_menu_cont_up');
				$('.booking_form_menu_inner').addClass('booking_form_menu_inner_scroll');
			} else {
				$('.single_hotel_full_menu_cont').removeClass('single_hotel_full_menu_cont_show');
				$('.global_bar_cont').removeClass('global_bar_cont_hide');
				$('.single_hotel_main_menu_cont').removeClass('single_hotel_main_menu_cont_up');
				$('.booking_form_menu_inner').removeClass('booking_form_menu_inner_scroll');
			}
		}
	});
	
});
// source --> https://axhotelsmalta.com/wp-content/themes/enfold-child/extra-js/open_popup_button_tab.js 
jQuery(document).ready(function($) {
	$(".open_popup_tab_btn").each(function(){
		$(this).on("click", function(){
			var get_tab_title = $(this).attr("data-tab");
			$(".single_filter_cont").each(function(){
				$(this).removeClass("active_filter");
			});
			
			$('.single_filter_cont[data-tab="'+get_tab_title+'"]').addClass('active_filter');
			
			$(".single_tab_cont").each(function(){
				$(this).removeClass("active_main_tab_content");
			});		
			
			if (screen.width <= 767) {
				$('.single_mob_filter[data-tab="'+get_tab_title+'"]').trigger("click");
				$('.single_tab_cont[data-tab="'+get_tab_title+'"]').addClass('active_main_tab_content');		
				$(".mob_filter_options_cont").removeClass("show_dropdown");
				$('html, body').scrollTop($("#anchor_main").offset().top - 200);
			} else {
				$('.single_tab_cont[data-tab="'+get_tab_title+'"]').addClass('active_main_tab_content');		
				$('html, body').scrollTop($("#anchor_main").offset().top - 250);
			}
			
		});
	});
});