(function(e,f,q){function z(a){return G.hasOwnProperty(a)?a:"cover"}var t=/^.*(youtu\.be\/|youtube\.com\/v\/|youtube\.com\/embed\/|youtube\.com\/watch\?v=|youtube\.com\/watch\?.*&v=)([^#&\?]*).*/i;e.fn.backstretch=function(a,c){var b=arguments;0===e(f).scrollTop()&&f.scrollTo(0,0);var d;this.each(function(g){var n=e(this),h=n.data("backstretch");if(h){if("string"===typeof b[0]&&"function"===typeof h[b[0]]){n=h[b[0]].apply(h,Array.prototype.slice.call(b,1));n===h&&(n=q);n!==q&&(d=d||[],d[g]=n);return}c=
e.extend(h.options,c);h.hasOwnProperty("destroy")&&h.destroy(!0)}if(!a||a&&0===a.length)(g=n.css("background-image"))&&"none"!==g?a=[{url:n.css("backgroundImage").replace(/url\(|\)|"|'/g,"")}]:e.error("No images were supplied for Backstretch, or element must have a CSS-defined background image.");h=new A(this,a,c||{});n.data("backstretch",h)});return d?1===d.length?d[0]:d:this};e.backstretch=function(a,c){return e("body").backstretch(a,c).data("backstretch")};e.expr[":"].backstretch=function(a){return e(a).data("backstretch")!==
q};e.fn.backstretch.defaults={duration:5E3,transition:"fade",transitionDuration:0,animateFirst:!0,alignX:.5,alignY:.5,paused:!1,start:0,preload:2,preloadSize:1,resolutionRefreshRate:2500,resolutionChangeRatioThreshold:.1};var H={left:0,top:0,overflow:"hidden",margin:0,padding:0,height:"100%",width:"100%",zIndex:-999999},I={position:"absolute",display:"none",margin:0,padding:0,border:"none",width:"100%",height:"100%",zIndex:-999999},J={position:"absolute",margin:0,padding:0,border:"none",width:"100%",
height:"100%",maxWidth:"none"},B=function(){var a=function(a){for(var b=1;b<a.length;b++){for(var c=a[b],d=b;a[d-1]&&parseInt(a[d-1].width,10)>parseInt(c.width,10);)a[d]=a[d-1],--d;a[d]=c}return a},c=function(a,b,c){var d=f.devicePixelRatio||1,e=K();b=b>a?"portrait":a>b?"landscape":"square";for(var g=0,n,m=0,k;m<c.length;m++)if(k=c[m],"string"===typeof k&&(k=c[m]={url:k}),!k.pixelRatio||"auto"===k.pixelRatio||parseFloat(k.pixelRatio)===d)if(!k.deviceOrientation||k.deviceOrientation===e)if(!k.windowOrientation||
k.windowOrientation===e)if(!k.orientation||k.orientation===b)if(g=m,n=a,"auto"===k.pixelRatio&&(a*=d),k.width>=n)break;return c[Math.min(m,g)]},b=function(a,c){if("string"===typeof a)a=a.replace(/{{(width|height)}}/g,c);else if(a instanceof Array)for(var d=0;d<a.length;d++)a[d].src?a[d].src=b(a[d].src,c):a[d]=b(a[d],c);return a};return function(d,g){for(var n=d.width(),h=d.height(),f=[],r=function(a,b){return"width"===b?n:"height"===b?h:a},l=0;l<g.length;l++)if(e.isArray(g[l])){g[l]=a(g[l]);var m=
c(n,h,g[l]);f.push(m)}else"string"===typeof g[l]&&(g[l]={url:g[l]}),m=e.extend({},g[l]),m.url=b(m.url,r),f.push(m);return f}}(),w=function(a){return t.test(a.url)||a.isVideo},C=function(a,c,b,d,g){var f=[],h=function(a){for(var b=0;b<f.length;b++)if(f[b].src===a.src)return f[b];f.push(a);return a};return function y(a,b,c,d,g){if("undefined"!==typeof a){e.isArray(a)||(a=[a]);5>arguments.length&&"function"===typeof arguments[arguments.length-1]&&(g=arguments[arguments.length-1]);b="function"!==typeof b&&
b?b:0;c="function"===typeof c||!c||0>c?a.length:Math.min(c,a.length);d="function"!==typeof d&&d?d:1;b>=a.length&&(c=b=0);0>d&&(d=c);d=Math.min(d,c);var f=a.slice(b+d,c-d);a=a.slice(b,d);if(c=a.length)for(var n=0,l=function(){n++;n===c&&("function"===typeof g&&g.call(a,!f),y(f,0,0,d,g))},k,m=0;m<a.length;m++){if(!w(a[m]))if(k=new Image,k.src=a[m].url,k=h(k),k.complete)l();else e(k).on("load error",l)}else"function"===typeof g&&g.call(a,!0)}}}(),D=function(a){for(var c=[],b=0;b<a.length;b++)"string"===
typeof a[b]?c.push({url:a[b]}):e.isArray(a[b])?c.push(D(a[b])):c.push(E(a[b]));return c},E=function(a,c){if(a.centeredX||a.centeredY)f.console&&f.console.log&&f.console.log("jquery.backstretch: `centeredX`/`centeredY` is deprecated, please use `alignX`/`alignY`"),a.centeredX&&(a.alignX=.5),a.centeredY&&(a.alignY=.5);a.speed!==q&&(f.console&&f.console.log&&f.console.log("jquery.backstretch: `speed` is deprecated, please use `transitionDuration`"),a.transitionDuration=a.speed,a.transition="fade");a.resolutionChangeRatioTreshold!==
q&&(f.console.log("jquery.backstretch: `treshold` is a typo!"),a.resolutionChangeRatioThreshold=a.resolutionChangeRatioTreshold);a.fadeFirst!==q&&(a.animateFirst=a.fadeFirst);a.fade!==q&&(a.transitionDuration=a.fade,a.transition="fade");a.scale&&(a.scale=z(a.scale));"left"===a.alignX?a.alignX=0:"center"===a.alignX?a.alignX=.5:"right"===a.alignX?a.alignX=1:a.alignX!==q&&(a.alignX=parseFloat(a.alignX),isNaN(a.alignX)&&(a.alignX=.5));"top"===a.alignY?a.alignY=0:"center"===a.alignY?a.alignY=.5:"bottom"===
a.alignY?a.alignY=1:a.alignX!==q&&(a.alignY=parseFloat(a.alignY),isNaN(a.alignY)&&(a.alignY=.5));return a},G={cover:"cover",fit:"fit","fit-smaller":"fit-smaller",fill:"fill"},A=function(a,c,b){this.options=e.extend({},e.fn.backstretch.defaults,b||{});this.firstShow=!0;E(this.options,!0);this.images=D(e.isArray(c)?c:[c]);this.options.paused&&(this.paused=!0);this.options.start>=this.images.length&&(this.options.start=this.images.length-1);0>this.options.start&&(this.options.start=0);this.isBody=a===
document.body;c=e(f);this.$container=e(a);this.$root=this.isBody?F?c:e(document):this.$container;this.originalImages=this.images;this.images=B(this.options.alwaysTestWindowResolution?c:this.$root,this.originalImages);C(this.images,this.options.start||0,this.options.preload||1);a=this.$container.children(".backstretch").first();this.$wrap=a.length?a:e('<div class="backstretch"></div>').css(this.options.bypassCss?{}:H).appendTo(this.$container);this.options.bypassCss||(this.isBody||(a=this.$container.css("position"),
b=this.$container.css("zIndex"),this.$container.css({position:"static"===a?"relative":a,zIndex:"auto"===b?0:b}),this.$wrap.css({zIndex:-999998})),this.$wrap.css({position:this.isBody&&F?"fixed":"absolute"}));this.index=this.options.start;this.show(this.index);c.on("resize.backstretch",e.proxy(this.resize,this)).on("orientationchange.backstretch",e.proxy(function(){this.isBody&&0===f.pageYOffset&&(f.scrollTo(0,1),this.resize())},this))},L=function(a){var c=a.transition||"fade";"string"===typeof c&&
-1<c.indexOf("|")&&(c=c.split("|"));c instanceof Array&&(c=c[Math.round(Math.random()*(c.length-1))]);var b=a["new"],d=a.old?a.old:e([]);switch(c.toString().toLowerCase()){default:case "fade":b.fadeIn({duration:a.duration,complete:a.complete,easing:a.easing||q});break;case "fadeinout":case "fade_in_out":c=function(){b.fadeIn({duration:a.duration/2,complete:a.complete,easing:a.easing||q})};d.length?d.fadeOut({duration:a.duration/2,complete:c,easing:a.easing||q}):c();break;case "pushleft":case "push_left":case "pushright":case "push_right":case "pushup":case "push_up":case "pushdown":case "push_down":case "coverleft":case "cover_left":case "coverright":case "cover_right":case "coverup":case "cover_up":case "coverdown":case "cover_down":c=
c.match(/^(cover|push)_?(.*)$/);var g="left"===c[2]?"right":"right"===c[2]?"left":"down"===c[2]?"top":"up"===c[2]?"bottom":"right",f={display:""},h={};f[g]="-100%";h[g]=0;b.css(f).animate(h,{duration:a.duration,complete:function(){b.css(g,"");a.complete.apply(this,arguments)},easing:a.easing||q});"push"===c[1]&&d.length&&(c={},c[g]="100%",d.animate(c,{duration:a.duration,complete:function(){d.css("display","none")},easing:a.easing||q}))}};A.prototype={resize:function(){try{var a=this.options.alwaysTestWindowResolution?
e(f):this.$root,c=a.width(),b=a.height(),d=c/(this._lastResizeContainerWidth||0),g=b/(this._lastResizeContainerHeight||0),n=this.options.resolutionChangeRatioThreshold||0;if((c!==this._lastResizeContainerWidth||b!==this._lastResizeContainerHeight)&&(Math.abs(d-1)>=n||isNaN(d)||Math.abs(g-1)>=n||isNaN(g))&&(this._lastResizeContainerWidth=c,this._lastResizeContainerHeight=b,this.images=B(a,this.originalImages),this.options.preload&&C(this.images,(this.index+1)%this.images.length,this.options.preload),
1===this.images.length&&this._currentImage.url!==this.images[0].url)){var h=this;clearTimeout(h._selectAnotherResolutionTimeout);h._selectAnotherResolutionTimeout=setTimeout(function(){h.show(0)},this.options.resolutionRefreshRate)}var p={left:0,top:0,right:"auto",bottom:"auto"},r=this.isBody?this.$root.width():this.$root.innerWidth(),l=this.isBody?f.innerHeight?f.innerHeight:this.$root.height():this.$root.innerHeight(),m=this.$itemWrapper.data("width"),k=this.$itemWrapper.data("height");a=m/k||1;
var t=this._currentImage.alignX===q?this.options.alignX:this._currentImage.alignX,y=this._currentImage.alignY===q?this.options.alignY:this._currentImage.alignY,x=z(this._currentImage.scale||this.options.scale);if("fit"===x||"fit-smaller"===x){var u=m;var v=k;if(u>r||v>l||"fit-smaller"===x)m=r/l,m>a?(u=Math.floor(l*a),v=l):m<a?(u=r,v=Math.floor(r/a)):(u=r,v=l)}else"fill"===x?(u=r,v=l):(u=Math.max(l*a,r),v=Math.max(u/a,l));p.top=-(v-l)*y;p.left=-(u-r)*t;p.width=u;p.height=v;this.options.bypassCss||
this.$wrap.css({width:r,height:l}).find(">.backstretch-item").not(".deleteable").each(function(){e(this).find("img,video,iframe").css(p)});var w=e.Event("backstretch.resize",{relatedTarget:this.$container[0]});this.$container.trigger(w,this)}catch(M){}return this},show:function(a,c){if(!(Math.abs(a)>this.images.length-1)){var b=this,d=b.$wrap.find(">.backstretch-item").addClass("deleteable"),g=b.videoWrapper,f={relatedTarget:b.$container[0]};b.$container.trigger(e.Event("backstretch.before",f),[b,
a]);this.index=a;var h=b.images[a];clearTimeout(b._cycleTimeout);delete b.videoWrapper;var t=w(h);t?(b.videoWrapper=new p(h),b.$item=b.videoWrapper.$video.css("pointer-events","none")):b.$item=e("<img />");b.$itemWrapper=e('<div class="backstretch-item">').append(b.$item);this.options.bypassCss?b.$itemWrapper.css({display:"none"}):(b.$itemWrapper.css(I),b.$item.css(J));b.$item.bind(t?"canplay":"load",function(h){h=e(this).parent();var l=h.data("options");c&&(l=e.extend({},l,c));var m=this.naturalHeight||
this.videoHeight||this.height;h.data("width",this.naturalWidth||this.videoWidth||this.width).data("height",m);var k=function(a){return l[a]!==q?l[a]:b.options[a]};m=k("transition");var n=k("transitionEasing");k=k("transitionDuration");var p=function(){g&&(g.stop(),g.destroy());d.remove();!b.paused&&1<b.images.length&&b.cycle();b.options.bypassCss||b.isBody||b.$container.css("background-image","none");e(["after","show"]).each(function(){b.$container.trigger(e.Event("backstretch."+this,f),[b,a])});
t&&b.videoWrapper.play()};b.firstShow&&!b.options.animateFirst||!k||!m?(h.show(),p()):L({"new":h,old:d,transition:m,duration:k,easing:n,complete:p});b.firstShow=!1;b.resize()});b.$itemWrapper.appendTo(b.$wrap);b.$item.attr("alt",h.alt||"");b.$itemWrapper.data("options",h);t||b.$item.attr("src",h.url);b._currentImage=h;return b}},current:function(){return this.index},next:function(){var a=Array.prototype.slice.call(arguments,0);a.unshift(this.index<this.images.length-1?this.index+1:0);return this.show.apply(this,
a)},prev:function(){var a=Array.prototype.slice.call(arguments,0);a.unshift(0===this.index?this.images.length-1:this.index-1);return this.show.apply(this,a)},pause:function(){this.paused=!0;this.videoWrapper&&this.videoWrapper.pause();return this},resume:function(){this.paused=!1;this.videoWrapper&&this.videoWrapper.play();this.cycle();return this},cycle:function(){if(1<this.images.length){clearTimeout(this._cycleTimeout);var a=this._currentImage&&this._currentImage.duration||this.options.duration,
c=w(this._currentImage),b=function(){this.$item.off(".cycle");this.paused||this.next()};if(c){if(!this._currentImage.loop){var d=0;this.$item.on("playing.cycle",function(){var a=e(this).data("player");clearTimeout(d);d=setTimeout(function(){a.pause();a.$video.trigger("ended")},1E3*(a.getDuration()-a.getCurrentTime()))}).on("ended.cycle",function(){clearTimeout(d)})}this.$item.on("error.cycle initerror.cycle",e.proxy(b,this))}if(c&&!this._currentImage.duration)this.$item.on("ended.cycle",e.proxy(b,
this));else this._cycleTimeout=setTimeout(e.proxy(b,this),a)}return this},destroy:function(a){e(f).off("resize.backstretch orientationchange.backstretch");this.videoWrapper&&this.videoWrapper.destroy();clearTimeout(this._cycleTimeout);a||this.$wrap.remove();this.$container.removeData("backstretch")}};var p=function(){this.init.apply(this,arguments)};p.prototype.init=function(a){var c=this,b="video";a.url instanceof Array||!t.test(a.url)||(b="youtube");c.type=b;if("youtube"===b){p.loadYoutubeAPI();
c.ytId=a.url.match(t)[2];b="https://www.youtube.com/embed/"+c.ytId+"?rel=0&autoplay=0&showinfo=0&controls=0&modestbranding=1&cc_load_policy=0&disablekb=1&iv_load_policy=3&loop=0&enablejsapi=1&origin="+encodeURIComponent(f.location.origin);c.__ytStartMuted=!!a.mute||a.mute===q;var d=e("<iframe />").attr({src_to_load:b}).css({border:0,margin:0,padding:0}).data("player",c);if(a.loop)d.on("ended.loop",function(){c.__manuallyStopped||c.play()});c.ytReady=!1;c.$video=d;c.video=d[0];if(f.YT)c._initYoutube(),
d.trigger("initsuccess");else e(f).one("youtube_api_load",function(){c._initYoutube();d.trigger("initsuccess")})}else{d=e("<video>").prop("autoplay",!1).prop("controls",!1).prop("loop",!!a.loop).prop("muted",!!a.mute||a.mute===q).prop("preload","auto").prop("poster",a.poster||"");a=a.url instanceof Array?a.url:[a.url];for(b=0;b<a.length;b++){var g=a[b];"string"===typeof g&&(g={src:g});e("<source>").attr("src",g.src).attr("type",g.type||null).appendTo(d)}d[0].canPlayType&&a.length?d.trigger("initsuccess"):
d.trigger("initerror");c.$video=d;c.video=d[0]}};p.prototype._initYoutube=function(){var a=this,c=f.YT;a.$video.attr("src",a.$video.attr("src_to_load")).removeAttr("src_to_load");var b=!!a.$video[0].parentNode;if(!b){var d=e("<div>").css("display","none !important").appendTo(document.body);a.$video.appendTo(d)}var g=new c.Player(a.video,{events:{onReady:function(){a.__ytStartMuted&&g.mute();b||(a.$video[0].parentNode===d[0]&&a.$video.detach(),d.remove());a.ytReady=!0;a._updateYoutubeSize();a.$video.trigger("canplay")},
onStateChange:function(b){switch(b.data){case c.PlayerState.PLAYING:a.$video.trigger("playing");break;case c.PlayerState.ENDED:a.$video.trigger("ended");break;case c.PlayerState.PAUSED:a.$video.trigger("pause");break;case c.PlayerState.BUFFERING:a.$video.trigger("waiting");break;case c.PlayerState.CUED:a.$video.trigger("canplay")}},onPlaybackQualityChange:function(){a._updateYoutubeSize();a.$video.trigger("resize")},onError:function(b){a.hasError=!0;a.$video.trigger({type:"error",error:b})}}});a.ytPlayer=
g;return a};p.prototype._updateYoutubeSize=function(){switch(this.ytPlayer.getPlaybackQuality()||"medium"){case "small":this.video.videoWidth=426;this.video.videoHeight=240;break;case "medium":this.video.videoWidth=640;this.video.videoHeight=360;break;default:case "large":this.video.videoWidth=854;this.video.videoHeight=480;break;case "hd720":this.video.videoWidth=1280;this.video.videoHeight=720;break;case "hd1080":this.video.videoWidth=1920;this.video.videoHeight=1080;break;case "highres":this.video.videoWidth=
2560,this.video.videoHeight=1440}return this};p.prototype.play=function(){this.__manuallyStopped=!1;"youtube"===this.type?this.ytReady&&(this.$video.trigger("play"),this.ytPlayer.playVideo()):this.video.play();return this};p.prototype.pause=function(){this.__manuallyStopped=!1;"youtube"===this.type?this.ytReady&&this.ytPlayer.pauseVideo():this.video.pause();return this};p.prototype.stop=function(){this.__manuallyStopped=!0;"youtube"===this.type?this.ytReady&&(this.ytPlayer.pauseVideo(),this.ytPlayer.seekTo(0)):
(this.video.pause(),this.video.currentTime=0);return this};p.prototype.destroy=function(){this.ytPlayer&&this.ytPlayer.destroy();this.$video.remove();return this};p.prototype.getCurrentTime=function(a){if("youtube"===this.type){if(this.ytReady)return this.ytPlayer.getCurrentTime()}else return this.video.currentTime;return 0};p.prototype.setCurrentTime=function(a){"youtube"===this.type?this.ytReady&&this.ytPlayer.seekTo(a,!0):this.video.currentTime=a;return this};p.prototype.getDuration=function(){if("youtube"===
this.type){if(this.ytReady)return this.ytPlayer.getDuration()}else return this.video.duration;return 0};p.loadYoutubeAPI=function(){if(!f.YT){e("script[src*=www\\.youtube\\.com\\/iframe_api]").length||e('<script type="text/javascript" src="https://www.youtube.com/iframe_api">').appendTo("body");var a=setInterval(function(){f.YT&&f.YT.loaded&&(e(f).trigger("youtube_api_load"),clearTimeout(a))},50)}};var K=function(){if("matchMedia"in f){if(f.matchMedia("(orientation: portrait)").matches)return"portrait";
if(f.matchMedia("(orientation: landscape)").matches)return"landscape"}return screen.height>screen.width?"portrait":"landscape"},F=function(){var a=navigator.userAgent,c=navigator.platform,b=a.match(/AppleWebKit\/([0-9]+)/);b=!!b&&b[1];var d=a.match(/Fennec\/([0-9]+)/);d=!!d&&d[1];var e=a.match(/Opera Mobi\/([0-9]+)/),n=!!e&&e[1],h=a.match(/MSIE ([0-9]+)/);h=!!h&&h[1];return!((-1<c.indexOf("iPhone")||-1<c.indexOf("iPad")||-1<c.indexOf("iPod"))&&b&&534>b||f.operamini&&"[object OperaMini]"==={}.toString.call(f.operamini)||
e&&7458>n||-1<a.indexOf("Android")&&b&&533>b||d&&6>d||"palmGetResource"in f&&b&&534>b||-1<a.indexOf("MeeGo")&&-1<a.indexOf("NokiaBrowser/8.5.0")||h&&6>=h)}()})(jQuery,window);