jQuery(window).load(function(){mpFixBackgroundVideoSize()});jQuery(window).resize(function(){this.mpResizeTimeout&&clearTimeout(this.mpResizeTimeout);this.mpResizeTimeout=setTimeout(function(){jQuery(this).trigger("mpResizeEnd")},500)});jQuery(window).on("mpResizeEnd",function(){mpFixBackgroundVideoSize()});function onYouTubeIframeAPIReady(){mpInitYouTubePlayers()}
function mpInitYouTubePlayers(a){function b(b){return function(e){$player=jQuery(a[b]);"1"===$player.attr("data-mute")&&e.target.mute()}}"undefined"===typeof a&&(a=jQuery(".mp-video-container>.mp-youtube-container>.mp-youtube-video"));a.each(function(c,e){$player=jQuery(e);var d=new YT.Player(a[c],{videoId:$player.attr("data-src"),events:{onReady:b(c)}});$player.data("ytplayer",d)})}
jQuery(".mp-video-container").on("click",function(a){jQuery(this).children("video").length?(a=jQuery(this).children("video")[0],a.paused?a.play():a.pause()):(a=jQuery(this).find("iframe.mp-youtube-video").data("ytplayer"))&&(2===a.getPlayerState()?a.playVideo():a.pauseVideo())});jQuery(".mp-row-video").on("click",function(a){jQuery(a.target).is(".mp-row-fluid")?jQuery(this).children(".mp-video-container").trigger("click"):jQuery(a.target).is("[class*=mp-span]")&&jQuery(this).closest(".mp-row-video").children(".mp-video-container").trigger("click")});
function mpFixBackgroundVideoSize(a){"undefined"===typeof a&&(a=jQuery(".mp-video-container"));jQuery.each(a,function(b){mpFixVideoSize(a[b])})}function mpRememberOriginalSize(a){a.originalsize||(a.originalsize={width:a.width(),height:a.height()})}
function mpFixVideoSize(a){var b;jQuery(a).children().is("video")?b=jQuery(a).children():(b=jQuery(a).find("iframe"),b.length||(b=jQuery(a).find("img")));mpRememberOriginalSize(b);var c=jQuery(a).width(),e=jQuery(a).height(),c=mpScaleVideo(b.originalsize.width,b.originalsize.height,c,e);jQuery(a).find(".mp-youtube-container").height(c.height);jQuery(a).find(".mp-youtube-container").width(c.width);b.width(c.width);b.height(c.height);b.css("max-width",c.width);jQuery(b).css("left",c.targetleft);jQuery(b).css("top",
c.targettop)}function mpScaleVideo(a,b,c,e){var d={width:0,height:0,fScaleToTargetWidth:!0};if(0>=a||0>=b||0>=c||0>=e)return d;var f=a*e/b;f<=c?(d.width=Math.floor(c),d.height=Math.floor(b*c/a),d.fScaleToTargetWidth=!0):(d.width=Math.floor(f),d.height=Math.floor(e),d.fScaleToTargetWidth=!1);d.targetleft=Math.floor((c-d.width)/2);d.targettop=Math.floor((e-d.height)/2);return d};
