Guest User

shortcodes.js

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