var tdVimeoPlayers={};jQuery().ready(function(){tdVimeoPlayers.init()});
(function(){tdVimeoPlayers={tdPlayerContainer:"player_vimeo",players:[],existingAutoplay:!1,init:function(){for(var b=jQuery(".td_wrapper_playlist_player_vimeo"),d=0;d<b.length;d++)tdVimeoPlayers.addPlayer(jQuery(b[d]));jQuery(".td_click_video_vimeo").on("click",function(){var a=jQuery(this).data("video-id"),c=jQuery(this).data("player-id");void 0!==c&&""!==c&&void 0!==a&&""!==a&&tdVimeoPlayers.operatePlayer(c,"play",a)});jQuery(".td_vimeo_control").on("click",function(){var a=jQuery(this).data("player-id");
void 0!==a&&""!==a&&(jQuery(this).hasClass("td-sp-video-play")?tdVimeoPlayers.operatePlayer(a,"play"):tdVimeoPlayers.operatePlayer(a,"pause"))})},addPlayer:function(b){var d=tdVimeoPlayers.tdPlayerContainer+"_"+tdVimeoPlayers.players.length,a=tdVimeoPlayers.createPlayer(d,b);b.parent().find(".td_vimeo_control").data("player-id",d);for(var c=b.parent().find(".td_click_video_vimeo"),e=0;e<c.length;e++)jQuery(c[e]).data("player-id",d),e+1<c.length?jQuery(c[e]).data("next-video-id",jQuery(c[e+1]).data("video-id")):
jQuery(c[e]).data("next-video-id",jQuery(c[0]).data("video-id"));"1"==b.data("autoplay")&&(a.autoplay=1);b=b.data("first-video");void 0!==b&&""!==b&&a.createPlayer(b);tdVimeoPlayers.players.push(a);return a},operatePlayer:function(b,d,a){for(var c=0;c<tdVimeoPlayers.players.length;c++)if(tdVimeoPlayers.players[c].playerId==b){b=tdVimeoPlayers.players[c];"play"===d?void 0!==a?(tdVimeoPlayers.existingAutoplay=!1,b.createPlayer(a)):b.playerPlay():"pause"===d&&b.playerPause();break}},createPlayer:function(b,
d){var a={playerId:b,jqTDWrapperVideoPlaylist:d.closest(".td_wrapper_video_playlist"),jqPlayerWrapper:d,currentVideoPlaying:"",player:"",jqControlPlayer:"",autoplay:0,createPlayer:function(c){if(""!==c){this.currentVideoPlaying=c;var b="",d=window.td_vimeo_list_ids["td_"+c].title,f=window.td_vimeo_list_ids["td_"+c].time;a.jqTDWrapperVideoPlaylist.find(".td_click_video_vimeo").removeClass("td_video_currently_playing");a.jqTDWrapperVideoPlaylist.find(".td_"+c).addClass("td_video_currently_playing");
a.jqTDWrapperVideoPlaylist.find(".td_current_video_play_title_vimeo").html(d);a.jqTDWrapperVideoPlaylist.find(".td_current_video_play_time_vimeo").html(f);a.jqControlPlayer=a.jqTDWrapperVideoPlaylist.find(".td_vimeo_control");tdVimeoPlayers.existingAutoplay||0===a.autoplay?a.playStatus():(b="&autoplay=1&muted=1",tdDetect.isMobileDevice?a.playStatus():a.pauseStatus());a.jqPlayerWrapper.html('<iframe id="'+a.playerId+'" src="https://player.vimeo.com/video/'+c+"?api=1&player_id="+a.playerId+b+'"  frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>');
a.createVimeoObjectPlayer(jQuery)}},createVimeoObjectPlayer:function(c){var b="";c=c("#"+a.playerId);c.length&&(b=$f(c[0]),a.player=b,b.addEvent("ready",function(){b.addEvent("play",function(b){a.pauseStatus()});b.addEvent("pause",function(b){a.playStatus()});b.addEvent("finish",function(b){b="";var c=a.jqTDWrapperVideoPlaylist.find(".td_video_currently_playing");c.length&&(c=jQuery(c).next(".td_click_video_vimeo"),c.length&&(b=jQuery(c).data("video-id")));""!==b?(a.createPlayer(b),tdDetect.isMobileDevice?
a.playStatus():a.pauseStatus()):a.playStatus()})}))},playerPlay:function(){a.player.api("play")},playerPause:function(){a.player.api("pause")},playStatus:function(){a.jqControlPlayer.removeClass("td-sp-video-pause").addClass("td-sp-video-play")},pauseStatus:function(){a.jqControlPlayer.removeClass("td-sp-video-play").addClass("td-sp-video-pause")}};return a}}})();
