Advertisement
Guest User

shortcodes.js

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