function playOoyalaVideo(n,t,i,r){var u="container_"+n+"_"+Math.round(Math.random()*1e6).toLocaleString("en",{minimumIntegerDigits:6,useGrouping:0}),f;t.attr("id",u);f={autoplay:i,muteFirstPlay:i,loop:!1,onCreate:function(n){t.get(0).player=n;n.subscribe("*","clearfix",function(i){var f;try{r&&r(n,t,i)}catch(e){}i==OO.EVENTS.PLAYBACK_READY&&(f=$("#"+u),f.is(".ooyala-video-container-clear")&&window.setTimeout(function(){f.find("a.oo-more-options").remove()},0));i==OO.EVENTS.PLAYHEAD_TIME_CHANGED&&(f=$("#"+u),f.find("a.oo-more-options").remove())})}};$(document).ready(function(){OO.ready(function(){OO.Player.create(u,n,f)})})}function playOoyalaElement(n,t,i){var r=$(n),u=r.data("contentid"),f=r.hasClass("ooyala-video-container-inline-play"),t;f||r.hide();t=t||r.hasClass("ooyala-video-container-popup-autoplay");playOoyalaVideo(u,r,t,i)}function ooyalaVideoInlinePlay(n){var i,t,r;return n=$(n),i=n.closest(".item").find(".ooyala-video-container"),i.length>0&&(t=i.first(),r=t.hasClass("ooyala-video-container-inline-play"),r&&(t.css({width:"",height:""}),playOoyalaElement(t,!0))),!1}function ooyalaVideoClicked(n){var r=$(n.target),t,i,u,f,e;return n.preventDefault(),t=r,r.hasClass("ooyala-video-container")||(t=r.closest(".item").find(".ooyala-video-container")),t.length>0&&(i=t.first(),t.hasClass("ooyala-video-protected")&&!$.auth.isAuth?$.auth.loginPopup(n):(u=i.hasClass("ooyala-video-container-playerpage"),u?(f=i.data("player-page"),e=i.data("video-id"),window.location.href=f+"?id="+e):playOoyalaElement(i,!1,displayPopup))),!1}function displayPopoupMain(n,t,i){if(typeof t=="undefined"){var t=$(window).width();t=t>900?Math.min(1200,t-400):t-100;i=t*.6}n.css({width:t,height:i});$.fancybox({autoPlay:!0,padding:0,autoScale:!1,autoSize:!1,transitionIn:"none",transitionOut:"none",title:this.title,width:t,height:i,href:"#"+n.attr("id"),afterClose:function(){n.get(0).player&&n.get(0).player.destroy()}})}function displayPopup(n,t,i){var f,e,u,r;i==OO.EVENTS.PLAYBACK_READY&&(n.alreadyResized||(f=t.find(".oo-player .oo-state-screen"),f.length>0&&(t.css("width","").css("height",""),t.show(),u=f.width(),r=f.height(),t.hide(),e=r/u,u=$(window).width(),u=u>900?Math.min(1200,u-400):u-100,r=u*e,r>$(window).height()&&(r=$(window).height(),r=r>500?Math.min(800,r-100):r-100,u=r/e),n.alreadyResized=!0,displayPopoupMain(t,u,r))));i==OO.EVENTS.PLAYED&&$.fancybox.close()}$(document).ready(function(){function i(n){var t=$(n),i=t.data("contentid");$.get("https://player.ooyala.com/api/v1/thumbnail_images/"+i,function(n){var i,r,f,u,e;if(n=n.data,n&&n.thumbnails&&n.available_widths&&(i=0,r=t.parent().find("img.thumb:first"),r.length>0)){f=r.width();for(u in n.available_widths)if(n.available_widths[u]>f){i=n.available_widths[u];break}i>0&&(e=n.thumbnails[0][i].url,r.attr("src",null).attr("src",e))}})}$.auth.init().then(function(){$(".visual-fix-size").each(function(){var n=$(this).find(".ooyala-video-container");!$.auth.isAuth&&n.hasClass("ooyala-video-protected")&&$(this).addClass("ooyala-video-protected")})});$(".visual-fix-size").each(function(){var t=$(this).find(".ooyala-video-container"),n;if(t.hasClass("ooyala-video-container-inline-play"))n=t.parent(),n.children(".clicklayer").remove(),n.children("img.thumb").remove(),n.children(".video-icon-container").remove(),n.parent().children(".cnt").remove(),ooyalaVideoInlinePlay(this);else{$(this).on("click",ooyalaVideoClicked);$(this).parent().children(".clicklayer").on("click",ooyalaVideoClicked)}});var n=[],t=function(){if(n.length>0){var r=n.shift();window.setTimeout(function(){i(r);t()},50)}};$(".ooyala-video-container-auto").lazyload({appear:function(){var i=n.length==0;n.push(this);i&&window.setTimeout(t,10)}});$(".ooyala-video-container-popup-autoplay").each(function(n,t){var r="video.displayed",i=$(t),u=i.data("contentid");if(u){try{if(i.hasClass("onetime")){if(window.localStorage.getItem(r)=="1")return;window.localStorage.setItem(r,"1")}}catch(f){}playOoyalaElement(i,!0,displayPopup)}})})