Advertisement
Guest User

Untitled

a guest
Mar 15th, 2018
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 163.50 KB | None | 0 0
  1. (function($)
  2. {  
  3.     "use strict";
  4.  
  5.     $(document).ready(function()
  6.     {  
  7.         //global variables that are used on several ocassions
  8.         $.avia_utilities = $.avia_utilities || {};
  9.        
  10.         if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && 'ontouchstart' in document.documentElement)
  11.         {
  12.             $.avia_utilities.isMobile =  true;
  13.         }
  14.         else
  15.         {
  16.             $.avia_utilities.isMobile =  false;
  17.         }
  18.    
  19.         //activate fixed bg fallback for mobile
  20.         if($.fn.avia_mobile_fixed)
  21.         $('.avia-bg-style-fixed').avia_mobile_fixed();
  22.        
  23.         //activate parallax scrolling for backgrounds.
  24.         if($.fn.avia_parallax)
  25.         $('.av-parallax').avia_parallax();
  26.        
  27.         //calculate the browser height and append a css rule to the head
  28.         if($.fn.avia_browser_height)
  29.         $('.av-minimum-height, .avia-fullscreen-slider, .av-cell-min-height').avia_browser_height();
  30.        
  31.         //calculate the height of each video section
  32.         if($.fn.avia_video_section)
  33.          $('.av-section-with-video-bg').avia_video_section();
  34.        
  35.         //creates team social icon tooltip
  36.         new $.AviaTooltip({'class': "avia-tooltip", data: "avia-tooltip", delay:0, scope: "body"});
  37.        
  38.         //creates icon element tooltip
  39.         new $.AviaTooltip({'class': "avia-tooltip avia-icon-tooltip", data: "avia-icon-tooltip", delay:0, scope: "body"});
  40.  
  41.         activate_shortcode_scripts();
  42.        
  43.         //layer slider height helper
  44.         $('.avia-layerslider').layer_slider_height_helper();
  45.        
  46.         //"ajax" portfolio
  47.         $('.grid-links-ajax').avia_portfolio_preview();
  48.        
  49.         // actiavte the masonry script: sorting/loading/etc
  50.         if($.fn.avia_masonry)
  51.         $('.av-masonry').avia_masonry();
  52.        
  53.         //activate the accordion
  54.         if($.fn.aviaccordion)
  55.         $('.aviaccordion').aviaccordion();
  56.        
  57.        
  58.         //activate the accordion
  59.         if($.fn.avia_textrotator)
  60.         $('.av-rotator-container').avia_textrotator();
  61.        
  62.         //activates the tab section shortcode
  63.         if($.fn.avia_sc_tab_section)
  64.         {
  65.             $('.av-tab-section-container').avia_sc_tab_section();
  66.         }
  67.        
  68.         //activates the hor gallery  shortcode
  69.         if($.fn.avia_hor_gallery)
  70.         {
  71.             $('.av-horizontal-gallery').avia_hor_gallery();
  72.         }
  73.        
  74.        
  75.         if($.fn.avia_delayed_animation_in_container)
  76.         {
  77.             $('.av-animation-delay-container').avia_delayed_animation_in_container();
  78.         }
  79.        
  80.        
  81.     });
  82.  
  83.  
  84.  
  85.  
  86.  
  87. // -------------------------------------------------------------------------------------------
  88. // ACTIVATE ALL SHORTCODES
  89. // -------------------------------------------------------------------------------------------
  90.  
  91.     function activate_waypoints(container)
  92.     {
  93.         //activates simple css animations of the content once the user scrolls to an elements
  94.         if($.fn.avia_waypoints)
  95.         {
  96.             if(typeof container == 'undefined'){ container = 'body';};
  97.  
  98.             $('.avia_animate_when_visible', container).avia_waypoints();
  99.             $('.avia_animate_when_almost_visible', container).avia_waypoints({ offset: '80%'});
  100.            
  101.             if(container == 'body') container = '.avia_desktop body';
  102.             $('.av-animated-generic', container).avia_waypoints({ offset: '95%'});
  103.         }
  104.     }
  105.  
  106.  
  107.     function activate_shortcode_scripts(container)
  108.     {
  109.         if(typeof container == 'undefined'){ container = 'body';}
  110.        
  111.         //activates the form shortcode
  112.         if($.fn.avia_ajax_form)
  113.         {
  114.             $('.avia_ajax_form:not( .avia-disable-default-ajax )', container).avia_ajax_form();
  115.         }
  116.        
  117.         activate_waypoints(container);
  118.        
  119.         //activate the video api
  120.         if($.fn.aviaVideoApi)
  121.         {
  122.             $('.avia-slideshow iframe[src*="youtube.com"], .av_youtube_frame, .avia-slideshow iframe[src*="vimeo.com"], .avia-slideshow video').aviaVideoApi({}, 'li');
  123.         }
  124.        
  125.         //activates the toggle shortcode
  126.         if($.fn.avia_sc_toggle)
  127.         {
  128.             $('.togglecontainer', container).avia_sc_toggle();
  129.         }
  130.        
  131.         //activates the tabs shortcode
  132.         if($.fn.avia_sc_tabs)
  133.         {
  134.             $('.top_tab', container).avia_sc_tabs();
  135.             $('.sidebar_tab', container).avia_sc_tabs({sidebar:true});
  136.         }
  137.        
  138.         //activates behavior and animation for gallery
  139.         if($.fn.avia_sc_gallery)
  140.         {
  141.             $('.avia-gallery', container).avia_sc_gallery();
  142.         }
  143.        
  144.         //activates animated number shortcode
  145.         if($.fn.avia_sc_animated_number)
  146.         {
  147.             $('.avia-animated-number', container).avia_sc_animated_number();
  148.         }
  149.        
  150.         //animation for elements that are not connected like icon shortcode
  151.         if($.fn.avia_sc_animation_delayed)
  152.         {
  153.             $('.av_font_icon', container).avia_sc_animation_delayed({delay:100});
  154.             $('.avia-image-container', container).avia_sc_animation_delayed({delay:100});
  155.             $('.av-hotspot-image-container', container).avia_sc_animation_delayed({delay:100});
  156.             $('.av-animated-generic', container).avia_sc_animation_delayed({delay:100});
  157.         }
  158.  
  159.         //activates animation for iconlist
  160.         if($.fn.avia_sc_iconlist)
  161.         {
  162.             $('.avia-icon-list.av-iconlist-big', container).avia_sc_iconlist();
  163.         }
  164.  
  165.         //activates animation for progress bar
  166.         if($.fn.avia_sc_progressbar)
  167.         {
  168.             $('.avia-progress-bar-container', container).avia_sc_progressbar();
  169.         }
  170.  
  171.         //activates animation for testimonial
  172.         if($.fn.avia_sc_testimonial)
  173.         {
  174.             $('.avia-testimonial-wrapper', container).avia_sc_testimonial();
  175.         }
  176.        
  177.         //activate the fullscreen slider
  178.         $('.avia-slideshow.av_fullscreen', container).aviaFullscreenSlider();
  179.        
  180.         //activate the aviaslider
  181.         $('.avia-slideshow:not(.av_fullscreen)', container).aviaSlider();
  182.        
  183.         //content slider
  184.         $('.avia-content-slider-active', container).aviaSlider({wrapElement: '.avia-content-slider-inner', slideElement:'.slide-entry-wrap', fullfade:true});
  185.  
  186.         //testimonial slider
  187.         $('.avia-slider-testimonials', container).aviaSlider({wrapElement: '.avia-testimonial-row', slideElement:'.avia-testimonial', fullfade:true});
  188.        
  189.         //load and activate maps
  190.         if($.fn.aviaMaps)
  191.         {
  192.             $('.avia-google-map-container', container).aviaMaps();
  193.         }
  194.        
  195.          //load magazine sorting
  196.         if($.fn.aviaMagazine)
  197.         {
  198.             $('.av-magazine-tabs-active', container).aviaMagazine();
  199.         }
  200.        
  201.          //load image hotspot
  202.         if($.fn.aviaHotspots)
  203.         {
  204.             $('.av-hotspot-image-container', container).aviaHotspots();
  205.         }
  206.        
  207.          //load countdown
  208.         if($.fn.aviaCountdown)
  209.         {
  210.             $('.av-countdown-timer', container).aviaCountdown();
  211.         }
  212.        
  213.          //load audio player
  214.         if($.fn.aviaPlayer)
  215.         {
  216.             $('.av-player', container).aviaPlayer();
  217.         }
  218.        
  219.        
  220.     }
  221.  
  222.  
  223.  
  224. // -------------------------------------------------------------------------------------------
  225. //
  226. // AVIA Countdown
  227. //
  228. // -------------------------------------------------------------------------------------------
  229. (function($)
  230. {
  231.     "use strict";
  232.    
  233.     var _units  = ['weeks','days','hours','minutes','seconds'],
  234.         _second = 1000,
  235.         _minute = _second * 60,
  236.         _hour   = _minute * 60,
  237.         _day    = _hour * 24,
  238.         _week   = _day * 7,
  239.         ticker  = function(_self)
  240.         {
  241.             var _time       = {},
  242.                 _now        = new Date(),
  243.                 _timestamp  = _self.end - _now;
  244.            
  245.             if(_timestamp <= 0)
  246.             {
  247.                 clearInterval(_self.countdown);
  248.                 return;
  249.             }  
  250.            
  251.             _self.time.weeks    = Math.floor( _timestamp / _week);
  252.             _self.time.days     = Math.floor((_timestamp % _week) / _day);
  253.             _self.time.hours    = Math.floor((_timestamp % _day) / _hour);
  254.             _self.time.minutes  = Math.floor((_timestamp % _hour) / _minute);
  255.             _self.time.seconds  = Math.floor((_timestamp % _minute) / _second);
  256.            
  257.             switch(_self.data.maximum)
  258.             {
  259.                 case 1: _self.time.seconds  = Math.floor(_timestamp / _second); break;
  260.                 case 2: _self.time.minutes  = Math.floor(_timestamp / _minute); break;
  261.                 case 3: _self.time.hours    = Math.floor(_timestamp / _hour);   break;
  262.                 case 4: _self.time.days     = Math.floor(_timestamp / _day);    break;
  263.             }
  264.            
  265.             for (var i in _self.time)
  266.             {  
  267.                 if(typeof _self.update[i] == "object")
  268.                 {
  269.                     if(_self.firstrun || _self.oldtime[i] != _self.time[i])
  270.                     {
  271.                         var labelkey = ( _self.time[i] === 1 ) ? "single" : "multi";
  272.                    
  273.                         _self.update[i].time_container.text(_self.time[i]);
  274.                         _self.update[i].label_container.text(_self.update[i][labelkey]);
  275.                     }
  276.                 }
  277.             }
  278.            
  279.             //show ticker
  280.             if(_self.firstrun) _self.container.addClass('av-countdown-active');
  281.            
  282.             _self.oldtime   = $.extend( {}, _self.time );
  283.             _self.firstrun  = false;
  284.         };
  285.        
  286.    
  287.     $.fn.aviaCountdown = function( options )
  288.     {  
  289.         if(!this.length) return;
  290.  
  291.         return this.each(function()
  292.         {
  293.             var _self           = {};
  294.             _self.update        = {};
  295.             _self.time          = {};          
  296.             _self.oldtime       = {};          
  297.             _self.firstrun      = true;        
  298.            
  299.             _self.container     = $(this);
  300.             _self.data          = _self.container.data();
  301.             _self.end           = new Date(_self.data.year, _self.data.month, _self.data.day, _self.data.hour, _self.data.minute );
  302.            
  303.             for (var i in _units)
  304.             {
  305.                 _self.update[_units[i]] = {
  306.                     time_container:  _self.container.find('.av-countdown-' + _units[i] + ' .av-countdown-time'),
  307.                     label_container: _self.container.find('.av-countdown-' + _units[i] + ' .av-countdown-time-label')
  308.                 };
  309.                
  310.                 if(_self.update[_units[i]].label_container.length)
  311.                 {
  312.                     _self.update[_units[i]].single = _self.update[_units[i]].label_container.data('label');
  313.                     _self.update[_units[i]].multi  = _self.update[_units[i]].label_container.data('label-multi');
  314.                 }
  315.             }
  316.            
  317.             ticker(_self);
  318.             _self.countdown     = setInterval(function(){ ticker(_self); }, 1000);
  319.  
  320.            
  321.         });
  322.     };
  323.    
  324.    
  325.    
  326. }(jQuery));
  327.  
  328.  
  329. // -------------------------------------------------------------------------------------------
  330. //
  331. // AVIA Player
  332. //
  333. // -------------------------------------------------------------------------------------------
  334. (function($)
  335. {
  336.     "use strict";
  337.    
  338.     var autostarted = false,
  339.         container = null,
  340.    
  341.         monitorStart = function( container )
  342.             {
  343.                 var play_pause  = container.find('.av-player-player-container .mejs-playpause-button');
  344.                
  345.                 if( play_pause.length == 0 )
  346.                 {
  347.                     setTimeout( function(){
  348.                             monitorStart( container );
  349.                         }, 200 );
  350.                 }
  351.                
  352.                 if( ! play_pause.hasClass('mejs-pause') )
  353.                 {
  354.                     play_pause.trigger( 'click' );
  355.                 }
  356.                
  357.             };
  358.    
  359.     $.fn.aviaPlayer = function( options )
  360.     {  
  361.         if( ! this.length ) return;
  362.  
  363.         return this.each(function()
  364.         {
  365.             var _self           = {};
  366.            
  367.             _self.container     = $( this );
  368.            
  369.             /**
  370.              * Limit autostart to the first player with this option set only
  371.              *
  372.              * DOM is not loaded completely and we have no event when player is loaded
  373.              */
  374.             if( _self.container.hasClass( 'avia-playlist-autoplay' ) && ! autostarted )
  375.             {
  376.                 if( ( _self.container.css('display') == 'none') || ( _self.container.css("visibility") == "hidden" ) )
  377.                 {
  378.                     return;
  379.                 }
  380.                
  381.                 autostarted = true;
  382.                 setTimeout( function(){
  383.                             monitorStart( _self.container );
  384.                         }, 200 );
  385.             }
  386.            
  387.         });
  388.     };
  389. }(jQuery));
  390.  
  391.  
  392. // -------------------------------------------------------------------------------------------
  393. //
  394. // AVIA Image Hotspots
  395. //
  396. // -------------------------------------------------------------------------------------------
  397. (function($)
  398. {
  399.     "use strict";
  400.  
  401.     $.fn.aviaHotspots = function( options )
  402.     {
  403.         if(!this.length) return;
  404.  
  405.         return this.each(function()
  406.         {
  407.             var _self = {};
  408.            
  409.             _self.container = $(this);
  410.             _self.hotspots  = _self.container.find('.av-image-hotspot');
  411.            
  412.                 _self.container.on('avia_start_animation', function()
  413.                 {
  414.                     setTimeout(function()
  415.                     {
  416.                         _self.hotspots.each(function(i)
  417.                         {
  418.                             var current = $(this);
  419.                             setTimeout(function(){ current.addClass('av-display-hotspot'); },300 * i);
  420.                         });
  421.                     },400);
  422.                 });
  423.  
  424.         });
  425.     };
  426.    
  427. }(jQuery));
  428.  
  429.  
  430.  
  431.  
  432. // -------------------------------------------------------------------------------------------
  433. //
  434. // AVIA Magazine function for magazine sorting
  435. //
  436. // -------------------------------------------------------------------------------------------
  437. (function($)
  438. {
  439.     "use strict";
  440.    
  441.     var animating = false,
  442.         methods = {
  443.        
  444.         switchMag: function(clicked, _self)
  445.         {
  446.             var current         = $(clicked)
  447.            
  448.             if(current.is('.active_sort') || animating) return;
  449.            
  450.             var filter          = current.data('filter'),
  451.                 oldContainer    = _self.container.filter(':visible'),
  452.                 newContainer    = _self.container.filter('.' + filter);
  453.            
  454.             //switch Class
  455.             animating = true;
  456.             _self.sort_buttons.removeClass('active_sort');
  457.             current.addClass('active_sort');
  458.            
  459.             //apply fixed heiht for transition
  460.             _self.magazine.height(_self.magazine.outerHeight());
  461.            
  462.             //switch items
  463.             oldContainer.avia_animate({opacity:0}, 200, function()
  464.             {
  465.                 oldContainer.css({display:'none'});
  466.                 newContainer.css({opacity:0, display:'block'}).avia_animate({opacity:1}, 150, function()
  467.                 {
  468.                     _self.magazine.avia_animate({height: (newContainer.outerHeight() + _self.sort_bar.outerHeight())}, 150, function()
  469.                     {
  470.                         _self.magazine.height('auto');
  471.                         animating = false;
  472.                     });
  473.                    
  474.                 });
  475.             });
  476.         }
  477.     };
  478.    
  479.    
  480.     $.fn.aviaMagazine = function( options )
  481.     {
  482.         if(!this.length) return;
  483.  
  484.         return this.each(function()
  485.         {
  486.             var _self = {};
  487.              
  488.             _self.magazine      = $(this),
  489.             _self.sort_buttons  = _self.magazine.find('.av-magazine-sort a');
  490.             _self.container     = _self.magazine.find('.av-magazine-group');
  491.             _self.sort_bar      = _self.magazine.find('.av-magazine-top-bar');
  492.            
  493.             _self.sort_buttons.on('click', function(e){ e.preventDefault(); methods.switchMag(this, _self);  } );
  494.         });
  495.     }
  496.    
  497. }(jQuery));
  498.  
  499. // -------------------------------------------------------------------------------------------
  500. //
  501. // AVIA MAPS API - loads the google maps api asynchronously
  502. //
  503. // afterwards applies the map to the container
  504. //
  505. // -------------------------------------------------------------------------------------------
  506.  
  507.  
  508. (function($)
  509. {
  510.     "use strict";
  511.  
  512.     $.AviaMapsAPI  =  function(options, container)
  513.     {
  514.         if(typeof window.av_google_map == 'undefined')
  515.         {
  516.             $.avia_utilities.log('Map creation stopped, var av_google_map not found');
  517.             return;
  518.         }
  519.    
  520.         // gatehr container and map data
  521.         this.container  = container;
  522.         this.$container = $( container );
  523.         this.$body      = $('body');
  524.         this.$mapid     = this.$container.data('mapid') - 1;
  525.         this.$data      = window.av_google_map[this.$mapid];
  526.         this.retina     = window.devicePixelRatio > 1;
  527.        
  528.         // set up the whole api object
  529.         this._init( options );
  530.     };
  531.    
  532.     $.AviaMapsAPI.apiFiles =
  533.     {
  534.         loading: false,
  535.         finished: false,
  536.         src: ''
  537.     };
  538.    
  539.     $.AviaMapsAPI.prototype =
  540.     {
  541.         _init: function()
  542.         {
  543.             if( 'undefined' == typeof avia_framework_globals.gmap_maps_loaded || avia_framework_globals.gmap_maps_loaded == '' )
  544.             {
  545.                         //  this is only a fallback setting
  546.                 $.AviaMapsAPI.apiFiles.src = 'https://maps.googleapis.com/maps/api/js?v=3.30&callback=aviaOnGoogleMapsLoaded';
  547.                 if( typeof avia_framework_globals.gmap_api != 'undefined' && avia_framework_globals.gmap_api != "" )
  548.                 {
  549.                     $.AviaMapsAPI.apiFiles.src += "&key=" + avia_framework_globals.gmap_api;
  550.                 }
  551.             }
  552.             else
  553.             {
  554.                 $.AviaMapsAPI.apiFiles.src = avia_framework_globals.gmap_maps_loaded;
  555.             }
  556.            
  557.             this._bind_execution();
  558.             this._getAPI();
  559.         },
  560.        
  561.         _getAPI: function( )
  562.         {  
  563.             //make sure the api file is loaded only once
  564.             if((typeof window.google == 'undefined' || typeof window.google.maps == 'undefined') && $.AviaMapsAPI.apiFiles.loading == false)
  565.             {  
  566.                 $.AviaMapsAPI.apiFiles.loading = true;
  567.                 var script  = document.createElement('script');
  568.                     script.type = 'text/javascript';   
  569.                     script.src  = $.AviaMapsAPI.apiFiles.src;
  570.  
  571.                 document.body.appendChild(script);
  572.             }
  573.             else if((typeof window.google != 'undefined' && typeof window.google.maps != 'undefined') || $.AviaMapsAPI.apiFiles.loading == false)
  574.             //else if($.AviaMapsAPI.apiFiles.finished === true)
  575.             {
  576.                 this._applyMap();
  577.             }
  578.         },
  579.        
  580.         _bind_execution: function()
  581.         {
  582.             this.$body.on('av-google-maps-api-loaded', $.proxy( this._applyMap, this) );
  583.         },
  584.        
  585.         _applyMap: function()
  586.         {
  587.             if(typeof this.map != 'undefined') return;
  588.             if(!this.$data.marker || !this.$data.marker[0] || !this.$data.marker[0].long || !this.$data.marker[0].long)
  589.             {
  590.                 $.avia_utilities.log('Latitude or Longitude missing', 'map-error');
  591.                 return;
  592.             }
  593.            
  594.             var _self = this,
  595.                 mobile_drag = $.avia_utilities.isMobile ? this.$data.mobile_drag_control : true,
  596.                 zoomValue   = this.$data.zoom == "auto" ? 10 : this.$data.zoom;
  597.        
  598.             var mapTypeControl = false;
  599.             var mapTypeId = google.maps.MapTypeId.ROADMAP;
  600.             var mapTypeControlOptions = google.maps.MapTypeControlStyle.DROPDOWN_MENU;
  601.            
  602.             switch( this.$data.maptype_control )
  603.             {
  604.                 case 'dropdown':
  605.                     mapTypeControl = true;
  606.                     mapTypeControlOptions = google.maps.MapTypeControlStyle.DROPDOWN_MENU;
  607.                     break;
  608.                 case 'horizontal':
  609.                     mapTypeControl = true;
  610.                     mapTypeControlOptions = google.maps.MapTypeControlStyle.HORIZONTAL_BAR;
  611.                     break;
  612.                 case 'default':
  613.                     mapTypeControl = true;
  614.                     mapTypeControlOptions = google.maps.MapTypeControlStyle.DEFAULT;
  615.                     break;
  616.                 default:
  617.                     mapTypeControl = false;
  618.                     mapTypeControlOptions = google.maps.MapTypeControlStyle.DROPDOWN_MENU;
  619.                     break;
  620.             }
  621.            
  622.             switch( this.$data.maptype_id )
  623.             {
  624.                 case 'SATELLITE':
  625.                     mapTypeId = google.maps.MapTypeId.SATELLITE;
  626.                     break;
  627.                 case 'HYBRID':
  628.                     mapTypeId = google.maps.MapTypeId.HYBRID;
  629.                     break;
  630.                 case 'TERRAIN':
  631.                     mapTypeId = google.maps.MapTypeId.TERRAIN;
  632.                     break;
  633.                 default:
  634.                     mapTypeId = google.maps.MapTypeId.ROADMAP;
  635.             }
  636.            
  637.             this.mapVars = {
  638.                 mapMaker: false, //mapmaker tiles are user generated content maps. might hold more info but also be inaccurate
  639.                 backgroundColor:'transparent',
  640.                 streetViewControl: false,
  641.                 zoomControl: this.$data.zoom_control,
  642.                 //draggable: mobile_drag,
  643.                 gestureHandling: 'cooperative',
  644.                 scrollwheel: false,
  645.                 zoom: zoomValue,
  646.                 mapTypeControl: mapTypeControl,
  647.                 mapTypeControlOptions: {style:mapTypeControlOptions},
  648.                 mapTypeId: mapTypeId,
  649.                 center: new google.maps.LatLng(this.$data.marker[0].lat, this.$data.marker[0].long),
  650.                 styles:[{featureType: "poi", elementType: "labels", stylers: [ { visibility: "off" }] }]
  651.             };
  652.  
  653.             this.map = new google.maps.Map(this.container, this.mapVars);
  654.        
  655.             this._applyMapStyle();
  656.            
  657.             if(this.$data.zoom == "auto")
  658.             {
  659.                 this._setAutoZoom();
  660.             }
  661.            
  662.             google.maps.event.addListenerOnce(this.map, 'tilesloaded', function() {
  663.                 _self._addMarkers();
  664.             });
  665.         },
  666.        
  667.         _setAutoZoom: function()
  668.         {
  669.             var bounds = new google.maps.LatLngBounds();
  670.            
  671.             for (var key in this.$data.marker)
  672.             {
  673.                 bounds.extend( new google.maps.LatLng (this.$data.marker[key].lat , this.$data.marker[key].long) );
  674.             }
  675.            
  676.             this.map.fitBounds(bounds);
  677.         },
  678.        
  679.         _applyMapStyle: function()
  680.         {
  681.             var stylers = [], style = [], mapType, style_color = "";
  682.            
  683.             if(this.$data.hue != "") stylers.push({hue: this.$data.hue});
  684.             if(this.$data.saturation != "") stylers.push({saturation: this.$data.saturation});
  685.            
  686.             if(stylers.length)
  687.             {
  688.                 style = [{
  689.                           featureType: "all",
  690.                           elementType: "all",
  691.                           stylers: stylers
  692.                         }, {
  693.                           featureType: "poi",
  694.                           stylers: [
  695.                             { visibility: "off" }
  696.                           ]
  697.                         }];
  698.                        
  699.                
  700.                 if(this.$data.saturation == "fill")
  701.                 {
  702.                        
  703.                     style_color = this.$data.hue || "#242424";
  704.                    
  705.                     var c = style_color.substring(1);      // strip #
  706.                     var rgb = parseInt(c, 16);   // convert rrggbb to decimal
  707.                     var r = (rgb >> 16) & 0xff;  // extract red
  708.                     var g = (rgb >>  8) & 0xff;  // extract green
  709.                     var b = (rgb >>  0) & 0xff;  // extract blue
  710.                    
  711.                     var luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; // per ITU-R BT.709
  712.                     var lightness = 1;
  713.                     var street_light = 2;
  714.                    
  715.                     if (luma > 60) {
  716.                         lightness = -1;
  717.                         street_light = 3;
  718.                     }
  719.                     if (luma > 220) {
  720.                         lightness = -2;
  721.                         street_light = -2;
  722.                     }
  723.                    
  724.                 style = [
  725. {"featureType":"all","elementType":"all","stylers":[{"color":style_color},{"lightness":0}]},
  726. {"featureType":"all","elementType":"labels.text.fill","stylers":[{"color":style_color},{"lightness":(25 * street_light)}]},
  727. {"featureType":"all","elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":style_color},{"lightness":3}]},
  728. {"featureType":"all","elementType":"labels.icon","stylers":[{"visibility":"off"}]},
  729. {"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":style_color},{"lightness":30}]},
  730. {"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":style_color},{"lightness":30},{"weight":1.2}]},
  731. {"featureType":"landscape","elementType":"geometry","stylers":[{visibility: 'simplified'},{"color":style_color},{"lightness":3}]},
  732. {"featureType":"poi","elementType":"geometry","stylers":[{ "visibility": "off" }]},
  733. {"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":style_color},{"lightness":-3}]},
  734. {"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":style_color},{"lightness":2},{"weight":0.2}]},
  735. {"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":style_color},{"lightness":-3}]},
  736. {"featureType":"road.local","elementType":"geometry","stylers":[{"color":style_color},{"lightness":-3}]},
  737. {"featureType":"transit","elementType":"geometry","stylers":[{"color":style_color},{"lightness":-3}]},
  738. {"featureType":"water","elementType":"geometry","stylers":[{"color":style_color},{"lightness":-20}]}
  739.                         ];
  740.                 }  
  741.                
  742.                 mapType = new google.maps.StyledMapType(style, { name:"av_map_style" });
  743.                 this.map.mapTypes.set('av_styled_map', mapType);
  744.                 this.map.setMapTypeId('av_styled_map');
  745.             }
  746.         },
  747.        
  748.         _addMarkers: function()
  749.         {
  750.             for (var key in this.$data.marker)
  751.             {  
  752.                 var _self = this;
  753.                
  754.                 (function(key, _self)
  755.                 {
  756.                     setTimeout(function()
  757.                     {
  758.                             var marker = "";
  759.                            
  760.                             if(!_self.$data.marker[key] || !_self.$data.marker[key].long || !_self.$data.marker[key].long)
  761.                             {
  762.                                 $.avia_utilities.log('Latitude or Longitude for single marker missing', 'map-error');
  763.                                 return;
  764.                             }
  765.                            
  766.                             _self.$data.LatLng = new google.maps.LatLng(_self.$data.marker[key].lat, _self.$data.marker[key].long);
  767.                            
  768.                             var markerArgs = {
  769.                               flat: false,
  770.                               position: _self.$data.LatLng,
  771.                               animation: google.maps.Animation.BOUNCE,
  772.                               map: _self.map,
  773.                               title: _self.$data.marker[key].address,
  774.                               optimized: false
  775.                             };
  776.                            
  777.                             //set a custom marker image if available. also set the size and reduce the marker on retina size so its sharp
  778.                             if(_self.$data.marker[key].icon && _self.$data.marker[key].imagesize)
  779.                             {
  780.                                 var size = _self.$data.marker[key].imagesize, half = "", full = "";
  781.                                
  782.                                 if(_self.retina && size > 40) size = 40;            //retina downsize to at least half the px size
  783.                                 half = new google.maps.Point(size / 2, size ) ;     //used to position the marker
  784.                                 full = new google.maps.Size(size , size ) ;         //marker size
  785.                                 markerArgs.icon = new google.maps.MarkerImage(_self.$data.marker[key].icon, null, null, half, full);
  786.                             }
  787.                            
  788.                             marker = new google.maps.Marker(markerArgs);
  789.                            
  790.                             setTimeout(function(){ marker.setAnimation(null); _self._infoWindow(_self.map, marker, _self.$data.marker[key]); },500);
  791.                            
  792.                     },200 * (parseInt(key,10) + 1));
  793.                        
  794.                 }(key, _self));
  795.             }
  796.         },
  797.        
  798.         _infoWindow: function(map, marker, data)
  799.         {
  800.             var info = $.trim(data.content);
  801.            
  802.             if(info != "")
  803.             {
  804.                 var infowindow = new google.maps.InfoWindow({
  805.                     content: info
  806.                 });
  807.                
  808.                 google.maps.event.addListener(marker, 'click', function() {
  809.                     infowindow.open(map,marker);
  810.                 });
  811.                
  812.                 if(data.tooltip_display) infowindow.open(map,marker);
  813.             }
  814.         }
  815.        
  816.        
  817.     };
  818.  
  819.     //simple wrapper to call the api. makes sure that the api data is not applied twice
  820.     $.fn.aviaMaps = function( options )
  821.     {
  822.         return this.each(function()
  823.         {  
  824.             var self = $.data( this, 'aviaMapsApi' );
  825.            
  826.             if(!self)
  827.             {
  828.                 self = $.data( this, 'aviaMapsApi', new $.AviaMapsAPI( options, this ) );
  829.             }
  830.         });
  831.     };
  832.    
  833. })( jQuery );
  834.  
  835. //this function is executed once the api file is loaded
  836. window.aviaOnGoogleMapsLoaded = function(){ $('body').trigger('av-google-maps-api-loaded'); $.AviaMapsAPI.apiFiles.finished = true; };
  837.  
  838.  
  839. // -------------------------------------------------------------------------------------------
  840. //
  841. // AVIA VIDEO API - make sure that youtube, vimeo and html 5 use the same interface
  842. //
  843. // requires froogaloop vimeo library and youtube iframe api (yt can be loaded async)
  844. //
  845. // -------------------------------------------------------------------------------------------
  846.  
  847.  
  848. (function($)
  849. {
  850.     "use strict";
  851.  
  852.     $.AviaVideoAPI  =  function(options, video, option_container)
  853.     {  
  854.         // actual video element. either iframe or video
  855.         this.$video = $( video );
  856.        
  857.         // container where the AviaVideoAPI object will be stored as data, and that can receive events like play, pause etc
  858.         // also the container that allows to overwrite javacript options by adding html data- attributes
  859.         this.$option_container = option_container ? $( option_container ) : this.$video;
  860.        
  861.         //mobile device?
  862.         this.isMobile   = $.avia_utilities.isMobile;
  863.        
  864.         //iamge fallback use
  865.         this.fallback = this.isMobile ? this.$option_container.is('.av-mobile-fallback-image') : false;
  866.        
  867.         if(this.fallback) return;
  868.        
  869.         // set up the whole api object
  870.         this._init( options );
  871.        
  872.     }
  873.  
  874.     $.AviaVideoAPI.defaults  = {
  875.    
  876.         loop: false,
  877.         mute: false,
  878.         controls: false,
  879.         events: 'play pause mute unmute loop toggle reset unload'
  880.  
  881.     };
  882.    
  883.     $.AviaVideoAPI.apiFiles =
  884.     {
  885.         youtube : {loaded: false, src: 'https://www.youtube.com/iframe_api' }
  886.     }
  887.    
  888.     $.AviaVideoAPI.prototype =
  889.     {
  890.         _init: function( options )
  891.         {  
  892.             // set slider options
  893.             this.options = this._setOptions(options);
  894.            
  895.             // info which video service we are using: html5, vimeo or youtube
  896.             this.type = this._getPlayerType();
  897.            
  898.             // store the player object to the this.player variable created by one of the APIs (mediaelement, youtube, vimeo)
  899.             this._setPlayer();         
  900.            
  901.             // set to true once the events are bound so it doesnt happen a second time by accident or racing condition
  902.             this.eventsBound = false;
  903.            
  904.             // info if the video is playing
  905.             this.playing = false;
  906.            
  907.             //set css class that video is currently not playing
  908.             this.$option_container.addClass('av-video-paused');
  909.            
  910.             //play pause indicator
  911.             this.pp = $.avia_utilities.playpause(this.$option_container);
  912.         },
  913.        
  914.        
  915.         //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
  916.         _setOptions: function(options)
  917.         {  
  918.             var newOptions  = $.extend( true, {}, $.AviaVideoAPI.defaults, options ),
  919.                 htmlData    = this.$option_container.data(),
  920.                 i           = "";
  921.  
  922.             //overwritte passed option set with any data properties on the html element
  923.             for (i in htmlData)
  924.             {
  925.                 if (htmlData.hasOwnProperty(i) && (typeof htmlData[i] === "string" || typeof htmlData[i] === "number" || typeof htmlData[i] === "boolean"))
  926.                 {
  927.                     newOptions[i] = htmlData[i];
  928.                 }
  929.             }
  930.        
  931.             return newOptions;
  932.         },
  933.        
  934.        
  935.         //get the player type
  936.         _getPlayerType: function()
  937.         {
  938.             var vid_src = this.$video.get(0).src || this.$video.data('src');
  939.            
  940.            
  941.             if(this.$video.is('video'))                 return 'html5';
  942.             if(this.$video.is('.av_youtube_frame'))     return 'youtube';
  943.             if(vid_src.indexOf('vimeo.com') != -1 )     return 'vimeo';
  944.             if(vid_src.indexOf('youtube.com') != -1)    return 'youtube';
  945.         },
  946.        
  947.         //get the player object
  948.         _setPlayer: function()
  949.         {
  950.             var _self = this;
  951.            
  952.             switch(this.type)
  953.             {
  954.                 case "html5":  
  955.                
  956.                     this.player = this.$video.data('mediaelementplayer');  
  957.                     this._playerReady();
  958.                    
  959.                 break;
  960.                    
  961.                 case "vimeo":  
  962.                    
  963.                     this.player = Froogaloop(this.$video.get(0));
  964.                     this._playerReady();
  965.                    
  966.                 break;
  967.                    
  968.                 case "youtube":
  969.                
  970.                     this._getAPI(this.type);
  971.                     $('body').on('av-youtube-iframe-api-loaded', function(){ _self._playerReady(); });
  972.                    
  973.                 break;
  974.             }
  975.         },
  976.        
  977.         _getAPI: function( api )
  978.         {  
  979.             //make sure the api file is loaded only once
  980.             if($.AviaVideoAPI.apiFiles[api].loaded === false)
  981.             {  
  982.                 $.AviaVideoAPI.apiFiles[api].loaded = true;
  983.                 //load the file async
  984.                 var tag     = document.createElement('script'),
  985.                     first   = document.getElementsByTagName('script')[0];
  986.                    
  987.                 tag.src = $.AviaVideoAPI.apiFiles[api].src;
  988.                 first.parentNode.insertBefore(tag, first);
  989.             }
  990.         },
  991.        
  992.        
  993.        
  994.         //wait for player to be ready, then bind events
  995.         _playerReady: function()
  996.         {  
  997.             var _self = this;
  998.            
  999.             this.$option_container.on('av-video-loaded', function(){ _self._bindEvents(); });
  1000.            
  1001.             switch(this.type)
  1002.             {
  1003.                 case "html5":
  1004.                        
  1005.                     this.$video.on('av-mediajs-loaded', function(){ _self.$option_container.trigger('av-video-loaded'); });
  1006.                     this.$video.on('av-mediajs-ended' , function(){ _self.$option_container.trigger('av-video-ended');  });
  1007.                    
  1008.                 break;
  1009.                 case "vimeo":  
  1010.                    
  1011.                     //finish event must be applied after ready event for firefox
  1012.                     _self.player.addEvent('ready',  function(){ _self.$option_container.trigger('av-video-loaded');
  1013.                     _self.player.addEvent('finish', function(){ _self.$option_container.trigger('av-video-ended');  });
  1014.                     });
  1015.                    
  1016.                     // vimeo sometimes does not fire. fallback jquery load event should fix this
  1017.                     // currently not used because it causes firefox problems
  1018.                     /*
  1019.                     this.$video.load(function()
  1020.                     {  
  1021.                         if(_self.eventsBound == true || typeof _self.eventsBound == 'undefined') return;
  1022.                         _self.$option_container.trigger('av-video-loaded');
  1023.                         $.avia_utilities.log('VIMEO Fallback Trigger');
  1024.                     });
  1025.                     */
  1026.                    
  1027.                
  1028.                 break;
  1029.                
  1030.                 case "youtube":
  1031.                    
  1032.                     var params = _self.$video.data();
  1033.                    
  1034.                     if(_self._supports_video()) params.html5 = 1;
  1035.                    
  1036.                     _self.player = new YT.Player(_self.$video.attr('id'), {
  1037.                         videoId: params.videoid,
  1038.                         height: _self.$video.attr('height'),
  1039.                         width: _self.$video.attr('width'),
  1040.                         playerVars: params,
  1041.                         events: {
  1042.                         'onReady': function(){ _self.$option_container.trigger('av-video-loaded'); },
  1043.                         'onError': function(player){ $.avia_utilities.log('YOUTUBE ERROR:', 'error', player); },
  1044.                         'onStateChange': function(event){
  1045.                             if (event.data === YT.PlayerState.ENDED)
  1046.                             {  
  1047.                                 var command = _self.options.loop != false ? 'loop' : 'av-video-ended';
  1048.                                 _self.$option_container.trigger(command);
  1049.                             }
  1050.                           }
  1051.                         }
  1052.                     });
  1053.                    
  1054.                    
  1055.                 break;
  1056.             }
  1057.            
  1058.             //fallback always trigger after 2 seconds
  1059.             setTimeout(function()
  1060.             {  
  1061.                 if(_self.eventsBound == true || typeof _self.eventsBound == 'undefined' || _self.type == 'youtube' ) { return; }
  1062.                 $.avia_utilities.log('Fallback Video Trigger "'+_self.type+'":', 'log', _self);
  1063.                
  1064.                 _self.$option_container.trigger('av-video-loaded');
  1065.                
  1066.             },2000);
  1067.            
  1068.         },
  1069.        
  1070.         //bind events we should listen to, to the player
  1071.         _bindEvents: function()
  1072.         {  
  1073.             if(this.eventsBound == true || typeof this.eventsBound == 'undefined')
  1074.             {
  1075.                 return;
  1076.             }
  1077.            
  1078.             var _self = this, volume = 'unmute';
  1079.            
  1080.             this.eventsBound = true;
  1081.            
  1082.             this.$option_container.on(this.options.events, function(e)
  1083.             {
  1084.                 _self.api(e.type);
  1085.             });
  1086.            
  1087.             if(!_self.isMobile)
  1088.             {
  1089.                 //set up initial options
  1090.                 if(this.options.mute != false) { volume = "mute";    }
  1091.                 if(this.options.loop != false) { _self.api('loop'); }
  1092.                
  1093.                 _self.api(volume);
  1094.             }
  1095.            
  1096.             //set timeout to prevent racing conditions with other scripts
  1097.             setTimeout(function()
  1098.             {
  1099.                 _self.$option_container.trigger('av-video-events-bound').addClass('av-video-events-bound');
  1100.             },50);
  1101.         },
  1102.        
  1103.        
  1104.         _supports_video: function() {
  1105.           return !!document.createElement('video').canPlayType;
  1106.         },
  1107.        
  1108.        
  1109.         /************************************************************************
  1110.         PUBLIC Methods
  1111.         *************************************************************************/
  1112.        
  1113.         api: function( action )
  1114.         {  
  1115.             //commands on mobile can not be executed if the player was not started manually
  1116.             if(this.isMobile && !this.was_started()) return;
  1117.            
  1118.             // prevent calling of unbound function
  1119.             if(this.options.events.indexOf(action) === -1) return;
  1120.            
  1121.             // broadcast that the command was executed
  1122.             this.$option_container.trigger('av-video-'+action+'-executed');
  1123.            
  1124.             // calls the function based on action. eg: _html5_play()
  1125.             if(typeof this[ '_' + this.type + '_' + action] == 'function')
  1126.             {
  1127.                 this[ '_' + this.type + '_' + action].call(this);
  1128.             }
  1129.            
  1130.             //call generic function eg: _toggle() or _play()
  1131.             if(typeof this[ '_' + action] == 'function')
  1132.             {
  1133.                 this[ '_' + action].call(this);
  1134.             }
  1135.            
  1136.         },
  1137.        
  1138.         was_started: function()
  1139.         {
  1140.             if(!this.player) return false;
  1141.        
  1142.             switch(this.type)
  1143.             {
  1144.                 case "html5":
  1145.                     if(this.player.getCurrentTime() > 0) return true;
  1146.                 break;
  1147.                    
  1148.                 case "vimeo":  
  1149.                     if(this.player.api('getCurrentTime') > 0) return true;
  1150.                 break;
  1151.                    
  1152.                 case "youtube":
  1153.                     if(this.player.getPlayerState() !== -1) return true;
  1154.                 break;
  1155.             }
  1156.            
  1157.             return false;
  1158.         },
  1159.        
  1160.         /************************************************************************
  1161.         Generic Methods, are always executed and usually set variables
  1162.         *************************************************************************/
  1163.         _play: function()
  1164.         {
  1165.             this.playing = true;
  1166.             this.$option_container.addClass('av-video-playing').removeClass('av-video-paused');
  1167.         },
  1168.        
  1169.         _pause: function()
  1170.         {
  1171.             this.playing = false;
  1172.             this.$option_container.removeClass('av-video-playing').addClass('av-video-paused');
  1173.         },
  1174.        
  1175.         _loop: function()
  1176.         {
  1177.             this.options.loop = true;
  1178.         },
  1179.        
  1180.         _toggle: function( )
  1181.         {
  1182.             var command = this.playing == true ? 'pause' : 'play';
  1183.            
  1184.             this.api(command);
  1185.             this.pp.set(command);
  1186.         },
  1187.        
  1188.        
  1189.         /************************************************************************
  1190.         VIMEO Methods
  1191.         *************************************************************************/
  1192.        
  1193.         _vimeo_play: function( )
  1194.         {  
  1195.             this.player.api('play');
  1196.         },
  1197.        
  1198.         _vimeo_pause: function( )
  1199.         {
  1200.             this.player.api('pause');  
  1201.         },
  1202.        
  1203.         _vimeo_mute: function( )
  1204.         {
  1205.             this.player.api('setVolume', 0);
  1206.         },
  1207.        
  1208.         _vimeo_unmute: function( )
  1209.         {
  1210.             this.player.api('setVolume', 0.7);
  1211.         },
  1212.        
  1213.         _vimeo_loop: function( )
  1214.         {
  1215.             // currently throws error, must be set in iframe
  1216.             // this.player.api('setLoop', true);
  1217.         },
  1218.        
  1219.         _vimeo_reset: function( )
  1220.         {
  1221.             this.player.api('seekTo',0);
  1222.         },
  1223.        
  1224.         _vimeo_unload: function()
  1225.         {
  1226.             this.player.api('unload');
  1227.         },
  1228.        
  1229.         /************************************************************************
  1230.         YOUTUBE Methods
  1231.         *************************************************************************/     
  1232.        
  1233.         _youtube_play: function( )
  1234.         {
  1235.             this.player.playVideo();
  1236.         },
  1237.        
  1238.         _youtube_pause: function( )
  1239.         {
  1240.             this.player.pauseVideo()
  1241.         },
  1242.        
  1243.         _youtube_mute: function( )
  1244.         {
  1245.             this.player.mute();
  1246.         },
  1247.        
  1248.         _youtube_unmute: function( )
  1249.         {
  1250.             this.player.unMute();
  1251.         },
  1252.        
  1253.         _youtube_loop: function( )
  1254.         {  
  1255.             // does not work properly with iframe api. needs to manual loop on "end" event
  1256.             // this.player.setLoop(true);
  1257.             if(this.playing == true) this.player.seekTo(0);
  1258.         },
  1259.        
  1260.         _youtube_reset: function( )
  1261.         {
  1262.             this.player.stopVideo();
  1263.         },
  1264.        
  1265.         _youtube_unload: function()
  1266.         {
  1267.             this.player.clearVideo();
  1268.         },
  1269.        
  1270.         /************************************************************************
  1271.         HTML5 Methods
  1272.         *************************************************************************/
  1273.        
  1274.         _html5_play: function( )
  1275.         {
  1276.             //disable stoping of other videos in case the user wants to run section bgs
  1277.             this.player.options.pauseOtherPlayers = false;
  1278.             this.player.play();
  1279.         },
  1280.        
  1281.         _html5_pause: function( )
  1282.         {
  1283.             this.player.pause();
  1284.         },
  1285.        
  1286.         _html5_mute: function( )
  1287.         {
  1288.             this.player.setMuted(true);
  1289.         },
  1290.        
  1291.         _html5_unmute: function( )
  1292.         {
  1293.             this.player.setVolume(0.7);
  1294.         },
  1295.        
  1296.         _html5_loop: function( )
  1297.         {
  1298.             this.player.options.loop = true;
  1299.         },
  1300.        
  1301.         _html5_reset: function( )
  1302.         {  
  1303.             this.player.setCurrentTime(0); 
  1304.         },
  1305.        
  1306.         _html5_unload: function()
  1307.         {
  1308.             this._html5_pause();
  1309.             this._html5_reset();
  1310.         }
  1311.     }
  1312.  
  1313.     //simple wrapper to call the api. makes sure that the api data is not applied twice
  1314.     $.fn.aviaVideoApi = function( options , apply_to_parent)
  1315.     {
  1316.         return this.each(function()
  1317.         {  
  1318.             // by default save the object as data to the initial video.
  1319.             // in the case of slideshows its more benefitial to save it to a parent element (eg: the slide)
  1320.             var applyTo = this;
  1321.            
  1322.             if(apply_to_parent)
  1323.             {
  1324.                 applyTo = $(this).parents(apply_to_parent).get(0);
  1325.             }
  1326.            
  1327.             var self = $.data( applyTo, 'aviaVideoApi' );
  1328.            
  1329.             if(!self)
  1330.             {
  1331.                 self = $.data( applyTo, 'aviaVideoApi', new $.AviaVideoAPI( options, this, applyTo ) );
  1332.             }
  1333.         });
  1334.     }
  1335.    
  1336. })( jQuery );
  1337.  
  1338. window.onYouTubeIframeAPIReady = function(){ $('body').trigger('av-youtube-iframe-api-loaded'); };
  1339.  
  1340.  
  1341.  
  1342. // -------------------------------------------------------------------------------------------
  1343. // Masonry
  1344. // -------------------------------------------------------------------------------------------
  1345.  
  1346. $.fn.avia_masonry = function(options)
  1347. {
  1348.     //return if we didnt find anything
  1349.     if(!this.length) return this;
  1350.    
  1351.     var the_body = $('body'),
  1352.         the_win  = $(window),
  1353.         isMobile = $.avia_utilities.isMobile,
  1354.         loading = false,
  1355.         methods = {
  1356.    
  1357.        
  1358.         masonry_filter: function()
  1359.         {
  1360.             var current     = $(this),
  1361.                 linktext    = current.html(),
  1362.                 selector    = current.data('filter'),
  1363.                 masonry     = current.parents('.av-masonry:eq(0)'),
  1364.                 container   = masonry.find('.av-masonry-container:eq(0)'),
  1365.                 links       = masonry.find('.av-masonry-sort a'),
  1366.                 activeCat   = masonry.find('.av-current-sort-title');
  1367.                
  1368.                 links.removeClass('active_sort');
  1369.                 current.addClass('active_sort');
  1370.                 container.attr('id', 'masonry_id_'+selector);
  1371.                
  1372.                 if(activeCat.length) activeCat.html(linktext);
  1373.                
  1374.                 methods.applyMasonry(container, selector, function()
  1375.                 {
  1376.                     container.css({overflow:'visible'});
  1377.                 });
  1378.            
  1379.                 setTimeout(function() { the_win.trigger('debouncedresize'); }, 500);
  1380.                
  1381.                 return false;
  1382.         },
  1383.        
  1384.         applyMasonry: function(container, selector, callback)
  1385.         {
  1386.             var filters = selector ? {filter: '.'+selector} : {};
  1387.            
  1388.             filters['layoutMode'] = 'packery';
  1389.             filters['packery'] = {gutter:0};
  1390.             filters['percentPosition'] = true;
  1391.             filters['itemSelector'] = "a.isotope-item, div.isotope-item";
  1392.            
  1393.             container.isotope(filters, function()
  1394.             {
  1395.                 the_win.trigger('av-height-change');
  1396.             });
  1397.            
  1398.             if(typeof callback === 'function')
  1399.             {
  1400.                 setTimeout(callback, 0);
  1401.             }
  1402.         },
  1403.        
  1404.         show_bricks: function(bricks, callback)
  1405.         {
  1406.             bricks.each(function(i)
  1407.             {
  1408.                 var currentLink     = $(this),
  1409.                     browserPrefix   = $.avia_utilities.supports('transition'),
  1410.                     multiplier      = isMobile ? 0 : 100;
  1411.                
  1412.                 setTimeout(function()
  1413.                 {
  1414.                     if(browserPrefix === false)
  1415.                     {
  1416.                         currentLink.css({visibility:"visible", opacity:0}).animate({opacity:1},1500);
  1417.                     }
  1418.                     else
  1419.                     {
  1420.                         currentLink.addClass('av-masonry-item-loaded');
  1421.                     }
  1422.                    
  1423.                     if(i == bricks.length - 1 && typeof callback == 'function')
  1424.                     {
  1425.                         callback.call();
  1426.                         the_win.trigger('av-height-change');
  1427.                     }
  1428.                    
  1429.                 }, (multiplier * i));
  1430.             });
  1431.         },
  1432.        
  1433.         loadMore: function(e)
  1434.         {
  1435.             e.preventDefault();
  1436.            
  1437.             if(loading) return false;
  1438.            
  1439.             loading = true;
  1440.        
  1441.             var current     = $(this),
  1442.                 data        = current.data(),
  1443.                 masonry     = current.parents('.av-masonry:eq(0)'),
  1444.                 container   = masonry.find('.av-masonry-container'),
  1445.                 items       = masonry.find('.av-masonry-entry'),
  1446.                 loader      = $.avia_utilities.loading(),
  1447.                 finished    = function(){ loading = false; loader.hide(); the_body.trigger('av_resize_finished'); };
  1448.                        
  1449.             //calculate a new offset   
  1450.             if(!data.offset){ data.offset = 0; }   
  1451.             data.offset += data.items;
  1452.             data.action = 'avia_ajax_masonry_more';
  1453.             data.loaded = []; //prevents duplicate entries from beeing loaded when randomized is active
  1454.            
  1455.             items.each(function(){
  1456.                 var item_id = $(this).data('av-masonry-item');
  1457.                 if(item_id) data.loaded.push( item_id );
  1458.             });
  1459.            
  1460.              $.ajax({
  1461.                 url: avia_framework_globals.ajaxurl,
  1462.                 type: "POST",
  1463.                 data:data,
  1464.                 beforeSend: function()
  1465.                 {
  1466.                     loader.show();
  1467.                 },
  1468.                 success: function(response)
  1469.                 {
  1470.                     if(response.indexOf("{av-masonry-loaded}") !== -1)
  1471.                     {
  1472.                         //fetch the response. if any php warnings were displayed before rendering of the items the are removed by the string split
  1473.                         var response  = response.split('{av-masonry-loaded}'),
  1474.                             new_items = $(response.pop()).filter('.isotope-item');
  1475.                            
  1476.                             //check if we got more items than we need. if not we have reached the end of items
  1477.                             if(new_items.length > data.items)
  1478.                             {
  1479.                                 new_items = new_items.not(':last');
  1480.                             }
  1481.                             else
  1482.                             {
  1483.                                 current.addClass('av-masonry-no-more-items');
  1484.                             }
  1485.                            
  1486.                             var load_container = $('<div class="loadcontainer"></div>').append(new_items);
  1487.                            
  1488.                            
  1489.                            
  1490.                             $.avia_utilities.preload({container: load_container, single_callback:  function()
  1491.                             {
  1492.                                 var links = masonry.find('.av-masonry-sort a'),
  1493.                                     filter_container = masonry.find('.av-sort-by-term'),
  1494.                                     allowed_filters = filter_container.data("av-allowed-sort");
  1495.                                
  1496.                                 filter_container.hide();
  1497.                                
  1498.                                 loader.hide();
  1499.                                 container.isotope( 'insert', new_items);
  1500.                                 $.avia_utilities.avia_ajax_call(masonry);
  1501.                                 setTimeout( function(){ methods.show_bricks( new_items , finished); },150);
  1502.                                 setTimeout(function(){ the_win.trigger('av-height-change'); }, 550);
  1503.                                 if(links)
  1504.                                 {
  1505.                                     $(links).each(function(filterlinkindex)
  1506.                                     {
  1507.                                         var filterlink = $(this),
  1508.                                         sort = filterlink.data('filter');
  1509.  
  1510.                                         if(new_items)
  1511.                                         {
  1512.                                             $(new_items).each(function(itemindex){
  1513.                                                 var item = $(this);
  1514.                                                
  1515.                                                 if(item.hasClass(sort) && allowed_filters.indexOf(sort) !== -1)
  1516.                                                 {
  1517.                                                     var term_count = filterlink.find('.avia-term-count').text();
  1518.                                                     filterlink.find('.avia-term-count').text(' ' + (parseInt(term_count) + 1) + ' ');
  1519.                                        
  1520.                                                     if(filterlink.hasClass('avia_hide_sort'))
  1521.                                                     {
  1522.                                                         filterlink.removeClass('avia_hide_sort').addClass('avia_show_sort');
  1523.                                                         masonry.find('.av-masonry-sort .'+sort+'_sep').removeClass('avia_hide_sort').addClass('avia_show_sort');
  1524.                                                         masonry.find('.av-masonry-sort .av-sort-by-term').removeClass('hidden');
  1525.                                                     }
  1526.                                                 }
  1527.                                             });
  1528.                                         }
  1529.                                     });
  1530.  
  1531.                                 }
  1532.  
  1533.                                                 filter_container.fadeIn();
  1534.                             }
  1535.                         });
  1536.                     }
  1537.                     else
  1538.                     {
  1539.                         finished();
  1540.                     }
  1541.                 },
  1542.                 error: finished,
  1543.                 complete: function()
  1544.                 {
  1545.                     setTimeout(function() { the_win.trigger('debouncedresize'); }, 500);
  1546.                 }
  1547.             });
  1548.         }
  1549.  
  1550.     };
  1551.  
  1552.     return this.each(function()
  1553.     {  
  1554.         var masonry         = $(this),
  1555.             container       = masonry.find('.av-masonry-container'),
  1556.             bricks          = masonry.find('.isotope-item'),
  1557.             filter          = masonry.find('.av-masonry-sort').css({visibility:"visible", opacity:0}).on('click', 'a',  methods.masonry_filter),
  1558.             load_more       = masonry.find('.av-masonry-load-more').css({visibility:"visible", opacity:0});
  1559.            
  1560.         $.avia_utilities.preload({container: container, single_callback:  function()
  1561.         {
  1562.             var start_animation = function()
  1563.             {
  1564.                 filter.animate({opacity:1}, 400);
  1565.                
  1566.                 //fix for non aligned elements because of scrollbar
  1567.                 if(container.outerHeight() + container.offset().top + $('#footer').outerHeight() > $(window).height())
  1568.                 {
  1569.                     $('html').css({'overflow-y':'scroll'});
  1570.                 }
  1571.                
  1572.                 methods.applyMasonry(container, false, function()
  1573.                 {
  1574.                     masonry.addClass('avia_sortable_active');
  1575.                     container.removeClass('av-js-disabled ');
  1576.                 });
  1577.                
  1578.                 methods.show_bricks(bricks, function()
  1579.                 {
  1580.                     load_more.css({opacity:1}).on('click',  methods.loadMore);
  1581.                 });
  1582.                
  1583.                 //container.isotope( 'reLayout' );
  1584.  
  1585.             };
  1586.            
  1587.             if(isMobile)
  1588.             {
  1589.                 start_animation();
  1590.             }
  1591.             else
  1592.             {
  1593.                 masonry.waypoint(start_animation , { offset: '80%'} );
  1594.             }
  1595.                    
  1596.             // update columnWidth on window resize
  1597.             $(window).on( 'debouncedresize', function()
  1598.             {
  1599.                 methods.applyMasonry(container, false, function()
  1600.                 {
  1601.                     masonry.addClass('avia_sortable_active');
  1602.                 });
  1603.             });
  1604.         }
  1605.     });
  1606.        
  1607.        
  1608.     });
  1609. };
  1610.  
  1611.  
  1612.  
  1613.  
  1614.    
  1615. // -------------------------------------------------------------------------------------------
  1616. // Avia AJAX Portfolio
  1617. // -------------------------------------------------------------------------------------------
  1618.  
  1619. (function($)
  1620. {
  1621.     "use strict";
  1622.     $.avia_utilities = $.avia_utilities || {};
  1623.    
  1624.     $.fn.avia_portfolio_preview = function(passed_options)
  1625.     {  
  1626.         var win  = $(window),
  1627.         the_body = $('body'),
  1628.         isMobile = $.avia_utilities.isMobile,
  1629.         defaults =
  1630.         {
  1631.             open_in:    '.portfolio-details-inner',
  1632.             easing:     'easeOutQuint',
  1633.             timing:     800,
  1634.             transition: 'slide' // 'fade' or 'slide'
  1635.         },
  1636.        
  1637.         options = $.extend({}, defaults, passed_options);
  1638.    
  1639.         return this.each(function()
  1640.         {  
  1641.             var container           = $(this),
  1642.                 portfolio_id        = container.data('portfolio-id'),
  1643.                 target_wrap         = $('.portfolio_preview_container[data-portfolio-id="' + portfolio_id + '"]'),
  1644.                 target_container    = target_wrap.find(options.open_in),
  1645.                 items               = container.find('.grid-entry'),
  1646.                 content_retrieved   = {},
  1647.                 is_open             = false,
  1648.                 animating           = false,
  1649.                 index_open          = false,
  1650.                 ajax_call           = false,
  1651.                 methods,
  1652.                 controls,
  1653.                 loader              = $.avia_utilities.loading();
  1654.                
  1655.             methods =
  1656.             {
  1657.                 load_item: function(e)
  1658.                 {
  1659.                     e.preventDefault();
  1660.  
  1661.                     var link            = $(this),
  1662.                         post_container  = link.parents('.post-entry:eq(0)'),
  1663.                         post_id         = "ID_" + post_container.data('ajax-id'),
  1664.                         clickedIndex    = items.index(post_container);
  1665.                    
  1666.                     //check if current item is the clicked item or if we are currently animating
  1667.                     if(post_id === is_open || animating == true)
  1668.                     {
  1669.                         return false;
  1670.                     }
  1671.                    
  1672.                     animating = true;
  1673.                    
  1674.                     container.find('.active_portfolio_item').removeClass('active_portfolio_item');
  1675.                     post_container.addClass('active_portfolio_item');
  1676.                     loader.show();
  1677.                    
  1678.                     methods.ajax_get_contents(post_id, clickedIndex);
  1679.                 },
  1680.                
  1681.                 scroll_top: function()
  1682.                 {
  1683.                     setTimeout(function()
  1684.                     {
  1685.                         var target_offset = target_wrap.offset().top - 175,
  1686.                             window_offset = win.scrollTop();
  1687.                                            
  1688.                         if(window_offset > target_offset || target_offset - window_offset > 100  )
  1689.                         {
  1690.                             $('html:not(:animated),body:not(:animated)').animate({ scrollTop: target_offset }, options.timing, options.easing);
  1691.                         }
  1692.                     },10);
  1693.                 },
  1694.                
  1695.                 attach_item: function(post_id)
  1696.                 {
  1697.                     content_retrieved[post_id] = $(content_retrieved[post_id]).appendTo(target_container);
  1698.                     ajax_call = true;
  1699.                 },
  1700.                
  1701.                 remove_video: function()
  1702.                 {
  1703.                     var del = target_wrap.find('iframe, .avia-video').parents('.ajax_slide:not(.open_slide)'); 
  1704.                    
  1705.                         if(del.length > 0)
  1706.                         {
  1707.                             del.remove();
  1708.                             content_retrieved["ID_" + del.data('slideId')] = undefined;
  1709.                         }
  1710.                 },
  1711.                
  1712.                 show_item: function(post_id, clickedIndex)
  1713.                 {
  1714.                
  1715.                     //check if current item is the clicked item or if we are currently animating
  1716.                     if(post_id === is_open)
  1717.                     {
  1718.                         return false;
  1719.                     }
  1720.                     animating = true;
  1721.                    
  1722.                    
  1723.                     loader.hide();
  1724.                    
  1725.                     if(false === is_open)
  1726.                     {
  1727.                         target_wrap.addClass('open_container');
  1728.                         content_retrieved[post_id].addClass('open_slide');
  1729.                        
  1730.                         methods.scroll_top();
  1731.                        
  1732.                         target_wrap.css({display:'none'}).slideDown(options.timing, options.easing, function()
  1733.                         {
  1734.                             if(ajax_call)
  1735.                             {
  1736.                                 activate_shortcode_scripts(content_retrieved[post_id]);
  1737.                                 $.avia_utilities.avia_ajax_call(content_retrieved[post_id]);
  1738.                                 the_body.trigger('av_resize_finished');
  1739.                                 ajax_call = false;
  1740.                             }
  1741.                            
  1742.                             methods.remove_video();
  1743.                             the_body.trigger('av_resize_finished');
  1744.                         });
  1745.                        
  1746.                             index_open  = clickedIndex;
  1747.                             is_open     = post_id;
  1748.                             animating   = false;
  1749.                        
  1750.                        
  1751.                        
  1752.                     }
  1753.                     else
  1754.                     {
  1755.                         methods.scroll_top();
  1756.                    
  1757.                         var initCSS = { zIndex:3 },
  1758.                             easing  = options.easing;
  1759.                            
  1760.                         if(index_open > clickedIndex) { initCSS.left = '-110%'; }
  1761.                         if(options.transition === 'fade'){ initCSS.left = '0%'; initCSS.opacity = 0; easing = 'easeOutQuad'; }
  1762.                        
  1763.                         //fixate height for container during animation
  1764.                         target_container.height(target_container.height()); //outerHeight = border problems?
  1765.                        
  1766.                         content_retrieved[post_id].css(initCSS).avia_animate({'left':"0%", opacity:1}, options.timing, easing);
  1767.                         content_retrieved[is_open].avia_animate({opacity:0}, options.timing, easing, function()
  1768.                         {
  1769.                             content_retrieved[is_open].attr({'style':""}).removeClass('open_slide');
  1770.                             content_retrieved[post_id].addClass('open_slide');
  1771.                                                                                                           //+ 2 fixes border problem (slides move up and down 2 px on transition)
  1772.                             target_container.avia_animate({height: content_retrieved[post_id].outerHeight() + 2}, options.timing/2, options.easing, function()
  1773.                             {
  1774.                                 target_container.attr({'style':""});
  1775.                                 is_open     = post_id;
  1776.                                 index_open  = clickedIndex;
  1777.                                 animating   = false;
  1778.                                
  1779.                                 methods.remove_video();
  1780.                                 if(ajax_call)
  1781.                                 {
  1782.                                     the_body.trigger('av_resize_finished');
  1783.                                     activate_shortcode_scripts(content_retrieved[post_id]);
  1784.                                     $.avia_utilities.avia_ajax_call(content_retrieved[post_id]);
  1785.                                     ajax_call = false;
  1786.                                 }
  1787.    
  1788.                             });
  1789.                            
  1790.                         });    
  1791.                     }
  1792.                 },
  1793.                
  1794.                 ajax_get_contents: function(post_id, clickedIndex)
  1795.                 {
  1796.                     if(content_retrieved[post_id] !== undefined)
  1797.                     {
  1798.                         methods.show_item(post_id, clickedIndex);
  1799.                         return;
  1800.                     }
  1801.                    
  1802.                     content_retrieved[post_id] = $('#avia-tmpl-portfolio-preview-' + post_id.replace(/ID_/,"")).html();
  1803.                    
  1804.                     //this line is necessary to prevent w3 total cache from messing up the portfolio if inline js is compressed
  1805.                     content_retrieved[post_id] = content_retrieved[post_id].replace('/*<![CDATA[*/','').replace('*]]>','');
  1806.                    
  1807.                     methods.attach_item(post_id);
  1808.                    
  1809.                     $.avia_utilities.preload({container: content_retrieved[post_id] , single_callback:  function(){ methods.show_item(post_id, clickedIndex); }});
  1810.                 },
  1811.                
  1812.                 add_controls: function()
  1813.                 {
  1814.                     controls = target_wrap.find('.ajax_controlls');
  1815.  
  1816.                     target_wrap.avia_keyboard_controls({27:'.avia_close', 37:'.ajax_previous', 39:'.ajax_next'});
  1817.                     //target_wrap.avia_swipe_trigger({prev:'.ajax_previous', next:'.ajax_next'});
  1818.                    
  1819.                     items.each(function(){
  1820.                    
  1821.                         var current = $(this), overlay;
  1822.                        
  1823.                         current.addClass('no_combo').bind('click', function(event)
  1824.                         {
  1825.                             overlay = current.find('.slideshow_overlay');
  1826.                            
  1827.                             if(overlay.length)
  1828.                             {
  1829.                                 event.stopPropagation();
  1830.                                 methods.load_item.apply(current.find('a:eq(0)'));
  1831.                                 return false;
  1832.                             }
  1833.                         });
  1834.                        
  1835.                        
  1836.                     });
  1837.                 },
  1838.                
  1839.                 control_click: function()
  1840.                 {
  1841.                     var showItem,
  1842.                         activeID = container.find('.active_portfolio_item').data('ajax-id'),
  1843.                         active   = container.find('.post-entry-'+activeID);
  1844.                
  1845.                     switch(this.hash)
  1846.                     {
  1847.                         case '#next':
  1848.                        
  1849.                             showItem = active.nextAll('.post-entry:visible:eq(0)').find('a:eq(0)');
  1850.                             if(!showItem.length) { showItem = $('.post-entry:visible:eq(0)', container).find('a:eq(0)'); }
  1851.                             showItem.trigger('click');
  1852.                    
  1853.                         break;
  1854.                         case '#prev':
  1855.                            
  1856.                             showItem = active.prevAll('.post-entry:visible:eq(0)').find('a:eq(0)');
  1857.                             if(!showItem.length) { showItem = $('.post-entry:visible:last', container).find('a:eq(0)'); }
  1858.                             showItem.trigger('click');
  1859.                        
  1860.                         break;
  1861.                         case '#close':
  1862.                        
  1863.                             animating = true;
  1864.                            
  1865.                             target_wrap.slideUp( options.timing, options.easing, function()
  1866.                             {
  1867.                                 container.find('.active_portfolio_item').removeClass('active_portfolio_item');
  1868.                                 content_retrieved[is_open].attr({'style':""}).removeClass('open_slide');
  1869.                                 target_wrap.removeClass('open_container');
  1870.                                 animating = is_open = index_open = false;
  1871.                                 methods.remove_video();
  1872.                                 the_body.trigger('av_resize_finished');
  1873.                             });
  1874.                            
  1875.                         break;
  1876.                     }
  1877.                     return false;
  1878.                 },
  1879.                
  1880.                
  1881.                 resize_reset: function()
  1882.                 {
  1883.                     if(is_open === false)
  1884.                     {
  1885.                         target_container.html('');
  1886.                         content_retrieved   = [];
  1887.                     }
  1888.                 }
  1889.             };
  1890.            
  1891.             methods.add_controls();
  1892.            
  1893.             container.on("click", "a", methods.load_item);
  1894.             controls.on("click", "a", methods.control_click);
  1895.             if(jQuery.support.leadingWhitespace) { win.bind('debouncedresize', methods.resize_reset); }
  1896.            
  1897.         });
  1898.     };
  1899. }(jQuery));
  1900.  
  1901.  
  1902.  
  1903. // -------------------------------------------------------------------------------------------
  1904. // Fullscreen Slideshow
  1905. //
  1906. // extends avia slideshow script with a more sophisticated preloader and fixed size for slider
  1907. // -------------------------------------------------------------------------------------------
  1908.  
  1909.  
  1910.     $.AviaFullscreenSlider  =  function(options, slider)
  1911.     {
  1912.         this.$slider    = $( slider );
  1913.         this.$inner     = this.$slider.find('.avia-slideshow-inner');
  1914.         this.$innerLi   = this.$inner.find('>li');
  1915.         this.$caption   = this.$inner.find('.avia-slide-wrap .caption_container');
  1916.         this.$win       = $( window );
  1917.         this.isMobile   = $.avia_utilities.isMobile;
  1918.         this.property   = {};
  1919.         this.scrollPos  = "0";
  1920.         this.transform3d= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
  1921.         this.ticking    = false;
  1922.        
  1923.        
  1924.         if($.avia_utilities.supported.transition === undefined)
  1925.         {
  1926.             $.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
  1927.         }
  1928.        
  1929.         this._init( options );
  1930.     }
  1931.  
  1932.     $.AviaFullscreenSlider.defaults  = {
  1933.  
  1934.         //height of the slider in percent
  1935.         height: 100,
  1936.        
  1937.         //subtract elements from the height
  1938.         subtract: '#wpadminbar, #header, #main>.title_container'
  1939.        
  1940.        
  1941.     };
  1942.  
  1943.     $.AviaFullscreenSlider.prototype =
  1944.     {
  1945.         _init: function( options )
  1946.         {
  1947.             var _self = this;
  1948.             //set the default options
  1949.             this.options = $.extend( true, {}, $.AviaFullscreenSlider.defaults, options );
  1950.            
  1951.             if(this.$slider.data('slide_height')) this.options.height = this.$slider.data('slide_height');
  1952.            
  1953.             //if background attachment is set to fixed or scroll disable the parallax effect
  1954.             this.options.parallax_enabled = this.$slider.data('image_attachment') == "" ? true : false;
  1955.            
  1956.             //elements that get subtracted from the image height
  1957.             this.$subtract = $(this.options.subtract);
  1958.            
  1959.            
  1960.             // set the slideshow size
  1961.             this._setSize();
  1962.            
  1963.             // set resizing script on window resize
  1964.             this.$win.on( 'debouncedresize',  $.proxy( this._setSize, this) );
  1965.            
  1966.             //parallax scroll if element if leaving viewport
  1967.             setTimeout(function()
  1968.             {
  1969.                 if(!_self.isMobile && _self.options.parallax_enabled) //disable parallax scrolling on mobile
  1970.                 {
  1971.                     _self.$win.on( 'scroll', $.proxy( _self._on_scroll, _self) );
  1972.                 }
  1973.                
  1974.             },100);
  1975.             /**/
  1976.            
  1977.             //activate the defaule slider
  1978.             this.$slider.aviaSlider({bg_slider:true});
  1979.            
  1980.            
  1981.         },
  1982.        
  1983.         _on_scroll: function(e)
  1984.         {
  1985.             var _self = this;
  1986.            
  1987.             if(!_self.ticking) {
  1988.              _self.ticking = true;
  1989.               window.requestAnimationFrame( $.proxy( _self._parallax_scroll, _self) );
  1990.             }
  1991.         },
  1992.        
  1993.        
  1994.         _fetch_properties: function(slide_height)
  1995.         {
  1996.             this.property.offset    = this.$slider.offset().top;
  1997.             this.property.wh        = this.$win.height();
  1998.             this.property.height    = slide_height || this.$slider.outerHeight();
  1999.            
  2000.             //re-position the slider
  2001.             this._parallax_scroll();
  2002.         },
  2003.        
  2004.         _setSize: function( )
  2005.         {  
  2006.             if(!$.fn.avia_browser_height)
  2007.             {
  2008.        
  2009.             var viewport        = this.$win.height(),
  2010.                 slide_height    = Math.ceil( (viewport / 100) * this.options.height );
  2011.            
  2012.             if(this.$subtract.length && this.options.height == 100)
  2013.             {
  2014.                 this.$subtract.each(function()
  2015.                 {
  2016.                     slide_height -= this.offsetHeight - 0.5;
  2017.                 });
  2018.             }
  2019.             else
  2020.             {
  2021.                 slide_height -= 1;
  2022.             }
  2023.             this.$slider.height(slide_height).removeClass('av-default-height-applied');
  2024.             this.$inner.css('padding',0);
  2025.             }
  2026.            
  2027.            
  2028.             this._fetch_properties(slide_height);
  2029.         },
  2030.        
  2031.         _parallax_scroll: function(e)
  2032.         {
  2033.             if(this.isMobile || ! this.options.parallax_enabled) return; //disable parallax scrolling on mobile
  2034.        
  2035.             var winTop      = this.$win.scrollTop(),
  2036.                 winBottom   =  winTop + this.property.wh,
  2037.                 scrollPos   = "0",
  2038.                 prop        = {}, prop2 = {};
  2039.            
  2040.             if(this.property.offset < winTop && winTop <= this.property.offset + this.property.height)
  2041.             {  
  2042.                 scrollPos = Math.round( (winTop - this.property.offset) * 0.3 );
  2043.             }
  2044.            
  2045.             if(this.scrollPos != scrollPos)
  2046.             {  
  2047.                 //slide background parallax
  2048.                 this.scrollPos = scrollPos;
  2049.                
  2050.                 //currently no 3d transform, because of browser quirks
  2051.                 //this.transform3d = false;
  2052.                
  2053.                 if(this.transform3d)
  2054.                 {
  2055.                     prop[$.avia_utilities.supported.transition+"transform"] = "translate3d(0px,"+ scrollPos +"px,0px)";
  2056.                 }
  2057.                 else
  2058.                 {
  2059.                     prop[$.avia_utilities.supported.transition+"transform"] = "translate(0px,"+ scrollPos +"px)";
  2060.                 }
  2061.                
  2062.                
  2063.                 this.$inner.css(prop);
  2064.                
  2065.                
  2066.                
  2067.                 //slider caption parallax
  2068.                
  2069.                 // prop2[$.avia_utilities.supported.transition+"transform"] = "translate(0px,-"+ ( scrollPos * 1) +"px)";
  2070.                 /*
  2071.                 prop2['opacity'] = Math.ceil((this.$slider.height() - (scrollPos * 2)) / 100)/ 10;
  2072.                 prop2['opacity'] = prop2['opacity'] < 0 ? 0 : prop2['opacity'];
  2073.                 this.$caption.css(prop2);
  2074.                 */
  2075.             }
  2076.            
  2077.             this.ticking = false;
  2078.         }
  2079.     };
  2080.  
  2081.  
  2082.  
  2083. $.fn.aviaFullscreenSlider = function( options )
  2084. {
  2085.     return this.each(function()
  2086.     {
  2087.         var active = $.data( this, 'aviaFullscreenSlider' );
  2088.  
  2089.         if(!active)
  2090.         {
  2091.             //make sure that the function doesnt get aplied a second time
  2092.             $.data( this, 'aviaFullscreenSlider', 1 );
  2093.            
  2094.             //create the preparations for fullscreen slider
  2095.             new $.AviaFullscreenSlider( options, this );
  2096.         }
  2097.     });
  2098. }
  2099.    
  2100. // -------------------------------------------------------------------------------------------
  2101. // makes sure that the fixed container height is removed once the layerslider is loaded, so it adapts to the screen resolution
  2102. // -------------------------------------------------------------------------------------------
  2103.  
  2104.     $.AviaParallaxElement  =  function(options, element)
  2105.     {
  2106.         this.$el        = $( element ).addClass('active-parallax');
  2107.         this.$win       = $( window );
  2108.         this.$body      = $( 'body' );
  2109.         this.$parent    = this.$el.parent();
  2110.         this.property   = {};
  2111.         this.isMobile   = $.avia_utilities.isMobile;
  2112.         this.ratio      = this.$el.data('avia-parallax-ratio') || 0.5;
  2113.         this.transform  = document.documentElement.className.indexOf('avia_transform') !== -1 ? true : false;
  2114.         this.transform3d= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
  2115.         this.ticking    = false;
  2116.        
  2117.         if($.avia_utilities.supported.transition === undefined)
  2118.         {
  2119.             $.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
  2120.         }
  2121.        
  2122.         this._init( options );
  2123.     }
  2124.    
  2125.     $.AviaParallaxElement.prototype = {
  2126.    
  2127.         _init: function( options )
  2128.         {
  2129.             var _self = this;
  2130.             if(_self.isMobile)
  2131.             {
  2132.                 return; //disable parallax scrolling on mobile
  2133.             }
  2134.            
  2135.             //fetch window constants
  2136.             setTimeout(function()
  2137.             {
  2138.                 _self._fetch_properties();
  2139.             },30);
  2140.            
  2141.             this.$win.on("debouncedresize av-height-change",  $.proxy( _self._fetch_properties, _self));
  2142.             this.$body.on("av_resize_finished",  $.proxy( _self._fetch_properties, _self));
  2143.            
  2144.            
  2145.            
  2146.             //activate the scrolling
  2147.             setTimeout(function()
  2148.             {
  2149.                 _self.$win.on( 'scroll', $.proxy( _self._on_scroll, _self) );
  2150.                
  2151.             },100);
  2152.         },
  2153.        
  2154.         _fetch_properties: function()
  2155.         {
  2156.             this.property.offset    = this.$parent.offset().top;
  2157.             this.property.wh        = this.$win.height();
  2158.             this.property.height    = this.$parent.outerHeight();
  2159.            
  2160.             //set the height of the element based on the windows height, offset ratio and parent height
  2161.             this.$el.height(Math.ceil((this.property.wh * this.ratio) + this.property.height));
  2162.            
  2163.             //re-position the element
  2164.             this._parallax_scroll();
  2165.         },
  2166.        
  2167.         _on_scroll: function(e)
  2168.         {
  2169.             var _self = this;
  2170.            
  2171.             if(!_self.ticking) {
  2172.              _self.ticking = true;
  2173.               window.requestAnimationFrame( $.proxy( _self._parallax_scroll, _self) );
  2174.             }
  2175.         },
  2176.        
  2177.         _parallax_scroll: function(e)
  2178.         {
  2179.             var winTop      =  this.$win.scrollTop(),
  2180.                 winBottom   =  winTop + this.property.wh,
  2181.                 scrollPos   = "0",
  2182.                 prop = {};
  2183.            
  2184.             //shift element when it moves into viewport
  2185.             if(this.property.offset < winBottom && winTop <= this.property.offset + this.property.height)
  2186.             {  
  2187.                 scrollPos = Math.ceil( (winBottom - this.property.offset) * this.ratio );
  2188.                
  2189.                 //parallax movement via backround position change, although
  2190.                 if(this.transform3d)
  2191.                 {
  2192.                     prop[$.avia_utilities.supported.transition+"transform"] = "translate3d(0px,"+ scrollPos +"px, 0px)";
  2193.                 }
  2194.                 else if(this.transform)
  2195.                 {
  2196.                     prop[$.avia_utilities.supported.transition+"transform"] = "translate(0px,"+ scrollPos +"px)";
  2197.                 }
  2198.                 else
  2199.                 {
  2200.                     prop["background-position"] = "0px "+ scrollPos +"px";
  2201.                 }
  2202.                
  2203.                 this.$el.css(prop);
  2204.             }
  2205.            
  2206.             this.ticking = false;
  2207.         }
  2208.     };
  2209.  
  2210.  
  2211. $.fn.avia_parallax = function(options)
  2212. {
  2213.     return this.each(function()
  2214.         {
  2215.             var self = $.data( this, 'aviaParallax' );
  2216.  
  2217.             if(!self)
  2218.             {
  2219.                 self = $.data( this, 'aviaParallax', new $.AviaParallaxElement( options, this ) );
  2220.             }
  2221.         });
  2222. }
  2223.  
  2224.  
  2225. // -------------------------------------------------------------------------------------------
  2226. // Helper to allow fixed bgs on mobile
  2227. // -------------------------------------------------------------------------------------------
  2228.  
  2229. $.fn.avia_mobile_fixed = function(options)
  2230. {
  2231.     var isMobile = $.avia_utilities.isMobile;
  2232.     if(!isMobile) return;
  2233.    
  2234.     return this.each(function()
  2235.     {
  2236.         var current             = $(this).addClass('av-parallax-section'),
  2237.             $background         = current.attr('style'),
  2238.             $attachment_class   = current.data('section-bg-repeat'),
  2239.             template            = "";
  2240.            
  2241.             if($attachment_class == 'stretch' || $attachment_class == 'no-repeat' )
  2242.             {
  2243.                 $attachment_class = " avia-full-stretch";
  2244.             }
  2245.             else
  2246.             {
  2247.                 $attachment_class = "";
  2248.             }
  2249.            
  2250.             template = "<div class='av-parallax " + $attachment_class + "' data-avia-parallax-ratio='0.0' style = '" + $background + "' ></div>";
  2251.            
  2252.             current.prepend(template);
  2253.             current.attr('style','');
  2254.     });
  2255. }
  2256.  
  2257.  
  2258.  
  2259.  
  2260.    
  2261. // -------------------------------------------------------------------------------------------
  2262. // makes sure that the fixed container height is removed once the layerslider is loaded, so it adapts to the screen resolution
  2263. // -------------------------------------------------------------------------------------------
  2264.  
  2265. $.fn.layer_slider_height_helper = function(options)
  2266. {
  2267.     return this.each(function()
  2268.     {
  2269.         var container   = $(this),
  2270.             first_div   = container.find('>div:first'),
  2271.             timeout     = false,
  2272.             counter     = 0,
  2273.             reset_size  = function()
  2274.             {
  2275.                 if(first_div.height() > 0 || counter > 5)
  2276.                 {
  2277.                     container.height('auto');
  2278.                 }
  2279.                 else
  2280.                 {
  2281.                     timeout = setTimeout(reset_size, 500);
  2282.                     counter++;
  2283.                 }
  2284.             };
  2285.  
  2286.         if(!first_div.length) return;
  2287.  
  2288.         timeout = setTimeout(reset_size, 0);
  2289.     });
  2290. }
  2291.  
  2292. // -------------------------------------------------------------------------------------------
  2293. // testimonial shortcode javascript
  2294. // -------------------------------------------------------------------------------------------
  2295.  
  2296. $.fn.avia_sc_testimonial = function(options)
  2297. {
  2298.     return this.each(function()
  2299.     {
  2300.         var container = $(this), elements = container.find('.avia-testimonial');
  2301.  
  2302.  
  2303.         //trigger displaying of thumbnails
  2304.         container.on('avia_start_animation', function()
  2305.         {
  2306.             elements.each(function(i)
  2307.             {
  2308.                 var element = $(this);
  2309.                 setTimeout(function(){ element.addClass('avia_start_animation') }, (i * 150));
  2310.             });
  2311.         });
  2312.     });
  2313. }
  2314.  
  2315.  
  2316. // -------------------------------------------------------------------------------------------
  2317. // Progress bar shortcode javascript
  2318. // -------------------------------------------------------------------------------------------
  2319.  
  2320. $.fn.avia_sc_progressbar = function(options)
  2321. {
  2322.     return this.each(function()
  2323.     {
  2324.         var container = $(this), elements = container.find('.avia-progress-bar');
  2325.        
  2326.        
  2327.         //trigger displaying of progress bar
  2328.         container.on('avia_start_animation', function()
  2329.         {
  2330.             elements.each(function(i)
  2331.             {
  2332.                 var element = $(this)
  2333.                
  2334.                 setTimeout(function()
  2335.                 {
  2336.                     element.find('.progress').addClass('avia_start_animation')
  2337.                     element.find('.progressbar-percent').avia_sc_animated_number(
  2338.                     {
  2339.                         instant_start:true, simple_up:true, start_timer: 10
  2340.                     });
  2341.                    
  2342.                 }, (i * 250));
  2343.             });
  2344.         });
  2345.     });
  2346. }
  2347.  
  2348. // -------------------------------------------------------------------------------------------
  2349. // Iconlist shortcode javascript
  2350. // -------------------------------------------------------------------------------------------
  2351.  
  2352. $.fn.avia_sc_iconlist = function(options)
  2353. {
  2354.     return this.each(function()
  2355.     {
  2356.         var iconlist = $(this), elements = iconlist.find('>li');
  2357.  
  2358.  
  2359.         //trigger displaying of thumbnails
  2360.         iconlist.on('avia_start_animation', function()
  2361.         {
  2362.             elements.each(function(i)
  2363.             {
  2364.                 var element = $(this);
  2365.                 setTimeout(function(){ element.addClass('avia_start_animation') }, (i * 350));
  2366.             });
  2367.         });
  2368.     });
  2369. }
  2370.  
  2371.  
  2372. // -------------------------------------------------------------------------------------------
  2373. //  shortcode javascript for delayed animation even when non connected elements are used
  2374. // -------------------------------------------------------------------------------------------
  2375.  
  2376. $.fn.avia_sc_animation_delayed = function(options)
  2377. {
  2378.     var global_timer = 0,
  2379.         delay = options.delay || 50,
  2380.         max_timer = 10,
  2381.         new_max = setTimeout(function(){ max_timer = 20; }, 500);
  2382.    
  2383.     return this.each(function()
  2384.     {
  2385.         var elements = $(this);
  2386.  
  2387.         //trigger displaying of thumbnails
  2388.         elements.on('avia_start_animation', function()
  2389.         {
  2390.             var element = $(this);
  2391.              
  2392.             if(global_timer < max_timer) global_timer ++;
  2393.            
  2394.             setTimeout(function()
  2395.             {
  2396.                 element.addClass('avia_start_delayed_animation');
  2397.                 if(global_timer > 0) global_timer --;
  2398.            
  2399.             }, (global_timer * delay));
  2400.            
  2401.         });
  2402.     });
  2403. }
  2404.  
  2405. /*delayd animations when used within tab sections or similar elements. this way they get animated each new time a tab is shown*/
  2406. $.fn.avia_delayed_animation_in_container = function(options)
  2407. {
  2408.     return this.each(function()
  2409.     {
  2410.         var elements = $(this);
  2411.        
  2412.         elements.on('avia_start_animation_if_current_slide_is_active', function()
  2413.         {
  2414.             var current = $(this),
  2415.                 animate = current.find('.avia_start_animation_when_active');
  2416.                
  2417.                 animate.addClass('avia_start_animation').trigger('avia_start_animation');
  2418.         });
  2419.        
  2420.         elements.on('avia_remove_animation', function()
  2421.         {
  2422.             var current = $(this),
  2423.                 animate = current.find('.avia_start_animation_when_active, .avia_start_animation');
  2424.                 animate.removeClass('avia_start_animation avia_start_delayed_animation');
  2425.         });
  2426.     });
  2427. }
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433. // -------------------------------------------------------------------------------------------
  2434. // Section Height Helper
  2435. // -------------------------------------------------------------------------------------------
  2436.  
  2437. $.fn.avia_browser_height = function()
  2438. {
  2439.     if(!this.length) return;
  2440.    
  2441.     var win         = $(window),
  2442.         html_el     = $('html'),
  2443.         subtract    = $('#wpadminbar, #header.av_header_top:not(.html_header_transparency #header), #main>.title_container'),
  2444.         css_block   = $("<style type='text/css' id='av-browser-height'></style>").appendTo('head:first'),
  2445.         sidebar_menu= $('.html_header_sidebar #top #header_main'),
  2446.         full_slider = $('.html_header_sidebar .avia-fullscreen-slider.avia-builder-el-0.avia-builder-el-no-sibling').addClass('av-solo-full'),
  2447.         calc_height = function()
  2448.         {
  2449.             var css         = "",
  2450.                 wh100       = win.height(),
  2451.                 ww100       = win.width(),
  2452.                 wh100_mod   = wh100,
  2453.                 whCover     = (wh100 / 9) * 16,
  2454.                 wwCover     = (ww100 / 16) * 9,
  2455.                 wh75        = Math.round( wh100 * 0.75 ),
  2456.                 wh50        = Math.round( wh100 * 0.5  ),
  2457.                 wh25        = Math.round( wh100 * 0.25 ),
  2458.                 solo        = 0;
  2459.            
  2460.             if(sidebar_menu.length) solo = sidebar_menu.height();
  2461.            
  2462.             subtract.each(function(){ wh100_mod -= this.offsetHeight - 1; });  
  2463.            
  2464.             var whCoverMod  = (wh100_mod / 9) * 16;
  2465.            
  2466.             //fade in of section content with minimum height once the height has been calculated
  2467.             css += ".avia-section.av-minimum-height .container{opacity: 1; }\n";
  2468.            
  2469.             //various section heights (100-25% as well as 100% - header/adminbar in case its the first builder element)
  2470.             css += ".av-minimum-height-100 .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";
  2471.             css += ".av-minimum-height-75 .container, .av-cell-min-height-75 > .flex_cell   {height:"+wh75+"px;}\n";
  2472.             css += ".av-minimum-height-50 .container, .av-cell-min-height-50 > .flex_cell   {height:"+wh50+"px;}\n";
  2473.             css += ".av-minimum-height-25 .container, .av-cell-min-height-25 > .flex_cell   {height:"+wh25+"px;}\n";
  2474.             css += ".avia-builder-el-0.av-minimum-height-100 .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";
  2475.            
  2476.             css += "#top .av-solo-full .avia-slideshow {min-height:"+solo+"px;}\n";
  2477.            
  2478.             //fullscreen video calculations
  2479.             if(ww100/wh100 < 16/9)
  2480.             {
  2481.                 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";
  2482.             }
  2483.             else
  2484.             {
  2485.                 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";
  2486.             }
  2487.            
  2488.             if(ww100/wh100_mod < 16/9)
  2489.             {
  2490.                 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";
  2491.             }
  2492.             else
  2493.             {
  2494.                 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";
  2495.             }
  2496.            
  2497.             //ie8 needs different insert method
  2498.             try{
  2499.                 css_block.text(css);
  2500.             }
  2501.             catch(err){
  2502.                 css_block.remove();
  2503.                 css_block = $("<style type='text/css' id='av-browser-height'>"+css+"</style>").appendTo('head:first');
  2504.             }
  2505.            
  2506.            
  2507.             setTimeout(function(){ win.trigger('av-height-change'); /*broadcast the height change*/ },100);
  2508.         };
  2509.    
  2510.     win.on( 'debouncedresize', calc_height);
  2511.     calc_height();
  2512. }
  2513.  
  2514. // -------------------------------------------------------------------------------------------
  2515. // Video Section helper
  2516. // -------------------------------------------------------------------------------------------
  2517.  
  2518. $.fn.avia_video_section = function()
  2519. {
  2520.     if(!this.length) return;
  2521.    
  2522.     var elements    = this.length, content = "",
  2523.         win         = $(window),
  2524.         css_block   = $("<style type='text/css' id='av-section-height'></style>").appendTo('head:first'),
  2525.         calc_height = function(section, counter)
  2526.         {
  2527.             if(counter === 0) { content = "";}
  2528.        
  2529.             var css         = "",
  2530.                 the_id      = '#' +section.attr('id'),
  2531.                 wh100       = section.height(),
  2532.                 ww100       = section.width(),
  2533.                 aspect      = section.data('sectionVideoRatio').split(':'),
  2534.                 video_w     = aspect[0],
  2535.                 video_h     = aspect[1],
  2536.                 whCover     = (wh100 / video_h ) * video_w,
  2537.                 wwCover     = (ww100 / video_w ) * video_h;
  2538.            
  2539.             //fullscreen video calculations
  2540.             if(ww100/wh100 < video_w/video_h)
  2541.             {
  2542.                 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";
  2543.             }
  2544.             else
  2545.             {
  2546.                 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";
  2547.             }
  2548.            
  2549.             content = content + css;
  2550.            
  2551.             if(elements == counter + 1)
  2552.             {
  2553.                 //ie8 needs different insert method
  2554.                 try{
  2555.                     css_block.text(content);
  2556.                 }
  2557.                 catch(err){
  2558.                     css_block.remove();
  2559.                     css_block = $("<style type='text/css' id='av-section-height'>"+content+"</style>").appendTo('head:first');
  2560.                 }
  2561.             }
  2562.         };
  2563.        
  2564.        
  2565.     return this.each(function(i)
  2566.     {
  2567.         var self = $(this);
  2568.        
  2569.         win.on( 'debouncedresize', function(){ calc_height(self, i); });
  2570.         calc_height(self, i);
  2571.     });
  2572.    
  2573. }
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.  
  2582. // -------------------------------------------------------------------------------------------
  2583. // Gallery shortcode javascript
  2584. // -------------------------------------------------------------------------------------------
  2585.  
  2586. $.fn.avia_sc_gallery = function(options)
  2587. {
  2588.     return this.each(function()
  2589.     {
  2590.         var gallery = $(this), images = gallery.find('img'), big_prev = gallery.find('.avia-gallery-big');
  2591.  
  2592.  
  2593.         //trigger displaying of thumbnails
  2594.         gallery.on('avia_start_animation', function()
  2595.         {
  2596.             images.each(function(i)
  2597.             {
  2598.                 var image = $(this);
  2599.                 setTimeout(function(){ image.addClass('avia_start_animation') }, (i * 110));
  2600.             });
  2601.         });
  2602.        
  2603.         if(gallery.hasClass('deactivate_avia_lazyload')) gallery.trigger('avia_start_animation');
  2604.  
  2605.         //trigger thumbnail hover and big prev image change
  2606.         if(big_prev.length)
  2607.         {
  2608.             gallery.on('mouseenter','.avia-gallery-thumb a', function()
  2609.             {
  2610.                 var _self = this;
  2611.  
  2612.                 big_prev.attr('data-onclick', _self.getAttribute("data-onclick"));
  2613.                 big_prev.height(big_prev.height());
  2614.                 big_prev.attr('href', _self.href)
  2615.  
  2616.                 var newImg      = _self.getAttribute("data-prev-img"),
  2617.                     oldImg      = big_prev.find('img'),
  2618.                     oldImgSrc   = oldImg.attr('src');
  2619.  
  2620.                 if(newImg != oldImgSrc)
  2621.                 {
  2622.                     var next_img = new Image();
  2623.                     next_img.src = newImg;
  2624.                    
  2625.                     var $next = $(next_img);
  2626.                    
  2627.                     if(big_prev.hasClass('avia-gallery-big-no-crop-thumb'))
  2628.                     {
  2629.                         $next.css({'height':big_prev.height(),'width':'auto'});
  2630.                     }
  2631.                    
  2632.                     big_prev.stop().animate({opacity:0}, function()
  2633.                     {
  2634.                         $next.insertAfter(oldImg);
  2635.                         oldImg.remove();
  2636.                         big_prev.animate({opacity:1});
  2637.                        
  2638.                         big_prev.attr('title',$(_self).attr('title'));
  2639.                        
  2640.                     });
  2641.                 }
  2642.             });
  2643.  
  2644.             big_prev.on('click', function()
  2645.             {
  2646.                 var imagelink = gallery.find('.avia-gallery-thumb a').eq(this.getAttribute("data-onclick") - 1);
  2647.  
  2648.                 if(imagelink && !imagelink.hasClass('aviaopeninbrowser'))
  2649.                 {
  2650.                     imagelink.trigger('click');
  2651.                 }
  2652.                 else if(imagelink)
  2653.                 {
  2654.                     var imgurl = imagelink.attr("href");
  2655.  
  2656.                     if(imagelink.hasClass('aviablank') && imgurl != '' )
  2657.                     {
  2658.                         window.open(imgurl, '_blank');
  2659.                     }
  2660.                     else if( imgurl != '' )
  2661.                     {
  2662.                         window.open(imgurl, '_self');
  2663.                     }
  2664.                 }
  2665.                 return false;
  2666.             });
  2667.  
  2668.  
  2669.             $(window).on("debouncedresize", function()
  2670.             {
  2671.                 big_prev.height('auto');
  2672.             });
  2673.  
  2674.         }
  2675.     });
  2676. }
  2677.  
  2678. // -------------------------------------------------------------------------------------------
  2679. // Toggle shortcode javascript
  2680. // -------------------------------------------------------------------------------------------
  2681.  
  2682. $.fn.avia_sc_toggle = function(options)
  2683. {
  2684.     var defaults =
  2685.     {
  2686.         single: '.single_toggle',
  2687.         heading: '.toggler',
  2688.         content: '.toggle_wrap',
  2689.         sortContainer:'.taglist'
  2690.     };
  2691.  
  2692.     var win = $(window),
  2693.         options = $.extend(defaults, options);
  2694.  
  2695.     return this.each(function()
  2696.     {
  2697.         var container   = $(this).addClass('enable_toggles'),
  2698.             toggles     = $(options.single, container),
  2699.             heading     = $(options.heading, container),
  2700.             allContent  = $(options.content, container),
  2701.             sortLinks   = $(options.sortContainer + " a", container);
  2702.  
  2703.         heading.each(function(i)
  2704.         {
  2705.             var thisheading =  $(this), content = thisheading.next(options.content, container);
  2706.  
  2707.             function scroll_to_viewport()
  2708.             {
  2709.                 //check if toggle title is in viewport. if not scroll up
  2710.                 var el_offset = content.offset().top,
  2711.                     scoll_target = el_offset - 50 - parseInt($('html').css('margin-top'),10);
  2712.  
  2713.                 if(win.scrollTop() > el_offset)
  2714.                 {
  2715.                     $('html:not(:animated),body:not(:animated)').animate({scrollTop: scoll_target},200);
  2716.                 }
  2717.             }
  2718.  
  2719.             if(content.css('visibility') != "hidden")
  2720.             {
  2721.                 thisheading.addClass('activeTitle');
  2722.             }
  2723.  
  2724.             thisheading.on('click', function()
  2725.             {
  2726.                 if(content.css('visibility') != "hidden")
  2727.                 {
  2728.                     content.slideUp(200, function()
  2729.                     {
  2730.                         content.removeClass('active_tc').attr({style:''});
  2731.                         win.trigger('av-height-change');
  2732.                         location.replace(thisheading.data('fake-id') + "-closed");
  2733.                     });
  2734.                     thisheading.removeClass('activeTitle');
  2735.  
  2736.                 }
  2737.                 else
  2738.                 {
  2739.                     if(container.is('.toggle_close_all'))
  2740.                     {
  2741.                         allContent.not(content).slideUp(200, function()
  2742.                         {
  2743.                             $(this).removeClass('active_tc').attr({style:''});
  2744.                             scroll_to_viewport();
  2745.                         });
  2746.                         heading.removeClass('activeTitle');
  2747.                     }
  2748.                    
  2749.                     content.addClass('active_tc');
  2750.                    
  2751.                     setTimeout(function(){
  2752.                        
  2753.                         content.slideDown(200,
  2754.                        
  2755.                             function()
  2756.                             {
  2757.                                 if(!container.is('.toggle_close_all'))
  2758.                                 {
  2759.                                     scroll_to_viewport();
  2760.                                 }
  2761.                                
  2762.                                 win.trigger('av-height-change');
  2763.                             }
  2764.                        
  2765.                         );
  2766.                    
  2767.                     }, 1);
  2768.                    
  2769.                     thisheading.addClass('activeTitle');
  2770.                     location.replace(thisheading.data('fake-id'));
  2771.                 }
  2772.                
  2773.                
  2774.                
  2775.             });
  2776.         });
  2777.  
  2778.  
  2779.         sortLinks.click(function(e){
  2780.  
  2781.             e.preventDefault();
  2782.             var show = toggles.filter('[data-tags~="'+$(this).data('tag')+'"]'),
  2783.                 hide = toggles.not('[data-tags~="'+$(this).data('tag')+'"]');
  2784.  
  2785.                 sortLinks.removeClass('activeFilter');
  2786.                 $(this).addClass('activeFilter');
  2787.                 heading.filter('.activeTitle').trigger('click');
  2788.                 show.slideDown();
  2789.                 hide.slideUp();
  2790.         });
  2791.  
  2792.  
  2793.         function trigger_default_open(hash)
  2794.         {
  2795.             if(!hash && window.location.hash) hash = window.location.hash;
  2796.             if(!hash) return;
  2797.            
  2798.             var open = heading.filter('[data-fake-id="'+hash+'"]');
  2799.  
  2800.             if(open.length)
  2801.             {
  2802.                 if(!open.is('.activeTitle')) open.trigger('click');
  2803.                 window.scrollTo(0, container.offset().top - 70);
  2804.             }
  2805.         }
  2806.         trigger_default_open(false);
  2807.        
  2808.         $('a').on('click',function(){
  2809.             var hash = $(this).attr('href');
  2810.             if(typeof hash != "undefined" && hash)
  2811.             {
  2812.                 hash = hash.replace(/^.*?#/,'');
  2813.                 trigger_default_open('#'+hash);
  2814.             }
  2815.         });
  2816.  
  2817.     });
  2818. };
  2819.  
  2820.  
  2821.  
  2822.  
  2823. // -------------------------------------------------------------------------------------------
  2824. // Tab Shortcode
  2825. // -------------------------------------------------------------------------------------------
  2826.  
  2827. $.fn.avia_sc_tabs= function(options)
  2828. {
  2829.     var defaults =
  2830.     {
  2831.         heading: '.tab',
  2832.         content:'.tab_content',
  2833.         active:'active_tab',
  2834.         sidebar: false
  2835.     };
  2836.  
  2837.     var win = $(window),
  2838.         options = $.extend(defaults, options);
  2839.  
  2840.     return this.each(function()
  2841.     {
  2842.         var container   = $(this),
  2843.             tab_titles  = $('<div class="tab_titles"></div>').prependTo(container),
  2844.             tabs        = $(options.heading, container),
  2845.             content     = $(options.content, container),
  2846.             newtabs     = false,
  2847.             oldtabs     = false;
  2848.  
  2849.         newtabs = tabs.clone();
  2850.         oldtabs = tabs.addClass('fullsize-tab');
  2851.         tabs = newtabs;
  2852.  
  2853.         tabs.prependTo(tab_titles).each(function(i)
  2854.         {
  2855.             var tab = $(this), the_oldtab = false;
  2856.  
  2857.             if(newtabs) the_oldtab = oldtabs.filter(':eq('+i+')');
  2858.  
  2859.             tab.addClass('tab_counter_'+i).bind('click', function()
  2860.             {
  2861.                 open_content(tab, i, the_oldtab);
  2862.                 return false;
  2863.             });
  2864.  
  2865.             if(newtabs)
  2866.             {
  2867.                 the_oldtab.bind('click', function()
  2868.                 {
  2869.                     open_content(the_oldtab, i, tab);
  2870.                     return false;
  2871.                 });
  2872.             }
  2873.         });
  2874.  
  2875.         set_size();
  2876.         trigger_default_open(false);
  2877.         win.on("debouncedresize", set_size);
  2878.        
  2879.         $('a').on('click',function(){
  2880.             var hash = $(this).attr('href');
  2881.             if(typeof hash != "undefined" && hash)
  2882.             {
  2883.                 hash = hash.replace(/^.*?#/,'');
  2884.                 trigger_default_open('#'+hash);
  2885.             }
  2886.         });
  2887.  
  2888.         function set_size()
  2889.         {
  2890.             if(!options.sidebar) return;
  2891.             content.css({'min-height': tab_titles.outerHeight() + 1});
  2892.         }
  2893.  
  2894.         function open_content(tab, i, alternate_tab)
  2895.         {
  2896.             if(!tab.is('.'+options.active))
  2897.             {
  2898.                 $('.'+options.active, container).removeClass(options.active);
  2899.                 $('.'+options.active+'_content', container).removeClass(options.active+'_content');
  2900.  
  2901.                 tab.addClass(options.active);
  2902.  
  2903.                 var new_loc = tab.data('fake-id');
  2904.                 if(typeof new_loc == 'string') location.replace(new_loc);
  2905.  
  2906.                 if(alternate_tab) alternate_tab.addClass(options.active);
  2907.                 var active_c = content.filter(':eq('+i+')').addClass(options.active+'_content');
  2908.  
  2909.                 if(typeof click_container != 'undefined' && click_container.length)
  2910.                 {
  2911.                     sidebar_shadow.height(active_c.outerHeight());
  2912.                 }
  2913.                
  2914.                 //check if tab title is in viewport. if not scroll up
  2915.                 var el_offset = active_c.offset().top,
  2916.                     scoll_target = el_offset - 50 - parseInt($('html').css('margin-top'),10);
  2917.                
  2918.                 if(win.scrollTop() > el_offset)
  2919.                 {
  2920.                     $('html:not(:animated),body:not(:animated)').scrollTop(scoll_target);
  2921.                 }
  2922.             }
  2923.         }
  2924.  
  2925.         function trigger_default_open(hash)
  2926.         {
  2927.             if(!hash && window.location.hash) hash = window.location.hash;
  2928.                     if(!hash) return;
  2929.                    
  2930.             var open = tabs.filter('[data-fake-id="'+hash+'"]');
  2931.  
  2932.             if(open.length)
  2933.             {
  2934.                 if(!open.is('.active_tab')) open.trigger('click');
  2935.                 window.scrollTo(0, container.offset().top - 70);
  2936.             }
  2937.         }
  2938.  
  2939.     });
  2940. };
  2941.  
  2942.  
  2943.  
  2944.  
  2945. // -------------------------------------------------------------------------------------------
  2946. // Tab Section
  2947. // -------------------------------------------------------------------------------------------
  2948.  
  2949. $.fn.avia_sc_tab_section= function()
  2950. {
  2951.     var win             = $(window),
  2952.         browserPrefix   = $.avia_utilities.supports('transition'),
  2953.         cssActive       = this.browserPrefix !== false ? true : false,
  2954.         isMobile        = $.avia_utilities.isMobile,
  2955.         transform3d     = document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false,
  2956.         transition      = {};
  2957.        
  2958.     return this.each(function()
  2959.     {
  2960.         var container       = $(this),
  2961.             tabs            = container.find('.av-section-tab-title'),
  2962.                 tab_outer = container.find('.av-tab-section-outer-container'),
  2963.             tab_wrap        = container.find('.av-tab-section-tab-title-container'),
  2964.             tab_nav         = container.find('.av_tab_navigation'),
  2965.             content_wrap    = container.find('.av-tab-section-inner-container'),
  2966.             single_tabs     = container.find('.av-animation-delay-container'), //for elements inside the tab that receive waypoint animation
  2967.             inner_content   = container.find('.av-layout-tab-inner'),
  2968.             sliding_active  = container.is('.av-tab-slide-transition'),
  2969.             flexible        = container.is('.av-tab-content-auto'),
  2970.             current_content = container.find('.__av_init_open'),
  2971.             min_width       = 0,
  2972.             change_tab      = function(e, prevent_hash)
  2973.             {
  2974.                 e.preventDefault();
  2975.                
  2976.                 var current_tab     = $(e.currentTarget),
  2977.                     current_arrow   = current_tab.find('.av-tab-arrow-container span'),
  2978.                     tab_nr          = current_tab.data('av-tab-section-title');
  2979.                    
  2980.                     current_content = container.find('[data-av-tab-section-content="'+tab_nr+'"]');
  2981.                
  2982.                 var new_bg          = current_content.data('av-tab-bg-color'),
  2983.                     new_font        = current_content.data('av-tab-color'),
  2984.                     prev_container  = container.find('.av-active-tab-content').not('[data-av-tab-section-content="'+tab_nr+'"]');
  2985.  
  2986.                 tabs.attr('style','').removeClass('av-active-tab-title');
  2987.                 current_tab.addClass('av-active-tab-title');
  2988.                 current_content.addClass("av-active-tab-content");
  2989.                
  2990.                 if(new_bg !== "") current_arrow.css('background-color', new_bg);
  2991.                 if(new_font !== "") current_tab.css('color', new_font);
  2992.                    
  2993.                 var new_pos = ((parseInt(tab_nr,10) - 1) * -100 );
  2994.                     if ($('body').hasClass('rtl')) {
  2995.                         new_pos = ((parseInt(tab_nr,10) - 1) * 100 );
  2996.                         }
  2997.                
  2998.                 if(cssActive)
  2999.                 {
  3000.                     //move the slides
  3001.                     new_pos = new_pos / tabs.length;
  3002.                     transition['transform']  = transform3d ? "translate3d(" + new_pos  + "%, 0, 0)" : "translate(" + new_pos + "%,0)"; //3d or 2d transform?
  3003.                     transition['left'] = "0%";
  3004.                     content_wrap.css(transition);
  3005.                 }
  3006.                 else
  3007.                 {
  3008.                     content_wrap.css('left',  new_pos + "%");
  3009.                 }
  3010.                
  3011.                 set_tab_titlte_pos();
  3012.                 set_slide_height();
  3013.                
  3014.                 if(!prevent_hash) location.hash = current_tab.attr('href');
  3015.                
  3016.                 setTimeout(function()
  3017.                 {
  3018.                     current_content.trigger('avia_start_animation_if_current_slide_is_active');
  3019.                     single_tabs.not(current_content).trigger('avia_remove_animation');
  3020.                    
  3021.                 }, 600);   
  3022.                
  3023.             },
  3024.             set_min_width = function()
  3025.             {
  3026.                 min_width = 0;
  3027.                 tabs.each(function()
  3028.                 {
  3029.                     min_width += $(this).outerWidth();
  3030.                 });
  3031.                
  3032.                 tab_wrap.css('min-width',min_width);
  3033.             },
  3034.            
  3035.             set_slide_height = function()
  3036.             {              
  3037.                 if(current_content.length && flexible)
  3038.                 {
  3039.                     var old_height = inner_content.height();
  3040.                     inner_content.height('auto');
  3041.                    
  3042.                     var height = current_content.find('.av-layout-tab-inner').height(),
  3043.                         add_height = tab_wrap.height();
  3044.                    
  3045.                     tab_outer.css('max-height', height + add_height + 100);
  3046.                     inner_content.height(old_height);
  3047.                     inner_content.height(height);
  3048.                    
  3049.                     inner_content.css( 'overflow', 'hidden' );
  3050.                    
  3051.                     setTimeout(function() { win.trigger('av-height-change'); }, 600);
  3052.                 }
  3053.             },
  3054.            
  3055.             set_tab_titlte_pos = function()
  3056.             {
  3057.                 //  scroll the tabs if there is not enough room to display them all - rtl allign right to left !!
  3058.                 var current_tab = container.find('.av-active-tab-title'),
  3059.                     viewport    = container.width(),
  3060.                     left_pos    = ( current_tab.position().left * - 1) - (current_tab.outerWidth() / 2) + (viewport / 2);
  3061.            
  3062.                 if( ! $('body').hasClass("rtl") )
  3063.                 {
  3064.                     if( viewport >= min_width )
  3065.                     {
  3066.                         left_pos = 0;
  3067.                     }
  3068.                    
  3069.                     if(left_pos + min_width < viewport) left_pos = (min_width - viewport) * -1;
  3070.                     if(left_pos > 0) left_pos = 0;
  3071.                
  3072.                     tab_wrap.css('left',left_pos );
  3073.                 }
  3074.                 else
  3075.                 {
  3076.                     var right_pos = 0;
  3077.                    
  3078.                     if( viewport < min_width )
  3079.                     {
  3080.                         if( left_pos + min_width > viewport )
  3081.                         {
  3082.                             if( left_pos > 0 ) left_pos = 0;
  3083.                            
  3084.                             var right_pos = (left_pos + min_width - viewport) * -1;
  3085.                             tab_wrap.css('left', 'auto' );
  3086.                             tab_wrap.css('right', right_pos );
  3087.                         }
  3088.                     }
  3089.                     tab_wrap.css('left', 'auto' );
  3090.                     tab_wrap.css('right', right_pos );
  3091.                 }
  3092.             },
  3093.             switch_to_next_prev = function(e)
  3094.             {
  3095.                 if(!isMobile) return;
  3096.                
  3097.                 var clicked         = $(e.currentTarget),
  3098.                     current_tab     = container.find('.av-active-tab-title');
  3099.                    
  3100.                     if(clicked.is('.av_prev_tab_section'))
  3101.                     {
  3102.                         current_tab.prev('.av-section-tab-title').trigger('click');
  3103.                     }
  3104.                     else
  3105.                     {
  3106.                         current_tab.next('.av-section-tab-title').trigger('click');
  3107.                     }
  3108.             },
  3109.            
  3110.             get_init_open = function()
  3111.             {
  3112.                 if(!hash && window.location.hash) var hash = window.location.hash;
  3113.                        
  3114.                 var open = tabs.filter('[href="'+hash+'"]');
  3115.                
  3116.                 if(open.length)
  3117.                 {
  3118.                     if(!open.is('.active_tab')) open.trigger('click');
  3119.                 }
  3120.                 else
  3121.                 {
  3122.                     //set correct color
  3123.                     container.find('.av-active-tab-title').trigger('click', true);
  3124.                 }
  3125.             };
  3126.                
  3127.         $.avia_utilities.preload({
  3128.            
  3129.             container: current_content ,
  3130.             single_callback:  function(){
  3131.            
  3132.                 tabs.on('click', change_tab);
  3133.                 tab_nav.on('click', switch_to_next_prev);
  3134.                 win.on('debouncedresize', set_tab_titlte_pos); 
  3135.                 win.on('debouncedresize av-height-change', set_slide_height);  
  3136.                
  3137.                 set_min_width();
  3138.                 set_slide_height();
  3139.                 get_init_open();
  3140.             }
  3141.            
  3142.         });
  3143.        
  3144.         content_wrap.avia_swipe_trigger({prev:'.av_prev_tab_section', next:'.av_next_tab_section'});
  3145.            
  3146.     });
  3147. };
  3148.  
  3149.  
  3150.  
  3151.  
  3152. // -------------------------------------------------------------------------------------------
  3153. // Horizontal Gallery
  3154. // -------------------------------------------------------------------------------------------
  3155.  
  3156. $.fn.avia_hor_gallery= function(options)
  3157. {
  3158.     var defaults =
  3159.         {
  3160.             slide_container : '.av-horizontal-gallery-inner', //element with max width
  3161.             slide_element   : '.av-horizontal-gallery-slider', //element that gets moved
  3162.             slide_content   : '.av-horizontal-gallery-wrap',
  3163.             active          : 'av-active-gal-item',             // must be a class string without the . in front
  3164.             prev            : '.av-horizontal-gallery-prev',
  3165.             next            : '.av-horizontal-gallery-next'
  3166.         };
  3167.  
  3168.     var options = $.extend(defaults, options);
  3169.    
  3170.     var win             = $(window),
  3171.         browserPrefix   = $.avia_utilities.supports('transition'),
  3172.         cssActive       = this.browserPrefix !== false ? true : false,
  3173.         isMobile        = $.avia_utilities.isMobile,
  3174.         transform3d     = document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false,
  3175.         transition      = {};
  3176.        
  3177.     return this.each(function()
  3178.     {
  3179.         var container           = $(this),
  3180.             slide_container     = container.find(options.slide_container),
  3181.             slide_element       = container.find(options.slide_element),
  3182.             slide_content       = container.find(options.slide_content),
  3183.             prev                = container.find(options.prev),
  3184.             next                = container.find(options.next),
  3185.             imgs                = container.find('img'),
  3186.            
  3187.             all_elements_width  = 0,
  3188.             currentIndex        = false,
  3189.             initial             = container.data('av-initial'),
  3190.            
  3191.             set_up = function( init )
  3192.             {
  3193.                 var sl_height = (slide_container.width() / 100 ) * slide_container.data('av-height');
  3194.                
  3195.                 slide_container.css({'padding':0}).height(sl_height);
  3196.                
  3197.                 //fixes img distortion when resizing browser:
  3198.                 imgs.css('display','inline-block');
  3199.                 setTimeout(function(){ imgs.css('display','block'); }, 10);
  3200.                
  3201.                 //calculate the slidelement width based on the elements inside
  3202.                 all_elements_width = 0;
  3203.                
  3204.                 slide_content.each(function()
  3205.                 {
  3206.                     all_elements_width += $(this).outerWidth( true );
  3207.                 });
  3208.                
  3209.                 slide_element.css( 'min-width' , all_elements_width );
  3210.                
  3211.                 if(currentIndex !== false )
  3212.                 {
  3213.                     change_active(currentIndex);
  3214.                 }
  3215.             },
  3216.             change_active = function(index)
  3217.             {
  3218.                 //scroll the tabs if there is not enough room to display them all
  3219.                 var current     = slide_element.find(options.slide_content).eq(index),
  3220.                     viewport    = slide_container.width(),
  3221.                     modifier    = container.data('av-enlarge') > 1  && currentIndex == index ? container.data('av-enlarge') : 1,
  3222.                     outerWidth  = current.outerWidth( true ) * modifier,
  3223.                     margin_right= parseInt( current.css('margin-right') , 10 ) / 2,
  3224.                     left_pos    = viewport < all_elements_width ? (current.position().left * - 1) - (outerWidth / 2) + (viewport / 2): 0;
  3225.                
  3226.                 //center properly
  3227.                 left_pos = left_pos + margin_right;
  3228.                
  3229.                 //out of bounce right side
  3230.                 if(left_pos + all_elements_width < viewport) left_pos = (all_elements_width - viewport - parseInt(current.css('margin-right'),10) ) * -1;
  3231.                
  3232.                 //out of bounce left side
  3233.                 if(left_pos > 0) left_pos = 0;
  3234.                
  3235.                 //set pos
  3236.                 slide_element.css('left',left_pos );
  3237.                
  3238.                 slide_container.find("." +options.active).removeClass(options.active);
  3239.                 current.addClass(options.active);
  3240.                 currentIndex = index;
  3241.                
  3242.             };
  3243.  
  3244.            
  3245.          $.avia_utilities.preload({container: container , global_callback:  function()
  3246.          {
  3247.              // activate behavior
  3248.             set_up( 'init' );
  3249.             win.on('debouncedresize', set_up);
  3250.             if(initial) change_active(initial - 1);
  3251.            
  3252.             setTimeout(function(){
  3253.                 container.addClass('av-horizontal-gallery-animated');
  3254.             },10);
  3255.        
  3256.           }});
  3257.            
  3258.        
  3259.        
  3260.        
  3261.        
  3262.        
  3263.        
  3264.         //swipe on mobile
  3265.         slide_element.avia_swipe_trigger({prev:options.prev, next:options.next});
  3266.        
  3267.         //element click
  3268.         slide_content.on('click', function(e)
  3269.         {
  3270.             var current = $(this);
  3271.             var index = slide_content.index(current);
  3272.            
  3273.             if(currentIndex === index)
  3274.             {
  3275.                 if(container.data('av-enlarge') > 1 && !$(e.target).is('a') )
  3276.                 {
  3277.                     //slide_container.find("." +options.active).removeClass(options.active);
  3278.                     //currentIndex = false;
  3279.                 }
  3280.                 return;
  3281.             }
  3282.            
  3283.             change_active(index);
  3284.         });
  3285.        
  3286.         prev.on('click', function(e)
  3287.         {
  3288.             if(currentIndex === false) currentIndex = 1;
  3289.             var index = currentIndex - 1;
  3290.             if(index < 0) index = 0;
  3291.            
  3292.             change_active(index);
  3293.         });
  3294.        
  3295.         next.on('click', function(e)
  3296.         {
  3297.             if(currentIndex === false) currentIndex = -1;
  3298.             var index = currentIndex + 1;
  3299.             if(index > slide_content.length - 1) index = slide_content.length - 1;
  3300.            
  3301.             change_active(index);
  3302.         });
  3303.        
  3304.         //if its a desktop browser add arrow navigation, otherwise add touch nav
  3305.         if(!isMobile)
  3306.         {
  3307.             container.avia_keyboard_controls({ 37: options.prev, 39: options.next });
  3308.         }
  3309.         else
  3310.         {
  3311.             container.avia_swipe_trigger({next: options.next, prev: options.prev});
  3312.         }
  3313.        
  3314.        
  3315.    
  3316.     });
  3317. };
  3318.  
  3319. // -------------------------------------------------------------------------------------------
  3320. // Big Number animation shortcode javascript
  3321. // -------------------------------------------------------------------------------------------
  3322.  
  3323. (function($)
  3324. {
  3325.     // options.simple_up = dont prepend leading zeros, options.instant_start = trigger counting instantly, options.start_timer = delay when to start counting
  3326.     $.fn.avia_sc_animated_number = function(options)
  3327.     {
  3328.         if(!this.length) return;
  3329.         if(this.is('.avia_sc_animated_number_active')) return;
  3330.        
  3331.         this.addClass('avia_sc_animated_number_active');
  3332.    
  3333.         var skipStep = false,
  3334.             simple_upcount  = (options && options.simple_up) ? true : false,
  3335.             start_timer     = (options && options.start_timer) ? options.start_timer : 300,
  3336.         start_count = function(element, countTo, increment, current, fakeCountTo)
  3337.         {
  3338.            
  3339.            
  3340.             //calculate the new number
  3341.             var newCount = current + increment;
  3342.            
  3343.             //if the number is bigger than our final number set the number and finish
  3344.             if(newCount >= fakeCountTo)
  3345.             {
  3346.                 element.text(countTo); //exit
  3347.                
  3348.             }
  3349.             else
  3350.             {
  3351.                 var prepend = "", addZeros = countTo.toString().length - newCount.toString().length
  3352.                
  3353.                 //if the number has less digits than the final number some zeros where omitted. add them to the front
  3354.                 for(var i = addZeros; i > 0; i--){ prepend += "0"; }
  3355.                
  3356.                 if(simple_upcount) prepend = 0;
  3357.                 element.text(prepend + newCount);
  3358.                
  3359.                 window.requestAnimationFrame(function(){ start_count(element, countTo, increment, newCount, fakeCountTo) });
  3360.             }
  3361.         };
  3362.    
  3363.         return this.each(function()
  3364.         {
  3365.             var number_container = $(this), elements = number_container.find('.__av-single-number'), countTimer = number_container.data('timer') || 3000;
  3366.            
  3367.             //prepare elements
  3368.             elements.each(function(i)
  3369.             {
  3370.                 var element = $(this), text = element.text();
  3371.                 if(window.addEventListener) element.text( text.replace(/./g, "0")); /*https://github.com/AviaThemes/wp-themes/issues/812*/
  3372.             });
  3373.            
  3374.             //trigger number animation
  3375.             number_container.addClass('number_prepared').on('avia_start_animation', function()
  3376.             {
  3377.                 if(number_container.is('.avia_animation_done')) return;
  3378.                 number_container.addClass('avia_animation_done');
  3379.                
  3380.                 elements.each(function(i)
  3381.                 {
  3382.                     var element = $(this), countTo = element.data('number'), fakeCountTo = countTo, current = parseInt(element.text(),10), zeroOnly = /^0+$/.test(countTo), increment = 0;
  3383.                    
  3384.                     //fallback for decimals like 00 or 000
  3385.                     if(zeroOnly && countTo !== 0) fakeCountTo = countTo.replace(/0/g, '9');
  3386.                    
  3387.                     increment = Math.round( fakeCountTo * 32 / countTimer);
  3388.                     if(increment == 0 || increment % 10 == 0) increment += 1;
  3389.                    
  3390.                     setTimeout(function(){ start_count(element, countTo, increment, current, fakeCountTo);}, start_timer);
  3391.                 });
  3392.             });
  3393.            
  3394.             if(options && options.instant_start == true)
  3395.             {
  3396.                 number_container.trigger('avia_start_animation');
  3397.             }
  3398.            
  3399.            
  3400.         });
  3401.     }
  3402. })(jQuery);
  3403.  
  3404.  
  3405.  
  3406.  
  3407. // -------------------------------------------------------------------------------------------
  3408. // contact form ajax
  3409. // -------------------------------------------------------------------------------------------
  3410.  
  3411. (function($)
  3412. {
  3413.     $.fn.avia_ajax_form = function(variables)
  3414.     {  
  3415.         var defaults =
  3416.         {
  3417.             sendPath: 'send.php',
  3418.             responseContainer: '.ajaxresponse'
  3419.         };
  3420.  
  3421.         var options = $.extend(defaults, variables);
  3422.  
  3423.         return this.each(function()
  3424.         {
  3425.             var form = $(this),
  3426.                 form_sent = false,
  3427.                 send =
  3428.                 {
  3429.                     formElements: form.find('textarea, select, input[type=text], input[type=checkbox], input[type=hidden]'),
  3430.                     validationError:false,
  3431.                     button : form.find('input:submit'),
  3432.                     dataObj : {}
  3433.                 },
  3434.  
  3435.                 responseContainer = form.next(options.responseContainer+":eq(0)");
  3436.  
  3437.                 send.button.bind('click', checkElements);
  3438.                
  3439.                
  3440.                 //change type of email forms on mobile so the e-mail keyboard with @ sign is used
  3441.                 if($.avia_utilities.isMobile)
  3442.                 {
  3443.                     send.formElements.each(function(i)
  3444.                     {
  3445.                         var currentElement = $(this), is_email = currentElement.hasClass('is_email');
  3446.                         if(is_email) currentElement.attr('type','email');
  3447.                     });
  3448.                 }
  3449.            
  3450.  
  3451.             function checkElements( e )
  3452.             {
  3453.                 // reset validation var and send data
  3454.                 send.validationError = false;
  3455.                 send.datastring = 'ajax=true';
  3456.  
  3457.                 send.formElements.each(function(i)
  3458.                 {
  3459.                     var currentElement = $(this),
  3460.                         surroundingElement = currentElement.parent(),
  3461.                         value = currentElement.val(),
  3462.                         name = currentElement.attr('name'),
  3463.                         classes = currentElement.attr('class'),
  3464.                         nomatch = true;
  3465.  
  3466.                         if(currentElement.is(':checkbox'))
  3467.                         {
  3468.                             if(currentElement.is(':checked')) { value = true } else {value = ''}
  3469.                         }
  3470.                        
  3471.                         send.dataObj[name] = encodeURIComponent(value);
  3472.  
  3473.                         if(classes && classes.match(/is_empty/))
  3474.                         {
  3475.                             if(value == '' || value == null)
  3476.                             {
  3477.                                 surroundingElement.removeClass("valid error ajax_alert").addClass("error");
  3478.                                 send.validationError = true;
  3479.                             }
  3480.                             else
  3481.                             {
  3482.                                 surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
  3483.                             }
  3484.                             nomatch = false;
  3485.                         }
  3486.  
  3487.                         if(classes && classes.match(/is_email/))
  3488.                         {
  3489.                             if(!value.match(/^[\w|\.|\-]+@\w[\w|\.|\-]*\.[a-zA-Z]{2,20}$/))
  3490.                             {
  3491.                                 surroundingElement.removeClass("valid error ajax_alert").addClass("error");
  3492.                                 send.validationError = true;
  3493.                             }
  3494.                             else
  3495.                             {
  3496.                                 surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
  3497.                             }
  3498.                             nomatch = false;
  3499.                         }
  3500.  
  3501.                         if(classes && classes.match(/is_phone/))
  3502.                         {
  3503.                             if(!value.match(/^(\d|\s|\-|\/|\(|\)|\[|\]|e|x|t|ension|\.|\+|\_|\,|\:|\;){3,}$/))
  3504.                             {
  3505.                                 surroundingElement.removeClass("valid error ajax_alert").addClass("error");
  3506.                                 send.validationError = true;
  3507.                             }
  3508.                             else
  3509.                             {
  3510.                                 surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
  3511.                             }
  3512.                             nomatch = false;
  3513.                         }
  3514.  
  3515.                         if(classes && classes.match(/is_number/))
  3516.                         {
  3517.                             if(!($.isNumeric(value)) || value == "")
  3518.                             {
  3519.                                 surroundingElement.removeClass("valid error ajax_alert").addClass("error");
  3520.                                 send.validationError = true;
  3521.                             }
  3522.                             else
  3523.                             {
  3524.                                 surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
  3525.                             }
  3526.                             nomatch = false;
  3527.                         }
  3528.  
  3529.                         if(classes && classes.match(/captcha/))
  3530.                         {
  3531.                             var verifier    = form.find("#" + name + "_verifier").val(),
  3532.                                 lastVer     = verifier.charAt(verifier.length-1),
  3533.                                 finalVer    = verifier.charAt(lastVer);
  3534.  
  3535.                             if(value != finalVer)
  3536.                             {
  3537.                                 surroundingElement.removeClass("valid error ajax_alert").addClass("error");
  3538.                                 send.validationError = true;
  3539.                             }
  3540.                             else
  3541.                             {
  3542.                                 surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
  3543.                             }
  3544.                             nomatch = false;
  3545.                         }
  3546.  
  3547.                         if(nomatch && value != '')
  3548.                         {
  3549.                             surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
  3550.                         }
  3551.                 });
  3552.  
  3553.                 if(send.validationError == false)
  3554.                 {
  3555.                     if(form.data('av-custom-send'))
  3556.                     {
  3557.                         mailchimp_send();  
  3558.                     }
  3559.                     else
  3560.                     {
  3561.                         send_ajax_form();
  3562.                     }
  3563.                 }
  3564.                
  3565.                 return false;
  3566.             }
  3567.            
  3568.            
  3569.             function send_ajax_form()
  3570.             {
  3571.                 if(form_sent){ return false; }
  3572.  
  3573.                 form_sent = true;
  3574.                 send.button.addClass('av-sending-button');
  3575.                 send.button.val(send.button.data('sending-label'));
  3576.                
  3577.                 var redirect_to = form.data('avia-redirect') || false,
  3578.                     action      = form.attr('action');
  3579.                
  3580.                 responseContainer.load(action+' '+options.responseContainer, send.dataObj, function()
  3581.                 {
  3582.                     if(redirect_to && action != redirect_to)
  3583.                     {
  3584.                         form.attr('action', redirect_to);
  3585.                         location.href = redirect_to;
  3586.                         // form.submit();
  3587.                     }
  3588.                     else
  3589.                     {
  3590.                         responseContainer.removeClass('hidden').css({display:"block"});
  3591.                         form.slideUp(400, function(){responseContainer.slideDown(400, function(){ $('body').trigger('av_resize_finished'); }); send.formElements.val('');});
  3592.                     }
  3593.                 });
  3594.             }
  3595.            
  3596.            
  3597.             function mailchimp_send()
  3598.             {
  3599.                 if(form_sent){ return false; }
  3600.  
  3601.                 form_sent = true;
  3602.                
  3603.                 var original_label = send.button.val();
  3604.  
  3605.                 send.button.addClass('av-sending-button');
  3606.                 send.button.val(send.button.data('sending-label'));
  3607.                 send.dataObj.ajax_mailchimp = true;
  3608.                
  3609.                 var redirect_to         = form.data('avia-redirect') || false,
  3610.                     action              = form.attr('action'),
  3611.                     error_msg_container = form.find('.av-form-error-container'),
  3612.                     form_id             = form.data('avia-form-id');
  3613.                
  3614.                 $.ajax({
  3615.                     url: action,
  3616.                     type: "POST",
  3617.                     data:send.dataObj,
  3618.                     beforeSend: function()
  3619.                     {
  3620.                         if(error_msg_container.length)
  3621.                         {
  3622.                             error_msg_container.slideUp(400, function()
  3623.                             {
  3624.                                 error_msg_container.remove();
  3625.                                 $('body').trigger('av_resize_finished');
  3626.                             });
  3627.                         }
  3628.                     },
  3629.                     success: function(responseText)
  3630.                     {
  3631.                         var response    = jQuery("<div>").append(jQuery.parseHTML(responseText)),
  3632.                             error       = response.find('.av-form-error-container');   
  3633.                        
  3634.                         if(error.length)
  3635.                         {
  3636.                             form_sent = false;
  3637.                             form.prepend(error);
  3638.                             error.css({display:"none"}).slideDown(400, function()
  3639.                             {
  3640.                                 $('body').trigger('av_resize_finished');
  3641.                             });
  3642.  
  3643.                             send.button.removeClass('av-sending-button');
  3644.                             send.button.val(original_label);
  3645.                         }
  3646.                         else
  3647.                         {
  3648.                             if(redirect_to && action != redirect_to)
  3649.                             {
  3650.                                 form.attr('action', redirect_to);
  3651.                                 location.href = redirect_to;
  3652.                                 // form.submit();
  3653.                             }
  3654.                             else
  3655.                             {
  3656.                                 var success_text = response.find(options.responseContainer + "_" + form_id);
  3657.                                
  3658.                                 responseContainer.html(success_text).removeClass('hidden').css({display:"block"});
  3659.                                
  3660.                                 form.slideUp(400, function()
  3661.                                 {
  3662.                                     responseContainer.slideDown(400, function()
  3663.                                     {
  3664.                                         $('body').trigger('av_resize_finished');
  3665.                                     });
  3666.                                    
  3667.                                 send.formElements.val('');
  3668.                             });
  3669.                             }
  3670.                         }
  3671.                        
  3672.                     },
  3673.                     error: function()
  3674.                     {
  3675.                        
  3676.                     },
  3677.                     complete: function()
  3678.                     {
  3679.                        
  3680.                     }
  3681.                 });
  3682.  
  3683.             }
  3684.            
  3685.            
  3686.         });
  3687.     };
  3688. })(jQuery);
  3689.  
  3690.  
  3691.  
  3692.  
  3693.  
  3694.  
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700.  
  3701. // -------------------------------------------------------------------------------------------
  3702. // Aviaccordion Slideshow
  3703. //
  3704. // accordion slider script
  3705. // -------------------------------------------------------------------------------------------
  3706.  
  3707.     $.AviaccordionSlider  =  function(options, slider)
  3708.     {
  3709.         this.$slider    = $( slider );
  3710.         this.$inner     = this.$slider.find('.aviaccordion-inner');
  3711.         this.$slides    = this.$inner.find('.aviaccordion-slide');
  3712.         this.$images    = this.$inner.find('.aviaccordion-image');
  3713.         this.$last      = this.$slides.filter(':last');
  3714.         this.$titles    = this.$slider.find('.aviaccordion-preview');
  3715.         this.$titlePos  = this.$slider.find('.aviaccordion-preview-title-pos');
  3716.         this.$titleWrap = this.$slider.find('.aviaccordion-preview-title-wrap');
  3717.         this.$win       = $( window );
  3718.        
  3719.         if($.avia_utilities.supported.transition === undefined)
  3720.         {
  3721.             $.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
  3722.         }
  3723.        
  3724.         this.browserPrefix  = $.avia_utilities.supported.transition;
  3725.         this.cssActive      = this.browserPrefix !== false ? true : false;
  3726.         this.transform3d    = document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
  3727.         this.isMobile       = $.avia_utilities.isMobile;
  3728.         this.property       = this.browserPrefix + 'transform',
  3729.         this.count          = this.$slides.length;
  3730.         this.open           = false;
  3731.         this.autoplay       = false;
  3732.         this.increaseTitle  = this.$slider.is(".aviaccordion-title-on-hover");
  3733.         // this.cssActive    = false; //testing no css3 browser
  3734.        
  3735.         this._init( options );
  3736.     }
  3737.  
  3738.     $.AviaccordionSlider.prototype =
  3739.     {
  3740.         _init: function( options )
  3741.         {
  3742.             var _self = this;
  3743.             _self.options = $.extend({}, options, this.$slider.data());
  3744.              $.avia_utilities.preload({container: this.$slider , single_callback:  function(){ _self._kickOff(); }});
  3745.         },
  3746.        
  3747.         _kickOff: function()
  3748.         {
  3749.             var _self = this;
  3750.            
  3751.             _self._calcMovement();
  3752.             _self._bindEvents();
  3753.             _self._showImages();
  3754.             _self._autoplay();
  3755.         },
  3756.        
  3757.         _autoplay: function()
  3758.         {
  3759.             var _self = this;
  3760.            
  3761.             if(_self.options.autoplay)
  3762.             {
  3763.                 _self.autoplay = setInterval(function()
  3764.                 {
  3765.                     _self.open = _self.open === false ? 0 : _self.open + 1;
  3766.                     if(_self.open >= _self.count) _self.open = 0;
  3767.                     _self._move({}, _self.open);
  3768.                    
  3769.                 }, _self.options.interval * 1000)
  3770.             }
  3771.         },
  3772.        
  3773.         _showImages: function()
  3774.         {
  3775.             var _self = this, counter = 0, delay = 300, title_delay = this.count * delay;
  3776.            
  3777.             if(this.cssActive)
  3778.             {
  3779.                 setTimeout(function(){ _self.$slider.addClass('av-animation-active'); } , 10);
  3780.             }
  3781.            
  3782.             this.$images.each(function(i)
  3783.             {
  3784.                 var current = $(this), timer = delay * (i + 1);
  3785.                    
  3786.                 setTimeout(function()
  3787.                 {
  3788.                     current.avia_animate({opacity:1}, 400, function()
  3789.                     {
  3790.                         current.css($.avia_utilities.supported.transition + "transform", "none");
  3791.                     });
  3792.                 },timer);
  3793.             });
  3794.            
  3795.             if(_self.increaseTitle) title_delay = 0;
  3796.            
  3797.             this.$titlePos.each(function(i)
  3798.             {
  3799.                 var current = $(this), new_timer = title_delay + 100 * (i + 1);
  3800.                        
  3801.                 setTimeout(function()
  3802.                 {
  3803.                     current.avia_animate({opacity:1}, 200, function()
  3804.                     {
  3805.                         current.css($.avia_utilities.supported.transition + "transform", "none");
  3806.                     });
  3807.                 },new_timer);
  3808.             });
  3809.         },
  3810.        
  3811.         _bindEvents: function()
  3812.         {
  3813.             var trigger = this.isMobile ? "click" : "mouseenter";
  3814.        
  3815.             this.$slider.on(trigger,'.aviaccordion-slide', $.proxy( this._move, this));
  3816.             this.$slider.on('mouseleave','.aviaccordion-inner', $.proxy( this._move, this));
  3817.             this.$win.on('debouncedresize', $.proxy( this._calcMovement, this));
  3818.             this.$slider.on('av-prev av-next', $.proxy( this._moveTo, this));
  3819.            
  3820.             if(this.isMobile)
  3821.             {
  3822.                 this.$slider.avia_swipe_trigger({next: this.$slider, prev: this.$slider, event:{prev: 'av-prev', next: 'av-next'}});
  3823.             }
  3824.            
  3825.         },
  3826.        
  3827.         _titleHeight: function()
  3828.         {
  3829.             var th = 0;
  3830.            
  3831.             this.$titleWrap.css({'height':'auto'}).each(function()
  3832.             {
  3833.                 var new_h = $(this).outerHeight();
  3834.                 if( new_h > th) th = new_h;
  3835.            
  3836.             }).css({'height':th + 2});
  3837.            
  3838.         },
  3839.        
  3840.         _calcMovement: function(event, allow_repeat)
  3841.         {
  3842.             var _self           = this,
  3843.                 containerWidth  = this.$slider.width(),
  3844.                 defaultPos      = this.$last.data('av-left'),
  3845.                 imgWidth        = this.$images.filter(':last').width() || containerWidth,
  3846.                 imgWidthPercent = Math.floor((100 / containerWidth) * imgWidth),
  3847.                 allImageWidth   = imgWidthPercent * _self.count,
  3848.                 modifier        = 3, // 10 - _self.count,
  3849.                 tempMinLeft     = 100 - imgWidthPercent,
  3850.                 minLeft         = tempMinLeft > defaultPos / modifier ? tempMinLeft : 0,
  3851.                 oneLeft         = minLeft / (_self.count -1 ),
  3852.                 titleWidth      = imgWidth;
  3853.            
  3854.            
  3855.            
  3856.             if(allImageWidth < 110 && allow_repeat !== false)
  3857.             {
  3858.                 //set height if necessary  
  3859.                 var slideHeight = this.$slider.height(),
  3860.                     maxHeight   = (slideHeight / allImageWidth) * 110 ;
  3861.                
  3862.                 this.$slider.css({'max-height': maxHeight});
  3863.                 _self._calcMovement(event, false);
  3864.                 return;
  3865.             }
  3866.            
  3867.             //backup so the minimized slides dont get too small
  3868.             if(oneLeft < 2) minLeft = 0;
  3869.            
  3870.             this.$slides.each(function(i)
  3871.             {
  3872.                 var current = $(this), newLeft = 0, newRight = 0, defaultLeft = current.data('av-left');
  3873.                    
  3874.                 if( minLeft !== 0)
  3875.                 {
  3876.                     newLeft  = oneLeft * i;
  3877.                     newRight = imgWidthPercent + newLeft - oneLeft;
  3878.                 }
  3879.                 else
  3880.                 {
  3881.                     newLeft  = defaultLeft / Math.abs(modifier);
  3882.                     newRight = 100 - ((newLeft / i) * (_self.count - i));
  3883.                 }
  3884.                
  3885.                 if(i == 1 && _self.increaseTitle) { titleWidth = newRight + 1; }
  3886.                
  3887.                 if(_self.cssActive)
  3888.                 {  
  3889.                     //if we are not animating based on the css left value but on css transform we need to subtract the left value
  3890.                     newLeft = newLeft - defaultLeft;
  3891.                     newRight = newRight - defaultLeft;
  3892.                     defaultLeft = 0;
  3893.                 }
  3894.                
  3895.                 current.data('av-calc-default', defaultLeft);
  3896.                 current.data('av-calc-left', newLeft);
  3897.                 current.data('av-calc-right', newRight);
  3898.                
  3899.             });
  3900.            
  3901.             if(_self.increaseTitle) { _self.$titles.css({width: titleWidth + "%"});}
  3902.         },
  3903.        
  3904.         _moveTo: function(event)
  3905.         {
  3906.             var direction   = event.type == "av-next" ? 1 : -1,
  3907.                 nextSlide   = this.open === false ? 0 : this.open + direction;
  3908.                
  3909.             if(nextSlide >= 0 && nextSlide < this.$slides.length) this._move(event, nextSlide);
  3910.         },
  3911.        
  3912.         _move: function(event, direct_open)
  3913.         {
  3914.             var _self  = this,
  3915.                 slide  = event.currentTarget,
  3916.                 itemNo = typeof direct_open != "undefined" ? direct_open : this.$slides.index(slide);
  3917.                
  3918.             this.open = itemNo;
  3919.            
  3920.             if(_self.autoplay && typeof slide != "undefined") { clearInterval(_self.autoplay); _self.autoplay = false; }
  3921.            
  3922.             this.$slides.removeClass('aviaccordion-active-slide').each(function(i)
  3923.             {
  3924.                 var current     = $(this),
  3925.                     dataSet     = current.data(),
  3926.                     trans_val   = i <= itemNo ? dataSet.avCalcLeft : dataSet.avCalcRight,
  3927.                     transition  = {},
  3928.                     reset       = event.type == 'mouseleave' ? 1 : 0,
  3929.                     active      = itemNo === i ? _self.$titleWrap.eq(i) : false;
  3930.                
  3931.                 if(active) current.addClass('aviaccordion-active-slide');
  3932.                    
  3933.                 if(reset)
  3934.                 {
  3935.                     trans_val = dataSet.avCalcDefault;
  3936.                     this.open = false;
  3937.                 }
  3938.                    
  3939.                 if(_self.cssActive) //do a css3 animation
  3940.                 {
  3941.                     //move the slides
  3942.                     transition[_self.property]  = _self.transform3d ? "translate3d(" + trans_val  + "%, 0, 0)" : "translate(" + trans_val + "%,0)"; //3d or 2d transform?
  3943.                     current.css(transition);
  3944.                 }
  3945.                 else
  3946.                 {
  3947.                     transition.left =  trans_val + "%";
  3948.                     current.stop().animate(transition, 700, 'easeOutQuint');
  3949.                 }  
  3950.             });
  3951.         }
  3952.     };
  3953.  
  3954.  
  3955. $.fn.aviaccordion = function( options )
  3956. {
  3957.     return this.each(function()
  3958.     {
  3959.         var active = $.data( this, 'AviaccordionSlider' );
  3960.  
  3961.         if(!active)
  3962.         {
  3963.             //make sure that the function doesnt get aplied a second time
  3964.             $.data( this, 'AviaccordionSlider', 1 );
  3965.            
  3966.             //create the preparations for fullscreen slider
  3967.             new $.AviaccordionSlider( options, this );
  3968.         }
  3969.     });
  3970. }
  3971.  
  3972.  
  3973.  
  3974.  
  3975.  
  3976.  
  3977.  
  3978.  
  3979.  
  3980.  
  3981.  
  3982. // -------------------------------------------------------------------------------------------
  3983. // Aviaccordion Slideshow
  3984. //
  3985. // accordion slider script
  3986. // -------------------------------------------------------------------------------------------
  3987.  
  3988.     $.AviaTextRotator  =  function(options, slider)
  3989.     {
  3990.         this.$win       = $( window );
  3991.         this.$slider    = $( slider );
  3992.         this.$inner     = this.$slider.find('.av-rotator-text');
  3993.         this.$slides    = this.$inner.find('.av-rotator-text-single');
  3994.         this.$current   = this.$slides.eq(0);
  3995.         this.open       = 0;
  3996.         this.count      = this.$slides.length;
  3997.        
  3998.         if($.avia_utilities.supported.transition === undefined)
  3999.         {
  4000.             $.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
  4001.         }
  4002.        
  4003.         this.browserPrefix  = $.avia_utilities.supported.transition;
  4004.         this.cssActive      = this.browserPrefix !== false ? true : false;
  4005.         this.property       = this.browserPrefix + 'transform',
  4006.        
  4007.         //this.cssActive    = false; //testing no css3 browser
  4008.        
  4009.         this._init( options );
  4010.     }
  4011.  
  4012.     $.AviaTextRotator.prototype =
  4013.     {
  4014.         _init: function( options )
  4015.         {
  4016.             var _self = this;
  4017.            
  4018.             if(this.count <= 1) return;
  4019.            
  4020.             _self.options = $.extend({}, options, this.$slider.data());
  4021.             _self.$inner.addClass('av-rotation-active');
  4022.             //if(_self.options.fixwidth == 1) this.$inner.width(this.$current.width());
  4023.             _self._autoplay();
  4024.         },
  4025.        
  4026.         _autoplay: function()
  4027.         {
  4028.             var _self = this;
  4029.            
  4030.             _self.autoplay = setInterval(function()
  4031.             {
  4032.                 _self.open = _self.open === false ? 0 : _self.open + 1;
  4033.                 if(_self.open >= _self.count) _self.open = 0;
  4034.                 _self._move({}, _self.open);
  4035.                
  4036.             }, _self.options.interval * 1000)
  4037.         },
  4038.                
  4039.         _move: function(event)
  4040.         {
  4041.             var _self       = this,
  4042.                 modifier    = 30 * _self.options.animation,
  4043.                 fade_out    = {opacity:0},
  4044.                 fade_start  = {display:'inline-block', opacity:0},
  4045.                 fade_in     = {opacity:1};
  4046.                
  4047.             this.$next = _self.$slides.eq(this.open);
  4048.            
  4049.             if(this.cssActive)
  4050.             {
  4051.                 fade_out[_self.property]    = "translate(0px," + modifier +"px)";
  4052.                 fade_start[_self.property]  = "translate(0px," + (modifier * -1) +"px)";
  4053.                 fade_in[_self.property]     = "translate(0px,0px)";
  4054.             }
  4055.             else
  4056.             {
  4057.                 fade_out['top']     = modifier;
  4058.                 fade_start['top']   = (modifier * -1);
  4059.                 fade_in['top']      = 0;
  4060.             }
  4061.            
  4062.            
  4063.             _self.$current.avia_animate(fade_out, function()
  4064.             {
  4065.                 _self.$current.css({display:'none'});
  4066.                 _self.$next.css(fade_start).avia_animate(fade_in, function()
  4067.                 {
  4068.                     _self.$current = _self.$slides.eq(_self.open);
  4069.                 });
  4070.             });
  4071.         }
  4072.     };
  4073.  
  4074.  
  4075. $.fn.avia_textrotator = function( options )
  4076. {
  4077.     return this.each(function()
  4078.     {
  4079.         var active = $.data( this, 'AviaTextRotator' );
  4080.  
  4081.         if(!active)
  4082.         {
  4083.             //make sure that the function doesnt get aplied a second time
  4084.             $.data( this, 'AviaTextRotator', 1 );
  4085.            
  4086.             //create the preparations for fullscreen slider
  4087.             new $.AviaTextRotator( options, this );
  4088.         }
  4089.     });
  4090. }
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096.  
  4097.  
  4098.  
  4099.  
  4100.  
  4101.  
  4102.  
  4103.  
  4104.  
  4105.  
  4106. // -------------------------------------------------------------------------------------------
  4107. // HELPER FUNCTIONS
  4108. // -------------------------------------------------------------------------------------------
  4109.  
  4110.  
  4111. //waipoint script when something comes into viewport
  4112.  $.fn.avia_waypoints = function(options_passed)
  4113.     {
  4114.         if(! $('html').is('.avia_transform')) return;
  4115.  
  4116.         var defaults = { offset: 'bottom-in-view' , triggerOnce: true},
  4117.             options  = $.extend({}, defaults, options_passed),
  4118.             isMobile = $.avia_utilities.isMobile;
  4119.  
  4120.         return this.each(function()
  4121.         {
  4122.             var element = $(this);
  4123.            
  4124.             setTimeout(function()
  4125.             {
  4126.                 if(isMobile)
  4127.                 {
  4128.                     element.addClass('avia_start_animation').trigger('avia_start_animation');
  4129.                 }
  4130.                 else
  4131.                 {
  4132.                     element.waypoint(function(direction)
  4133.                     {
  4134.                         var current     = $(this.element),
  4135.                             parent      = current.parents('.av-animation-delay-container:eq(0)');
  4136.                        
  4137.                         if(parent.length)
  4138.                         {
  4139.                             current.addClass('avia_start_animation_when_active').trigger('avia_start_animation_when_active');
  4140.                         }
  4141.                        
  4142.                         if(!parent.length || (parent.length && parent.is('.__av_init_open')))
  4143.                         {
  4144.                             current.addClass('avia_start_animation').trigger('avia_start_animation');
  4145.                         }
  4146.                        
  4147.                        
  4148.                        
  4149.                     }, options );
  4150.                 }
  4151.             },100)
  4152.            
  4153.         });
  4154.     };
  4155.  
  4156.  
  4157.  
  4158.  
  4159.  
  4160.  
  4161.  
  4162. // window resize script
  4163. var $event = $.event, $special, resizeTimeout;
  4164.  
  4165. $special = $event.special.debouncedresize = {
  4166.     setup: function() {
  4167.         $( this ).on( "resize", $special.handler );
  4168.     },
  4169.     teardown: function() {
  4170.         $( this ).off( "resize", $special.handler );
  4171.     },
  4172.     handler: function( event, execAsap ) {
  4173.         // Save the context
  4174.         var context = this,
  4175.             args = arguments,
  4176.             dispatch = function() {
  4177.                 // set correct event type
  4178.                 event.type = "debouncedresize";
  4179.                 $event.dispatch.apply( context, args );
  4180.             };
  4181.  
  4182.         if ( resizeTimeout ) {
  4183.             clearTimeout( resizeTimeout );
  4184.         }
  4185.  
  4186.         execAsap ?
  4187.             dispatch() :
  4188.             resizeTimeout = setTimeout( dispatch, $special.threshold );
  4189.     },
  4190.     threshold: 150
  4191. };
  4192.  
  4193.  
  4194.  
  4195.  
  4196.  
  4197. $.easing['jswing'] = $.easing['swing'];
  4198.  
  4199. $.extend( $.easing,
  4200. {
  4201.     def: 'easeOutQuad',
  4202.     swing: function (x, t, b, c, d) { return $.easing[$.easing.def](x, t, b, c, d); },
  4203.     easeInQuad: function (x, t, b, c, d) { return c*(t/=d)*t + b; },
  4204.     easeOutQuad: function (x, t, b, c, d) { return -c *(t/=d)*(t-2) + b; },
  4205.     easeInOutQuad: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t + b; return -c/2 * ((--t)*(t-2) - 1) + b; },
  4206.     easeInCubic: function (x, t, b, c, d) { return c*(t/=d)*t*t + b; },
  4207.     easeOutCubic: function (x, t, b, c, d) { return c*((t=t/d-1)*t*t + 1) + b; },
  4208.     easeInOutCubic: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t + b; return c/2*((t-=2)*t*t + 2) + b; },
  4209.     easeInQuart: function (x, t, b, c, d) { return c*(t/=d)*t*t*t + b;  },
  4210.     easeOutQuart: function (x, t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b; },
  4211.     easeInOutQuart: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t*t + b; return -c/2 * ((t-=2)*t*t*t - 2) + b;  },
  4212.     easeInQuint: function (x, t, b, c, d) { return c*(t/=d)*t*t*t*t + b;    },
  4213.     easeOutQuint: function (x, t, b, c, d) { return c*((t=t/d-1)*t*t*t*t + 1) + b;  },
  4214.     easeInOutQuint: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; return c/2*((t-=2)*t*t*t*t + 2) + b; },
  4215.     easeInSine: function (x, t, b, c, d) {  return -c * Math.cos(t/d * (Math.PI/2)) + c + b;    },
  4216.     easeOutSine: function (x, t, b, c, d) { return c * Math.sin(t/d * (Math.PI/2)) + b; },
  4217.     easeInOutSine: function (x, t, b, c, d) { return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;    },
  4218.     easeInExpo: function (x, t, b, c, d) { return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; },
  4219.     easeOutExpo: function (x, t, b, c, d) { return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;    },
  4220.     easeInOutExpo: function (x, t, b, c, d) {
  4221.         if (t==0) return b;
  4222.         if (t==d) return b+c;
  4223.         if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
  4224.         return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
  4225.     },
  4226.     easeInCirc: function (x, t, b, c, d) { return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;   },
  4227.     easeOutCirc: function (x, t, b, c, d) {return c * Math.sqrt(1 - (t=t/d-1)*t) + b;   },
  4228.     easeInOutCirc: function (x, t, b, c, d) { if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; },
  4229.     easeInElastic: function (x, t, b, c, d) {
  4230.         var s=1.70158;var p=0;var a=c;
  4231.         if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
  4232.         if (a < Math.abs(c)) { a=c; var s=p/4; }
  4233.         else var s = p/(2*Math.PI) * Math.asin (c/a);
  4234.         return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  4235.     },
  4236.     easeOutElastic: function (x, t, b, c, d) {
  4237.         var s=1.70158;var p=0;var a=c;
  4238.         if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
  4239.         if (a < Math.abs(c)) { a=c; var s=p/4; }
  4240.         else var s = p/(2*Math.PI) * Math.asin (c/a);
  4241.         return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
  4242.     },
  4243.     easeInOutElastic: function (x, t, b, c, d) {
  4244.         var s=1.70158;var p=0;var a=c;
  4245.         if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
  4246.         if (a < Math.abs(c)) { a=c; var s=p/4; }
  4247.         else var s = p/(2*Math.PI) * Math.asin (c/a);
  4248.         if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  4249.         return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
  4250.     },
  4251.     easeInBack: function (x, t, b, c, d, s) {
  4252.         if (s == undefined) s = 1.70158;
  4253.         return c*(t/=d)*t*((s+1)*t - s) + b;
  4254.     },
  4255.     easeOutBack: function (x, t, b, c, d, s) {
  4256.         if (s == undefined) s = 1.70158;
  4257.         return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
  4258.     },
  4259.     easeInOutBack: function (x, t, b, c, d, s) {
  4260.         if (s == undefined) s = 1.70158;
  4261.         if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
  4262.         return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
  4263.     },
  4264.     easeInBounce: function (x, t, b, c, d) {
  4265.         return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
  4266.     },
  4267.     easeOutBounce: function (x, t, b, c, d) {
  4268.         if ((t/=d) < (1/2.75)) {
  4269.             return c*(7.5625*t*t) + b;
  4270.         } else if (t < (2/2.75)) {
  4271.             return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
  4272.         } else if (t < (2.5/2.75)) {
  4273.             return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
  4274.         } else {
  4275.             return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
  4276.         }
  4277.     },
  4278.     easeInOutBounce: function (x, t, b, c, d) {
  4279.         if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
  4280.         return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
  4281.     }
  4282. });
  4283.  
  4284. })( jQuery );
  4285.  
  4286.  
  4287.  
  4288. /*utility functions*/
  4289.  
  4290.  
  4291. (function($)
  4292. {
  4293.     "use strict";
  4294.  
  4295.     $.avia_utilities = $.avia_utilities || {};
  4296.  
  4297.     /************************************************************************
  4298.     gloabl loading function
  4299.     *************************************************************************/
  4300.     $.avia_utilities.loading = function(attach_to, delay){
  4301.  
  4302.         var loader = {
  4303.  
  4304.             active: false,
  4305.  
  4306.             show: function()
  4307.             {
  4308.                 if(loader.active === false)
  4309.                 {
  4310.                     loader.active = true;
  4311.                     loader.loading_item.css({display:'block', opacity:0});
  4312.                 }
  4313.  
  4314.                 loader.loading_item.stop().animate({opacity:1});
  4315.             },
  4316.  
  4317.             hide: function()
  4318.             {  
  4319.                 if(typeof delay === 'undefined'){ delay = 600; }
  4320.  
  4321.                 loader.loading_item.stop().delay( delay ).animate({opacity:0}, function()
  4322.                 {
  4323.                     loader.loading_item.css({display:'none'});
  4324.                     loader.active = false;
  4325.                 });
  4326.             },
  4327.  
  4328.             attach: function()
  4329.             {
  4330.                 if(typeof attach_to === 'undefined'){ attach_to = 'body';}
  4331.  
  4332.                 loader.loading_item = $('<div class="avia_loading_icon"><div class="av-siteloader"></div></div>').css({display:"none"}).appendTo(attach_to);
  4333.             }
  4334.         }
  4335.  
  4336.         loader.attach();
  4337.         return loader;
  4338.     };
  4339.    
  4340.     /************************************************************************
  4341.     gloabl play/pause visualizer function
  4342.     *************************************************************************/
  4343.     $.avia_utilities.playpause = function(attach_to, delay){
  4344.  
  4345.         var pp = {
  4346.  
  4347.             active: false,
  4348.             to1: "",
  4349.             to2: "",
  4350.             set: function(status)
  4351.             {  
  4352.                 pp.loading_item.removeClass('av-play av-pause');
  4353.                 pp.to1 = setTimeout(function(){ pp.loading_item.addClass('av-' + status); },10);
  4354.                 pp.to2 = setTimeout(function(){ pp.loading_item.removeClass('av-' + status); },1500);
  4355.             },
  4356.  
  4357.             attach: function()
  4358.             {
  4359.                 if(typeof attach_to === 'undefined'){ attach_to = 'body';}
  4360.  
  4361.                 pp.loading_item = $('<div class="avia_playpause_icon"></div>').css({display:"none"}).appendTo(attach_to);
  4362.             }
  4363.         }
  4364.  
  4365.         pp.attach();
  4366.         return pp;
  4367.     };
  4368.    
  4369.    
  4370.  
  4371.     /************************************************************************
  4372.     preload images, as soon as all are loaded trigger a special load ready event
  4373.     *************************************************************************/
  4374.     $.avia_utilities.preload = function(options_passed)
  4375.     {
  4376.         new $.AviaPreloader(options_passed);
  4377.     }
  4378.    
  4379.     $.AviaPreloader  =  function(options)
  4380.     {
  4381.         this.win        = $(window);
  4382.         this.defaults   =
  4383.         {
  4384.             container:          'body',
  4385.             maxLoops:           10,
  4386.             trigger_single:     true,
  4387.             single_callback:    function(){},
  4388.             global_callback:    function(){}
  4389.  
  4390.         };
  4391.         this.options    = $.extend({}, this.defaults, options);
  4392.         this.preload_images = 0;
  4393.        
  4394.         this.load_images();
  4395.     }
  4396.    
  4397.     $.AviaPreloader.prototype  =
  4398.     {
  4399.         load_images: function()
  4400.         {  
  4401.             var _self = this;
  4402.            
  4403.             if(typeof _self.options.container === 'string'){ _self.options.container = $(_self.options.container); }
  4404.  
  4405.             _self.options.container.each(function()
  4406.             {
  4407.                 var container       = $(this);
  4408.    
  4409.                 container.images    = container.find('img');
  4410.                 container.allImages = container.images;
  4411.    
  4412.                 _self.preload_images += container.images.length;
  4413.                 setTimeout(function(){ _self.checkImage(container); }, 10);
  4414.             });
  4415.         },
  4416.        
  4417.         checkImage: function(container)
  4418.         {  
  4419.             var _self = this;
  4420.            
  4421.             container.images.each(function()
  4422.             {
  4423.                 if(this.complete === true)
  4424.                 {
  4425.                     container.images = container.images.not(this);
  4426.                     _self.preload_images -= 1;
  4427.                 }
  4428.             });
  4429.  
  4430.             if(container.images.length && _self.options.maxLoops >= 0)
  4431.             {
  4432.                 _self.options.maxLoops-=1;
  4433.                 setTimeout(function(){ _self.checkImage(container); }, 500);
  4434.             }
  4435.             else
  4436.             {
  4437.                 _self.preload_images = _self.preload_images - container.images.length;
  4438.                 _self.trigger_loaded(container);
  4439.             }
  4440.         },
  4441.  
  4442.         trigger_loaded: function(container)
  4443.         {
  4444.             var _self = this;
  4445.            
  4446.             if(_self.options.trigger_single !== false)
  4447.             {
  4448.                 _self.win.trigger('avia_images_loaded_single', [container]);
  4449.                 _self.options.single_callback.call(container);
  4450.             }
  4451.  
  4452.             if(_self.preload_images === 0)
  4453.             {
  4454.                 _self.win.trigger('avia_images_loaded');
  4455.                 _self.options.global_callback.call();
  4456.             }
  4457.  
  4458.         }
  4459.     }
  4460.  
  4461.  
  4462.     /************************************************************************
  4463.     CSS Easing transformation table
  4464.     *************************************************************************/
  4465.     /*
  4466.     Easing transform table from jquery.animate-enhanced plugin
  4467.     http://github.com/benbarnett/jQuery-Animate-Enhanced
  4468.     */
  4469.     $.avia_utilities.css_easings = {
  4470.             linear:         'linear',
  4471.             swing:          'ease-in-out',
  4472.             bounce:         'cubic-bezier(0.0, 0.35, .5, 1.3)',
  4473.             easeInQuad:     'cubic-bezier(0.550, 0.085, 0.680, 0.530)' ,
  4474.             easeInCubic:    'cubic-bezier(0.550, 0.055, 0.675, 0.190)' ,
  4475.             easeInQuart:    'cubic-bezier(0.895, 0.030, 0.685, 0.220)' ,
  4476.             easeInQuint:    'cubic-bezier(0.755, 0.050, 0.855, 0.060)' ,
  4477.             easeInSine:     'cubic-bezier(0.470, 0.000, 0.745, 0.715)' ,
  4478.             easeInExpo:     'cubic-bezier(0.950, 0.050, 0.795, 0.035)' ,
  4479.             easeInCirc:     'cubic-bezier(0.600, 0.040, 0.980, 0.335)' ,
  4480.             easeInBack:     'cubic-bezier(0.600, -0.280, 0.735, 0.04)' ,
  4481.             easeOutQuad:    'cubic-bezier(0.250, 0.460, 0.450, 0.940)' ,
  4482.             easeOutCubic:   'cubic-bezier(0.215, 0.610, 0.355, 1.000)' ,
  4483.             easeOutQuart:   'cubic-bezier(0.165, 0.840, 0.440, 1.000)' ,
  4484.             easeOutQuint:   'cubic-bezier(0.230, 1.000, 0.320, 1.000)' ,
  4485.             easeOutSine:    'cubic-bezier(0.390, 0.575, 0.565, 1.000)' ,
  4486.             easeOutExpo:    'cubic-bezier(0.190, 1.000, 0.220, 1.000)' ,
  4487.             easeOutCirc:    'cubic-bezier(0.075, 0.820, 0.165, 1.000)' ,
  4488.             easeOutBack:    'cubic-bezier(0.175, 0.885, 0.320, 1.275)' ,
  4489.             easeInOutQuad:  'cubic-bezier(0.455, 0.030, 0.515, 0.955)' ,
  4490.             easeInOutCubic: 'cubic-bezier(0.645, 0.045, 0.355, 1.000)' ,
  4491.             easeInOutQuart: 'cubic-bezier(0.770, 0.000, 0.175, 1.000)' ,
  4492.             easeInOutQuint: 'cubic-bezier(0.860, 0.000, 0.070, 1.000)' ,
  4493.             easeInOutSine:  'cubic-bezier(0.445, 0.050, 0.550, 0.950)' ,
  4494.             easeInOutExpo:  'cubic-bezier(1.000, 0.000, 0.000, 1.000)' ,
  4495.             easeInOutCirc:  'cubic-bezier(0.785, 0.135, 0.150, 0.860)' ,
  4496.             easeInOutBack:  'cubic-bezier(0.680, -0.550, 0.265, 1.55)' ,
  4497.             easeInOutBounce:'cubic-bezier(0.580, -0.365, 0.490, 1.365)',
  4498.             easeOutBounce:  'cubic-bezier(0.760, 0.085, 0.490, 1.365)'
  4499.         };
  4500.  
  4501.     /************************************************************************
  4502.     check if a css feature is supported and save it to the supported array
  4503.     *************************************************************************/
  4504.     $.avia_utilities.supported  = {};
  4505.     $.avia_utilities.supports   = (function()
  4506.     {
  4507.         var div     = document.createElement('div'),
  4508.             vendors = ['Khtml', 'Ms','Moz','Webkit'];  // vendors   = ['Khtml', 'Ms','Moz','Webkit','O'];
  4509.  
  4510.         return function(prop, vendor_overwrite)
  4511.         {
  4512.             if ( div.style[prop] !== undefined  ) { return ""; }
  4513.             if (vendor_overwrite !== undefined) { vendors = vendor_overwrite; }
  4514.  
  4515.             prop = prop.replace(/^[a-z]/, function(val)
  4516.             {
  4517.                 return val.toUpperCase();
  4518.             });
  4519.  
  4520.             var len = vendors.length;
  4521.             while(len--)
  4522.             {
  4523.                 if ( div.style[vendors[len] + prop] !== undefined )
  4524.                 {
  4525.                     return "-" + vendors[len].toLowerCase() + "-";
  4526.                 }
  4527.             }
  4528.  
  4529.             return false;
  4530.         };
  4531.  
  4532.     }());
  4533.  
  4534.     /************************************************************************
  4535.     animation function
  4536.     *************************************************************************/
  4537.     $.fn.avia_animate = function(prop, speed, easing, callback)
  4538.     {
  4539.         if(typeof speed === 'function') {callback = speed; speed = false; }
  4540.         if(typeof easing === 'function'){callback = easing; easing = false;}
  4541.         if(typeof speed === 'string'){easing = speed; speed = false;}
  4542.  
  4543.         if(callback === undefined || callback === false){ callback = function(){}; }
  4544.         if(easing === undefined || easing === false)    { easing = 'easeInQuad'; }
  4545.         if(speed === undefined || speed === false)      { speed = 400; }
  4546.  
  4547.         if($.avia_utilities.supported.transition === undefined)
  4548.         {
  4549.             $.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
  4550.         }
  4551.        
  4552.        
  4553.  
  4554.         if($.avia_utilities.supported.transition !== false )
  4555.         {
  4556.             var prefix      = $.avia_utilities.supported.transition + 'transition',
  4557.                 cssRule     = {},
  4558.                 cssProp     = {},
  4559.                 thisStyle   = document.body.style,
  4560.                 end         = (thisStyle.WebkitTransition !== undefined) ? 'webkitTransitionEnd' : (thisStyle.OTransition !== undefined) ? 'oTransitionEnd' : 'transitionend';
  4561.  
  4562.             //translate easing into css easing
  4563.             easing = $.avia_utilities.css_easings[easing];
  4564.  
  4565.             //create css transformation rule
  4566.             cssRule[prefix] =  'all '+(speed/1000)+'s '+easing;
  4567.             //add namespace to the transition end trigger
  4568.             end = end + ".avia_animate";
  4569.            
  4570.             //since jquery 1.10 the items passed need to be {} and not [] so make sure they are converted properly
  4571.             for (var rule in prop)
  4572.             {
  4573.                 if (prop.hasOwnProperty(rule)) { cssProp[rule] = prop[rule]; }
  4574.             }
  4575.             prop = cssProp;
  4576.            
  4577.            
  4578.            
  4579.             this.each(function()
  4580.             {
  4581.                 var element = $(this), css_difference = false, rule, current_css;
  4582.  
  4583.                 for (rule in prop)
  4584.                 {
  4585.                     if (prop.hasOwnProperty(rule))
  4586.                     {
  4587.                         current_css = element.css(rule);
  4588.  
  4589.                         if(prop[rule] != current_css && prop[rule] != current_css.replace(/px|%/g,""))
  4590.                         {
  4591.                             css_difference = true;
  4592.                             break;
  4593.                         }
  4594.                     }
  4595.                 }
  4596.  
  4597.                 if(css_difference)
  4598.                 {
  4599.                     //if no transform property is set set a 3d translate to enable hardware acceleration
  4600.                     if(!($.avia_utilities.supported.transition+"transform" in prop))
  4601.                     {
  4602.                         prop[$.avia_utilities.supported.transition+"transform"] = "translateZ(0)";
  4603.                     }
  4604.                    
  4605.                     var endTriggered = false;
  4606.                    
  4607.                     element.on(end,  function(event)
  4608.                     {
  4609.                         if(event.target != event.currentTarget) return false;
  4610.                        
  4611.                         if(endTriggered == true) return false;
  4612.                         endTriggered = true;
  4613.  
  4614.                         cssRule[prefix] = "none";
  4615.  
  4616.                         element.off(end);
  4617.                         element.css(cssRule);
  4618.                         setTimeout(function(){ callback.call(element); });
  4619.                     });
  4620.                    
  4621.                    
  4622.                     //desktop safari fallback if we are in another tab to trigger the end event
  4623.                     setTimeout(function(){
  4624.                         if(!endTriggered && !avia_is_mobile && $('html').is('.avia-safari') ) {
  4625.                             element.trigger(end);
  4626.                             $.avia_utilities.log('Safari Fallback '+end+' trigger');
  4627.                         }
  4628.                     }, speed + 100);
  4629.                    
  4630.                     setTimeout(function(){ element.css(cssRule);},10);
  4631.                     setTimeout(function(){ element.css(prop);   },20);
  4632.                 }
  4633.                 else
  4634.                 {
  4635.                     setTimeout(function(){ callback.call(element); });
  4636.                 }
  4637.  
  4638.             });
  4639.         }
  4640.         else // if css animation is not available use default JS animation
  4641.         {
  4642.             this.animate(prop, speed, easing, callback);
  4643.         }
  4644.  
  4645.         return this;
  4646.     };
  4647.  
  4648. })( jQuery );
  4649.  
  4650.  
  4651. /* ======================================================================================================================================================
  4652. Avia Slideshow
  4653. ====================================================================================================================================================== */
  4654.  
  4655. (function($)
  4656. {
  4657.     "use strict";
  4658.  
  4659.     $.AviaSlider  =  function(options, slider)
  4660.     {
  4661.         var self = this;
  4662.        
  4663.         this.$win    = $( window );
  4664.        
  4665.         this.$slider = $( slider );
  4666.        
  4667.         this.isMobile = $.avia_utilities.isMobile;
  4668.        
  4669.         this._prepareSlides(options);
  4670.        
  4671.         //default preload images then init slideshow
  4672.         $.avia_utilities.preload({container: this.$slider , single_callback:  function(){ self._init( options ); }});
  4673.     }
  4674.  
  4675.     $.AviaSlider.defaults  = {
  4676.  
  4677.         //interval between autorotation switches
  4678.         interval:5,
  4679.  
  4680.         //autorotation active or not
  4681.         autoplay:false,
  4682.        
  4683.         //set if the loop will stop at the last/first slide or if the slides will loop infinite
  4684.         //set to false for infinite loop, "last" to stop at the last slide or "first" to stop at the first slide
  4685.         stopinfiniteloop: false,
  4686.  
  4687.         //fade or slide animation
  4688.         animation:'slide',
  4689.  
  4690.         //transition speed when switching slide
  4691.         transitionSpeed:900,
  4692.  
  4693.         //easing method for the transition
  4694.         easing:'easeInOutQuart',
  4695.  
  4696.         //slide wrapper
  4697.         wrapElement: '>ul',
  4698.  
  4699.         //slide element
  4700.         slideElement: '>li',
  4701.  
  4702.         //pause if mouse cursor is above item
  4703.         hoverpause: false,
  4704.        
  4705.         //attach images as background
  4706.         bg_slider: false,
  4707.        
  4708.         //delay of miliseconds to wait before showing the next slide
  4709.         show_slide_delay: 0,
  4710.        
  4711.         //if slider animation is set to "fade" the fullfade property sets the crossfade behaviour
  4712.         fullfade: false
  4713.  
  4714.     };
  4715.  
  4716.     $.AviaSlider.prototype =
  4717.     {
  4718.         _init: function( options )
  4719.         {
  4720.             // set slider options
  4721.             this.options = this._setOptions(options);
  4722.  
  4723.             //slidewrap
  4724.             this.$sliderUl  = this.$slider.find(this.options.wrapElement);
  4725.  
  4726.             // slide elements
  4727.             this.$slides = this.$sliderUl.find(this.options.slideElement);
  4728.  
  4729.             // goto dots
  4730.             this.gotoButtons = this.$slider.find('.avia-slideshow-dots a');
  4731.            
  4732.             //perma caption
  4733.             this.permaCaption =  this.$slider.find('>.av-slideshow-caption');
  4734.  
  4735.             // slide count
  4736.             this.itemsCount = this.$slides.length;
  4737.  
  4738.             // current image index
  4739.             this.current = 0;
  4740.  
  4741.             //loop count
  4742.             this.loopCount = 0;
  4743.  
  4744.             // control if the slicebox is animating
  4745.             this.isAnimating = false;
  4746.  
  4747.             // css browser prefix like -webkit-, -moz-
  4748.             this.browserPrefix = $.avia_utilities.supports('transition');
  4749.            
  4750.             // css3 animation?
  4751.             this.cssActive = this.browserPrefix !== false ? true : false;
  4752.            
  4753.             // css3D animation?
  4754.             this.css3DActive = document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
  4755.            
  4756.             //store the aviaVideoApi object for the current slide if available
  4757.             this.video  = false;
  4758.            
  4759.             //if we have a bg slider no images were preloaded yet. in that case start preloading and attaching images
  4760.             if(this.options.bg_slider == true)
  4761.             {
  4762.                 //create array that holds all image urls to preload
  4763.                 this.imageUrls = [];
  4764.                
  4765.                 //create a preloader icon to indicate loading
  4766.                 this.loader = $.avia_utilities.loading(this.$slider);
  4767.                
  4768.                 //preload the images ony by one
  4769.                 this._bgPreloadImages();
  4770.                
  4771.             }
  4772.             else //if it was a default slider all images are already loaded and we can start showing the slider
  4773.             {          
  4774.                 //kickoff the slider: bind functions, show first slide, if active start the autorotation timer
  4775.                 this._kickOff();
  4776.             }
  4777.         },
  4778.  
  4779.         //set the slider options by first merging the efault options and the passed options, then checking the slider element if any data attributes overwrite the option set
  4780.         _setOptions: function(options)
  4781.         {
  4782.             var newOptions  = $.extend( true, {}, $.AviaSlider.defaults, options ),
  4783.                 htmlData    = this.$slider.data(),
  4784.                 i           = "";
  4785.  
  4786.             //overwritte passed option set with any data properties on the html element
  4787.             for (i in htmlData)
  4788.             {
  4789.                 if (htmlData.hasOwnProperty(i))
  4790.                 {
  4791.                     if(typeof htmlData[i] === "string" || typeof htmlData[i] === "number" || typeof htmlData[i] === "boolean")
  4792.                     {
  4793.                         newOptions[i] = htmlData[i];
  4794.                     }
  4795.                 }
  4796.             }
  4797.  
  4798.             return newOptions;
  4799.         },
  4800.        
  4801.         _prepareSlides: function(options)
  4802.         {  
  4803.             //if its a mobile device find all video slides that need to be altered
  4804.             if(this.isMobile)
  4805.             {
  4806.                 var alter = this.$slider.find('.av-mobile-fallback-image');
  4807.                 alter.each(function()
  4808.                 {  
  4809.                     var current  = $(this).removeClass('av-video-slide').data({'avia_video_events': true, 'video-ratio':0}),
  4810.                         fallback = current.data('mobile-img');
  4811.                        
  4812.                     current.find('.av-click-overlay, .mejs-mediaelement, .mejs-container').remove();
  4813.                    
  4814.                     if(!fallback)
  4815.                     {
  4816.                         var appendTo = current.find('.avia-slide-wrap');
  4817.                         $('<p class="av-fallback-message"><span>Please set a mobile device fallback image for this video in your wordpress backend</span></p>').appendTo(appendTo);
  4818.                     }
  4819.                    
  4820.                     if(options && options.bg_slider)
  4821.                     {
  4822.                         current.data('img-url', fallback);
  4823.                     }
  4824.                     else
  4825.                     {
  4826.                         var image = $('<img src="'+fallback+'" alt="" title="" />');
  4827.                         current.find('.avia-slide-wrap').append(image);
  4828.                     }
  4829.                    
  4830.                 });
  4831.             }
  4832.            
  4833.         },
  4834.        
  4835.         //start preloading the background images
  4836.         _bgPreloadImages : function(callback)
  4837.         {
  4838.             this._getImageURLS();
  4839.            
  4840.             this._preloadSingle(0, function()
  4841.             {
  4842.                 this._kickOff();
  4843.                 this._preloadNext(1);
  4844.             });
  4845.         },
  4846.        
  4847.         //if we are using a background image slider, fetch the images from a data attribute and preload them one by one
  4848.         _getImageURLS: function()
  4849.         {
  4850.             var _self = this;
  4851.            
  4852.             //collect url strings of the images to preload
  4853.             this.$slides.each(function(i)
  4854.             {
  4855.                 _self.imageUrls[i] = [];
  4856.                 _self.imageUrls[i]['url'] = $(this).data("img-url");
  4857.                
  4858.                 //if no image is passed we can set the slide to loaded
  4859.                 if(typeof _self.imageUrls[i]['url'] == 'string')
  4860.                 {
  4861.                     _self.imageUrls[i]['status'] = false;
  4862.                 }
  4863.                 else
  4864.                 {
  4865.                     _self.imageUrls[i]['status'] = true;
  4866.                 }
  4867.             });
  4868.         },
  4869.        
  4870.        
  4871.         _preloadSingle: function(key, callback)
  4872.         {
  4873.             var _self       = this,
  4874.                 objImage    = new Image();
  4875.            
  4876.             if(typeof _self.imageUrls[key]['url'] == 'string')
  4877.             {
  4878.                 $(objImage).bind('load error', function()
  4879.                 {
  4880.                     _self.imageUrls[key]['status'] = true;
  4881.                     _self.$slides.eq(key).css('background-image','url(' + _self.imageUrls[key]['url'] + ')');
  4882.                     if(typeof callback == 'function') callback.apply( _self, [objImage, key] );
  4883.                 });
  4884.                
  4885.                 if(_self.imageUrls[key]['url'] != "")
  4886.                 {
  4887.                     objImage.src = _self.imageUrls[key]['url'];
  4888.                 }
  4889.                 else
  4890.                 {
  4891.                     $(objImage).trigger('error');
  4892.                 }
  4893.             }
  4894.             else
  4895.             {
  4896.                 if(typeof callback == 'function') callback.apply( _self, [objImage, key] );
  4897.             }
  4898.         },
  4899.        
  4900.         _preloadNext: function(key)
  4901.         {
  4902.             if(typeof this.imageUrls[key] != "undefined")
  4903.             {
  4904.                 this._preloadSingle(key, function()
  4905.                 {
  4906.                     this._preloadNext(key + 1);
  4907.                 });
  4908.             }
  4909.         },
  4910.        
  4911.  
  4912.         //bind click events of slide controlls to the public functions
  4913.         _bindEvents: function()
  4914.         {
  4915.             var self = this,
  4916.                 win  = $( window );
  4917.  
  4918.             this.$slider.on('click','.next-slide', $.proxy( this.next, this) );
  4919.             this.$slider.on('click','.prev-slide', $.proxy( this.previous, this) );
  4920.             this.$slider.on('click','.goto-slide', $.proxy( this.go2, this) );
  4921.  
  4922.             if(this.options.hoverpause)
  4923.             {
  4924.                 this.$slider.on('mouseenter', $.proxy( this.pause, this) );
  4925.                 this.$slider.on('mouseleave', $.proxy( this.resume, this) );
  4926.             }
  4927.  
  4928.             if(this.options.stopinfiniteloop && this.options.autoplay)
  4929.             {
  4930.                 if(this.options.stopinfiniteloop == 'last')
  4931.                 {
  4932.                     this.$slider.on('avia_slider_last_slide', $.proxy(this._stopSlideshow, this) );
  4933.                 }
  4934.                 else if(this.options.stopinfiniteloop == 'first')
  4935.                 {
  4936.                     this.$slider.on('avia_slider_first_slide', $.proxy(this._stopSlideshow, this) );
  4937.                 }
  4938.             }
  4939.  
  4940.             win.on( 'debouncedresize.aviaSlider',  $.proxy( this._setSize, this) );
  4941.  
  4942.             //if its a desktop browser add arrow navigation, otherwise add touch nav
  4943.             if(!this.isMobile)
  4944.             {
  4945.                 this.$slider.avia_keyboard_controls();
  4946.             }
  4947.             else
  4948.             {
  4949.                 this.$slider.avia_swipe_trigger();
  4950.             }
  4951.            
  4952.             self._attach_video_events();
  4953.         },
  4954.  
  4955.         //kickoff the slider by binding all functions to slides and buttons, show the first slide and start autoplay
  4956.         _kickOff: function()
  4957.         {
  4958.             var self            = this,
  4959.                 first_slide     = self.$slides.eq(0),
  4960.                 video           = first_slide.data('video-ratio');
  4961.                    
  4962.             // bind events to to the controll buttons
  4963.             self._bindEvents();
  4964.            
  4965.             this.$slider.removeClass('av-default-height-applied');
  4966.            
  4967.             //show the first slide. if its a video set the correct size, otherwise make sure to remove the % padding
  4968.             if(video)
  4969.             {
  4970.                 self._setSize(true);
  4971.             }
  4972.             else
  4973.             {
  4974.                 if(this.options.keep_pading != true)
  4975.                 {
  4976.                     self.$sliderUl.css('padding',0);
  4977.                     self.$win.trigger('av-height-change');
  4978.                 }
  4979.             }
  4980.            
  4981.             self._setCenter();
  4982.             first_slide.css({visibility:'visible', opacity:0}).avia_animate({opacity:1}, function()
  4983.             {
  4984.                 var current = $(this).addClass('active-slide');
  4985.                
  4986.                 if(self.permaCaption.length)
  4987.                 {
  4988.                     self.permaCaption.addClass('active-slide');
  4989.                 }
  4990.             });
  4991.            
  4992.            
  4993.            
  4994.             // start autoplay if active
  4995.             if( self.options.autoplay )
  4996.             {
  4997.                 self._startSlideshow();
  4998.             }
  4999.            
  5000.         },
  5001.  
  5002.         //calculate which slide should be displayed next and call the executing transition function
  5003.         _navigate : function( dir, pos ) {
  5004.            
  5005.             if( this.isAnimating || this.itemsCount < 2 || !this.$slider.is(":visible") )
  5006.             {
  5007.                 return false;
  5008.             }
  5009.            
  5010.             this.isAnimating = true;
  5011.  
  5012.             // current item's index
  5013.             this.prev = this.current;
  5014.  
  5015.             // if position is passed
  5016.             if( pos !== undefined )
  5017.             {
  5018.                 this.current = pos;
  5019.                 dir = this.current > this.prev ? 'next' : 'prev';
  5020.             }
  5021.             // if not check the boundaries
  5022.             else if( dir === 'next' )
  5023.             {
  5024.                 this.current = this.current < this.itemsCount - 1 ? this.current + 1 : 0;
  5025.                
  5026.                 if( this.current === 0 && this.options.autoplay_stopper == 1 && this.options.autoplay )
  5027.                 {
  5028.                     this.isAnimating = false;
  5029.                     this.current = this.prev;
  5030.                     this._stopSlideshow();
  5031.                     return false;
  5032.                 }
  5033.             }
  5034.             else if( dir === 'prev' )
  5035.             {
  5036.                 this.current = this.current > 0 ? this.current - 1 : this.itemsCount - 1;
  5037.             }
  5038.  
  5039.             //set goto button
  5040.             this.gotoButtons.removeClass('active').eq(this.current).addClass('active');
  5041.  
  5042.             //set slideshow size
  5043.             this._setSize();
  5044.            
  5045.             //if we are using a background slider make sure that the image is loaded. if not preload it, then show the slide
  5046.             if(this.options.bg_slider == true)
  5047.             {
  5048.                 if(this.imageUrls[this.current]['status'] == true )
  5049.                 {
  5050.                     this['_' + this.options.animation].call(this, dir);
  5051.                 }
  5052.                 else
  5053.                 {
  5054.                     this.loader.show();
  5055.                     this._preloadSingle(this.current, function()
  5056.                     {
  5057.                         this['_' + this.options.animation].call(this, dir);
  5058.                         this.loader.hide();
  5059.                     });
  5060.                 }
  5061.             }
  5062.             else //no background loader -> images are already loaded
  5063.             {
  5064.                 //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
  5065.                 this['_' + this.options.animation].call(this, dir);
  5066.             }
  5067.  
  5068.             if(this.current == 0)
  5069.             {
  5070.                 this.loopCount++;
  5071.                 this.$slider.trigger('avia_slider_first_slide');
  5072.             }
  5073.             else if(this.current == this.itemsCount - 1)
  5074.             {
  5075.                 this.$slider.trigger('avia_slider_last_slide');
  5076.             }
  5077.             else
  5078.             {
  5079.                 this.$slider.trigger('avia_slider_navigate_slide');
  5080.             }
  5081.         },
  5082.  
  5083.         //if the next slide has a different height than the current change the slideshow height
  5084.         _setSize: function(instant)
  5085.         {
  5086.             //if images are attached as bg images the slider has a fixed height
  5087.             if(this.options.bg_slider == true) return;
  5088.            
  5089.             var self            = this,
  5090.                 slide           = this.$slides.eq(this.current),
  5091.                 img             = slide.find('img'),
  5092.                 current         = Math.floor(this.$sliderUl.height()),
  5093.                 ratio           = slide.data('video-ratio'),
  5094.                 setTo           = ratio ? this.$sliderUl.width() / ratio : Math.floor(slide.height()),
  5095.                 video_height    = slide.data('video-height'), //forced video height %. needs to be set only once
  5096.                 video_toppos    = slide.data('video-toppos'); //forced video top position
  5097.                
  5098.                 this.$sliderUl.height(current).css('padding',0); //make sure to set the slideheight to an actual value
  5099.                
  5100.                 if(setTo != current)
  5101.                 {
  5102.                     if(instant == true)
  5103.                     {
  5104.                         this.$sliderUl.css({height:setTo});
  5105.                         this.$win.trigger('av-height-change');
  5106.                     }
  5107.                     else
  5108.                     {
  5109.                         this.$sliderUl.avia_animate({height:setTo}, function()
  5110.                         {
  5111.                             self.$win.trigger('av-height-change');
  5112.                         });
  5113.                     }
  5114.                 }
  5115.                
  5116.                 this._setCenter();
  5117.                
  5118.                 if(video_height && video_height!= "set")
  5119.                 {
  5120.                     slide.find('iframe, embed, video, object, .av_youtube_frame').css({height: video_height + '%', top: video_toppos + '%'});
  5121.                     slide.data('video-height','set');
  5122.                 }
  5123.         },
  5124.        
  5125.         _setCenter: function()
  5126.         {
  5127.             //if the image has a min width and is larger than the slider center it
  5128.             //positon img based on caption. right caption->left pos, left caption -> right pos
  5129.             var slide       = this.$slides.eq(this.current),
  5130.                 img         = slide.find('img'),
  5131.                 min_width   = parseInt(img.css('min-width'),10),
  5132.                 slide_width = slide.width(),
  5133.                 caption     = slide.find('.av-slideshow-caption'),
  5134.                 css_left    = ((slide_width - min_width) / 2);
  5135.            
  5136.             if(caption.length)
  5137.             {
  5138.                 if(caption.is('.caption_left'))
  5139.                 {
  5140.                     css_left = ((slide_width - min_width) / 1.5);
  5141.                 }
  5142.                 else if(caption.is('.caption_right'))
  5143.                 {
  5144.                     css_left = ((slide_width - min_width) / 2.5);
  5145.                 }
  5146.             }
  5147.            
  5148.             if(slide_width >= min_width)
  5149.             {
  5150.                 css_left = 0;
  5151.             }
  5152.            
  5153.             img.css({left:css_left});
  5154.         },
  5155.        
  5156.         _slide: function(dir)
  5157.         {
  5158.             var dynamic         = false, //todo: pass by option if a slider is dynamic
  5159.                 modifier        = dynamic == true ? 2 : 1,
  5160.                 sliderWidth     = this.$slider.width(),
  5161.                 direction       = dir === 'next' ? -1 : 1,
  5162.                 property        = this.browserPrefix + 'transform',
  5163.                 reset           = {}, transition = {},  transition2 = {},
  5164.                 trans_val       = ( sliderWidth * direction * -1),
  5165.                 trans_val2      = ( sliderWidth * direction) / modifier;
  5166.            
  5167.             //do a css3 animation
  5168.             if(this.cssActive)
  5169.             {
  5170.                 property  = this.browserPrefix + 'transform';
  5171.  
  5172.                 //do a translate 3d transformation if available, since it uses hardware acceleration
  5173.                 if(this.css3DActive)
  5174.                 {
  5175.                     reset[property]  = "translate3d(" + trans_val + "px, 0, 0)";
  5176.                     transition[property]  = "translate3d(" + trans_val2 + "px, 0, 0)";
  5177.                     transition2[property] = "translate3d(0,0,0)";
  5178.                 }
  5179.                 else //do a 2d transform. still faster than a position "left" change
  5180.                 {
  5181.                     reset[property]  = "translate(" + trans_val + "px,0)";
  5182.                     transition[property]  = "translate(" + trans_val2 + "px,0)";
  5183.                     transition2[property] = "translate(0,0)";                   }
  5184.             }
  5185.             else
  5186.             {
  5187.                 reset.left = trans_val;
  5188.                 transition.left = trans_val2;
  5189.                 transition2.left = 0;
  5190.             }
  5191.            
  5192.             if(dynamic)
  5193.             {
  5194.                 transition['z-index']  = "1";
  5195.                 transition2['z-index']  = "2";
  5196.             }
  5197.            
  5198.             this._slide_animate(reset, transition, transition2);
  5199.         },
  5200.        
  5201.         _slide_up: function(dir)
  5202.         {
  5203.             var dynamic         = true, //todo: pass by option if a slider is dynamic
  5204.                 modifier        = dynamic == true ? 2 : 1,
  5205.                 sliderHeight    = this.$slider.height(),
  5206.                 direction       = dir === 'next' ? -1 : 1,
  5207.                 property        = this.browserPrefix + 'transform',
  5208.                 reset           = {}, transition = {},  transition2 = {},
  5209.                 trans_val       = ( sliderHeight * direction * -1),
  5210.                 trans_val2      = ( sliderHeight * direction) / modifier;
  5211.            
  5212.             //do a css3 animation
  5213.             if(this.cssActive)
  5214.             {
  5215.                 property  = this.browserPrefix + 'transform';
  5216.  
  5217.                 //do a translate 3d transformation if available, since it uses hardware acceleration
  5218.                 if(this.css3DActive)
  5219.                 {
  5220.                     reset[property]  = "translate3d( 0," + trans_val + "px, 0)";
  5221.                     transition[property]  = "translate3d( 0," + trans_val2 + "px, 0)";
  5222.                     transition2[property] = "translate3d(0,0,0)";
  5223.                 }
  5224.                 else //do a 2d transform. still faster than a position "left" change
  5225.                 {
  5226.                     reset[property]  = "translate( 0," + trans_val + "px)";
  5227.                     transition[property]  = "translate( 0," + trans_val2 + "px)";
  5228.                     transition2[property] = "translate(0,0)";                   }
  5229.             }
  5230.             else
  5231.             {
  5232.                 reset.top = trans_val;
  5233.                 transition.top = trans_val2;
  5234.                 transition2.top = 0;
  5235.             }
  5236.            
  5237.             if(dynamic)
  5238.             {
  5239.                 transition['z-index']  = "1";
  5240.                 transition2['z-index']  = "2";
  5241.             }
  5242.             this._slide_animate(reset, transition, transition2);
  5243.         },
  5244.        
  5245.        
  5246.         //slide animation: do a slide transition by css3 transform if possible. if not simply do a position left transition
  5247.         _slide_animate: function( reset , transition , transition2 )
  5248.         {
  5249.            
  5250.             var self            = this,
  5251.                 displaySlide    = this.$slides.eq(this.current),
  5252.                 hideSlide       = this.$slides.eq(this.prev);
  5253.                
  5254.                 hideSlide.trigger('pause');
  5255.                 if( !displaySlide.data('disableAutoplay') ) displaySlide.trigger('play');
  5256.  
  5257.                 displaySlide.css({visibility:'visible', zIndex:4, opacity:1, left:0, top:0});
  5258.                 displaySlide.css(reset);
  5259.                
  5260.                 hideSlide.avia_animate(transition, this.options.transitionSpeed, this.options.easing);
  5261.                
  5262.                 var after_slide = function()
  5263.                 {
  5264.                     self.isAnimating = false;
  5265.                     displaySlide.addClass('active-slide');
  5266.                     hideSlide.css({visibility:'hidden'}).removeClass('active-slide');
  5267.                     self.$slider.trigger('avia-transition-done');
  5268.                 }
  5269.                
  5270.                 if(self.options.show_slide_delay > 0)
  5271.                 {
  5272.                     setTimeout(function() { displaySlide.avia_animate(transition2, self.options.transitionSpeed, self.options.easing, after_slide); },self.options.show_slide_delay);
  5273.                 }
  5274.                 else
  5275.                 {
  5276.                     displaySlide.avia_animate(transition2, self.options.transitionSpeed, self.options.easing, after_slide);
  5277.                 }
  5278.  
  5279.         },
  5280.        
  5281.         //simple fade transition of the slideshow
  5282.         _fade: function()
  5283.         {
  5284.             var self            = this,
  5285.                 displaySlide    = this.$slides.eq(this.current),
  5286.                 hideSlide       = this.$slides.eq(this.prev),
  5287.                 properties      = {visibility:'visible', zIndex:3, opacity:0},
  5288.                 fadeCallback    = function()
  5289.                 {
  5290.                     self.isAnimating = false;
  5291.                     displaySlide.addClass('active-slide');
  5292.                     hideSlide.css({visibility:'hidden', zIndex:2}).removeClass('active-slide');
  5293.                     self.$slider.trigger('avia-transition-done');
  5294.                    
  5295.                 };
  5296.            
  5297.             hideSlide.trigger('pause');
  5298.             if( !displaySlide.data('disableAutoplay') ) displaySlide.trigger('play');
  5299.            
  5300.             if(self.options.fullfade == true)
  5301.             {
  5302.                 hideSlide.avia_animate({opacity:0}, 200, 'linear', function()
  5303.                 {  
  5304.                     displaySlide.css(properties).avia_animate({opacity:1}, self.options.transitionSpeed, 'linear',fadeCallback);               
  5305.                 });
  5306.             }
  5307.             else
  5308.             {
  5309.                 displaySlide.css(properties).avia_animate({opacity:1}, self.options.transitionSpeed/2, 'linear', function()
  5310.                 {
  5311.                     hideSlide.avia_animate({opacity:0}, 200, 'linear', fadeCallback);
  5312.                 });
  5313.             }
  5314.            
  5315.         },
  5316.        
  5317.        
  5318.         /************************************************************************
  5319.         Video functions
  5320.         *************************************************************************/
  5321.        
  5322.         //bind events to the video that tell the slider to autorotate once a video has been played
  5323.         _attach_video_events: function()
  5324.         {
  5325.             var self = this, $html = $('html');
  5326.                        
  5327.             self.$slides.each(function(i)
  5328.             {
  5329.                 var currentSlide    = $(this),
  5330.                     caption         = currentSlide.find('.caption_fullwidth, .av-click-overlay'),
  5331.                     mejs            = currentSlide.find('.mejs-mediaelement');
  5332.                                
  5333.                 if(currentSlide.data('avia_video_events') != true)
  5334.                 {
  5335.                     currentSlide.data('avia_video_events', true);
  5336.                    
  5337.                     currentSlide.on('av-video-events-bound', { slide: currentSlide, wrap: mejs , iteration: i , self: self }, onReady);
  5338.                    
  5339.                     currentSlide.on('av-video-ended', { slide: currentSlide , self: self}, onFinish);
  5340.                    
  5341.                     currentSlide.on('av-video-play-executed', function(){ setTimeout(function(){  self.pause() }, 100); });
  5342.                        
  5343.                     caption.on('click', { slide: currentSlide }, toggle);
  5344.                    
  5345.                     // also if the player was loaded before the _bindEvents function was bound trigger it manually
  5346.                     if(currentSlide.is('.av-video-events-bound')) currentSlide.trigger('av-video-events-bound');
  5347.                 }
  5348.             });
  5349.            
  5350.            
  5351.             //helper functions
  5352.             function onReady( event )
  5353.             {  
  5354.                 //autostart for first slide
  5355.                 if(event.data.iteration === 0)
  5356.                 {  
  5357.                     event.data.wrap.css('opacity',0);
  5358.                     if(!event.data.self.isMobile && !event.data.slide.data('disableAutoplay')) { event.data.slide.trigger('play'); } 
  5359.                     setTimeout(function(){ event.data.wrap.avia_animate({opacity:1}, 400); }, 50);
  5360.                 }
  5361.                 else if ($html.is('.avia-msie') && !event.data.slide.is('.av-video-service-html5'))
  5362.                 {  
  5363.                     /*
  5364.                     * Internet Explorer fires the ready event for external videos once they become visible
  5365.                     * as oposed to other browsers which always fire immediately.
  5366.                     */
  5367.                     if( !event.data.slide.data('disableAutoplay') ) event.data.slide.trigger('play');
  5368.                 }
  5369.                
  5370.             }
  5371.            
  5372.            
  5373.            
  5374.            
  5375.             function onFinish( event )
  5376.             {  
  5377.                 //if the video is not looped resume the slideshow
  5378.                 if(!event.data.slide.is('.av-single-slide') && !event.data.slide.is('.av-loop-video'))
  5379.                 {
  5380.                     event.data.slide.trigger('reset');
  5381.                     self._navigate( 'next' );  
  5382.                     self.resume();
  5383.                 }
  5384.                
  5385.                 //safari 8 workaround for self hosted videos which wont loop by default
  5386.                 if(event.data.slide.is('.av-loop-video') && event.data.slide.is('.av-video-service-html5'))
  5387.                 {
  5388.                     if($html.is('.avia-safari-8'))
  5389.                     {
  5390.                         setTimeout(function(){ event.data.slide.trigger('play'); },1);
  5391.                     }
  5392.                 }
  5393.             }
  5394.            
  5395.             function toggle( event )
  5396.             {
  5397.                 if(event.target.tagName != "A")
  5398.                 {
  5399.                     event.data.slide.trigger('toggle');
  5400.                 }
  5401.             }
  5402.            
  5403.         },
  5404.        
  5405.        
  5406.        
  5407.         /************************************************************************
  5408.         Slideshow control functions
  5409.         *************************************************************************/
  5410.        
  5411.         _timer: function(callback, delay, first)
  5412.         {  
  5413.             var self = this, start, remaining = delay;
  5414.            
  5415.             self.timerId = 0;
  5416.            
  5417.             this.pause = function() {
  5418.                 window.clearTimeout(self.timerId);
  5419.                 remaining -= new Date() - start;
  5420.             };
  5421.  
  5422.             this.resume = function() {
  5423.                 start = new Date();
  5424.                 self.timerId = window.setTimeout(callback, remaining);
  5425.             };
  5426.  
  5427.             this.destroy = function()
  5428.             {
  5429.                 window.clearTimeout(self.timerId);
  5430.             };
  5431.  
  5432.             this.resume(true);
  5433.         },
  5434.  
  5435.         //start autorotation
  5436.         _startSlideshow: function()
  5437.         {
  5438.             var self = this;
  5439.            
  5440.             this.isPlaying = true;
  5441.            
  5442.             this.slideshow = new this._timer( function()
  5443.             {
  5444.                 /*
  5445.                 var videoApi = self.$slides.eq(self.current).data('aviaVideoApi')
  5446.                 if(!videoApi){}
  5447.                 */
  5448.                
  5449.                 self._navigate( 'next' );
  5450.        
  5451.                 if ( self.options.autoplay )
  5452.                 {
  5453.                     self._startSlideshow();
  5454.                 }
  5455.  
  5456.             }, (this.options.interval * 1000));
  5457.         },
  5458.  
  5459.         //stop autorotation
  5460.         _stopSlideshow: function()
  5461.         {
  5462.             if ( this.options.autoplay ) {
  5463.  
  5464.                 this.slideshow.destroy();
  5465.                 this.isPlaying = false;
  5466.                 this.options.autoplay = false;
  5467.             }
  5468.         },
  5469.  
  5470.         // public method: shows next image
  5471.         next : function(e)
  5472.         {  
  5473.             e.preventDefault();
  5474.             this._stopSlideshow();
  5475.             this._navigate( 'next' );
  5476.         },
  5477.  
  5478.         // public method: shows previous image
  5479.         previous : function(e)
  5480.         {
  5481.             e.preventDefault();
  5482.             this._stopSlideshow();
  5483.             this._navigate( 'prev' );
  5484.         },
  5485.  
  5486.         // public method: goes to a specific image
  5487.         go2 : function( pos )
  5488.         {
  5489.             //if we didnt pass a number directly lets asume someone clicked on a link that triggered the goto transition
  5490.             if(isNaN(pos))
  5491.             {
  5492.                 //in that case prevent the default link behavior and set the slide number to the links hash
  5493.                 pos.preventDefault();
  5494.                 pos = pos.currentTarget.hash.replace('#','');
  5495.             }
  5496.  
  5497.             pos -= 1;
  5498.  
  5499.             if( pos === this.current || pos >= this.itemsCount || pos < 0 )
  5500.             {
  5501.                 return false;
  5502.             }
  5503.  
  5504.             this._stopSlideshow();
  5505.             this._navigate( false, pos );
  5506.  
  5507.         },
  5508.  
  5509.         // public method: starts the slideshow
  5510.         // any call to next(), previous() or goto() will stop the slideshow autoplay
  5511.         play : function()
  5512.         {
  5513.             if( !this.isPlaying )
  5514.             {
  5515.                 this.isPlaying = true;
  5516.  
  5517.                 this._navigate( 'next' );
  5518.                 this.options.autoplay = true;
  5519.                 this._startSlideshow();
  5520.             }
  5521.  
  5522.         },
  5523.  
  5524.         // public methos: pauses the slideshow
  5525.         pause : function()
  5526.         {
  5527.             if( this.isPlaying )
  5528.             {
  5529.                 this.slideshow.pause();
  5530.             }
  5531.         },
  5532.  
  5533.         // publiccmethos: resumes the slideshow
  5534.         resume : function()
  5535.         {
  5536.             if( this.isPlaying )
  5537.             {
  5538.                 this.slideshow.resume();
  5539.             }
  5540.         },
  5541.  
  5542.         // public methos: destroys the instance
  5543.         destroy : function( callback )
  5544.         {
  5545.             this.slideshow.destroy( callback );
  5546.         }
  5547.  
  5548.     }
  5549.  
  5550.     //simple wrapper to call the slideshow. makes sure that the slide data is not applied twice
  5551.     $.fn.aviaSlider = function( options )
  5552.     {
  5553.         return this.each(function()
  5554.         {
  5555.             var self = $.data( this, 'aviaSlider' );
  5556.  
  5557.             if(!self)
  5558.             {
  5559.                 self = $.data( this, 'aviaSlider', new $.AviaSlider( options, this ) );
  5560.             }
  5561.         });
  5562.     }
  5563.  
  5564.  
  5565.  
  5566. })( jQuery );
  5567.  
  5568.  
  5569.  
  5570.  
  5571. // -------------------------------------------------------------------------------------------
  5572. // keyboard controls
  5573. // -------------------------------------------------------------------------------------------
  5574.  
  5575. (function($)
  5576. {
  5577.     "use strict";
  5578.  
  5579.     /************************************************************************
  5580.     keyboard arrow nav
  5581.     *************************************************************************/
  5582.     $.fn.avia_keyboard_controls = function(options_passed)
  5583.     {
  5584.         var defaults    =
  5585.         {
  5586.             37: '.prev-slide',  // prev
  5587.             39: '.next-slide'   // next
  5588.         },
  5589.  
  5590.         methods     = {
  5591.  
  5592.             mousebind: function(slider)
  5593.             {
  5594.                 slider.hover(
  5595.                     function(){  slider.mouseover   = true;  },
  5596.                     function(){  slider.mouseover   = false; }
  5597.                 );
  5598.             },
  5599.  
  5600.             keybind: function(slider)
  5601.             {
  5602.                 $(document).keydown(function(e)
  5603.                 {
  5604.                     if(slider.mouseover && typeof slider.options[e.keyCode] !== 'undefined')
  5605.                     {
  5606.                         var item;
  5607.  
  5608.                         if(typeof slider.options[e.keyCode] === 'string')
  5609.                         {
  5610.                             item = slider.find(slider.options[e.keyCode]);
  5611.                         }
  5612.                         else
  5613.                         {
  5614.                             item = slider.options[e.keyCode];
  5615.                         }
  5616.  
  5617.                         if(item.length)
  5618.                         {
  5619.                             item.trigger('click', ['keypress']);
  5620.                             return false;
  5621.                         }
  5622.                     }
  5623.                 });
  5624.             }
  5625.         };
  5626.  
  5627.  
  5628.         return this.each(function()
  5629.         {
  5630.             var slider          = $(this);
  5631.             slider.options      = $.extend({}, defaults, options_passed);
  5632.             slider.mouseover    = false;
  5633.  
  5634.             methods.mousebind(slider);
  5635.             methods.keybind(slider);
  5636.  
  5637.         });
  5638.     };
  5639.  
  5640.  
  5641.     /************************************************************************
  5642.     swipe nav
  5643.     *************************************************************************/
  5644.     $.fn.avia_swipe_trigger = function(passed_options)
  5645.     {
  5646.         var win     = $(window),
  5647.         isMobile    = $.avia_utilities.isMobile,
  5648.         defaults    =
  5649.         {
  5650.             prev: '.prev-slide',
  5651.             next: '.next-slide',
  5652.             event: {
  5653.                 prev: 'click',
  5654.                 next: 'click'
  5655.             }
  5656.         },
  5657.  
  5658.         methods = {
  5659.  
  5660.             activate_touch_control: function(slider)
  5661.             {
  5662.                 var i, differenceX, differenceY;
  5663.  
  5664.                 slider.touchPos = {};
  5665.                 slider.hasMoved = false;
  5666.  
  5667.                 slider.on('touchstart', function(event)
  5668.                 {
  5669.                     slider.touchPos.X = event.originalEvent.touches[0].clientX;
  5670.                     slider.touchPos.Y = event.originalEvent.touches[0].clientY;
  5671.                 });
  5672.  
  5673.                 slider.on('touchend', function(event)
  5674.                 {
  5675.                     slider.touchPos = {};
  5676.                     if(slider.hasMoved) { event.preventDefault(); }
  5677.                     slider.hasMoved = false;
  5678.                 });
  5679.  
  5680.                 slider.on('touchmove', function(event)
  5681.                 {
  5682.                     if(!slider.touchPos.X)
  5683.                     {
  5684.                         slider.touchPos.X = event.originalEvent.touches[0].clientX;
  5685.                         slider.touchPos.Y = event.originalEvent.touches[0].clientY;
  5686.                     }
  5687.                     else
  5688.                     {
  5689.                         differenceX = event.originalEvent.touches[0].clientX - slider.touchPos.X;
  5690.                         differenceY = event.originalEvent.touches[0].clientY - slider.touchPos.Y;
  5691.  
  5692.                         //check if user is scrolling the window or moving the slider
  5693.                         if(Math.abs(differenceX) > Math.abs(differenceY))
  5694.                         {
  5695.                             event.preventDefault();
  5696.  
  5697.                             if(slider.touchPos !== event.originalEvent.touches[0].clientX)
  5698.                             {
  5699.                                 if(Math.abs(differenceX) > 50)
  5700.                                 {
  5701.                                     i = differenceX > 0 ? 'prev' : 'next';
  5702.  
  5703.                                     if(typeof slider.options[i] === 'string')
  5704.                                     {
  5705.                                         slider.find(slider.options[i]).trigger(slider.options.event[i], ['swipe']);
  5706.                                     }
  5707.                                     else
  5708.                                     {
  5709.                                         slider.options[i].trigger(slider.options.event[i], ['swipe']);
  5710.                                     }
  5711.  
  5712.                                     slider.hasMoved = true;
  5713.                                     slider.touchPos = {};
  5714.                                     return false;
  5715.                                 }
  5716.                             }
  5717.                         }
  5718.                     }
  5719.                 });
  5720.             }
  5721.         };
  5722.  
  5723.         return this.each(function()
  5724.         {
  5725.             if(isMobile)
  5726.             {
  5727.                 var slider  = $(this);
  5728.  
  5729.                 slider.options  = $.extend({}, defaults, passed_options);
  5730.  
  5731.                 methods.activate_touch_control(slider);
  5732.             }
  5733.         });
  5734.     };
  5735.  
  5736.  
  5737.  
  5738.  
  5739.  
  5740.  
  5741.  
  5742.  
  5743.  
  5744.  
  5745.  
  5746.  
  5747.  
  5748. }(jQuery));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement