!function(a,b){var c=/^\-?\d*\.?\d*$/,d=/^[\[\{]/,e=function(b,c){var d;a.each(b.settings,function(e){if(d=c.attr("data-"+e),"undefined"!=typeof d){var g=f(d);b.settings[e]="object"==typeof g?a.extend({},b.settings[e],g):g}})},f=function(b){try{return b?"true"===b||("false"===b?!1:"null"===b?null:c.test(b)?+b:d.test(b)?a.parseJSON(b):b):b}catch(e){return b}},g=function(a){var b={xxs:"(max-width: 479px)",xs:"(max-width: 767px) and (min-width: 480px)",sm:"(max-width: 991px) and (min-width: 768px)",md:"(max-width: 1199px) and (min-width: 992px)",lg:"(min-width: 1200px)"};return Modernizr.mq(b[a])},h=function(){var a=["bot","googlebot","crawler","spider","robot","crawling","gtmetrix"].join("|"),b=new RegExp("/"+a+"/");return b.test(navigator.userAgent)},i=function(){return/iPhone/i.test(navigator.userAgent)},j=function(c,d){var f=this,g="https://www.youtube.com/iframe_api",h=function(){i(),e(f,c),j(),k(),l()},i=function(){var b={videoId:"",autoplay:0,mute:1,loop:1,videoQuality:"hd720",playerVars:{controls:0,showinfo:0,rel:0,iv_load_policy:3,enablejsapi:1}};f.settings=a.extend(b,d||{})},j=function(){f.$player=c,f.$flickity=q(),f.videoIdExists=f.settings.videoId.length>0,f.iFrameApiScriptExists=a('script[src="'+g+'"]').length>0,f.isVideoInFlickity=f.$flickity.length>0,f.ytPlayerReady=!1,f.videoStoppedAt=0},k=function(){if(f.videoIdExists&&!f.iFrameApiScriptExists){var b=a("<script></script>");b.attr("src",g),b.insertBefore(a("script:first"))}},l=function(){if(f.videoIdExists){var a=b.onYouTubePlayerAPIReady;b.onYouTubePlayerAPIReady=function(){"function"==typeof a&&a(),m()}}},m=function(){f.videoIdExists&&(f.ytPlayer=new YT.Player(f.$player[0],{videoId:f.settings.videoId,playerVars:f.settings.playerVars,events:{onReady:o,onStateChange:n}}),f.$player=a(f.ytPlayer.getIframe()))},n=function(a){var b=a.target,c=a.data;1===f.settings.loop&&c===YT.PlayerState.ENDED&&b.playVideo()},o=function(c){var d=c.target;d.setPlaybackQuality(f.settings.videoQuality),1===f.settings.mute&&d.mute(),f.ytPlayerReady=!0,a(b).trigger("playerReady.xgx")},p=function(){var c=a(b),d=c.scrollTop(),e=d+c.height(),g=f.$player.offset().top,h=g+f.$player.height();return h>=d&&e>=g},q=function(){var a=f.$player.closest("[data-flickity]");return 0===a.length&&(a=f.$player.closest(".flickity-viewport").parent()),a},r=function(){if(f.isVideoInFlickity){var b=a(f.$flickity.data("flickity").selectedElement);return b.find(f.$player).length>0}return!0};f.checkVideo=function(){if(f.ytPlayerReady){var a=p()&&r()&&1===f.settings.autoplay,b=f.ytPlayer.getPlayerState();return a?b!==YT.PlayerState.PLAYING&&(1===f.ytPlayer.getVideoLoadedFraction()?f.ytPlayer.playVideo():f.ytPlayer.seekTo(f.videoStoppedAt)):(b===YT.PlayerState.PLAYING||b===YT.PlayerState.BUFFERING)&&(1===f.ytPlayer.getVideoLoadedFraction()?f.ytPlayer.pauseVideo():(f.videoStoppedAt=f.ytPlayer.getCurrentTime(),f.ytPlayer.stopVideo())),a}},h()},k=function(c,d){var f=this,h=function(){k(),e(f,c),l(),n(),m()},k=function(){var b={videoPlaceholderSelector:".js-video-placeholder",videoWrapperSelector:".js-video-wrapper",videoPlayerSelector:".js-video-player",playerType:"YT",playerSettings:{},scrollDelay:100,showPlayerDealy:1e3,fadeOutDuration:400,noVideoMobile:!1};f.settings=a.extend(b,d||{})},l=function(){f.$videoElement=c,f.$videoPlaceholder=f.$videoElement.find(f.settings.videoPlaceholderSelector),f.$videoWrapper=f.$videoElement.find(f.settings.videoWrapperSelector),f.$videoPlayer=f.$videoElement.find(f.settings.videoPlayerSelector),f.videoPlayerExists=f.$videoPlayer.length>0},m=function(){f.videoPlayerExists&&(a(document).on("scroll.flickity",o),a(b).on("scroll playerReady.xgx",o))},n=function(){if(f.videoPlayerExists&&q())switch(f.settings.playerType){case"YT":f.playerInstance=new j(f.$videoPlayer,f.settings.playerSettings)}},o=function(){f.videoPlayerExists&&q()&&(clearTimeout(a.data(f,"scrollCheck")),a.data(f,"scrollCheck",setTimeout(function(){f.playerInstance.checkVideo()&&p()},f.settings.scrollDelay)))},p=function(){f.videoPlayerExists&&setTimeout(function(){if(g("xxs")||g("xs")||g("sm"))if(i()){var a=b.innerWidth>0?b.innerWidth:screen.width;a>320&&f.$videoPlaceholder.stop().fadeOut()}else f.$videoPlaceholder.stop().fadeOut();else f.$videoPlaceholder.stop().animate({opacity:0},400)},f.settings.showPlayerDealy)},q=function(){return!((g("xxs")||g("xs")||g("sm"))&&f.settings.noVideoMobile)};h()};a.fn.videoElement=function(b){return this.each(function(){var c=a(this);if(c.data("videoElement"))return c.data("videoElement");var d=new k(c,b);c.data("videoElement",d)})};var l=a(".js-video-element");l.length>0&&!h()&&l.videoElement()}(jQuery,window);