!function(e){"use strict";e.AviaVideoAPI=function(t,i,o){this.videoElement=i,this.$video=e(i),this.$option_container=o?e(o):this.$video,this.load_btn=this.$option_container.find(".av-click-to-play-overlay"),this.video_wrapper=this.$video.parents("ul").eq(0),this.lazy_load=!!this.video_wrapper.hasClass("av-show-video-on-click"),this.isMobile=e.avia_utilities.isMobile,this.fallback=!!this.isMobile&&this.$option_container.is(".av-mobile-fallback-image"),this.fallback||this._init(t)},e.AviaVideoAPI.defaults={loop:!1,mute:!1,controls:!1,events:"play pause mute unmute loop toggle reset unload"},e.AviaVideoAPI.apiFiles={youtube:{loaded:!1,src:"https://www.youtube.com/iframe_api"}},e.AviaVideoAPI.players={},e.AviaVideoAPI.prototype={_init:function(t){this.options=this._setOptions(t),this.type=this._getPlayerType(),this.player=!1,this._bind_player(),this.eventsBound=!1,this.playing=!1,this.$option_container.addClass("av-video-paused"),this.pp=e.avia_utilities.playpause(this.$option_container)},_setOptions:function(t){var i=e.extend(!0,{},e.AviaVideoAPI.defaults,t),o=this.$option_container.data(),n="";for(n in o)!o.hasOwnProperty(n)||"string"!=typeof o[n]&&"number"!=typeof o[n]&&"boolean"!=typeof o[n]||(i[n]=o[n]);return i},_getPlayerType:function(){var e=this.$video.get(0).src||this.$video.data("src");return this.$video.is("video")?"html5":this.$video.is(".av_youtube_frame")?"youtube":-1!=e.indexOf("vimeo.com")?"vimeo":-1!=e.indexOf("youtube.com")?"youtube":void 0},_bind_player:function(){var t=this,i=e("html").hasClass("av-cookies-needs-opt-in")||e("html").hasClass("av-cookies-can-opt-out"),o=!0,n=e("html").hasClass("av-cookies-user-silent-accept"),a="html5"==this.type;!i||n||a||(!document.cookie.match(/aviaCookieConsent/)||e("html").hasClass("av-cookies-session-refused")?o=!1:document.cookie.match(/aviaPrivacyRefuseCookiesHideBar/)&&document.cookie.match(/aviaPrivacyEssentialCookiesEnabled/)?document.cookie.match(/aviaPrivacyVideoEmbedsDisabled/)&&(o=!1):o=!1),o?this.lazy_load&&this.load_btn.length&&"html5"!=this.type?(this.$option_container.addClass("av-video-lazyload"),this.load_btn.on("click",function(){t.load_btn.remove(),t._setPlayer()})):(this.lazy_load=!1,this._setPlayer()):this._use_external_link()},_use_external_link:function(){this.$option_container.addClass("av-video-lazyload"),this.load_btn.on("click",function(t){if(void 0!==t.originalEvent){var i=e(this).parents(".avia-slide-wrap").find("div[data-original_url]").data("original_url");i&&window.open(i,"_blank")}})},_setPlayer:function(){var t=this;switch(this.type){case"html5":this.player=this.$video.data("mediaelementplayer"),this.player||(this.$video.data("mediaelementplayer",e.AviaVideoAPI.players[this.$video.attr("id").replace(/_html5/,"")]),this.player=this.$video.data("mediaelementplayer")),this._playerReady();break;case"vimeo":var i=document.createElement("iframe"),o=e(i);i.onload=function(){t.player=Froogaloop(i),t._playerReady(),t.$option_container.trigger("av-video-loaded")},i.setAttribute("src",this.$video.data("src")),o.insertAfter(this.$video),this.$video.remove(),this.$video=i;break;case"youtube":this._getAPI(this.type),e("body").on("av-youtube-iframe-api-loaded",function(){t._playerReady()})}},_getAPI:function(t){if(!1===e.AviaVideoAPI.apiFiles[t].loaded){e.AviaVideoAPI.apiFiles[t].loaded=!0;var i=document.createElement("script"),o=document.getElementsByTagName("script")[0];i.src=e.AviaVideoAPI.apiFiles[t].src,o.parentNode.insertBefore(i,o)}},_playerReady:function(){var t=this;switch(this.$option_container.on("av-video-loaded",function(){t._bindEvents()}),this.type){case"html5":this.$video.on("av-mediajs-loaded",function(){t.$option_container.trigger("av-video-loaded")}),this.$video.on("av-mediajs-ended",function(){t.$option_container.trigger("av-video-ended")});break;case"vimeo":t.player.addEvent("ready",function(){t.$option_container.trigger("av-video-loaded"),t.player.addEvent("finish",function(){t.$option_container.trigger("av-video-ended")})});break;case"youtube":var i=t.$video.data();t._supports_video()&&(i.html5=1),t.player=new YT.Player(t.$video.attr("id"),{videoId:i.videoid,height:t.$video.attr("height"),width:t.$video.attr("width"),playerVars:i,events:{onReady:function(){t.$option_container.trigger("av-video-loaded")},onError:function(t){e.avia_utilities.log("YOUTUBE ERROR:","error",t)},onStateChange:function(e){if(e.data===YT.PlayerState.ENDED){var i=0!=t.options.loop?"loop":"av-video-ended";t.$option_container.trigger(i)}}}})}setTimeout(function(){1!=t.eventsBound&&void 0!==t.eventsBound&&"youtube"!=t.type&&(e.avia_utilities.log('Fallback Video Trigger "'+t.type+'":',"log",t),t.$option_container.trigger("av-video-loaded"))},2e3)},_bindEvents:function(){if(1!=this.eventsBound&&void 0!==this.eventsBound){var e=this,t="unmute";this.eventsBound=!0,this.$option_container.on(this.options.events,function(t){e.api(t.type)}),e.isMobile||(0!=this.options.mute&&(t="mute"),0!=this.options.loop&&e.api("loop"),e.api(t)),setTimeout(function(){e.$option_container.trigger("av-video-events-bound").addClass("av-video-events-bound")},50)}},_supports_video:function(){return!!document.createElement("video").canPlayType},api:function(e){this.isMobile&&!this.was_started()||-1!==this.options.events.indexOf(e)&&(this.$option_container.trigger("av-video-"+e+"-executed"),"function"==typeof this["_"+this.type+"_"+e]&&this["_"+this.type+"_"+e].call(this),"function"==typeof this["_"+e]&&this["_"+e].call(this))},was_started:function(){if(!this.player)return!1;switch(this.type){case"html5":if(this.player.getCurrentTime()>0)return!0;break;case"vimeo":if(this.player.api("getCurrentTime")>0)return!0;break;case"youtube":if(-1!==this.player.getPlayerState())return!0}return!1},_play:function(){this.playing=!0,this.$option_container.addClass("av-video-playing").removeClass("av-video-paused")},_pause:function(){this.playing=!1,this.$option_container.removeClass("av-video-playing").addClass("av-video-paused")},_loop:function(){this.options.loop=!0},_toggle:function(){var e=1==this.playing?"pause":"play";this.api(e),this.pp.set(e)},_vimeo_play:function(){this.player.api("play")},_vimeo_pause:function(){this.player.api("pause")},_vimeo_mute:function(){this.player.api("setVolume",0)},_vimeo_unmute:function(){this.player.api("setVolume",.7)},_vimeo_loop:function(){},_vimeo_reset:function(){this.player.api("seekTo",0)},_vimeo_unload:function(){this.player.api("unload")},_youtube_play:function(){this.player.playVideo()},_youtube_pause:function(){this.player.pauseVideo()},_youtube_mute:function(){this.player.mute()},_youtube_unmute:function(){this.player.unMute()},_youtube_loop:function(){1==this.playing&&this.player.seekTo(0)},_youtube_reset:function(){this.player.stopVideo()},_youtube_unload:function(){this.player.clearVideo()},_html5_play:function(){this.player&&(this.player.options.pauseOtherPlayers=!1,this.player.play())},_html5_pause:function(){this.player&&this.player.pause()},_html5_mute:function(){this.player&&this.player.setMuted(!0)},_html5_unmute:function(){this.player&&this.player.setVolume(.7)},_html5_loop:function(){this.player&&(this.player.options.loop=!0)},_html5_reset:function(){this.player&&this.player.setCurrentTime(0)},_html5_unload:function(){this._html5_pause(),this._html5_reset()}},e.fn.aviaVideoApi=function(t,i){return this.each(function(){var o=this;i&&(o=e(this).parents(i).get(0));var n=e.data(o,"aviaVideoApi");n||(n=e.data(o,"aviaVideoApi",new e.AviaVideoAPI(t,this,o)))})}}(jQuery),window.onYouTubeIframeAPIReady=function(){jQuery("body").trigger("av-youtube-iframe-api-loaded")};var Froogaloop=function(){function e(t){return new e.fn.init(t)}var t={},i=!1,o=(Array.prototype.slice,"*");function n(e,t,i){if(!i.contentWindow.postMessage)return!1;var n=JSON.stringify({method:e,value:t});i.contentWindow.postMessage(n,o)}function a(e){var n,a;try{a=(n=JSON.parse(e.data)).event||n.method}catch(e){}if("ready"!=a||i||(i=!0),!/^https?:\/\/player.vimeo.com/.test(e.origin))return!1;"*"===o&&(o=e.origin);var s=n.value,r=n.data,l=""===l?null:n.player_id,d=function(e,i){return i&&t[i]&&t[i][e]?t[i][e]:t[e]}(a,l),u=[];return!!d&&(void 0!==s&&u.push(s),r&&u.push(r),l&&u.push(l),u.length>0?d.apply(null,u):d.call())}function s(e,i,o){o?(t[o]||(t[o]={}),t[o][e]=i):t[e]=i}function r(e){return!!(e&&e.constructor&&e.call&&e.apply)}return e.fn=e.prototype={element:null,init:function(e){return"string"==typeof e&&(e=document.getElementById(e)),this.element=e,this},api:function(e,t){if(!this.element||!e)return!1;var i=this.element,o=""!==i.id?i.id:null,a=r(t)?null:t,l=r(t)?t:null;return l&&s(e,l,o),n(e,a,i),this},addEvent:function(e,t){if(!this.element)return!1;var o=this.element,a=""!==o.id?o.id:null;return s(e,t,a),"ready"!=e?n("addEventListener",e,o):"ready"==e&&i&&t.call(null,a),this},removeEvent:function(e){if(!this.element)return!1;var i=this.element,o=function(e,i){if(i&&t[i]){if(!t[i][e])return!1;t[i][e]=null}else{if(!t[e])return!1;t[e]=null}return!0}(e,""!==i.id?i.id:null);"ready"!=e&&o&&n("removeEventListener",e,i)}},e.fn.init.prototype=e.fn,window.addEventListener?window.addEventListener("message",a,!1):window.attachEvent("onmessage",a),window.Froogaloop=window.$f=e}();