var cv=cv||{},CV,MetaChapterItem;(function(n,t){var i={RECEIVE:{PLAY:"cv-player-play",PAUSE:"cv-player-pause",SETVOLUME:"cv-player-setvolume",NEXTCHAPTER:"cv-player-nextchapter",PREVCHAPTER:"cv-player-previouschapter",CHANGECHAPTER:"cv-player-changechapter",TOGGLECLIPPING:"cv-player-cliptooltoggle",SETCLIPPOINTS:"cv-player-cliptoolset",CLIP:"cv-player-setclip",CLEARCLIP:"cv-player-clearclip",SEEKTO:"cv-player-seekto",CONTROLS:"cv-player-showcontrols",SUBTITLES:"cv-player-subtitles",SETQUALITY:"cv-player-setquality",QUERY:"cv-player-query",ADDLISTENER:"cv-player-addlistener",REMOVELISTENER:"cv-player-removelistener",PING:"cv-player-ping"},TRIGGER:{PLAY:"cv-player-play",PAUSE:"cv-player-pause",VIDEOEND:"cv-player-ended",VOLCHANGE:"cv-player-volumechange",CHAPTERCHANGE:"cv-player-chapterchange",TIMEUPDATE:"cv-player-timeupdate",FULLSCREENCHANGE:"cv-player-fullscreenchange",CLIPPOINTSUPDATE:"cv-player-cliptoolupdate",QUALITYCHANGE:"cv-player-qualitychange",QUERYCALLBACK:"cv-player-querycallback",SUBTITLESENABLED:"cv-player-hassubtitles",SUBTITLES:"cv-player-subtitles",TIMEUPDATE2:"cv-player-timeupdate2",PONG:"cv-player-pong",LOADEDMETADATA:"cv-player-loadedmetadata"},CVTRIGGER:{FULLSCREENCHANGE:"_cvwp:fsc",DEVICESBTNCLICK:"_cvwp:devices:click"},LISTENABLE:["cv-player-timeupdate2"]},r=function(i){var u=this;return(this instanceof r)?n.parent?(u.eventApi=new CVEventsApi(n.parent),u.player=i,u._setupListeners(),u._setupPlayerListeners(),u.knownHandlers={},u.timeupdateTimeout=-1,u.eventApi.trigger("_cv:evntsapi:ping"),u._listenEvents=[],u._hasMetaChapters=t.param.Video.HasMetaChapters,u):void 0:new r(i)};r.prototype._setupListeners=function(){var n=this;this.eventApi.on(i.RECEIVE.PING,function(){n.eventApi.trigger(i.TRIGGER.PONG)});this.eventApi.on(i.RECEIVE.PLAY,function(){n.player.play()});this.eventApi.on(i.RECEIVE.PAUSE,function(){n.player.pause()});this.eventApi.on(i.RECEIVE.SETVOLUME,function(t,i){n.player.volume(Math.round(i*10)/10)});this.eventApi.on(i.RECEIVE.NEXTCHAPTER,function(){n._hasMetaChapters?n.player.playlist.nextMeta():n.player.playlist.next(!0)});this.eventApi.on(i.RECEIVE.PREVCHAPTER,function(){n._hasMetaChapters?n.player.playlist.prevMeta():n.player.playlist.prev(!0)});this.eventApi.on(i.RECEIVE.CHANGECHAPTER,function(t,i,r){n.changeChapter(i,r,!0)});this.eventApi.on(i.RECEIVE.TOGGLECLIPPING,function(t,i){i?n.player.triggerEvent("clippingtoolstart"):n.player.triggerEvent("clippingtoolstop")});this.eventApi.on(i.RECEIVE.SETCLIPPOINTS,function(t,i){n.player.clipping.setClipPoints(i)});this.eventApi.on(i.RECEIVE.SEEKTO,function(t,i,r){n.player.scrubbing=!!r;r&&typeof n.videoWasPlaying!="boolean"&&(n.videoWasPlaying=!n.player.paused(),n.player.pause());n.seekTo(i);r||(n.videoWasPlaying===!0&&n.player.play(),n.videoWasPlaying=null)});this.eventApi.on(i.RECEIVE.CONTROLS,function(t,i){typeof i!="boolean"&&(i=!0);i?n.player.triggerEvent("cv-showcontrols"):n.player.triggerEvent("cv-hidecontrols")});this.eventApi.on(i.RECEIVE.SUBTITLES,function(t,i){if(i){var r=n.player.textTracks[0];if(!r)return;n.player.showTextTrack(r.id,r.kind);n.player.triggerEvent("enabletextrack")}else n.player.showTextTrack(0,"subtitles"),n.player.triggerEvent("disabletextrack")});this.eventApi.on(i.RECEIVE.SETQUALITY,function(t,i){var u=n.getQualities(),r;(isNaN(+i)||(i=i+"p"),r=_.findWhere(u,{text:i}),r)&&(n.player.playlist.setFormatPlayingAndReload(r.text),n.player.options.currentResolution=r.text,n.player.triggerEvent("changeRes"),CV.Modules.Cookies.Create("quality",r.text.convertToField(),21))});this.eventApi.on(i.RECEIVE.CLIP,function(t,i){var r,u,f,e;if(i){if(r=Math.floor(i.start),u=Math.floor(i.end),isNaN(r)){_V_.log("Clip start required");return}if(isNaN(u)){_V_.log("Clip end required");return}if(u<=r){_V_.log("Clip end must be greater than start");return}if(r<0){_V_.log("Clip start is outside of bounds");return}if(u<0){_V_.log("Clip end is outside of bounds");return}f=i.chapterIndex;e=i.autoPlay;e===!1?n.player.pause():e===!0&&n.player.play();isNaN(+f)?n.player.currentTime(r):n.changeChapter(f,r,!0);n.player.options.startTime=r;n.player.options.endTime=u;n.player.triggerEvent("clipenabled")}});this.eventApi.on(i.RECEIVE.CLEARCLIP,function(){n.player.options.startTime=-1;n.player.options.endTime=-1;n.player.triggerEvent("clipdisabled")});this.eventApi.on(i.RECEIVE.QUERY,function(t,r,u){var f;switch(r){case"getAvailableQualities":f=n.getQualities();break;case"currentQuality":f=n.player.options.currentResolution;break;case"paused":f=n.player.paused();break;case"currentTime":f=n.player.currentTime();break;case"getChapters":f=n._hasMetaChapters?n.getMetaChapters():n.getChapters();break;case"hasMetadataChapters":f=n._hasMetaChapters;break;default:_V_.log("Unknown query '"+r+"'");f=null}n.eventApi.trigger(i.TRIGGER.QUERYCALLBACK+"-"+u,f)});this.eventApi.on(i.RECEIVE.ADDLISTENER,function(t,r){i.LISTENABLE.indexOf(r)!==-1&&n._listenEvents.push(r)});this.eventApi.on(i.RECEIVE.REMOVELISTENER,function(t,i){var r=n._listenEvents.indexOf(i);r!==-1&&n._listenEvents.splice(r,1)});this.eventApi.on("_cv:showfsbtn",function(){t.param.FullScreenButtonVisible&&(n.player.triggerEvent("popoutButtonHide"),n.player.triggerEvent("fsButtonShow"),t.showFs=!0)});this.eventApi.on("_cv:showdevicesbtn",function(){n.player.triggerEvent("devicesbtnshow")});this.eventApi.on("_cv:toggledevicesbtn",function(t,i){i===!0&&n.player.triggerEvent("devicesbtnoff");i===!1&&n.player.triggerEvent("devicesbtnoff")});this.eventApi.on("_cv:evntsapi:on",function(t,i){n.knownHandlers[i.type]?n.knownHandlers[i.type].push(i.guid):n.knownHandlers[i.type]=[i.guid]});this.eventApi.on("_cv:evntsapi:pong",function(t,i){n.knownHandlers=i.hc})};r.prototype.sendTimeUpdate=function(){var u={},e=this.player.currentTime(),n,r,f;this.hasMetaChapters?(n=this.player.playlist.getCurrentMetaChapterIndex(),r=this.player.playlist.getCurrentMetaChapter()):(n=this.player.playlist.getCurrentChapterIndex(),r=t.param.Video.Chapters[n]);r&&(u={duration:this.player.duration(),chapterIndex:n});f=Math.round(e);this.eventApi.trigger(i.TRIGGER.TIMEUPDATE,f,u)};r.prototype._setupPlayerListeners=function(){var n=this,r;this.player.addEvent("play",function(){n.eventApi.trigger(i.TRIGGER.PLAY)});this.player.addEvent("pause",function(){n.eventApi.trigger(i.TRIGGER.PAUSE)});this.player.addEvent("volumechange",function(){n.eventApi.trigger(i.TRIGGER.VOLCHANGE,n.player.volume())});this.player.addEvent("cv-videoended",function(){n.eventApi.trigger(i.TRIGGER.VIDEOEND)});this.player.addEvent("fullscreenchange",function(){n.eventApi.trigger(i.TRIGGER.FULLSCREENCHANGE,n.player.isFullScreen)});this.player.addEvent("changeRes",function(){n.eventApi.trigger(i.TRIGGER.QUALITYCHANGE,n.player.options.currentResolution)});this.player.addEvent("closeCaptionSourceChange",function(){n.eventApi.trigger(i.TRIGGER.SUBTITLESENABLED,!0)});this.player.addEvent("mastercaptionsbtn:show",function(){n.eventApi.trigger(i.TRIGGER.SUBTITLESENABLED,!0)});this.player.addEvent("closeCaptionSourceNullChange",function(){n.eventApi.trigger(i.TRIGGER.SUBTITLESENABLED,!1)});this.player.addEvent("subtitleson",function(){n.eventApi.trigger(i.TRIGGER.SUBTITLES,!0)});this.player.addEvent("subtitlesoff",function(){n.eventApi.trigger(i.TRIGGER.SUBTITLES,!1)});this.player.addEvent("loadedmetadata",function(){n.eventApi.trigger(i.TRIGGER.LOADEDMETADATA)});this.player.addEvent("timeupdate",function(){var t=n.player,i=1-t.currentTime()%1;(t.paused()&&n.sendTimeUpdate(),n.timeupdateTimeout>-1)||(n.timeupdateTimeout=setTimeout(function(){(n.timeupdateTimeout=-1,t.paused())||n.sendTimeUpdate()},Math.ceil(i*1e3)+5))});this.player.addEvent("timeupdate",function(){var t,r,u;n._listenEvents.indexOf(i.TRIGGER.TIMEUPDATE2)!==-1&&(t=n.player.playlist.getCurrentChapterIndex(),r=n.player.currentTime(),n._hasMetaChapters&&(t=n.player.playlist.getCurrentMetaChapterIndex()),u={duration:n.player.duration(),chapterIndex:t},n.eventApi.trigger(i.TRIGGER.TIMEUPDATE2,r,u))});this.player.addEvent("chapIndexChange",function(){var r={},u=n.player.playlist.getCurrentChapterIndex(),f=t.param.Video.Chapters[u];f&&(r=n.formatChapter(f),r.totalChapters=t.param.Video.Chapters.length,r.qualities=n.getQualities());n.eventApi.trigger(i.TRIGGER.CHAPTERCHANGE,r,u)});this.player.addEvent("metachapterchange",function(){var r={},u=n.player.playlist.getCurrentMetaChapter(),f=n.player.playlist.getCurrentMetaChapterIndex();u&&(r=n.formatMetaChapter(u),r.totalChapters=t.param.Video.MetaChapters.length,r.qualities=n.getQualities());n.eventApi.trigger(i.TRIGGER.CHAPTERCHANGE,r,f)});r={start:0,end:0};this.player.addEvent("clipupdate",function(){var u=n.player.clipping.getClipPoints(),f=Math.floor(u.start),e=Math.floor(u.end),o,t;(r.start!==f||r.end!==e)&&(o=n.player.playlist.getCurrentChapterIndex(),t={start:f,end:e,chapterIndex:o,duration:n.player.duration(),currentTime:n.player.currentTime()||0},n.eventApi.trigger(i.TRIGGER.CLIPPOINTSUPDATE,t),r=t)});this.player.addEvent("reqfs",function(){n.eventApi.trigger(i.CVTRIGGER.FULLSCREENCHANGE,!0,!0)});this.player.addEvent("reqfsw",function(){n.eventApi.trigger(i.CVTRIGGER.FULLSCREENCHANGE,!0,!1)});this.player.addEvent("cnfs",function(){n.eventApi.trigger(i.CVTRIGGER.FULLSCREENCHANGE,!1,!0)});this.player.addEvent("cnfsw",function(){n.eventApi.trigger(i.CVTRIGGER.FULLSCREENCHANGE,!1,!1)});this.player.addEvent("devicesbtn:click:on",function(){n.eventApi.trigger(i.CVTRIGGER.DEVICESBTNCLICK,!0)});this.player.addEvent("devicesbtn:click:off",function(){n.eventApi.trigger(i.CVTRIGGER.DEVICESBTNCLICK,!1)})};r.prototype.getQualities=function(){var r=function(n){var t=+n.replace(/p/gi,"");return isNaN(t)?0:t},n,i;return this.player.playlist.isUsingAlternateServer()?(n=r(this.player.options.currentResolution),n===0)?[]:[{text:this.player.options.currentResolution,value:n}]:(i=[],_.each(t.param.Qualities,function(n,t){if(n){var u=t.convertToLabel(),f=r(u);f!==0&&i.push({text:u,value:f})}}),i)};r.prototype.getChapters=function(){var n=this.player.playlist.getCurrentChapterIndex(),i=t.param.Video.Chapters[n];return _.map(t.param.Video.Chapters,function(n){var t=this.formatChapter(n);return t.current=n===i,t},this)};r.prototype.getMetaChapters=function(){var n=this.player.playlist.getCurrentMetaChapter();return _.map(t.param.Video.MetaChapters,function(t){var i=this.formatMetaChapter(t);return i.current=t===n,i},this)};r.prototype.seekTo=function(n){var i=this,r=i.player.duration(),u=function(n){isNaN(n)||(n>=r&&(n-=.1),i.player.currentTime(n))},t,f,e;if(typeof n=="string"||typeof n=="number"){if(!isNaN(+n))return u(+n),!0;if(typeof n=="string"&&(t=n.indexOf("%"),t>=0))return f=n.substring(0,t),e=r*(f/100),u(e),!0}return!1};r.prototype.changeChapter=function(n,t,i){var r=this,u,f;if(typeof n!="number"||isNaN(Number(n)))throw new Error("Invalid index");if(r._hasMetaChapters){if(!r.player.playlist.changeMetaChapter(n,t))throw new Error("Failed to change chapter");}else{if(u=r.player.playlist.chapters.length,n<0||n>=u)throw new Error("Chapter index is outside of bounds");if(r.player.playlist.getCurrentChapterIndex()===n){if(f=r.player.duration(),t>f)throw new Error("Time is outside of bounds");return r.player.currentTime(t),!0}return r.player.playlist.play(n,i,t),!0}};r.prototype.formatChapter=function(n){return{title:n.Title,number:n.Number,duration:n.DurationInSec}};r.prototype.formatMetaChapter=function(n){var i=n.EndTime||this.player.duration()||t.param.Video.Duration;return{title:n.Name,number:n.Number,duration:i-n.StartTime}};t.CVPlayerEventsApi=r})(this,cv,jQuery);cv=cv||{},function(n,t){t.constants={P240_field:"P240",P360_field:"P360",P480_field:"P480",P720_field:"P720",P1080_field:"P1080",P240_label:"240p",P360_label:"360p",P480_label:"480p",P720_label:"720p",P1080_label:"1080p"};var i=function(){if(t.param.PreferredQuality!==0)return"P"+t.param.PreferredQuality;if(CV.Modules.Cookies.Exists("quality")){var n=CV.Modules.Cookies.Value("quality");if(n)return n}return!1};t.getAvailableResolutionLabel=function(){var n=i(),r;if(n!==!1){if(t.hasQuality(n))return t.formatQualityToText(n);if(r=t.getNextBestQuality(n),r!==!1)return t.formatQualityToText(r)}return t.param.Qualities.P480?t.constants.P480_label:t.param.Qualities.P360?t.constants.P360_label:t.param.Qualities.P240?t.constants.P240_label:t.param.Qualities.P720?t.constants.P720_label:t.param.Qualities.P1080?t.constants.P1080_label:void 0};t.getAvailableResolutionField=function(n){var r=n||i(),u;if(r!==!1){if(t.hasQuality(r))return r;if(u=t.getNextBestQuality(r),u!==!1)return u}return t.param.Qualities.P480?t.constants.P480_field:t.param.Qualities.P360?t.constants.P360_field:t.param.Qualities.P240?t.constants.P240_field:t.param.Qualities.P720?t.constants.P720_field:t.param.Qualities.P1080?t.constants.P1080_field:void 0};t.getNextBestQuality=function(n){var r=["P1080","P720","P480","P360","P240",],u=r.indexOf(n),i;if(u>=0)for(i=u+1;i<r.length;i++)if(t.hasQuality(r[i]))return r[i];return!1};t.formatQualityToText=function(n){var t=n.replace("P","");return t+"p"};t.hasQuality=function(n){var i=t.param.Qualities[n];return typeof i=="undefined"?!1:i};String.prototype.endsWith=function(n){return this.indexOf(n,this.length-n.length)!==-1};String.prototype.convertToField=function(){var n=this;return this.endsWith("p")&&(n="P"+this.substring(0,this.length-1)),n.toString()};String.prototype.convertToLabel=function(){var n=this;return this.indexOf("P")===0&&(n=this.substring(1,this.length)+"p"),n.toString()}}(jQuery,cv);cv=cv||{};_V_.PlaylistEngine=_V_.Class.extend({hasMetaChapters:!1,currentMetaChapter:null,_localCacheAddress:null,init:function(n,t){this.useAlternateServer=!1;this.player=n;this.chapters=t;this.currentChapterIndexPlaying=0;this.formatPlaying=cv.getAvailableResolutionField();this.player.addEvent("chapIndexChange",_V_.proxy(this,this.onChapterChange));this.player.addEvent("timeupdate",_V_.proxy(this,this.onTimeUpdate));this.player.addEvent("subtitlestrackchange",_V_.proxy(this,this.onSubsChange))},onTimeUpdate:function(){var u=cv.param.Video,i,r,t,n;if(u.HasMetaChapters){for(i=this.player.currentTime(),r=this.getMetaChapters(),t=0;t<r.length;t++)if((n=r[t],!(i<n.StartTime))&&(n.EndTime==null||!(i>=n.EndTime))){if(this.currentMetaChapter===n)return;this.currentMetaChapter=n;this.player.triggerEvent("metachapterchange");return}this.currentMetaChapter=null;this.player.triggerEvent("metachapterchange")}},setCurrentChapter:function(n){this.chapters.length>=1&&n<=this.chapters.length-1||(n=0,_V_.log("Playlist is empty"));this.currentChapterIndexPlaying=n;this.updateVideoSrc();this.player.triggerEvent("chapIndexChange");this.player.triggerEvent("titleChapterUpdate")},play:function(n,t,i){if(this.chapters.length>=1)n||n===0?(this.currentChapterIndexPlaying=n,this.updateVideo(i,t)):(!t||this.player.paused())&&t||this.player.play();else throw new Error("Playlist is empty");},pause:function(){this.player.pause()},next:function(n){this.currentChapterIndexPlaying<this.chapters.length-1&&(this.incrementCurrentIndex(),this.useAlternateServer&&this.setFormatPlaying(this.getFormatPlaying()),this.updateVideo(!1,n))},prev:function(n){this.currentChapterIndexPlaying>0?(this.decrementCurrentIndex(),this.useAlternateServer&&this.setFormatPlaying(this.getFormatPlaying()),this.updateVideo(!1,n)):this.player.currentTime(0)},getMetaChapters:function(){return cv.param.Video.MetaChapters},nextMeta:function(){if(!cv.param.Video.HasMetaChapters)return!1;var n=this.getCurrentMetaChapterIndex();return(n===-1&&(n=0),this.changeMetaChapter(n+1))?!0:this.changeMetaChapter(0)},prevMeta:function(){if(!cv.param.Video.HasMetaChapters)return!1;var n=this.getCurrentMetaChapterIndex();return(n===-1&&(n=0),this.changeMetaChapter(n-1))?!0:this.changeMetaChapter(0)},changeMetaChapter:function(n,t){if(n===null)return!1;var i;return(i=typeof n=="object"&&typeof n.StartTime=="number"?n:this.getMetaChapter(n),!i)?!1:(typeof t!="number"&&(t=0),this.player.currentTime(i.StartTime+t),!0)},getMetaChapter:function(n){if(!cv.param.Video.HasMetaChapters)return!1;var t=this.getMetaChapters();return t?t[n]:!1},getCurrentMetaChapterIndex:function(){var n=this.currentMetaChapter,t=this.getMetaChapters();return t.indexOf(n)},reload:function(n,t){var i=this,u=!1,r=function(){if(!u){if(i.currentTime){var n=i.player.duration();i.currentTime>n?_V_.log("Time is outside of bounds"):i.player.currentTime(i.currentTime)}i.currentTime=null;u=!0}t!==!1&&i.player.play()};this.player.one("loadedmetadata",function(){r()});this.player.one("loadeddata",function(){r()});this.player.one("canplay",function(){r()});setTimeout(function(){i.player.load()},1)},incrementCurrentIndex:function(){this.currentChapterIndexPlaying++},decrementCurrentIndex:function(){this.currentChapterIndexPlaying--},onChapterChange:function(){this.setCurrentCaptions()},getCurrentChapterTitle:function(){return this.chapters[this.currentChapterIndexPlaying].Title},updateVideo:function(n,t){var i=!0;t&&(i=!this.player.paused());this.updateVideoSrc(n);this.reload(n,i);this.player.triggerEvent("chapIndexChange");this.player.triggerEvent("titleChapterUpdate")},updateVideoSrc:function(n){_.isBoolean(n)?n&&(this.currentTime=this.player.currentTime()):_.isNumber(n)&&(this.currentTime=n);var t=this.getCurrentSource();t&&this.player.src({type:"video/mp4",src:t})},getCurrentSource:function(){var n,t;try{return this.useAlternateServer?this.getAlternateServer():(n=this.chapters[this.currentChapterIndexPlaying][this.formatPlaying],n||(n=_.last(_.filter(_.values(this.chapters[this.currentChapterIndexPlaying][this.formatPlaying]),function(n){return!!n}))),t=new RegExp(/^https?:\/\//),n=n.replace(t,"https://"),this.isUsingLocalCache())?this.getLocalCacheUrl(n):n}catch(i){return""}},reloadChapters:function(){var i=this,n=$.Deferred(),t;return _V_.log("Reloading chapters..."),t="ajax/videos/chapters",t+=cv.param.MasterVideoId?"?vid="+cv.param.MasterVideoId:"?p="+cv.param.Video.TrackingCode,$.ajax({url:t,type:"GET",headers:{requestToken:cv.token}}).done(function(t){i.chapters=t;i.updateVideo(!0,!0);n.resolve()}).fail(function(){n.reject()}),n},setFormatPlayingAndReload:function(n){var t=!this.player.paused();this.formatPlaying=n.convertToField();this.updateVideoSrc(!0);this.reload(!0,t)},setFormatPlayingWithoutPlay:function(n){this.formatPlaying=n.convertToField();this.updateVideoSrc(!0)},setFormatPlaying:function(n){this.formatPlaying=n.convertToField()},getFormatPlaying:function(){return this.formatPlaying},setLocalCacheAddress:function(n){this._localCacheAddress=n},getLocalCacheAddress:function(){return this._localCacheAddress},isUsingLocalCache:function(){return!!this._localCacheAddress},getLanguageSubTag:function(n){if(!n)return null;var t=n.indexOf("-");return t===-1?n:n.substring(0,t)},_currentTrack:null,onSubsChange:function(){var n=this;this._currentTrack=null;_.each(this.player.textTracks,function(t){t.mode===2&&(n._currentTrack=t)})},setCurrentCaptions:function(){var r=this,h=this.chapters[this.currentChapterIndexPlaying],i,n,o,s,f;if(cv.param.Video.HasSubtitles){var e=[],u=h.Subtitles,t={};for(_.each(u,function(n){var i=r.getLanguageSubTag(n.Language);isNaN(t[i])&&(t[i]=0);t[i]++}),i=0;i<u.length;i++)n=u[i],o=r.getLanguageSubTag(n.Language),s=t[o]>1?window.CVLanguages.getFullNativeName(n.Language):window.CVLanguages.getNativeName(n.Language),e.push({kind:"subtitles",label:s||"unknown",srclang:n.Language,src:"/SubTitles/?subtitleUrl="+n.Url});this._currentTrack&&(f=this._currentTrack,this._currentTrack.disable(),this._currentTrack=null);this.player.textTracks=[];this.player.addTextTracks(e);this.player.triggerEvent("updatesubtitles");f&&_.each(this.player.textTracks,function(n){n.language===f.language&&r.player.showTextTrack(n.id,n.kind)})}},_addTextTrack:function(n){this.player.textTracks=[];$(".vjs-text-track").remove();var t="/SubTitles/?subtitleUrl="+n,i=[{src:t,"default":!0}];this.player.addTextTracks(i)},updateVideoPoster:function(){var n="//home.clickview.com.au/chapterimages/CVCH_"+this.chapters[this.currentChapterIndexPlaying].CheckSum+".jpg";n&&(this.player.tag.poster=n)},getLocalCacheUrl:function(n){return this._localCacheAddress+"/cache?file="+encodeURIComponent(n)},getAlternateServer:function(){var n=this.formatPlaying.substring(1);return"http://"+cv.param.Video.AlternativeServer+":9053/Media/CV_"+this.chapters[this.currentChapterIndexPlaying].CheckSum+"_mp4_"+n+".cache"},getCurrentChapterIndex:function(){return this.currentChapterIndexPlaying}});cv=cv||{};_V_.NextButton=_V_.Button.extend({title:"Next Chapter",buildCSSClass:function(){return this._super()+" vjs-cv-next-control"},init:function(n,t){this._super(n,t);this.hide();n.addEvent("nextbtn:show",_V_.proxy(this,this.show));n.addEvent("clipdisabled",_V_.proxy(this,this.updateState));n.addEvent("clipenabled",_V_.proxy(this,this.disable));n.addEvent("chapIndexChange",_V_.proxy(this,this.updateState))},createElement:function(n,t){return t=_V_.merge({className:this.buildCSSClass(),innerHTML:'<div><span class="vjs-control-text">Next Chapter<\/span><\/div>'},t),this._super(n,t)},onClick:function(){this.disabled||this.player.playlist.getCurrentChapterIndex()<this.player.playlist.chapters.length-1&&(this.player.triggerEvent("next:click"),this.player.playlist.engine.next())},updateState:function(){var n=this.player.playlist,t=n.getChapters()||[],i=n.getCurrentChapterIndex()||0;t.length===i+1?this.disable():this.enable()}});_V_.BackButton=_V_.Button.extend({title:"Previous Chapter",buildCSSClass:function(){return this._super()+" vjs-cv-prev-control"},init:function(n,t){this._super(n,t);this.hide();n.addEvent("backbtn:show",_V_.proxy(this,this.show));n.addEvent("clipdisabled",_V_.proxy(this,this.updateState));n.addEvent("clipenabled",_V_.proxy(this,this.disable));n.addEvent("chapIndexChange",_V_.proxy(this,this.updateState))},createElement:function(n,t){return t=_V_.merge({className:this.buildCSSClass(),innerHTML:'<div><span class="vjs-control-text">Previous Chapter<\/span><\/div>'},t),this._super(n,t)},onClick:function(){this.disabled||this.player.playlist.getCurrentChapterIndex()>0&&(this.player.triggerEvent("back:click"),this.player.playlist.engine.prev())},updateState:function(){var n=this.player.playlist,t=n.getCurrentChapterIndex()||0;t===0?this.disable():this.enable()}});cv=cv||{};_V_.MetaNextButton=_V_.Button.extend({title:"Next Chapter",buildCSSClass:function(){return this._super()+" vjs-cv-next-control"},init:function(n,t){this._super(n,t);this.hide();n.addEvent("nextbtn:show",_V_.proxy(this,this.show));n.addEvent("clipdisabled",_V_.proxy(this,this.updateState));n.addEvent("clipenabled",_V_.proxy(this,this.disable));n.addEvent("metachapterchange",_V_.proxy(this,this.updateState))},createElement:function(n,t){return t=_V_.merge({className:this.buildCSSClass(),innerHTML:'<div><span class="vjs-control-text">Next Chapter<\/span><\/div>'},t),this._super(n,t)},onClick:function(){this.disabled||this.player.playlist.nextMetaChapter()},updateState:function(){var t=this.player.playlist.getCurrentMetaChapter(),n=cv.param.Video.MetaChapters,i=n.indexOf(t);i===n.length-1?this.disable():this.enable()}});_V_.MetaBackButton=_V_.Button.extend({title:"Previous Chapter",buildCSSClass:function(){return this._super()+" vjs-cv-prev-control"},init:function(n,t){this._super(n,t);this.hide();n.addEvent("backbtn:show",_V_.proxy(this,this.show));n.addEvent("clipdisabled",_V_.proxy(this,this.updateState));n.addEvent("clipenabled",_V_.proxy(this,this.disable));n.addEvent("metachapterchange",_V_.proxy(this,this.updateState))},createElement:function(n,t){return t=_V_.merge({className:this.buildCSSClass(),innerHTML:'<div><span class="vjs-control-text">Previous Chapter<\/span><\/div>'},t),this._super(n,t)},onClick:function(){this.disabled||this.player.playlist.prevMetaChapter()},updateState:function(){var n=this.player.playlist.getCurrentMetaChapter(),t=cv.param.Video.MetaChapters,i=t.indexOf(n);i===0||n===null?this.disable():this.enable()}});cv=cv||{};_V_.Playlist=_V_.Component.extend({init:function(n,t){this._super(n,t);this.player.playlist=this;this.engine=new _V_.PlaylistEngine(this.player,this.chapters);this.show()},play:function(n,t,i){this.engine.play(n,t,i)},pause:function(){this.player.pause()},next:function(n){this.engine.next(n)},prev:function(n){this.engine.prev(n)},setFormatPlayingAndReload:function(n){this.engine.setFormatPlayingAndReload(n)},setFormatPlayingWithoutPlay:function(n){this.engine.setFormatPlayingWithoutPlay(n)},reload:function(n){this.engine.reload(n)},loadCurrentVideoSrc:function(){this.engine.updateVideoSrc()},setCurrentChapter:function(n){this.engine.setCurrentChapter(n)},setAlternateServer:function(n){this.engine.useAlternateServer=n},setLocalCacheAddress:function(n){this.engine.setLocalCacheAddress(n)},getLocalCacheAddress:function(){return this.engine.getLocalCacheAddress()},isUsingAlternateServer:function(){return this.engine.useAlternateServer},isUsingLocalCache:function(){return this.engine.isUsingLocalCache()},getCurrentChapter:function(){return this.engine.currentChapterIndexPlaying},getCurrentChapterTitle:function(){return this.engine.getCurrentChapterTitle()},getCurrentSource:function(){return this.engine.getCurrentSource()},getCurrentChapterIndex:function(){return this.engine.getCurrentChapterIndex()},getFormatPlaying:function(){return this.engine.getFormatPlaying()},nextMetaChapter:function(){return this.engine.nextMeta()},prevMetaChapter:function(){return this.engine.prevMeta()},changeMetaChapter:function(n){return this.engine.changeMetaChapter(n)},getMetaChapter:function(n){return this.engine.getMetaChapter(n)},getCurrentMetaChapterIndex:function(){return this.engine.getCurrentMetaChapterIndex()},getCurrentMetaChapter:function(){return this.engine.currentMetaChapter},reloadChapters:function(){return this.engine.reloadChapters()},show:function(){this._super()},createElement:function(){var t,n,u,f;this.chapters=this.getChapters();t=this.player.el.id+"_playlist";n=this._super("div",{id:t});this.wrapperEl=this._super("div",{className:"playlist-wrapper"});var e=cv.param.Video.HasMetaChapters,i=_V_.NextButton,r=_V_.BackButton;return e&&(i=_V_.MetaNextButton,r=_V_.MetaBackButton),u=new r(this.player,null),f=new i(this.player,null),this.wrapperEl.appendChild(u.el),this.wrapperEl.appendChild(f.el),n.appendChild(this.wrapperEl),n},getChapters:function(){return cv.param.Video.Chapters}});CV=CV||{};CV.Modules=CV.Modules||{},function(n){n.Cookies=function(){var n=function(n,t,i){var u="",r;i&&(r=new Date,r.setDate(r.getDate()+i),u="; expires="+r.toGMTString());document.cookie=n+"="+escape(t)+u+"; path=/"},t=function(n){for(var r=n+"=",u=document.cookie.split(";"),t,i=0;i<u.length;i++){for(t=u[i];t.charAt(0)==" ";)t=t.substring(1,t.length);if(t.indexOf(r)==0)return t.substring(r.length,t.length)}return null},i=function(t){n(t,null,-1)};return checkExists=function(n){var i=t(n);return i===null||typeof i=="undefined"?!1:!0},{Create:n,Value:t,Clear:i,Exists:checkExists}}()}(CV.Modules=CV.Modules||{});_V_.ResolutionSelector=_V_.Button.extend({kind:"resolution",className:"vjs-cv-quality-control right",init:function(n,t){n.options.currentResolution=cv.getAvailableResolutionLabel();this._super(n,t);this.menu=this.createMenu();this.items.length===0&&this.hide();this.player.addEvent("changeRes",_V_.proxy(this,this.onChangeRes));this.player.addEvent("volumeOpen",_V_.proxy(this,this.onVolumeOpen));this.player.addEvent("chapterListOpen",_V_.proxy(this,this.onChapterListOpen));this.player.addEvent("loadedmetadata",_V_.proxy(this,this.onPlay))},createMenu:function(){var n=new _V_.Menu(this.player);return this.items=this.createItems(),this.each(this.items,function(t){n.addItem(t)}),this.addComponent(n),n},createItems:function(){var n=[],t=cv.param.Qualities;return t.P1080&&n.push(new _V_.ResolutionMenuItem(this.player,{label:cv.constants.P1080_label,cssClass:"hd",text:"1080"})),t.P720&&n.push(new _V_.ResolutionMenuItem(this.player,{label:cv.constants.P720_label,cssClass:"hd",text:"720"})),t.P480&&n.push(new _V_.ResolutionMenuItem(this.player,{label:cv.constants.P480_label,text:"480"})),t.P360&&n.push(new _V_.ResolutionMenuItem(this.player,{label:cv.constants.P360_label,text:"360"})),t.P240&&n.push(new _V_.ResolutionMenuItem(this.player,{label:cv.constants.P240_label,text:"240"})),n},createElement:function(n,t){t=_V_.merge({className:this.buildCSSClass(),innerHTML:'<div><span class="vjs-control-text">Resolution<\/span><\/div>',role:"button",tabIndex:0,title:"Resolution"},t);return this._super(n,t)},createMenuForCurrent:function(){var n=new _V_.Menu(this.player),t=this.player.playlist.getFormatPlaying(),i=new _V_.ResolutionMenuItem(this.player,{label:t.replace(/^\D+/g,"")+"p",selected:!0});return n.addItem(i),this.addComponent(n),n},buildCSSClass:function(){var n="";switch(this.player.options.currentResolution){case cv.constants.P1080_label:n="p1080";break;case cv.constants.P720_label:n="p720";break;case cv.constants.P480_label:n="p480";break;case cv.constants.P360_label:n="p360";break;case cv.constants.P240_label:n="p240"}return this.className+" vjs-cv-menu-button "+this._super()+" "+n},onClick:function(n){if(!$(n.target).is("li")){var t=$(this.menu.el);if(t.is(":visible"))this.menu.unlockShowing();else{this.menu.lockShowing();this.one("mouseleave",this.proxy(function(){this.menu.unlockShowing();this.el.blur()}))}}},onChangeRes:function(){_V_.log("Change Res: "+this.player.options.currentResolution);var n=this.buildCSSClass();this.el.className=n},onVolumeOpen:function(){this.menu.el.style.display="none"},onChapterListOpen:function(){this.menu.el.style.display="none"},onPlay:function(){var t=$(this.el).find(".vjs-menu").last(),i,n;this.player.playlist.isUsingAlternateServer()?(i=this.player.options.currentResolution,n=!1,t.find("li").each(function(){$(this).text()!=i?$(this).hide():(n=!0,$(this).show())}),n||(this.menu=this.createMenuForCurrent())):t.find("li").show()}});_V_.ResolutionMenuItem=_V_.MenuItem.extend({init:function(n,t){t.selected=t.selected||t.label===n.options.currentResolution;this._super(n,t);this.player.addEvent("changeRes",_V_.proxy(this,this.update))},createElement:function(n,t){return this._super("li",_V_.merge({className:"vjs-menu-item "+(this.options.cssClass||""),innerHTML:this.options.label},t))},onClick:function(){this.options.label!==this.player.options.currentResolution&&(this.player.playlist.setFormatPlayingAndReload(this.options.label),this.player.options.currentResolution=this.options.label,this.player.triggerEvent("changeRes"),CV.Modules.Cookies.Create("quality",this.options.label.convertToField(),21))},update:function(){var n=this.options.label===this.player.options.currentResolution;this.selected(n)}});_V_.ResolutionSelectorButton=_V_.ResolutionSelector.extend({buttonText:cv.getAvailableResolutionLabel(),chapter:cv.param.Video.Chapters[cv.param.StartingChapterNumber-1]});cv=cv||{};MetaChapterItem=_V_.Component.extend({_isCurrent:!1,init:function(n,t){this._super(n,t);this.addEvent("click",this.onClick);this.player.addEvent("metachapterchange",_V_.proxy(this,this.onChapterChange,500))},createElement:function(){var n=this.options.chapter,t=_V_.formatTime(n.StartTime);return $(this._super("tr")).html("<td class='vjs-cv-chapter-list-item-index'>Chapter "+n.Number+"<\/td><td class='vjs-cv-chapter-list-item-title'>"+n.Name+"<\/td><td class='vjs-cv-chapter-list-item-time'>"+t+"<\/td>").get(0)},onChapterChange:function(){var n=this.player.playlist.getCurrentMetaChapter();if(n===this.options.chapter){$(this.el).addClass("current");return}$(this.el).removeClass("current")},onClick:function(){var n=this.options.chapter;n&&(this.player.playlist.changeMetaChapter(n),this.player.triggerEvent("metachapter:click"),this.player.triggerEvent("metachapterlist:hide"))}});_V_.MetaChapterList=_V_.Button.extend({hideAgain:null,shown:!1,init:function(n,t){this._super(n,t);this.hide();this.player.addEvent("metachapterlist:hide",_V_.proxy(this,this.hideMe));this.player.addEvent("metachapterlist:show",_V_.proxy(this,this.showMe));this.player.addEvent("panels:hide",_V_.proxy(this,this.hideMe))},createElement:function(){var r=this,n=this._super("div",{className:"vjs-cv-meta-chapter-list vjs-cv-chapter-list vjs-cv-untouched off",innerHTML:""}),t=document.createElement("table"),i=document.createElement("tbody");return _V_.each(cv.param.Video.MetaChapters,function(n){var t=new MetaChapterItem(r.player,{chapter:n});i.appendChild(t.el)}),t.appendChild(i),n.appendChild(t),n},showMe:function(){this.shown||(this.hideAgain=this.player.autoHideControls,this.player.triggerEvent("panels:hide"),this.player.autoHideControls=!1,this.removeClass("off"),this.addClass("on"),this.show(),this.shown=!0,this.player.triggerEvent("metachapterlist:shown"))},hideMe:function(){this.hideAgain!==null&&(this.player.autoHideControls=this.hideAgain);this.addClass("off");this.removeClass("on");this.hide();this.shown=!1;this.player.triggerEvent("metachapterlist:hidden")}});_V_.MetaChapterListButton=_V_.Button.extend({buildCSSClass:function(){return this._super()+" vjs-cv-chapter-list-control right"},init:function(n,t){this._super(n,t);this.hide();n.addEvent("metachapterbtn:show",_V_.proxy(this,this.show));n.addEvent("clipdisabled",_V_.proxy(this,this.enable));n.addEvent("clipenabled",_V_.proxy(this,this.disable));n.addEvent("metachapterlist:shown",_V_.proxy(this,this._listShown));n.addEvent("metachapterlist:hidden",_V_.proxy(this,this._listHidden))},createElement:function(n,t){return t=_V_.merge({className:this.buildCSSClass(),innerHTML:'<div><span class="vjs-control-text">Chapter List<\/span><\/div>',title:"Chapters"},t),this._super(n,t)},_listOpen:!1,_listHidden:function(){this._listOpen=!1},_listShown:function(){this._listOpen=!0},onClick:function(){this.disabled||(this._listOpen?this.player.triggerEvent("metachapterlist:hide"):(this.player.triggerEvent("metachapterlist:show"),this.player.triggerEvent("chapterListOpen")))}});VideoJS.merge(VideoJS.options.components,{MetaChapterList:{}});cv=cv||{};_V_.ChapterList=_V_.Button.extend({hideAgain:null,init:function(n,t){this._super(n,t);this.hide();this.player.addEvent("chapIndexChange",_V_.proxy(this,this.onChapIndexChange));this.player.addEvent("chapterlist:hide",_V_.proxy(this,this.hideMe));this.player.addEvent("chapterlist:show",_V_.proxy(this,this.showMe));this.player.addEvent("panels:hide",_V_.proxy(this,this.hideMe))},createElement:function(){var r=this,n=this._super("div",{className:"vjs-cv-chapter-list",innerHTML:""}),t=document.createElement("table"),i=document.createElement("tbody");return _V_.each(cv.param.Video.Chapters,function(n,t){n.Number=t+1;var u=new _V_.ChapterItem(r.player,n);n.Number==1&&(u.el.className="current");i.appendChild(u.el)}),t.appendChild(i),n.appendChild(t),n},onChapIndexChange:function(){var n=$(this.el.childNodes[0]);n.find("tr.current").removeClass("current");n.find("tr").eq(this.getCurrentChapter()-1).addClass("current")},showMe:function(){this.hideAgain=this.player.autoHideControls;this.player.triggerEvent("panels:hide");this.player.autoHideControls=!1;var n=this.proxy(this.show);n();this.removeClass("off");this.addClass("on");this.show();$(this.player.controlBar.ChapterListButton.el).addClass("on")},hideMe:function(){this.hideAgain!==null&&(this.player.autoHideControls=this.hideAgain);var n=this.proxy(this.hide);this.addClass("off");this.removeClass("on");$(this.player.controlBar.ChapterListButton.el).removeClass("on");n()},getCurrentChapter:function(){return this.player.playlist.getCurrentChapter()+1}});_V_.CloseChapterListButton=_V_.Component.extend({init:function(n,t){this._super(n,t);this.addEvent("click",this.onClick)},createElement:function(){return this._super("a",{className:"vjs-cv-chapter-list-close",innerHTML:"&times "})},onClick:function(){this.player.ChapterList.hideMe()}});_V_.ChapterItem=_V_.Component.extend({init:function(n,t){this._super(n,t);this.addEvent("click",this.onClick)},createElement:function(){var n=_V_.formatTime(this.options.DurationInSec);return $(this._super("tr")).html("<td class='vjs-cv-chapter-list-item-index'>Chapter "+this.options.Number+"<\/td><td class='vjs-cv-chapter-list-item-title'>"+this.options.Title+"<\/td><td class='vjs-cv-chapter-list-item-time'>"+n+"<\/td>").attr("data-index",this.options.Number).get(0)},onClick:function(){var n=this.el.getAttribute("data-index");this.player.triggerEvent("chapter:click");this.player.playlist.play(n-1);this.player.ChapterList.hideMe()}});_V_.ChapterListButton=_V_.Button.extend({buildCSSClass:function(){return this._super()+" vjs-cv-chapter-list-control right"},init:function(n,t){this._super(n,t);this.hide();n.addEvent("chapterbtn:show",_V_.proxy(this,this.show));n.addEvent("clipdisabled",_V_.proxy(this,this.enable));n.addEvent("clipenabled",_V_.proxy(this,this.disable))},createElement:function(n,t){return t=_V_.merge({className:this.buildCSSClass(),innerHTML:'<div><span class="vjs-control-text">Chapter List<\/span><\/div>',title:"Chapters"},t),this._super(n,t)},onClick:function(){this.disabled||($(this.player.ChapterList.el).hasClass("on")?this.player.triggerEvent("chapterlist:hide"):(this.player.triggerEvent("chapterlist:show"),this.player.triggerEvent("chapterListOpen")))}});VideoJS.merge(VideoJS.options.components,{ChapterList:{}});cv=cv||{};_V_.VideoTitle=_V_.Component.extend({player:null,descPxPerChar:0,init:function(n,t){this._super(n,t);this.player=n;n.addEvent("titleChapterUpdate",_V_.proxy(this,this.updateChapter));n.addEvent("metachapterchange",_V_.proxy(this,this.updateMetaChapter));n.addEvent("titleShow",_V_.proxy(this,this.slideVisible));n.addEvent("titleHide",_V_.proxy(this,this.slideHide))},createElement:function(){var n=this._super("div",{className:"vjs-default-skin vjs-cv-video-title",innerHTML:"<div class='title ellipsis'>"+cv.param.Video.Title+"<\/div><div class='desc chapter-number'><\/div><div class='desc chapter ellipsis'><\/div>"});return this.updateChapter(n),n},updateChapter:function(n){var t=cv.param.Video.Chapters.length,i,r;t<=1||(i=this.player.playlist.getCurrentChapterTitle(),r=this.getChapterText(this.player.playlist.getCurrentChapter()+1,t),this.update(n,i,r))},updateMetaChapter:function(n){var i=cv.param.Video.MetaChapters.length,t=this.player.playlist.getCurrentMetaChapter(),r,u;if(!(i<=1)){if(!t){this.clear();return}r=t.Name;u=this.getChapterText(t.Number,i);this.update(n,r,u)}},clear:function(n){this.update(n,"","")},getChapterText:function(n,t){return"("+n+"/"+t+")"},update:function(n,t,i){var r=this.el||n,u=$(r).find(".chapter"),f=$(r).find(".chapter-number");u.html(t);f.html(i)}});VideoJS.merge(VideoJS.options.components,{VideoTitle:{}});_V_.ClosedCaptionButton=_V_.Button.extend({textTractEnabled:!0,buildCSSClass:function(){return this._super()+" vjs-cv-closed-caption-control right"},init:function(n,t){this._super(n,t);this.hide();this.onCloseCaptionSourceNullChange();n.addEvent("captionsbtn:show",_V_.proxy(this,this.setup));this.setOff()},setup:function(){this.player.addEvent("closeCaptionSourceChange",_V_.proxy(this,this.onCloseCaptionSourceChange));this.player.addEvent("closeCaptionSourceNullChange",_V_.proxy(this,this.onCloseCaptionSourceNullChange));this.player.addEvent("enabletextrack",_V_.proxy(this,this.on));this.player.addEvent("disabletextrack",_V_.proxy(this,this.off));this.show()},createElement:function(n,t){return t=_V_.merge({className:this.buildCSSClass(),innerHTML:'<div><span class="vjs-control-text">Closed Captions<\/span><\/div>',title:"Closed Captions"},t),this._super(n,t)},onClick:function(){this.textTractEnabled?this.off():this.on()},setOff:function(){$(this.el).removeClass("on");$(".vjs-text-track").hide();this.textTractEnabled=!1},off:function(){this.disabled||(this.player.triggerEvent("subtitlesoff"),this.setOff())},on:function(){this.disabled||(this.player.triggerEvent("subtitleson"),$(this.el).addClass("on"),$(".vjs-text-track").show(),this.textTractEnabled=!0)},onCloseCaptionSourceChange:function(){$(this.el).removeClass("disabled");this.disabled=!1;this.textTractEnabled?this.on():this.off()},onCloseCaptionSourceNullChange:function(){$(this.el).addClass("disabled");this.disabled=!0}});_V_.MasterClosedCaptionButton=_V_.Button.extend({textTractEnabled:!0,buildCSSClass:function(){return this._super()+" vjs-cv-closed-caption-control right"},init:function(n,t){this._super(n,t);this.hide();this.disable();this.menu=this.createMenu();this.player.addEvent("updatesubtitles",_V_.proxy(this,this.updateMenu));this.player.addEvent("mastercaptionsbtn:show",_V_.proxy(this,this.setup))},setup:function(){this.player.addEvent("subtitlestrackchange",_V_.proxy(this,this.subsChange));this.show()},createMenu:function(){var n=new _V_.Menu(this.player);return n.addItem(new _V_.MasterCaptionOffMenuItem(this.player,{kind:"subtitles","default":!0})),this.addMenuItems(),this.addComponent(n),n},updateMenu:function(){this.destroyItems(this.items);this.addMenuItems()},addMenuItems:function(){this.items=this.createItems();this.each(this.items,function(n){this.menu.addItem(n)});this.items.length>0?this.enable():this.disable()},createItems:function(){var n=[];return this.each(this.player.textTracks,function(t){n.push(new _V_.MasterCaptionMenuItem(this.player,{track:t}))}),n},destroyItems:function(n){this.each(n,function(n){$(n.el).remove();delete n})},createElement:function(n,t){return t=_V_.merge({className:this.buildCSSClass(),innerHTML:'<div><span class="vjs-control-text">Closed Captions<\/span><\/div>',title:"Closed Captions"},t),this._super(n,t)},onClick:function(){if(!this.disabled){this.menu.lockShowing();this.one("mouseleave",this.proxy(function(){this.menu.unlockShowing();this.el.blur()}))}},subsChange:function(){for(var t,n=0;n<this.player.textTracks.length;n++)if(t=this.player.textTracks[n],t.mode===2){this.on();return}this.off()},off:function(){this.disabled||(this.player.triggerEvent("subtitlesoff"),$(this.el).removeClass("on"),this.textTractEnabled=!1)},on:function(){this.disabled||(this.player.triggerEvent("subtitleson"),$(this.el).addClass("on"),this.textTractEnabled=!0,$(".vjs-text-track").show())}});_V_.MasterCaptionMenuItem=_V_.TextTrackMenuItem.extend({onClick:function(){this._super();this.player.triggerEvent("enabletextrack")}});_V_.MasterCaptionOffMenuItem=_V_.OffTextTrackMenuItem.extend({onClick:function(){this._super();this.player.triggerEvent("disabletextrack")}});_V_.SplashScreen=_V_.Button.extend({init:function(n,t){this._super(n,t)},createElement:function(){var n="<div><img src='"+cv.param.SplashScreen.Url+"' /><\/div>";return _V_.createElement("div",{className:"vjs-cv-splash-screen",innerHTML:n,tabIndex:-1})},onClick:function(){this.player.play()}});VideoJS.merge(VideoJS.options.components,{SplashScreen:{}});_V_.CVTimeDisplay=_V_.Button.extend({init:function(n,t){this._super(n,t);n.addEvent("play",_V_.proxy(this,this.onPlay))},onPlay:function(){var t;if(!this._firstLoad){if(this._firstLoad=!0,this.player.duration()){this._durationDisplay.setContent(this.player.duration());return}var i=this.player.playlist.getCurrentChapterIndex(),r=this.player.playlist.getChapters(),n=r[i];if(!n)return;t=n.DurationInSec||0;this._durationDisplay.setContent(t)}},_firstLoad:!1,_durationDisplay:null,createElement:function(){var t=this._super("div",{className:"vjs-control vjs-cv-time-display",innerHTML:""}),n=this._super("div",{className:"",innerHTML:""}),i,r;return t.appendChild(n),i=new _V_.CurrentTimeDisplay(this.player,null),n.appendChild(i.el),r=new _V_.TimeDivider(this.player,null),n.appendChild(r.el),this._durationDisplay=new _V_.DurationDisplay(this.player,{duration:cv.param.Video.Duration}),n.appendChild(this._durationDisplay.el),t}});cv=cv||{};_V_.DevicesButton=_V_.Button.extend({buildCSSClass:function(){return this._super()+" vjs-cv-devices-control right"},init:function(n,t){this._super(n,t);n.addEvent("devicesbtnshow",_V_.proxy(this,this.show));n.addEvent("devicesbtnon",_V_.proxy(this,this.setOn));n.addEvent("devicesbtnoff",_V_.proxy(this,this.setOff));this.hide()},createElement:function(n,t){return t=_V_.merge({className:this.buildCSSClass(),innerHTML:'<div><span class="vjs-control-text">Play on device<\/span><\/div>',title:"Play on device"},t),this._super(n,t)},_on:!1,setOn:function(){this.addClass("on");this._on=!0},setOff:function(){this.removeClass("on");this._on=!1},onClick:function(){this.disabled||(this._on?this.player.triggerEvent("devicesbtn:click:on"):this.player.triggerEvent("devicesbtn:click:off"))}});_V_.CVVolumeControlButton=_V_.Button.extend({kind:"volume",className:"vjs-cv-volume-control right",init:function(n,t){this._super(n,t);this.menu=this.createMenu();this.preVolume=0;n.addEvent("volumechange",_V_.proxy(this,this.update))},createMenu:function(){var n=new _V_.CV_Volume_Menu(this.player);return this.items=this.createItems(),this.each(this.items,function(t){n.addItem(t)}),this.addComponent(n),$(n.el).wrap('<div class="vjs-cv-volume-menu-container" />'),n},createItems:function(){for(var t=[],n=10;n>=1;n--)t.push(new _V_.CVVolumeItem(this.player,{label:"&nbsp;",index:n}));return t},createElement:function(n,t){t=_V_.merge({className:this.buildCSSClass(),innerHTML:'<div><span class="vjs-control-text">Volume Control<\/span><\/div>',role:"button",tabIndex:0,title:"Volume"},t);var i=this._super(n,t),r=this;$(i).on("mouseenter",function(){r.player.triggerEvent("volumeOpen");$(".vjs-cv-volume-menu-container").show()}).on("mouseleave",function(){$(".vjs-cv-volume-menu-container").hide()});return i},buildCSSClass:function(){return this.className+" vjs-cv-volume-button "+this._super()},onClick:function(n){if($(".vjs-cv-volume-menu-container").hide(),$(n.target).is("li")){if(this.player.volumeChoice||this.player.volumeChoice===0){this.player.muted(!1);var t=this.player.volumeChoice/10;this.player.volume(t)}return}this.player.muted()?($(".vjs-cv-volume-menu-container").show(),this.player.muted(!1),this.player.volume(this.preVolume)):(this.preVolume=this.player.volume(),this.player.muted(!0),this.player.volume(0))},update:function(){var t=this.player.volume(),n=3;t==0||this.player.muted()?n=0:t<.33?n=1:t<.67&&(n=2);_V_.each.call(this,[0,1,2,3],function(n){_V_.removeClass(this.el,"vjs-cv-vol-"+n)});_V_.addClass(this.el,"vjs-cv-vol-"+n)}});_V_.CV_Volume_Menu=_V_.Component.extend(function(){var n=null,t=function(t,i){n=t;this._super(t,i)},i=function(n){this.addComponent(n);n.addEvent("click",this.proxy(function(){this.unlockShowing()}))},r=function(){var t=this._super("ul",{className:"vjs-cv-volume-menu"});return $(t).mouseleave(function(){var t=Math.ceil(n.volume()*100);$(".vjs-cv-volume-item").each(function(n,i){var r=$(i),u=r.data("index")*10;u<=t?r.addClass("vjs-cv-volume-item-selected"):r.removeClass("vjs-cv-volume-item-selected")})}),t};return{init:t,addItem:i,createElement:r}}());_V_.CVVolumeItem=_V_.Button.extend({init:function(n,t){this._super(n,t);t.selected&&this.addClass("vjs-cv-volume-item-selected");$(this.el).attr("data-index",t.index);this.addEvent("mouseover",this.proxy(this.onMouseOver));this.player.addEvent("volumechange",this.proxy(this.onVolumeChange))},createElement:function(n,t){var i=this._super("li",_V_.merge({className:"vjs-cv-volume-item",innerHTML:this.options.label},t)),r=this;this.player.one("ready",function(){var n=$(i);r.updateBackGround(n);n.data("index")==0&&(n.addClass("vjs-cv-volume-item-toggle"),n.removeClass("vjs-cv-volume-item"))});return i},onClick:function(n){this.player.volumeChoice=this.currentChoice;var t=$(n.currentTarget);t.data("index")==0&&(this.player.volumeChoice===0?(t.removeClass("vjs-cv-volume-item-toggle"),t.addClass("vjs-cv-volume-item-toggle-mute")):(t.addClass("vjs-cv-volume-item-toggle"),t.removeClass("vjs-cv-volume-item-toggle-mute")))},onMouseOver:function(){this.currentChoice=$(this.el).data("index");this.updateBackGrounds()},onVolumeChange:function(){var n=$(this.el);this.updateBackGround(n)},updateBackGround:function(n){var i=Math.ceil(this.player.volume()*100),t=n.data("index")*10;t<=i&&t!==0?n.addClass("vjs-cv-volume-item-selected"):n.removeClass("vjs-cv-volume-item-selected")},updateBackGrounds:function(){var n=this;$(".vjs-cv-volume-item").each(function(t,i){var r=$(i);r.data("index")<=n.currentChoice?r.addClass("vjs-cv-volume-item-selected"):r.removeClass("vjs-cv-volume-item-selected")})}});cv=cv||{};_V_.ResourceList=_V_.Button.extend({hideAgain:null,init:function(n,t){this._super(n,t);var i=this;this.player.addEvent("panels:hide",_V_.proxy(this,this.hideMe));this.hide()},createElement:function(){var f=this,n=this._super("div",{className:"vjs-cv-resource-list off",innerHTML:""}),t=document.createElement("table"),i=document.createElement("tbody"),e=this.player,r=cv.param.Video.Id,u=!1;return cv.param.MasterVideoId&&(r=cv.param.MasterVideoId,u=!0),this.getResources(r,u,function(n){n&&n.length>0&&e.triggerEvent("VideoHasResources");cv.param.Video.Resources=n;_V_.each(n,function(n){var t=new _V_.ResourceItem(f.player,n);i.appendChild(t.el)})}),t.appendChild(i),n.appendChild(t),n},showMe:function(){this.hideAgain=this.player.autoHideControls;this.player.triggerEvent("panels:hide");this.player.autoHideControls=!1;cv.setResourceListHeight();var n=this.proxy(this.show);n();this.removeClass("off");this.addClass("on");$(this.player.controlBar.ResourceListButton.el).addClass("on");this.show()},hideMe:function(){this.hideAgain!==null&&(this.player.autoHideControls=this.hideAgain);var n=this.proxy(this.hide);this.addClass("off");this.removeClass("on");$(this.player.controlBar.ResourceListButton.el).removeClass("on");n()},getResources:function(n,t,i){var r="/ajax/resources";r+=t?"?vid="+n:"?id="+n;$.ajax({url:r,dataType:"json",success:i,headers:{requestToken:cv.token}})}});_V_.ResourceItem=_V_.Component.extend({init:function(n,t){this._super(n,t);this.addEvent("click",this.onClick)},createElement:function(){return $(this._super("tr")).html("<td class='vjs-cv-resource-list-pad'><\/td><td class='vjs-cv-resource-list-item-title'>"+this.options.Title+"<\/td><td class='vjs-cv-resource-list-item-type'>"+this.options.Type+"<\/td><td class='vjs-cv-resource-list-pad'><\/td>").attr("data-index",this.options.Id).get(0)},onClick:function(){var r=this.el.getAttribute("data-index"),n=$.grep(cv.param.Video.Resources,function(n){return n.Id===r}),i,t;if(n=$(n).get(0),n&&n.Url)if(i=n.Url,n.OpenExternal)window.open(n.Url,"_blank");else{if(t=$("#download-iframe"),t.length===0){t=$('<iframe id="download-iframe" />').hide();$("body").append(t);t.on("load",function(){_V_.log("Failed to download resource")})}t.attr("src",i)}this.player.ResourceList.hideMe()}});_V_.ResourceListButton=_V_.Button.extend({hasResources:!1,buildCSSClass:function(){return this._super()+" vjs-cv-resource-list-control right"},buttonText:"Resources",init:function(n,t){this._super(n,t);this.player.addEvent("VideoHasResources",_V_.proxy(this,this.changeHasResources));this.hasResources||$(this.el).addClass("disabled")},createElement:function(n,t){return t=_V_.merge({className:this.buildCSSClass(),innerHTML:'<div><span class="vjs-control-text">'+this.buttonText+"<\/span><\/div>",title:"Resources"},t),this._super(n,t)},onClick:function(){this.hasResources&&($(this.player.ResourceList.el).hasClass("on")?this.player.ResourceList.hideMe():this.player.ResourceList.showMe())},changeHasResources:function(){$(this.el).removeClass("disabled");this.hasResources=!0}});VideoJS.merge(VideoJS.options.components,{ResourceList:{}});_V_.CacheIndicatorButton=_V_.Button.extend({className:"vjs-cv-indicator",init:function(n,t){this._super(n,t);this._isShowing=!1;this.player.addEvent("ended",_V_.proxy(this,this.onEnded));this.player.addEvent("play",_V_.proxy(this,this.doCheck));this.player.addEvent("loadedmetadata",_V_.proxy(this,this.doCheck));this.player.addEvent("controlsvisible",_V_.proxy(this,this.fadeIn));this.player.addEvent("controlshidden",_V_.proxy(this,this.fadeOut))},createElement:function(n,t){return t=_V_.merge({className:this.className,innerHTML:"<div><\/div>",title:""},t),this._super(n,t)},onEnded:function(){this.hide()},doCheck:function(){this.player.playlist.isUsingAlternateServer()?(this.setAlternateServer(),this._isShowing=!0):this.player.playlist.isUsingLocalCache()?(this.setLocalCache(),this._isShowing=!0):this._isShowing=!1;this._isShowing?this.show():this.hide()},setAlternateServer:function(){this.el.title="Downloaded from the ClickView cache without using your internet connection";this.el.className=this.className+" alternate-server"},setLocalCache:function(){this.el.title="Streamed from your institutes ClickView Local Cache";this.el.className=this.className+" local-cache"},fadeOut:function(){this._isShowing&&$(this.el).fadeTo(600,.3)},fadeIn:function(){this._isShowing&&($(this.el).stop(),$(this.el).fadeTo(300,.7))}}),function(){cv.localCache=function(){var n=function(n){var t=["P720","P480","P360","P240","P1080"],i,r;return n==null?t[0].convertToLabel():(n=n.convertToField(),i=_.indexOf(t,n),i==4)?null:(r=t[i+1],r.substring(1)+"p")};return{getNexFormat:n}}()}(),function(n,t){var i=function(t){var i=n.Deferred(),r={url:t+"/ping",type:"GET",cache:!1,dataType:"text",timeout:1e3};return n.ajax(r).done(function(n){n==="PONG"?i.resolve(t):i.reject()}).fail(function(n,t){_V_.log("Failed to ping Local Cache: "+t);i.reject()}),i.promise()},r=function(t){var r=n.Deferred();if(t==null)return r.reject(),r.promise();var e=function(n,i){r.resolve(n,i,t)},u=0,f=0,o;return i(t.HttpsAddress).done(function(n){f=1;e(n,!0)}).fail(function(){f=-1;u===1?e(o,!1):u===-1&&r.reject()}),i(t.HttpAddress).done(function(n){u=1;o=n;f===-1&&e(n,!1)}).fail(function(){u=-1;f===-1&&r.reject()}),r.promise()},u=function(t){var i=n.Deferred(),u;if(t==null||t.length===0)return i.reject(),i.promise();var f=function(n){for(var t,r=0;r<n.length;r++){if(t=n[r],typeof t=="undefined")return;if(t!=null){i.resolve(t.url,t.isHttps,t.device);return}}i.reject();return},e=function(n,t,i){r(i).done(function(i,r,u){n[t]={url:i,isHttps:r,device:u}}).fail(function(){n[t]=null}).always(function(){f(n)})},o=[];for(u=0;u<t.length;u++)e(o,u,t[u]);return i.promise()};t.localCache2={getAddress:r,getFirstAddress:u}}(window.jQuery,window.cv);_V_.PlayToggleWithReplay=_V_.Button.extend({buttonText:"Play",title:"Play",init:function(n,t){this._super(n,t);n.addEvent("play",_V_.proxy(this,this.onPlay));n.addEvent("pause",_V_.proxy(this,this.onPause));n.addEvent("ended",_V_.proxy(this,this.onEnded));n.addEvent("endseek",_V_.proxy(this,this.onEndSeeking));n.addEvent("clipended",_V_.proxy(this,this.onClipEnded));this.player.addEvent("clipenabled",_V_.proxy(this,this.reload));this.player.addEvent("clipdisabled",_V_.proxy(this,this.reload))},buildCSSClass:function(){return"vjs-play-control "+this._super()},onClick:function(){if(this.isReplay()){this.player.triggerEvent("replay");return}this.player.paused()?this.player.play():this.player.pause()},onPlay:function(){_V_.removeClass(this.el,"vjs-paused");_V_.removeClass(this.el,"vjs-replay");_V_.addClass(this.el,"vjs-playing");this.title="Pause";this.el.title=this.title},onPause:function(){if(this.shouldShowReplay()){this.showReplay();return}_V_.removeClass(this.el,"vjs-playing");_V_.removeClass(this.el,"vjs-replay");_V_.addClass(this.el,"vjs-paused");this.title="Play";this.el.title=this.title},onEnded:function(){this.isEnded()&&this.showReplay()},onClipEnded:function(){this.showReplay()},onEndSeeking:function(){this.player.paused()?this.onPause():this.onPlay()},reload:function(){if(this.isEnded()){this.showReplay();return}if(this.player.paused()){this.onPause();return}this.onPlay()},showReplay:function(){_V_.removeClass(this.el,"vjs-paused");_V_.removeClass(this.el,"vjs-playing");_V_.addClass(this.el,"vjs-replay");this.title="Replay";this.el.title=this.title},isReplay:function(){return this.el?$(this.el).hasClass("vjs-replay"):!1},shouldShowReplay:function(){return this.player.options.endTime&&this.player.options.endTime>0&&this.player.currentTime()>=this.player.options.endTime},isEnded:function(){return this.player.playlist.getChapters().length-1===this.player.playlist.getCurrentChapter()}}),function(n){"use strict";var t=function(){var n=this instanceof t?this:Object.create(t.prototype);return n.url="/ajax/log-event",n};_.extend(t.prototype,{logEvent:function(n){return $.ajax({url:this.url,type:"POST",contentType:"application/json",data:JSON.stringify(n)})},logVideoWatch:function(n,t){t=t||{};var i={video:this._toLogVideo(n.Video),request:this._getClientData(),params:this._getParams(n),flags:t};this.logEvent(i)},_getParams:function(n){return{loop:!!n.Loop,startTime:Number(n.StartTime),autoPlay:!!n.AutoStart,startingChapter:Number(n.StartingChapterNumber)}},_toLogVideo:function(n){return{title:n.Title,trackingCode:n.TrackingCode,alternateServer:n.AlternativeServer,ownerId:n.CustomerId,masterId:n.MasterId,apiCache:n.FromCache}},_getClientData:function(){return{url:this._getTopLocation(),browser:this._getBrowserName(),referrer:this._getReferrer(),userAgent:navigator.userAgent,ScreenSize:this._getScreenSize(),operatingSystem:this._getOSName()}},_getTopLocation:function(){try{if(window.top&&window.top.location)return window.top.location.href}catch(n){}return window.location.href},_getScreenSize:function(){return screen.width+"x"+screen.height},_getBrowserName:function(){var n=navigator.userAgent;return/(msie|trident)/i.test(n)?"Internet Explorer":/opera/i.test(n)||/opr/i.test(n)?"Opera":/chrome/i.test(n)?"Chrome":/phantom/i.test(n)?"Phantom":/touchpad/i.test(n)?"TouchPad":/iphone/i.test(n)?"iPhone":/ipad/i.test(n)?"iPad":/android/i.test(n)?"Android":/safari/i.test(n)?"Safari":/firefox/i.test(n)?"Firefox":"Other"},_getReferrer:function(){return document.referrer},_getOSName:function(){var i=navigator.appVersion,n=navigator.userAgent,t;return/iphone/i.test(n)?"iPhone":/ipad/i.test(n)?"iPad":/android/i.test(n)?"Android":/blackberry/i.test(n)?"BlackBerry":/Mac/i.test(i)?"MacOS":/X11/i.test(i)?"UNIX":/Linux/i.test(i)?"Linux":/Win/i.test(i)?(t="Windows",/nt 5.0/i.test(n)&&(t+=" 2000"),/nt 5.1/i.test(n)&&(t+=" XP"),/nt 6.0/i.test(n)&&(t+=" Vista"),/nt 6.1/i.test(n)&&(t+=" 7"),/nt 6.2/i.test(n)&&(t+=" 8"),t):"Other"}});n.AnalyticsService=new t}(window.cv);_V_.ClipEndScreen=_V_.Component.extend({options:{components:{ClipReplayButton:{},ClipContinueButton:{}}},init:function(n,t){this._super(n,t);this.player.addEvent("play",_V_.proxy(this,this.hide));this.player.addEvent("clipended",_V_.proxy(this,this.show));this.player.addEvent("resize",_V_.proxy(this,this.positionButtons));this.player.addEvent("clipenabled",_V_.proxy(this,this.hide));this.player.addEvent("clipdisabled",_V_.proxy(this,this.hide));this.hide()},show:function(){this._super();this.positionButtons()},positionButtons:function(){var n=$(this.el),t=n.find(".clip-endscreen-container"),u=n.width(),i=n.height(),r=t.height();t.css({top:i/2-r/2+"px"})},createElement:function(){return _V_.createElement("div",{className:"vjs-cv-clip-endscreen",innerHTML:'<div class="mask"><\/div><div class="clip-endscreen-container"><h3>Clip has ended<\/h3><div class="clip-button-container"><\/div><\/div>',tabIndex:-1})},addComponent:function(n,t){var i,r,u;return typeof n=="string"?(t=t||{},r=t.componentClass||_V_.uc(n),i=new _V_[r](this.player||this,t)):i=n,u=$(this.el).find(".clip-button-container"),u.append(i.el),i}});_V_.ClipButton=_V_.Button.extend({createElement:function(){return _V_.createElement("div",{className:"vjs-cv-clip-button "+this.buildCSSClass(),innerHTML:this.buildButton(),tabIndex:-1})},buildCSSClass:function(){return this.cssClass},buildButton:function(){return'<div class="clip-button-icon"><span><\/span><\/div><div class="clip-button-text">'+(this.buttonText||"")+"<\/div><\/div>"}});_V_.ClipReplayButton=_V_.ClipButton.extend({buttonText:"Replay clip",cssClass:"replay-clip",onClick:function(){this.player.triggerEvent("replay")}});_V_.ClipContinueButton=_V_.ClipButton.extend({buttonText:"Continue video",cssClass:"continue",onClick:function(){this.player.options.startTime=-1;this.player.options.endTime=-1;this.player.triggerEvent("clipdisabled");this.player.play()}});VideoJS.merge(VideoJS.options.components,{ClipEndScreen:{}});_V_.ClippingBar=_V_.Component.extend({options:{components:{bar:{componentClass:"ClippingBarBar"},startHandle:{componentClass:"ClipHandle",handleIndex:"start"},endHandle:{componentClass:"ClipHandle",handleIndex:"end"}}},init:function(n,t){n.clipping={options:{minClipTime:3},points:{start:0,end:0},setClipPoints:function(t){if(t){var r=n.duration(),i={start:this.points.start,end:this.points.end};t.start==="now"&&(t.start=n.currentTime());t.end==="now"&&(t.end=n.currentTime());t.start>=0&&i.end>t.start&&(i.start=t.start);t.end>=0&&t.end>i.start&&(t.end+1>r&&r>0&&(t.end=r),i.end=t.end);i.end-i.start>=this.options.minClipTime&&(this.points=i);n.triggerEvent("clipupdate")}},getClipPoints:function(){return this.points}};this._super(n,t);n.addEvent("clippingtoolstart",_V_.proxy(this,this.start));n.addEvent("clippingtoolstop",_V_.proxy(this,this.stop));n.addEvent("chapIndexChange",_V_.proxy(this,this.onChapterChange));window.cv.isMobileDevice()&&(this.startHandle.destroy(),this.endHandle.destroy());this.hide()},createElement:function(){return this._super("div",{className:"vjs-clip-bar",innerHTML:""})},start:function(){this.player.clipping.setClipPoints({start:0,end:this.player.duration()});this.show();this.player.controlBar.showControls(!0);this.player.isClipping=!0},stop:function(){this.player.triggerEvent("clipupdate");this.hide();this.player.controlBar.showControls(!1);this.player.isClipping=!1},onChapterChange:function(){var n=this.player,t=function(t){t&&n.isClipping&&n.clipping.setClipPoints({start:0,end:t})};t(this.player.duration());this.player.one("loadedmetadata",function(){t(n.duration())})}});_V_.ClippingBarBar=_V_.Component.extend({init:function(n,t){this._super(n,t);n.addEvent("clipupdate",_V_.proxy(this,this.onClipUpdate));n.addEvent("loadedmetadata",_V_.proxy(this,this.update))},createElement:function(){return this._super("div",{className:"vjs-clip-fill",innerHTML:""})},onClipUpdate:function(){this.update()},update:function(){var t=this.player.clipping.getClipPoints().start,i=this.player.clipping.getClipPoints().end,n=this.player.duration(),r=t/n,u=(n-i)/n;this.el.style&&(this.el.style.left=_V_.round(r*100,2)+"%",this.el.style.right=_V_.round(u*100,2)+"%")}});_V_.ClipHandle=_V_.Slider.extend({init:function(n,t){this._super(n,t);n.addEvent("clipupdate",_V_.proxy(this,this.onClipUpdate));n.addEvent("loadedmetadata",_V_.proxy(this,this.update))},createElement:function(){var n=[this.options.handleIndex,"vjs-clip-handle"];return this._super("div",{className:n.join(" "),innerHTML:""})},calculateDistance:function(n){var u=this.el.parentNode,t=_V_.findPosX(u),i=u.offsetWidth,e=this,f=e.el.offsetWidth,r;return t=t+f/2,i=i-f,r=n.pageX,n.originalEvent.touches&&(r=n.originalEvent.touches[0].pageX),Math.max(0,Math.min(1,(r-t)/i))},onMouseMove:function(n){var t={};t[this.options.handleIndex]=this.calculateDistance(n)*this.player.duration();this.player.clipping.setClipPoints(t)},update:function(){var t=this.player.clipping.getClipPoints()[this.options.handleIndex],i=this.player.duration(),n=0;i>0&&(n=t/this.player.duration());this.el&&(this.el.style.left=_V_.round(n*100,2)+"%")},onClipUpdate:function(){this.update()}});_V_.ClipIndicator=_V_.Component.extend({options:{components:{startHandle:{componentClass:"ClipIndicatorStartHandle"},endHandle:{componentClass:"ClipIndicatorEndHandle"}}},init:function(n,t){this._super(n,t);this.hide();n.addEvent("chapIndexChange",_V_.proxy(this,this.update));n.addEvent("loadedmetadata",_V_.proxy(this,this.update));n.addEvent("play",_V_.proxy(this,this.update));n.addEvent("clipdisabled",_V_.proxy(this,this.update));n.addEvent("clipenabled",_V_.proxy(this,this.update))},update:function(){cv.isClipped()?this.show():this.hide()},createElement:function(){return this._super("div",{className:"cv-clip-indicators",innerHTML:""})}});_V_.ClipIndicatorHandle=_V_.Component.extend({init:function(n,t){this._super(n,t);n.addEvent("chapIndexChange",_V_.proxy(this,this.update));n.addEvent("loadedmetadata",_V_.proxy(this,this.update));n.addEvent("play",_V_.proxy(this,this.update));n.addEvent("clipenabled",_V_.proxy(this,this.update))},className:"",createElement:function(){return this._super("div",{className:"cv-clip-indicator "+(this.className||""),innerHTML:""})},getPosition:function(){},setPosition:function(){},toPercent:function(n){return _V_.round(n*100,2)+"%"},update:function(){if(!this.canShow()){this.hide();return}var n=this.getPosition();if(!n){this.hide();return}this.setPosition(n);this.show()},canShow:function(){return!1}});_V_.ClipIndicatorStartHandle=_V_.ClipIndicatorHandle.extend({className:"start",getPosition:function(){var n=this.player.options.startTime,t=this.player.duration();return typeof n!="number"||n<1||t<1?-1:n/t},setPosition:function(n){this.el.style.left=this.toPercent(n)},canShow:function(){return!0}});_V_.ClipIndicatorEndHandle=_V_.ClipIndicatorHandle.extend({className:"end",getPosition:function(){var n=this.player.options.endTime,t=this.player.duration();return typeof n!="number"||n<1||t<1?-1:(t-n)/t},setPosition:function(n){this.el.style.right=this.toPercent(n)},canShow:function(){return!0}});cv=cv||{},function(n,t){var i,h=t.param.StartingChapterNumber-1,v=35,c=39,nt,tt,it,rt,ut,ft,r,y,ni=800,p=null,u=!1,e=!1,f=!1,et=null,ot=null,st=!1,ht=function(){var n=document.getElementById(i.id).parentElement.offsetWidth,t=document.getElementById(i.id).parentElement.offsetHeight;i.height(document.getElementById(i.id).parentElement.offsetHeight);i.width(document.getElementById(i.id).parentElement.offsetWidth)},yr=function(){ct()&&(r=n("iframe",parent.document),y=n(parent.document),nt=r.width(),tt=r.height(),it=r.css("top"),rt=r.css("left"),ut=r.css("position"),ft=r.css("z-index"))},ti=function(){var n=y.width(),t=y.height();r.width(n);r.height(t);r.css("top",0);r.css("left",0);r.css("position","absolute");r.css("z-index","999")},ii=function(){r.width(nt);r.height(tt);r.css("top",it);r.css("left",rt);r.css("position",ut);r.css("z-index",ft)},pr=function(){ct()&&(i.isFullScreen?ti():ii())},ri=function(){var t=n(".vjs-fullscreen-control");t.hasClass("disabled")||(i.isFullScreen?(t.removeClass("vjs-cv-fullscreen-off"),t.addClass("vjs-cv-fullscreen-on")):(t.removeClass("vjs-cv-fullscreen-on"),t.addClass("vjs-cv-fullscreen-off")))},ct=function(){return n.browser.msie&&n.browser.version.slice(0,1)==="9"},ui=function(){return!!navigator.userAgent.match(/Trident.*rv 11\./)},o=function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|CriOS|Opera Mini/i.test(navigator.userAgent)},w=function(){var n=i.options.startTime,t=i.options.endTime,u=typeof n=="number"&&n>=0,r=typeof t=="number"&&t>0;return u&&r||r},fi=function(){return!!document.documentElement.requestFullscreen||!!document.documentElement.mozRequestFullScreen||!!document.documentElement.webkitRequestFullScreen||!1},lt=function(){var n=window.location.protocol;return n.indexOf("https")>=0},s=function(){return navigator.platform.indexOf("iPhone")!=-1||navigator.platform.indexOf("iPad")!=-1},wr=function(){var t=n.browser;return t.mozilla},at=function(){t.param.AutoStart?(s()||i.bigPlayButton.hide(),i.playlist.play()):(n(i.bigPlayButton.el).show(),n(".vjs-play-control").addClass("vjs-paused"))},b=function(){var t=n("#cvVideo").height(),i=100;t>=480&&(i=(t-480)*.28+100);n(".vjs-text-track-display").attr("style","font-size: "+i+"%")},vt=function(n){var i=-Math.max(0,(n.height()||t.param.SplashScreen.Height)/2);n.css({"margin-top":i+"px"})},ei=function(n){var t=n.find("div img");vt(t);t.on("load",function(){vt(t)})},l=function(){var u=n("#cvVideo"),t=v||n(".vjs-cv-video-title").outerHeight(),r=c||n(".vjs-controls").outerHeight(),i=n(".vjs-cv-chapter-list"),f=u.height()-(t+r+1);t>0&&r>0?i.height(f):i.height("auto");t>0&&i.css({top:t})},a=function(){var u=n("#cvVideo"),t=v||n(".vjs-cv-video-title").outerHeight(),r=c||n(".vjs-controls").outerHeight(),i=n(".vjs-cv-resource-list"),f=u.height()-(t+r+1);t>0&&r>0?i.height(f):i.height("auto");t>0&&i.css({top:t})},yt=function(n){var t=0,i,r;return n.indexOf("m")>=1&&(i=n.split("m")[0],i.indexOf("s")>=0&&(i=i.split("s")[1]),t+=parseInt(i)*60),n.indexOf("s")>=1&&(r=n.split("s")[0],r.indexOf("m")>=0&&(r=r.split("m")[1]),t+=parseInt(r)),t===0&&(t=parseInt(n)),t},pt=function(n){var t=n.convertToLabel();i.playlist.setFormatPlayingWithoutPlay(t);i.options.currentResolution=t;i.triggerEvent("changeRes")},oi=function(){var c=i.duration(),n=h,l=window.location.href,a=l.indexOf("#"),e,r,o,s,u,f;if(a>-1&&(e=l.substring(a+1),r=e.split(","),e&&r[0].indexOf("/")==-1&&(n=r[0]-1,h=r[0]-1,i.options.startTime=parseFloat(r[1]))),i.playlist.isUsingAlternateServer()&&pt("720p"),i.options.startTime=0,o=yt(t.param.StartTime),o>=0&&(i.options.startTime=Math.floor(o)),s=yt(t.param.EndTime),s>=0&&(u=Math.floor(s),u>i.options.startTime&&(!c||u<c)&&(i.options.endTime=u)),n<0&&(n=0,_V_.log("Bad start chapter index")),w()&&i.triggerEvent("clipenabled"),t.param.Video.HasMetaChapters){if(_V_.log("Meta chapters"),f=i.playlist.getMetaChapter(n),!f){_V_.log("Could not find meta chapter");return}i.options.startTime===-1&&(i.options.startTime=0);i.options.startTime+=f.StartTime;i.options.endTime>0&&(i.options.endTime+=f.StartTime);h=0;n=0}i.playlist.setCurrentChapter(n)},k=function(){if(clearTimeout(t.videoTimoutHandler),i.playlist.isUsingAlternateServer()){if(f&&!u){_V_.log("Alternate server didn't respond in a timely manner.");d();f=!1;return}if(!u){s()&&_V_.log("Please hit play immediately");var n=t.localCache.getNexFormat(p);n?(i.playlist.setFormatPlayingWithoutPlay(n),i.options.currentResolution=n,i.triggerEvent("changeRes"),p=n,s()&&i.play(),o()||wt()):(_V_.log("Alternate server cannot be contacted."),d())}}if(i.playlist.isUsingLocalCache()&&!u){d();f=!1;return}f=!1},d=function(){_V_.log("Resetting back to cloud");var n=ai();n?(i.playlist.setFormatPlayingWithoutPlay(n),i.playlist.setAlternateServer(!1),i.playlist.setLocalCacheAddress(null),i.options.currentResolution=n,i.triggerEvent("changeRes"),i.triggerEvent("resetToCloud"),i.playlist.loadCurrentVideoSrc(),at(),s()&&i.play()):li()},wt=function(){if(!u){var n=ni,i=o();i&&(n=2e3);t.videoTimoutHandler=setTimeout(function(){i&&(f=!0);_V_.log("timeout");k()},n)}},si=function(){},hi=function(){var n=0,t=function(){i.options.startTime<=0||i.currentTime()>=i.options.startTime||(_V_.log("setting currentTime to: "+i.options.startTime),i.currentTime(i.options.startTime),n++,i.currentTime()<=0&&n<10?setTimeout(t,100):st=!0)};i.options.startTime>0&&!st&&i.isReady&&setTimeout(function(){i.duration()>=i.options.startTime&&t()},50)},bt=function(){i.pause();i.controlBar.showControls(!0);i.triggerEvent("clipended")},ci=function(){var n=i.options.endTime,t;n&&(n<=0||i.scrubbing||(t=i.currentTime(),t>=n&&bt()))},li=function(){_V_.log("WMV");window.location.href="http://wmv-webplayer.clickview.com.au/ev.aspx"+window.location.search},ai=function(){return t.getAvailableResolutionLabel()},vi=function(){if(!e){if(t.param.isPopout){e=!0;return}clearTimeout(et);et=setTimeout(function(){var r=i.playlist.isUsingLocalCache(),u={isUsingLocalCache:i.playlist.isUsingAlternateServer(),isUsingLocalCache2:r,tech:i.techName},n;r&&(n=(i.playlist.getLocalCacheAddress()||"").split("://"),n.length>0&&(u.localCacheProtocol=n[0]));t.AnalyticsService.logVideoWatch(t.param,u);e=!0},1e3)}},yi=function(){u=!1},pi=function(){u=!1},wi=function(){u=!1},kt=function(){n(".vjs-controls").hide();n(".vjs-cv-video-title").hide();i.showControls=!1},bi=function(){n(".vjs-controls").show();n(".vjs-cv-video-title").show();i.showControls=!0;i.controlBar.showControls()},ki=function(){n(i.bigPlayButton.el).hide()},di=function(){e||(setTimeout(ot),ot=setTimeout(function(){e||vi()},3e3))},gi=function(){hi();clearTimeout(t.videoTimoutHandler)},nr=function(){u=!0;si();p=null;clearTimeout(t.videoTimoutHandler)},tr=function(n,t){if(_V_.log("Error: "+t),n.srcElement!=null&&rr(n.srcElement.error),(i.playlist.isUsingAlternateServer()||i.playlist.isUsingLocalCache())&&(f||k()),n.srcElement!=null){var r=n.srcElement.error;u&&r&&r.code==r.MEDIA_ERR_NETWORK&&(i.options.startTime=n.srcElement.currentTime,u=!1,ir().done(function(){k()}))}},ir=_.throttle(function(){return i.playlist.reloadChapters()},9e5),rr=function(n){if(n)switch(n.code){case n.MEDIA_ERR_ABORTED:_V_.log("You aborted the video playback.");break;case n.MEDIA_ERR_NETWORK:_V_.log("A network error caused the video download to fail part-way.");break;case n.MEDIA_ERR_DECODE:_V_.log("The video playback was aborted due to a corruption problem or because the video used features your browser did not support.");break;case n.MEDIA_ERR_SRC_NOT_SUPPORTED:_V_.log("The video could not be loaded, either because the server or network failed or because the format is not supported.");break;default:_V_.log("An unknown error occurred.")}else _V_.log("An unknown error occurred.")},ur=function(){var n=window.location.href,t=n.indexOf("#")},fr=function(){ht();a();l();b()},dt=function(){ri();b();a();l()},er=function(n){i.isClipping||(i.bigPlayButton.hide(),setTimeout(function(){if(i.playlist.getChapters().length-1===i.playlist.getCurrentChapter()){if(w()){bt();return}i.loadingSpinner.hide();t.param.Loop||(i.bigPlayButton.show(),i.controlBar.showControls(!0));i.triggerEvent("cv-videoended",n);u=!1;i.playlist.getChapters().length>1&&i.playlist.setCurrentChapter(0);i.playlist.isUsingAlternateServer()&&i.playlist.setFormatPlayingWithoutPlay(i.playlist.getFormatPlaying());!t.param.Loop||i.play()}else u=!1,i.bigPlayButton.hide(),i.playlist.next()},1))},gt=function(){i.one("play",function(){i.controlBar.showControls(!1)})},or=function(){u=!1},sr=function(){h!==i.playlist.getCurrentChapterIndex()&&(i.options.startTime=-1,i.options.endTime=-1,i.triggerEvent("clipdisabled"))},hr=function(){i.currentTime(i.options.startTime||0);i.play()},cr=function(){ci()},lr=function(){i.triggerEvent("panels:hide");i.triggerEvent("updateseekbar")},ar=function(){i.triggerEvent("updateseekbar")},vr=function(){var u;if(i.addEvent("loadedmetadata",nr),t.param.ChromeEnabled||kt(),b(),i.volume(1),o()&&i.addClass("mobile"),_V_.isTouch&&(i.addClass("touch"),o()&&(_V_.log("Mobile touch device detected"),i.volume(1),i.controlBar.CVVolumeControlButton.hide())),!t.param.AutoStart&&(t.param.Poster&&t.param.Poster.length>0&&(i.posterImage.el.src=decodeURIComponent(t.param.Poster),i.posterImage.show()),!1)){i.posterImage.el.src=t.param.Video.Attributes.Image;i.posterImage.show();n(".vjs-controls").hide();n(".vjs-cv-video-title").hide();n(document).on("click",".vjs-poster, .vjs-big-play-button",function(){n(".vjs-controls").show();n(".vjs-cv-video-title").show();i.posterImage.hide();i.bigPlayButton.hide()})}n(".vjs-fullscreen-control").addClass("vjs-cv-fullscreen-off");t.param.FullScreenButtonVisible?(i.addEvent("fsButtonShow",_V_.proxy(this,function(){n(".vjs-fullscreen-control").show()})),(!fi()&&!_V_.isTouch&&window.top!==window.self&&!t.showFs||opener||ui()||t.param.isPopout)&&(n(".vjs-fullscreen-control").hide(),i.triggerEvent("popoutButtonShow"))):n(".vjs-fullscreen-control").hide();t.param.ChapterAndResourceButtonVisible||n(".vjs-cv-resource-list-control").hide();(t.param.Video.Chapters.length>1||t.param.Video.HasMetaChapters)&&(i.triggerEvent("nextbtn:show"),i.triggerEvent("backbtn:show"),t.param.ChapterAndResourceButtonVisible&&(t.param.Video.HasMetaChapters?i.triggerEvent("metachapterbtn:show"):i.triggerEvent("chapterbtn:show")));t.param.Video.HasSubtitles===null?i.triggerEvent("captionsbtn:show"):i.triggerEvent("mastercaptionsbtn:show");t.param.ResourceTabVisible||n(".vjs-cv-resource-list-control").hide();i.addEvent("fullscreenchange",dt);i.addEvent("ended",_.throttle(er,100));i.addEvent("play",ki);i.addEvent("error",_V_.proxy(this,tr));i.addEvent("pause",_V_.proxy(this,ur));i.addEvent("changeRes",_V_.proxy(this,or));i.addEvent("next:click",_V_.proxy(this,yi));i.addEvent("back:click",_V_.proxy(this,pi));i.addEvent("chapter:click",_V_.proxy(this,wi));i.addEvent("canplay",_V_.proxy(this,gi));i.addEvent("timeupdate",_V_.proxy(this,cr));i.addEvent("chapIndexChange",_V_.proxy(this,sr));i.addEvent("replay",_V_.proxy(this,hr));i.addEvent("clipended",_V_.proxy(this,gt));i.addEvent("cv-videoended",_V_.proxy(this,gt));i.addEvent("clipenabled",_V_.proxy(this,lr));i.addEvent("clipdisabled",_V_.proxy(this,ar));i.addEvent("cv-showcontrols",_V_.proxy(this,bi));i.addEvent("cv-hidecontrols",_V_.proxy(this,kt));i.one("play",_V_.proxy(this,di));i&&i.tag&&i.tag.id&&document.getElementById(i.tag.id).addEventListener("webkitendfullscreen",function(){s&&(i.isFullScreen=!1,dt())});i.addEvent("bigPlay:click",_V_.proxy(this,function(){return}));window.onresize=fr;i.triggerEvent("volumechange");v=n(".vjs-cv-video-title").outerHeight();c=n(".vjs-controls").outerHeight();a();l();t.setResourceListHeight=a;t.setChapterListHeight=l;n(".vjs-cv-indicator").css({bottom:c+10});u=n(".vjs-cv-splash-screen");t.param.SplashEnabled?ei(u):u.hide();var r=n.Deferred(),f=function(){var n=lt()?!1:!!t.param.Video.AlternativeServer;i.playlist.setAlternateServer(n)},e=function(){oi();var u=function(){at();i.playlist.isUsingAlternateServer()&&wt()},f=n(".vjs-cv-splash-screen");t.param.SplashEnabled?f.children("div").fadeOut(1e3,"easeInQuart",function(){f.hide();r.done(u)}):r.done(u)};t.param.LocalCacheAddresses&&t.param.LocalCacheAddresses.length>0?t.localCache2.getFirstAddress(t.param.LocalCacheAddresses).done(function(n,r,u){if((r||!lt())&&(_V_.log("Using Local Cache: "+u.Name),i.playlist.setLocalCacheAddress(n),u.PlaybackQuality>0&&(typeof t.param.PreferredQuality!="number"||t.param.PreferredQuality<=0))){var f=t.getAvailableResolutionField("P"+u.PlaybackQuality);_V_.log("Setting quality to "+f+" ("+u.PlaybackQuality+") for Local Cache");pt(f)}}).fail(function(){f()}).always(function(){e();r.resolve()}):(f(),e(),r.resolve())},g;window.cv.isClipped=w;window.cv.isMobileDevice=o;n(document).ready(function(){i=_V_("cvVideo");ht();i.autoHideControls=!0;i.autoplay(!1);(navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/i))&&i.bigPlayButton.hide();n("video").on("contextmenu",function(){return!1});setTimeout(function(){n("video .video-load-error").show()},500);var r=new t.CVPlayerEventsApi(i);window.evApi=r;_V_.log("ClickView WebPlayer v"+t.param.VersionNumber);i.ready(function(){setTimeout(vr,1)})});t.startDebuggy=function(n){g=new debuggy(_V_.players.cvVideo,{logEventObj:n})};t.stopDebuggy=function(){g.stop();delete g}}(jQuery,cv);jQuery.extend(jQuery.easing,{easeInQuart:function(n,t,i,r,u){return r*(t/=u)*t*t*t+i}}),function(n,t){n.debuggy=function(n,i){this.player=n;this._events={};return this.options=t.extend({},{logEventObj:!0},i),this.addEventListeners(),console.log("Debugging started"),this};n.debuggy.prototype.addEventListeners=function(){var n=this;t.each(["loadstart","progress","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","play","pause","ratechange","resize","volumechange"],function(t,i){var r=function(t){n.logEvent(i,t)};n.player.addEvent(i,r);n._events[i]=r})};n.debuggy.prototype.stop=function(){var n=this;t.each(this._events,function(t,i){n.player.removeEvent(t,i);delete n._events[t]});console.log("Debugging stopped")};n.debuggy.prototype.logEvent=function(n,t){this.options.logEventObj?this.log(n,t):this.log(n)};n.debuggy.prototype.log=function(n,t){var i=new Date,r=i.getHours()+":"+i.getMinutes()+":"+i.getSeconds();t?console.log("["+r+"]",n,t):console.log("["+r+"]",n)}}(this,jQuery)