var updateQueryStringParam=function(n,t){var o=[location.protocol,"//",location.host,location.pathname].join(""),r=document.location.search,u=n+"="+t,i="?"+u,f,e;r&&(f=new RegExp("([?&])"+n+"[^&]*"),e=new RegExp("([?&])"+n+"=[^&;]+[&;]?"),typeof t=="undefined"||t==null||t==""?(i=r.replace(e,"$1"),i=i.replace(/[&;]$/,"")):i=r.match(f)!==null?r.replace(f,"$1"+u):r+"&"+u);i=i=="?"?"":i;window.history.replaceState({},"",o+i)},muteHandler=function(){var t=$("#wvInlineVideoContainer").find("iframe").attr("id"),n=YT.get(t);n&&(n.unMute(),$(".video-controls-display").css("display","none"))},InlineVideo=function(n){var t=this;t.element=n;t.player=null;t.isSinglePlayer=!1;t.isMediaCapable=!1;t.playerInteraction=!1;t.done=!1;t.playerHasStarted=!1;t.isPaused=!1;t.isFirstRun=!0;t.mediaPlayerName="YouTubePlayer";t.videoPlayedPage="";t.mediaName="";t.firstPlay=!1;t.milestones=[];t.hasEnded=!1;t.videoPlayerInterval=null;t.updateSeoVideoParam=function(n,t,i,r,u,f){var s,e,h,o;$("#seoVideoDatablock").length>0&&(s=$("#seoVideoDatablock").html(),e=JSON.parse(s),e.name=n,h=new RegExp("(\r\n|\r|\n)+"),e.description=t.replace(h,"").trim(),e.thumbnailUrl=[location.protocol,"//",location.host,i].join(""),e.contentUrl=r,u.length>0&&(o=convertDurationToISO8601(u.trim()),o!=null&&(e.duration=o)),e.uploadDate=f,document.getElementById("seoVideoDatablock").innerHTML=JSON.stringify(e))};t.isPlayerInited=function(){return typeof t.player!="undefined"&&t.player!==null};t.stopVideo=function(){t.isPlayerInited()&&t.player.stopVideo&&!t.isSinglePlayer&&t.player.stopVideo()};t.pauseVideo=function(){t.player&&t.isPlayerInited()&&t.player.pauseVideo&&!t.isSinglePlayer&&t.player.pauseVideo()};t.replayVideo=function(){t.player&&t.isPlayerInited()&&t.player.seekTo&&(t.player.seekTo(0,!0),t.player.playVideo())};t.closeVideo=function(){t.stopVideo()};t.initVideo=function(n,i){var s,h,w;t.firstPlay=!1;var u=$(t.element),v=u.attr("data-video-id"),c=u.attr("data-target-id"),f=u.attr("data-video-title"),y=u.attr("data-video-type"),e=u.attr("data-vimeo-id"),l=!0,a=u.attr("data-has-image-placeholder");if(typeof a!="undefined"&&a==="false"&&(l=!1),e||(e=u.attr("data-vimeo2-id")),y==="vimeo"&&e){t.videoPlayedPage=f;var p=$("#"+c),r=new Vimeo.Player(p[0]),o=!1;r.off("play");r.off("ended");r.off("pause");r.on("play",function(){console&&console.log("vimeo ||| player PLAY event");t.trackVimeoMilestones(r);t.firstPlay||t.hasEnded||(t.firstPlay=!0,r.getDuration().then(function(n){tealium.fireLinkEvent({event_name:"video_start",video_name:tealium.codify(f),video_length:n.toString(),video_playhead:"0"})}))});r.on("pause",function(){if(!o){o=!0;return}console&&console.log("vimeo ||| player PAUSE event");t.hasEnded||(clearInterval(t.videoPlayerInterval),tealium.fireLinkEvent({event_name:"video_pause",video_name:tealium.codify(f)}))});r.on("ended",function(){console&&console.log("vimeo ||| player ENDED event");t.hasEnded||(t.hasEnded=!0,o=!1,r.getDuration().then(function(n){tealium.fireLinkEvent({event_name:"video_100",video_name:tealium.codify(f),video_length:n.toString(),video_playhead:n.toString()})}))});r.getVideoId().then(function(n){if(e==n){if(l||!IsiOS())try{r.play()}catch(t){console&&console.log(t)}}else r.loadVideo(e).then(function(){try{r.play()}catch(n){console&&console.log(n)}}).catch(function(n){switch(n.name){}})})}else i&&(s=document.createElement("script"),s.src="https://www.youtube.com/iframe_api",h=document.getElementsByTagName("script")[0],h.parentNode.insertBefore(s,h)),w=!1,t.player=new YT.Player(c,{height:"100%",width:"100%",host:"https://www.youtube-nocookie.com",type:"movie",videoId:v,playerVars:{showinfo:1,modestbranding:1,playsinline:1,rel:0,wmode:"opaque",autoplay:1,origin:"//"+document.domain},events:{onReady:function(i){t.setIsMediaCapable();t.isSinglePlayer=n;t.playerHasStarted=!1;t.videoPlayedPage=f;t.mediaName=f;t.componentIndex=InlineVideo.all.length;InlineVideo.all.push(t);n?(window.matchMedia("(max-width: 1024px)").matches&&(i.target.mute(),$(".video-controls-display").css("display","block"),document.getElementById("mute").addEventListener("click",muteHandler),document.getElementById("mute").addEventListener("touchstart",muteHandler,!1)),i.target.playVideo(),t.onPlay()):t.onPlay();$(window).trigger("resize")},onStateChange:t.onPlayerStateChange}})};t.initHandlers=function(){var i=$(t.element).attr("data-target-wrapper-id"),n=$(t.element).attr("data-placeholder-id");$(t.element).on("click",function(){var r=n?$("#"+n):$(this);r.hide();$("#"+i).show();t.initVideo();intervalDaemon(t,t.player).trackVideoProgress()})};t.initSingleHandlers=function(n){var i=$(t.element).attr("data-target-id");$(t.element).on("click",function(){var l;document.getElementById("mute").removeEventListener("click",muteHandler);document.getElementById("mute").removeEventListener("touchstart",muteHandler,!1);$(".inline-video").removeClass("now-playing");$("html, body").animate({scrollTop:0},"fast");$(this).closest(".inline-video").addClass("now-playing");var e=$(this).attr("data-video-id"),a=$(this).attr("data-tcmid"),v=$(this).attr("data-id"),o=$(this).attr("data-video-image-url"),y=$(this).attr("data-video-duration"),p=$(this).attr("data-video-upload-date"),s=document.createElement("div"),u=$(this).closest(".thumbnail").find(".text-column h3,.text-column h4").html(),r=u.replace(/<[^>]+>/g,""),f=$(this).closest(".thumbnail").find(".text-column p").html(),h=f.replace(/<[^>]+>/g,""),c=$("#wvInlineVideoContainer").find(".caption"),w=$(this).attr("data-video-type");s.setAttribute("id",i);$("#wvInlineVideoWrapper").children().children().html(s);c.find("h1,h2").find("span.video-title").html(u);c.find("p").html(f);var b=[location.protocol,"//",location.host,location.pathname].join(""),k=location.pathname.split("/"),d=location.pathname.split("/")[k.length-2];history.pushState(null,r+" | Videos | Viking Cruises",b.replace(d,v));t.updateSeoVideoParam(u,f,o,"https://youtu.be/"+e,y,p);$('link[rel="canonical"]').attr("href",window.location.href);document.title=r+" | Videos | Viking Cruises";$('meta[name="description"]').attr("content",h);$('meta[property="og:description"]').attr("content",h);$('meta[property="og:title"]').attr("content",r+" | Videos | Viking Cruises");$('meta[property="og:image"]').attr("content",o);$('meta[name="pageuri"]').attr("content",a);w==="vimeo"&&(l=$(this).attr("data-vimeo2-id"),l&&$("#vimeoInlineVideoContainer").attr("title",r));t.initVideo(!0);typeof n=="function"&&n(e)})};t.initSingleVideoHandlers=function(){var i=$(t.element).attr("data-target-id"),n=document.createElement("div");n.setAttribute("id",i);$("#wvInlineVideoWrapper").children().children().html(n);t.initVideo(!0,!0)};t.initSingleVideo=function(){t.initSingleVideoHandlers()};t.init=function(n){typeof n=="function"?t.initSingleHandlers(n):t.initHandlers()};t.onPlay=function(){typeof InlineVideo.activeIndex!="undefined"&&InlineVideo.activeIndex!==-1&&InlineVideo.all[InlineVideo.activeIndex].pauseVideo();InlineVideo.activeIndex=t.componentIndex};t.onNotPlay=function(){InlineVideo.activeIndex===t.componentIndex&&(InlineVideo.activeIndex=-1)};t.setIsMediaCapable=function(){typeof s!="undefined"&&typeof s.Media!="undefined"&&typeof s.Media.open=="function"&&typeof s.Media.play=="function"&&typeof s.Media.stop=="function"&&typeof s.Media.close=="function"&&(t.isMediaCapable=!0)};t.setOmniture=function(n){if(typeof s!="undefined")if(n){var t=n.replace(/<[^>]+>/g,"");typeof s.channel!="undefined"&&(s.pageName=s.channel+":"+t);s.eVar16=t;s.prop36=t;s.eVar51=t}else s.eVar16="[No MediaName Set]"};t.pauseAll=function(){};t.onPlayerStateChange=function(n){var i,r;if(t.initTealiumTracking(n),n.data===YT.PlayerState.ENDED&&n.target.playVideo(),n.data!==YT.PlayerState.PLAYING&&t.onNotPlay(),n.data===YT.PlayerState.UNSTARTED&&t.playerHasStarted&&t.isMediaCapable&&t.isPlayerInited()&&typeof t.player.getCurrentTime=="function"&&(t.playerHasStarted=!1,s.Media.stop(t.mediaName,t.player.getCurrentTime()),modalsLogger.log("GA EVENT: STOP"),typeof ga!="undefined"&&ga("send","event","Video","stop",t.mediaName),t.isPaused=!0),n.data===YT.PlayerState.PLAYING&&(t.isFirstRun?t.isFirstRun=!1:t.onPlay(),t.playerInteraction=!0),n.data!==!YT.PlayerState.PLAYING||t.done||(t.stopVideo(),modalsLogger.log("GA EVENT: STOP"),typeof ga!="undefined"&&ga("send","event","Video","stop",t.mediaName)),n.data===YT.PlayerState.CUED&&(console.log("CUED"),modalsLogger.log("GA EVENT: OPEN"),typeof ga!="undefined"&&ga("send","event","Video","open",t.mediaName)),n.data===YT.PlayerState.PLAYING){if(t.isMediaCapable===!1||t.isPlayerInited()===!1||typeof t.player.getCurrentTime!="function"||typeof t.player.getDuration!="function")return null;t.playerHasStarted===!1?(i=t.player.getDuration(),i>0&&(t.pauseAll(),t.setOmniture(t.mediaName,"from playing 2"),s.Media.open(t.mediaName,i,t.mediaPlayerName),modalsLogger.log("GA EVENT: OPEN"),typeof ga!="undefined"&&(ga("send","event","Video","open",t.mediaName),ga("set","dimension5",t.mediaName)),s.Media.play(t.mediaName,0),t.playerHasStarted=!0)):(t.pauseAll(),r=t.player.getCurrentTime(),s.Media.play(t.mediaName,r),modalsLogger.log("GA EVENT: PLAY"),typeof ga!="undefined"&&ga("send","event","Video","play",t.mediaName,Math.round(r)),t.isPaused=!1)}return n.data===YT.PlayerState.BUFFERING,n.data===YT.PlayerState.PAUSED&&t.playerHasStarted&&t.isMediaCapable&&t.isPlayerInited()&&typeof t.player.getCurrentTime=="function"&&(s.Media.stop(t.mediaName,t.player.getCurrentTime()),modalsLogger.log("GA EVENT: PAUSE"),typeof ga!="undefined"&&ga("send","event","Video","pause",t.mediaName,Math.round(t.player.getCurrentTime())),t.isPaused=!0),n.data===YT.PlayerState.ENDED&&t.playerHasStarted&&t.isMediaCapable&&t.isPlayerInited()&&(typeof t.player.getCurrentTime=="function"&&(s.Media.stop(t.mediaName,t.player.getCurrentTime()),typeof ga!="undefined"&&(ga("send","event","Video","end",t.mediaName),modalsLogger.log("GA EVENT: END"),ga("send","event","Video","watchedtime",t.mediaName,Math.round(t.player.getCurrentTime()))),s.Media.close(t.mediaName)),t.playerHasStarted=!1),!1};t.initTealiumTracking=function(n){var i=tealium.codify(t.videoPlayedPage),r=t.player.getDuration().toString();switch(n.data){case YT.PlayerState.PLAYING:t.trackMilestones();t.firstPlay||t.hasEnded||(t.firstPlay=!0,tealium.fireLinkEvent({event_name:"video_start",video_name:i,video_length:r,video_playhead:"0"}));break;case YT.PlayerState.PAUSED:t.hasEnded||(clearInterval(t.videoPlayerInterval),tealium.fireLinkEvent({event_name:"video_pause",video_name:i}));break;case YT.PlayerState.ENDED:t.hasEnded||(t.hasEnded=!0,tealium.fireLinkEvent({event_name:"video_100",video_name:i,video_length:r,video_playhead:r}))}};t.trackMilestones=function(){t.hasEnded||(t.videoPlayerInterval=setInterval(function(){var n=t.player.getCurrentTime(),i=t.player.getDuration(),r=parseInt((n/i*100).toFixed());t.parseMilestone(r,i.toString(),n.toString())},1e3))};t.trackVimeoMilestones=function(n){t.hasEnded||(t.videoPlayerInterval=setInterval(function(){n.getDuration().then(function(i){n.getCurrentTime().then(function(n){var r=parseInt(n/i*100).toFixed();t.parseMilestone(r,i.toString(),n.toString())})})},2e3))};t.parseMilestone=function(n,i,r){var u=t.milestones;n>=25&&u.indexOf("video_25")===-1?(u.push("video_25"),tealium.fireLinkEvent({event_name:"video_25",video_name:tealium.codify(t.videoPlayedPage),video_length:i,video_playhead:r})):n>=50&&u.indexOf("video_50")===-1?(u.push("video_50"),tealium.fireLinkEvent({event_name:"video_50",video_name:tealium.codify(t.videoPlayedPage),video_length:i,video_playhead:r})):n>=75&&u.indexOf("video_75")===-1&&(u.push("video_75"),tealium.fireLinkEvent({event_name:"video_75",video_name:tealium.codify(t.videoPlayedPage),video_length:i,video_playhead:r}))}};InlineVideo.all=[];InlineVideo.activeIndex=-1;var intervalDaemon=function(n,t){function o(n){return n&&{}.toString.call(n)==="[object Function]"}var r=0,u=0,f,i=[];i.push(75);i.push(50);i.push(25);i.push(10);var s=function(n){return n/u*100},e=function(){r!==0&&(modalsLogger.log("Interval Cleared"),window.clearInterval(r))},h=function(){var h,a,r,c,l;typeof t!="undefined"&&t!==null&&o(t.getPlayerState)&&(h=n.mediaName,typeof h=="undefined"&&(h=n.MediaName),a=t.getPlayerState(),r=t.getCurrentTime(),u=t.getDuration(),a===YT.PlayerState.PLAYING)&&(r===f&&e(),f=r,c=s(r),modalsLogger.log(c),c>=i[i.length-1]&&(l=i.pop(),modalsLogger.log("GA PROGRESS EVENT: "+l),typeof ga!="undefined"&&ga("send","event","Video","video_progress_"+l+"perc",h,Math.round(r))))},c=function(){e();r=window.setInterval(h,2e3)};return{trackVideoProgress:c}},convertDurationToISO8601=function(n){try{var t=n.split(":"),i=t.length>0?parseInt(t[t.length-1]):0,r=t.length>1?parseInt(t[t.length-2]):0,u=t.length>2?parseInt(t[t.length-3]):0;return"PT"+(u>0?u+"H":"")+(r>0?r+"M":"")+(i>0?i+"S":"")}catch(f){return null}},screenXs=window.matchMedia("(max-width:767px)"),screenSm=window.matchMedia("(min-width:768px) and (max-width:1023px)"),screenMd=window.matchMedia("(min-width:1024px) and (max-width:1365px)"),screenLg=window.matchMedia("(min-width:1366px)"),headerOffset=0,navScrollObj=null;$(document).ready(function(){headerOffset=$("#cruise-hdr").length?$("#trd-header").outerHeight()+$("#cruise-hdr").outerHeight():$("#trd-header").outerHeight();$(".inline-video-trigger").each(function(){var n=new InlineVideo(this);n.init()})})