(function(b){function a(d,c){this.init(d,c)}a.prototype.init=function(e,d){var c=this;this.data=null;this.settings={videoId:null,debug:(window.location.search.indexOf("debug=1")>-1||window.location.search.indexOf("debug=true")>-1),triggerStart:false,afterInit:function(i,h){},countViews:true,showTitleWithPlaceholder:false};b.extend(this.settings,d);if(this.settings.videoId==null){var g=b(e).data("video-id");var f=parseInt(g,10);if(isNaN(f)){c.debug("no video ID");return false}this.settings.videoId=f}b.ajax({type:"GET",url:"/apps/video/details",data:{v:this.settings.videoId},dataType:"json"}).done(function(h){if(h.success===true){c.debug(h);this.data=h.video;c.insertVideo(b(e),this.data)}else{c.debug("failure on server")}})};a.prototype.debug=function(d){if(this.settings.debug&&window.console){try{window.console.log(d)}catch(c){}}};a.prototype.insertVideo=function(p,v){var r=this;var c='";if(navigator.appVersion.indexOf("MSIE 7.")!=-1){if(v.versions.length>2){var k=v.versions[v.versions.length-2]["url"]}else{var k=v.versions[0]["url"]}p.html('

:( Sorry, you are using an unsupported browser. You can download the video here: download

');return}const z=v.embedCode;if(z&&typeof z==="string"&&z.length>0){try{const g=new DOMParser();const y=g.parseFromString(z,"text/html");const l=y.body.querySelector("iframe");if(l){l.width="100%";l.height="100%";p.html(l);return}window.console.error("No iframe provided in embedCode")}catch(w){window.console.error(w)}}var s;var f=p.height();var o=p.width();var d=(v.isAudio===true);this.aspectRatio=v.versions[0].width/v.versions[0].height;if(!d){s=p.width()/this.aspectRatio}else{s=360}if(s>f){s=f}if(s<150){f=s+100;s="100%"}else{f=s}p.height(f);this.singleVideo=m(v,d,this.settings.showTitleWithPlaceholder);if(d){p.append(c+n(this.singleVideo)+u(v,this.settings.forEditingCaptions)+j)}else{p.append(c+x(this.singleVideo)+u(v,this.settings.forEditingCaptions)+j)}var h={controls:true,height:s,width:o,poster:this.singleVideo.image,plugins:{resolutionSelector:{default_res:"360"}}};var i={controls:h.controls,height:h.height,width:"100%",poster:h.poster,plugins:h.plugins};this.myPlayer=videojs("video_placeholder",i);var q;if(this.settings.showTitleWithPlaceholder){q='
'+this.singleVideo.title+"
"}else{q="
"}b("#video_placeholder").append(q);if(this.settings.triggerStart==true){this.myPlayer.load();this.myPlayer.play()}var t=document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled;this.myPlayer.on("fullscreenchange",function(){if(t){return}var e=$parent.parents();var A=[];if(this.isFullscreen()){e.each(function(B,C){var D=b(C).css("z-index");A[B]=D;if(D!=="auto"){b(C).css("z-index",2147483647)}})}else{e.each(function(C,D){var B=A[C];if(B!=="auto"){b(D).css("z-index",B)}})}});if(r.settings.countViews===true){r._initializeViewCounting(r.myPlayer)}if(b("#go_hd").length>0){r._initializeHDButton(r.myPlayer)}r.settings.afterInit.call(r,v,r.myPlayer);function m(C,D,B){var e={};if(!D){var E=C.placeholders.PH720;if(!E){E=C.placeholders.PH360}if(!E){E=C.placeholders.THUMB}e={image:E,sources:A()}}else{e={image:"/apps/pics/audio_largethumb.png",sources:[{file:C.versions[0].url,label:C.versions[0].height}]}}if(B){e.title=C.title}return e;function A(){var F=new Array();b.each(C.versions,function(H,G){var I={file:G.url,label:G.height};if(G.height==360){I["default"]=true}F.push(I)});return F}}function x(e){var A="";b.each(e.sources,function(B,C){A+='\n'});return A}function n(e){var A="";b.each(e.sources,function(B,C){A+=''});return A}function u(E,C){var D={en:"English",es:"Spanish",fr:"French"};var B="English";var A="en";if(E.audioLanguage){var F=E.audioLanguage.substring(0,E.audioLanguage.indexOf("-"));B=D[F];A=F}var e="";e+='\n';return e}window.edlioVjsPlayer=this.myPlayer;this.myPlayer.ready(function(){window.dispatchEvent(new Event("edlio.video.ready"))})};a.prototype._initializeViewCounting=function(f){var h=this;var g=0,c=30,d=false,e=true;f.refreshIntervalId=setInterval(function(){if(!e&&!d&&!f.paused()){var i=f.duration();if(i>0&&(0.65*i)c){h.incrementCount();d=true}h.debug("view count check "+g)}},1000);f.on("firstplay",function(){e=false})};a.prototype._initializeHDButton=function(d){var g=this;if(d.getResolutionsCount()<2){return}var c=true;d.on("firstplay",function(){if(c){if(b("#go_hd").length>0){if(d.getCurrentRes()==d.getHighestRes()){f()}b("#go_hd").show()}c=false}});d.on("changeRes",function(){if(d.getCurrentRes()==d.getHighestRes()){f()}else{e()}});b("#go_hd").on("click",function(h){d.trigger("changeToHd");h.preventDefault();if(b(this).hasClass("in-hd-mode")){if(d.hasDefaultRes()){d.trigger("changeToDefaultRes")}else{d.trigger("changeToLowestRes")}e()}else{d.trigger("changeToHighestRes");f()}});function f(){b("#go_hd").addClass("in-hd-mode");b("#go_hd").html("Go to standard definition")}function e(){b("#go_hd").html('Go ');b("#go_hd").removeClass("in-hd-mode")}};a.prototype.incrementCount=function(){var c=this;b.ajax({type:"POST",url:"/apps/video/increment",data:{v:this.settings.videoId},dataType:"json"}).done(function(d){if(d.success!==true){c.debug("Something went wrong incrementing")}})};a.prototype.changeDimensions=function(f,e){var d=b(f);var c=e.height;if(!c||isNaN(parseInt(c,10))){c=e.width/this.aspectRatio}d.height(c);this.myPlayer.height(c)};a.prototype.getCurrentVideoData=function(c){return this.data};b.fn.videoInitialize=function(c,d){return this.each(function(){var e=this;if(typeof c==="string"){var g=b.data(this,"videoInitialize");var f=g[c];if(c.charAt(0)!=="_"&&typeof f==="function"){f.call(g,this,d)}}else{b.data(this,"videoInitialize",new a(this,c))}})}})((typeof jq18=="function")?jq18:jQuery);