function setupYoutube(n){document.getElementsByClassName||(document.getElementsByClassName=function(n){return this.querySelectorAll("."+n)},Element.prototype.getElementsByClassName=document.getElementsByClassName);for(var t,f,i,u=n&&n.find(".youtube")||document.getElementsByClassName("youtube"),r=0;r<u.length;r++)i=u[r],t=document.createElement("div"),t.setAttribute("data-bg","https://i.ytimg.com/vi/"+i.id+"/maxresdefault.jpg"),t.setAttribute("class","thumb"),f=document.createElement("div"),f.setAttribute("class","start"),i.appendChild(t),i.appendChild(f);$.each(u,function(n,t){var i=document.getElementById(t.getAttribute("data-videoContainerId"));t.onclick=function(){onYoutubePlayerClicked.call(t,t.id,i)}})}function onYoutubePlayerClicked(n,t){var u;if(deviceWidthWhenPlayed=Math.max(document.documentElement.clientWidth,window.innerWidth||0),currentYoutubePlayer===undefined||currentYoutubePlayer.b.b.videoId!==n){var i=document.createElement("iframe"),r=window.location,f=r.protocol+"//"+r.host;if(i.setAttribute("src","https://www.youtube.com/embed/"+n+"?autoplay=1&autohide=1&border=0&wmode=opaque&enablejsapi=1&rel=0&origin="+f),i.setAttribute("width","560"),i.setAttribute("height","315"),currentYoutubePlayer!==undefined)try{currentYoutubePlayer.stopVideo()}catch(e){}!!t&&deviceWidthWhenPlayed>=601?SetUpBigYoutubePlayerContainer(t,i):this.parentNode.replaceChild(i,this);u=$(i).parent();$(u).fitVids();!t||(i.onload=function(){setUpYoutubePlayer(i,n);i.onload=null})}}function onPlayerStateChange(n){var t,u;if(n.data===1&&(currentYoutubePlayer!==undefined&&currentYoutubePlayer.a.src!==n.target.getIframe().src&&(currentYoutubePlayer.stopVideo(),currentYoutubePlayer=n.target),t=$("#youtube-play-container")[0],CloseUnusedPlayerForMobile(n.target.getIframe().id,t),u=deviceWidthWhenPlayed,deviceWidthWhenPlayed=Math.max(document.documentElement.clientWidth,window.innerWidth||0),u!==deviceWidthWhenPlayed||!(deviceWidthWhenPlayed<601||$(t).find(".fluid-width-video-wrapper").length!==0&&$(t).find(".fluid-width-video-wrapper")[0].firstChild.id===n.target.getIframe().id))&&!!t){if(deviceWidthWhenPlayed>=601){var i=n.target.getIframe(),f=n.target.b.b.videoId,e=$(i).parent(),r=CreateYoutubeThumbnailContainer(f);r.onclick=function(){onYoutubePlayerClicked.call(r,f,t)};$(e).replaceWith(r);i.setAttribute("width","560");i.setAttribute("height","315");SetUpBigYoutubePlayerContainer(t,i);lastWatchedVideoPlayTime=n.target.getCurrentTime()}$(t).fitVids()}}function CloseUnusedPlayerForMobile(n,t){var i=Math.max(document.documentElement.clientWidth,window.innerWidth||0);if(i<601&&$(t).find(".fluid-width-video-wrapper").length!==0&&$(t).find(".fluid-width-video-wrapper")[0].firstChild.id!==n)while(t.firstChild)t.style.display="none",t.removeChild(t.firstChild)}function CreateYoutubePlayerContainerCloseButton(n){var t=document.createElement("span");return t.setAttribute("class","fas fa-times video-close-button"),t.onclick=function(){for(n.style.display="none";n.firstChild;)n.removeChild(n.firstChild);lastWatchedVideoPlayTime=0;currentYoutubePlayer=undefined},t}function SetUpBigYoutubePlayerContainer(n,t){var i=CreateYoutubePlayerContainerCloseButton(n);n.innerHTML="";n.appendChild(i);n.appendChild(t);n.style.display=""}function CreateYoutubeThumbnailContainer(n){var t=document.createElement("div"),i,u,r;return t.setAttribute("id",n),t.setAttribute("class","youtube"),t.setAttribute("data-videoContainerId","youtube-play-container"),i=document.createElement("div"),u="background-image: url(https://i.ytimg.com/vi/"+n+"/maxresdefault.jpg)",i.setAttribute("style",u),i.setAttribute("class","thumb lazy-hidden"),r=document.createElement("div"),r.setAttribute("class","start"),t.appendChild(i),t.appendChild(r),t}function setUpYoutubePlayer(n,t){(currentYoutubePlayer===undefined||n.src!==currentYoutubePlayer.src)&&(lastWatchedVideoPlayTime=0,currentYoutubePlayer=new YT.Player(n,{videoId:t,events:{onStateChange:onPlayerStateChange,onReady:onPlayerReady}}))}function pauseCurrentPlayer(){currentYoutubePlayer!==undefined&&currentYoutubePlayer.a.contentWindow!==null&&currentYoutubePlayer.a.contentWindow!==undefined&&currentYoutubePlayer.pauseVideo()}function onPlayerReady(n){n.target.seekTo(lastWatchedVideoPlayTime)}var deviceWidthWhenPlayed=Math.max(document.documentElement.clientWidth,window.innerWidth||0),lastWatchedVideoPlayTime=0,currentYoutubePlayer;$(document).ready(function(){setupYoutube();var n=$("#pdp-video-carousel");if(n.length===1)n.on("changed.owl.carousel",function(){var n=Math.max(document.documentElement.clientWidth,window.innerWidth||0);n<601&&pauseCurrentPlayer()})})