/*!
 * 
 * Modern HTML5 Responsive Youtube Playlist Player
 * For jQuery 1.9 and above
 * 
 * @author  Rik de Vos
 * @link    http://rikdevos.com/
 * @version 1.6.0
 *
 * This is not free software. Visit http://codecanyon.net/item/modern-html5-responsive-youtube-playlist-player/8619272?ref=RikdeVos to purchase a license
 * 
 */

function onYouTubeIframeAPIReady(){jQuery("body").addClass("yesp-youtube-iframe-ready")}!function(e){e.youtube_video=function(o,t){var i=this;i.$el=e(o),i.el=o,i.$el.data("youtube_video",i),i.init=function(){if(i.options=e.extend({},e.youtube_video.defaultOptions,t),i.options_copy=e.extend({},e.youtube_video.defaultOptions,t),i.api_key=i.options.api_key,i.$el.addClass("yesp"),i.$logo=[],i.type=!1,i.options.playlist!==!1)i.id="yt_player_"+i.options.playlist.replace(/[^a-z0-9]/gi,""),i.type="playlist";else if(i.options.channel!==!1)i.id="yt_player_"+i.options.channel.replace(/[^a-z0-9]/gi,""),i.type="channel";else if(i.options.user!==!1)i.id="yt_player_"+i.options.user.replace(/[^a-z0-9]/gi,""),i.type="user";else{if(i.options.videos===!1)return void i.display_error("No playlist/channel/user/videos entered. Set at least 1.",!0);"string"==typeof i.options.videos&&(i.options.videos=[i.options.videos]),i.id="yt_player_"+i.options.videos[0].replace(/[^a-z0-9]/gi,""),i.type="videos"}"undefined"!=typeof i.options.player_id&&i.options.player_id!==!1&&(i.id=i.options.player_id),"undefined"!=typeof i.$el.attr("id")&&i.$el.attr("id")!==!1?i.id=i.$el.attr("id"):i.$el.attr("id",i.id),i.options.max_results>50&&(i.options.max_results=50),i.$controls=[],i.$title=null,i.$container=i.$el.find(".yesp-container"),i.youtube=null,i.playlist_items=[],i.playlist_count=0,i.info={width:0,height:0,duration:0,current_time:0,previous_time:0,volume:i.options.volume,time_drag:!1,volume_drag:!1,ie:i.detect_ie(),ie_previous_time:0,touch:i.detect_touch(),youtube_loaded:!1,ios:navigator.userAgent.match(/(iPad|iPhone|iPod)/g)?!0:!1,mobile:navigator.userAgent.match(/(Android|webOS|iPad|iPhone|iPod|BlackBerry|Windows Phone)/g)?!0:!1,state:!1,index:0,hover:!0,fullscreen:!1,idle_time:0,idle_controls_hidden:!1,playlist_shown:!0,horizontal_playlist_shown:!0,playlist_width:200,playlist_animating:!1,first_play:!1,current_video_url:"",next_page_token:!1,playlist_i:0,alternative_api_ready_check:!1,youtube_logo_timer:!1},i.info.ios&&(i.$el.addClass("yesp-ios"),i.options.volume_control=!1,i.options_copy.volume_control=!1),i.info.mobile&&(i.options.show_controls_on_load=!0,i.options.show_controls_on_pause=!0,i.options.show_controls_on_play=!0,i.$el.addClass("yesp-mobile")),i.info.ie&&i.$el.addClass("yesp-ie"),i.$el[0].requestFullScreen||i.$el[0].mozRequestFullScreen||i.$el[0].webkitRequestFullScreen||(i.options.fullscreen_control=!1),i.create_player_element(),i.init_playlist(),i.create_controls(),i.create_title(),i.create_overlays(),i.show_controls(),i.bind_controls(),e(window).on("resize",i.resize),i.resize(),i.init_time_slider(),i.init_volume_slider(),i.set_style(),i.options.width!==!1&&(i.$el.css("width",i.options.width),i.resize()),i.options.show_controls_on_load||i.hide_controls(),"horizontal"===i.options.playlist_type?(i.hide_playlist(!0),i.options.show_playlist?i.show_horizontal_playlist():i.hide_horizontal_playlist()):(i.hide_horizontal_playlist(),i.options.show_playlist||i.hide_playlist(!0)),document.addEventListener("fullscreenchange",function(){document.fullscreen||i.exit_fullscreen()},!1),document.addEventListener("mozfullscreenchange",function(){document.mozFullScreen||i.exit_fullscreen()},!1),document.addEventListener("webkitfullscreenchange",function(){document.webkitIsFullScreen||i.exit_fullscreen()},!1),document.addEventListener("msfullscreenchange",function(){document.msFullscreenElement||i.exit_fullscreen()},!1),setInterval(function(){i.info.mobile||(i.info.idle_time+=500,i.info.fullscreen&&i.info.idle_time>2e3&&(i.info.idle_controls_hidden=!0,i.hide_controls(!0)))},500),i.$el.mousemove(function(){i.info.idle_time=0,i.info.idle_controls_hidden&&i.info.fullscreen&&(i.info.idle_controls_hidden=!1,i.show_controls())}),i.$el.keypress(function(){i.info.idle_time=0,i.info.idle_controls_hidden&&i.info.fullscreen&&(i.info.idle_controls_hidden=!1,i.show_controls())}),i.info.touch&&i.$el.addClass("yesp-touch"),setTimeout(function(){i.info.alternative_api_ready_check=!0},1e3)},i.display_error=function(e,o){var t=i.$el.find(".yesp-error").html('<i class="yesp-icon yesp-icon-warning"></i>'+e).slideDown();0===t.length&&alert(e),o===!0&&(i.$el.find(".yesp-video").remove(),i.$el.find(".yesp-container, .yesp-hp").css("background-image","none"))},i.remove_next_page=function(){i.info.next_page_token=!1,i.$el.find(".yesp-next-page").remove(),i.$el.find(".yesp-hp-next-page").remove(),i.$el.find(".yesp-hp-videos").css("width",160*i.playlist_count)},i.get_playlist_next=function(){return i.info.next_page_token===!1?void i.remove_next_page():(i.$el.find(".yesp-next-page").html('<i class="yesp-icon yesp-icon-spinner yesp-icon-spin"></i>'),void i.get_playlist(i.info.next_page_token,i.options.playlist))},i.get_playlist=function(o,t){"undefined"==typeof o||o===!1?(o=!1,through_pagination=!1):through_pagination=!0;var n="https://www.googleapis.com/youtube/v3/playlistItems?part=snippet,status&maxResults="+i.options.max_results+"&playlistId="+t+"&key="+i.options.api_key;through_pagination===!0&&(n+="&pageToken="+o);var s=e.getJSON(n,function(e){if("undefined"!=typeof e.items){0===e.items.length&&i.display_error("This playlist is empty.",!0),i.options.shuffle&&(e.items=i.shuffle_array(e.items));var o=i.create_playlist(through_pagination,e.items,e.items.length);i.playlist_items=i.playlist_items.concat(o.items),i.playlist_count+=o.count,i.options.pagination===!0?"undefined"==typeof e.nextPageToken?i.remove_next_page():(i.info.next_page_token=e.nextPageToken,i.$el.find(".yesp-next-page").html('<i class="yesp-icon yesp-icon-plus"></i>'+i.options.load_more_text).show()):i.info.next_page_token=!1,i.playlist_count<2&&!through_pagination&&i.info.next_page_token===!1&&(i.hide_playlist(!0),i.options.show_playlist=!1,i.options.playlist_toggle_control=!1,i.$controls.playlist_toggle.hide(),i.options.fwd_bck_control=!1,i.options_copy.fwd_bck_control=!1,i.$controls.forward.hide(),i.$controls.backward.hide(),i.resize(),0===i.playlist_count&&i.display_error("This playlist is empty.",!0))}else i.display_error("An error occured while retrieving the playlist.",!0)});s.fail(function(o){var t="An error occured while retrieving the playlist.";if("undefined"!=typeof o.responseText){var n=e.parseJSON(o.responseText);t="404"==n.error.code?"The playlist was not found.":"403"==n.error.code?n.error.message:"400"==n.error.code?"The API key you have entered is invalid.":"An error occured while retrieving the playlist.<br /><em>"+n.error.message+"</em>"}i.display_error(t,!0),i.hide_playlist(!0)})},i.get_channel=function(o,t){var n="";n="user"===o?"https://www.googleapis.com/youtube/v3/channels?part=contentDetails&maxResults="+i.options.max_results+"&forUsername="+encodeURIComponent(t)+"&key="+i.api_key:"https://www.googleapis.com/youtube/v3/channels?part=contentDetails&maxResults="+i.options.max_results+"&id="+t+"&key="+i.api_key,e.getJSON(n,function(e){if(void 0!==typeof e.items&&1==e.items.length){var o=e.items[0].contentDetails.relatedPlaylists.uploads;i.options.playlist=o,i.get_playlist(!1,i.options.playlist)}else i.display_error("An error occured while retrieving the channel/user.",!0)})},i.get_videos=function(o){for(var t="",n=o.length,s=0;n>s;s++)t+=s!==n-1?o[s]+",":o[s];var l="https://www.googleapis.com/youtube/v3/videos?part=snippet,status&maxResults="+i.options.max_results+"&id="+t+"&key="+i.api_key;e.getJSON(l,function(e){if("undefined"!=typeof e.items){for(var o=0;o<e.items.length;o++)e.items[o].snippet.resourceId={videoId:e.items[o].id};var t=i.create_playlist(!1,e.items,e.items.length);i.playlist_items=i.playlist_items.concat(t.items),i.playlist_count+=t.count,i.playlist_count<2&&(i.hide_playlist(!0),i.options.show_playlist=!1,i.options.playlist_toggle_control=!1,i.$controls.playlist_toggle.hide(),i.options.fwd_bck_control=!1,i.options_copy.fwd_bck_control=!1,i.$controls.forward.hide(),i.$controls.backward.hide(),i.resize(),0===i.playlist_count&&i.display_error("This playlist is empty, or the video's were not found.",!0))}else i.display_error("An error occured while retrieving the video(s).",!0)})},i.init_playlist=function(){return"playlist"===i.type?void i.get_playlist(!1,i.options.playlist):"channel"==i.type?void i.get_channel("channel",i.options.channel):"user"==i.type?void i.get_channel("user",i.options.user):"videos"==i.type?void i.get_videos(i.options.videos):void 0},i.create_playlist=function(o,t,n){o||i.create_youtube_element();for(var s=0;"undefined"!=typeof t[s];)"private"!=t[s].status.privacyStatus&&"undefined"!=typeof t[s].snippet.thumbnails?s++:(t.splice(s,1),n--);for(i.options.on_done_loading(t),i.info.playlist_i;i.info.playlist_i<i.playlist_count+n;i.info.playlist_i++){var l=t[i.info.playlist_i-i.playlist_count],a="";"undefined"!=typeof l.snippet.thumbnails.medium&&l.snippet.thumbnails.medium.width/l.snippet.thumbnails.medium.height==16/9?a=l.snippet.thumbnails.medium.url:"undefined"!=typeof l.snippet.thumbnails.medium?a=l.snippet.thumbnails.medium.url:"undefined"!=typeof l.snippet.thumbnails.high?a=l.snippet.thumbnails.high.url:"undefined"!=typeof l.snippet.thumbnails["default"]&&(a=l.snippet.thumbnails["default"].url);{l.snippet.title}l.snippet.title.length>85&&(l.snippet.title=l.snippet.title.substr(0,85)+"..."),l.snippet.channelTitle.length>20&&(l.snippet.channelTitle=l.snippet.channelTitle.substr(0,20)+"...");var r=e('<div class="yesp-playlist-video" data-playing="0" data-index="'+i.info.playlist_i+'"><img src="'+a+'" width="200" /><div class="yesp-playlist-overlay"><div class="yesp-playlist-title">'+l.snippet.title+'</div><div class="yesp-playlist-channel">'+l.snippet.channelTitle+'</div></div><div class="yesp-playlist-current"><i class="yesp-icon yesp-icon-play"></i><span>'+i.options.now_playing_text+"</span></div></div>");r.click(function(o){o.preventDefault(),i.options.show_controls_on_play||i.hide_controls(),i.play_video(parseFloat(e(this).attr("data-index")))}),0==i.options.show_channel_in_playlist&&r.find(".yesp-playlist-channel").remove(),r.insertBefore(i.$el.find(".yesp-playlist .yesp-next-page")),i.$el.find(".yesp-playlist, .yesp-hp").css("background-image","none");var p=l.snippet.title;p.length>45&&(p=l.snippet.title.substring(0,45)+"...");var u=e('<div class="yesp-hp-video" data-playing="0" data-index="'+i.info.playlist_i+'"><img src="'+a+'" width="200" /><div class="yesp-hp-overlay"><div class="yesp-hp-title">'+p+'</div><div class="yesp-hp-channel">'+l.snippet.channelTitle+'</div></div><div class="yesp-hp-current"><i class="yesp-icon yesp-icon-play"></i><span>'+i.options.now_playing_text+"</span></div></div>");u.click(function(o){o.preventDefault(),i.options.show_controls_on_play||i.hide_controls(),i.play_video(parseFloat(e(this).attr("data-index")))}),0==i.options.show_channel_in_playlist&&u.find(".yesp-hp-channel").remove(),u.insertBefore(i.$el.find(".yesp-hp .yesp-hp-next-page"))}return i.$el.find(".yesp-hp-videos").css("width",160*i.info.playlist_i+50),o===!1&&(i.$el.find(".yesp-playlist").perfectScrollbar({suppressScrollX:!0}),i.$el.find(".yesp-hp").perfectScrollbar({suppressScrollY:!0,useBothWheelAxes:!0}),i.resize(!1,!0)),o===!0&&setTimeout(function(){i.update_scroll_position(!1,Math.floor(i.info.playlist_width/16*9)*(i.playlist_count-n))},10),{items:t,count:n}},i.check_youtube_api_ready=function(){if(i.info.alternative_api_ready_check){if(typeof YT!=typeof{})return!1;if(0==YT.loaded)return!1}else if(!e("body").hasClass("yesp-youtube-iframe-ready"))return!1;return!0},i.create_youtube_element=function(){if(!i.check_youtube_api_ready())return void setTimeout(i.create_youtube_element,10);if(!i.info.youtube_loaded){i.info.youtube_loaded=!0;var e={controls:0,showinfo:0,fullscreen:0,iv_load_policy:i.options.show_annotations?1:3,fs:0,wmode:"opaque"};i.options.force_hd&&(e.vq="hd720"),i.options.hide_youtube_logo&&(e.modestbranding=1);for(var o in i.options.player_vars)e[o]=i.options.player_vars[o];window.YTConfig={host:"https://www.youtube.com"},i.youtube=new YT.Player(i.id+"_yt",{playerVars:e,events:{onReady:i.youtube_ready,onStateChange:i.youtube_state_change}})}},i.youtube_ready=function(){setInterval(i.youtube_player_updates,500),0!=i.playlist_count&&(i.play_video(i.options.first_video,!i.options.autoplay,!0),i.options.volume!==!1&&i.update_volume(0,i.options.volume),i.$el.find(".yesp-container").hover(function(){i.info.hover=!0,i.show_controls()},function(){i.info.hover=!1;var e=i.youtube.getPlayerState();(!i.options.show_controls_on_pause||-1!=e&&0!=e&&2!=e&&5!=e)&&(i.options.show_controls_on_play||i.hide_controls()),i.hide_share()}))},i.youtube_player_updates=function(){if(i.info.current_time=i.youtube.getCurrentTime(),i.youtube.getCurrentTime()||(i.info.current_time=0),i.info.duration=i.youtube.getDuration(),i.info.duration&&i.info.current_time!=i.info.previous_time){i.info.previous_time=i.info.current_time,i.$controls.time.html("full"==i.options.time_indicator?i.format_time(i.info.current_time)+" / "+i.format_time(i.info.duration):i.format_time(i.info.current_time));var e=Math.round(i.info.current_time);0==e?i.$controls.youtube.attr("href",i.$controls.youtube.attr("data-href")):i.$controls.youtube.attr("href",i.$controls.youtube.attr("data-href")+"#t="+e),i.info.current_video_url=i.$controls.youtube.attr("data-href");var o=100*i.info.current_time/i.info.duration;i.$controls.time_bar_time.css("width",o+"%"),i.$controls.time_bar_buffer.css("width",100*i.youtube.getVideoLoadedFraction()+"%"),i.options.on_time_update(i.info.current_time)}},i.youtube_state_change=function(e){var o=e.data;0==o?i.options.continuous?i.forward():(i.play_video(i.info.index,!0),i.$controls.play.removeClass("yesp-icon-play").removeClass("yesp-icon-pause").addClass("yesp-icon-undo"),i.show_controls()):1==o||3==o?i.$controls.play.removeClass("yesp-icon-play").addClass("yesp-icon-pause").removeClass("yesp-icon-undo"):2==o&&i.$controls.play.addClass("yesp-icon-play").removeClass("yesp-icon-pause").removeClass("yesp-icon-undo"),i.info.first_play||-1===o||5===o||(i.info.first_play=!0),i.youtube_player_updates(),i.options.on_state_change(o)},i.create_player_element=function(){i.$el.css("width","100%").addClass("yesp").html('<div class="yesp-container"><div class="yesp-autoposter"><div class="yesp-autoposter-icon"><div></div></div></div><div class="yesp-video-container"><div class="yesp-video" id="'+i.id+'_yt"></div><div class="yesp-error"></div></div></div><div class="yesp-playlist"><div class="yesp-next-page"><i class="yesp-icon yesp-icon-plus"></i>Load More</div></div><div class="yesp-hp"><div class="yesp-hp-videos"><div class="yesp-hp-next-page"><i class="yesp-icon yesp-icon-plus"></i></div></div></div>'),i.$el.find(".yesp-video-container").click(function(){i.play_pause()}),"horizontal"==i.options.playlist_type&&i.$el.find(".yesp-playlist").remove(),i.$el.find(".yesp-next-page, .yesp-hp-next-page").click(function(){i.get_playlist_next()}),i.$el.find(".yesp-autoposter").click(function(e){e.preventDefault(),i.play()})},i.create_controls=function(){var o=e('<div class="yesp-controls"></div>');o.html('<div class="yesp-controls-wrapper"><a href="#" class="yesp-play yesp-icon yesp-icon-play"></a><div class="yesp-time">00:00 / 00:00</div><div class="yesp-bar"><div class="yesp-bar-buffer"></div><div class="yesp-bar-time"></div></div><div class="yesp-volume"><a href="#" class="yesp-volume-icon yesp-icon yesp-icon-volume-up" title="Toggle Mute"></a><div class="yesp-volume-bar"><div class="yesp-volume-amount"></div></div></div><a href="#" class="yesp-share yesp-icon yesp-icon-share-square-o" title="Share"></a><a href="#" target="_blank" class="yesp-youtube yesp-icon yesp-icon-youtube-play" title="Open in YouTube"></a><a href="#" class="yesp-backward yesp-icon yesp-icon-backward" title="Previous Video"></a><a href="#" class="yesp-forward yesp-icon yesp-icon-forward" title="Forward Video"></a><a href="#" class="yesp-playlist-toggle yesp-icon yesp-icon-align-justify yesp-icon-rotate-180" title="Toggle Playlist"></a><a href="#" class="yesp-fullscreen yesp-icon yesp-icon-expand" title="Toggle Fullscreen"></a></div>'),i.$controls.play=o.find(".yesp-play"),i.$controls.time=o.find(".yesp-time"),i.$controls.time_bar=o.find(".yesp-bar"),i.$controls.time_bar_buffer=o.find(".yesp-bar-buffer"),i.$controls.time_bar_time=o.find(".yesp-bar-time"),i.$controls.volume=o.find(".yesp-volume"),i.$controls.volume_icon=o.find(".yesp-volume-icon"),i.$controls.volume_bar=o.find(".yesp-volume-bar"),i.$controls.volume_amount=o.find(".yesp-volume-amount"),i.$controls.share=o.find(".yesp-share"),i.$controls.youtube=o.find(".yesp-youtube"),i.$controls.forward=o.find(".yesp-forward"),i.$controls.backward=o.find(".yesp-backward"),i.$controls.playlist_toggle=o.find(".yesp-playlist-toggle"),i.$controls.fullscreen=o.find(".yesp-fullscreen"),i.options.play_control||i.$controls.play.hide(),i.options.time_indicator?"full"==i.options.time_indicator&&i.$controls.time.addClass("yesp-full-time"):i.$controls.time.hide(),i.options.volume_control||i.$controls.volume.hide(),i.options.share_control||i.$controls.share.hide(),i.options.youtube_link_control||i.$controls.youtube.hide(),i.options.fwd_bck_control||(i.$controls.backward.hide(),i.$controls.forward.hide()),i.options.fullscreen_control||i.$controls.fullscreen.hide(),i.options.playlist_toggle_control||i.$controls.playlist_toggle.hide(),o.appendTo(this.$el.find(".yesp-container")),i.$logo=e('<a href="#" target="_blank" class="yesp-youtube-logo"></a>'),i.$logo.appendTo(this.$el.find(".yesp-container")),(i.options.hide_youtube_logo||i.info.mobile)&&(i.$logo.hide(),i.options.hide_youtube_logo=!0)},i.create_title=function(){i.$title=e('<div class="yesp-title"></div>'),i.$title.html('<div class="yesp-title-wrapper"></div>'),i.$title.appendTo(i.$el.find(".yesp-container"))},i.update_title=function(e,o,t){i.$title.find("div.yesp-title-wrapper").html(i.options.show_channel_in_title?'<a href="'+t+'" target="_blank" class="yesp-subtitle">'+o+"</a>"+e:e)},i.create_overlays=function(){i.$social=e('<div class="yesp-social" data-show="0"><a href="#" class="yesp-social-button yesp-social-google yesp-icon yesp-icon-google-plus"></a><a href="#" class="yesp-social-button yesp-social-twitter yesp-icon yesp-icon-twitter"></a><a href="#" class="yesp-social-button yesp-social-facebook yesp-icon yesp-icon-facebook"></a></div>').appendTo(i.$el.find(".yesp-container")),i.$social.find(".yesp-social-facebook").click(function(e){e.preventDefault(),i.share_facebook()}),i.$social.find(".yesp-social-twitter").click(function(e){e.preventDefault(),i.share_twitter()}),i.$social.find(".yesp-social-google").click(function(e){e.preventDefault(),i.share_google()})},i.share_link=function(){},i.share_facebook=function(){window.open("https://www.facebook.com/sharer/sharer.php?u="+i.share_url(),"Share on Facebook","height=300,width=600")},i.share_twitter=function(){window.open("https://twitter.com/home?status="+i.share_url(),"Share on Twitter","height=300,width=600")},i.share_google=function(){window.open("https://plus.google.com/share?url="+i.share_url(),"Share on Google+","height=300,width=600")},i.bind_controls=function(){i.$controls.play.click(function(e){e.preventDefault(),i.play_pause()}),i.$controls.volume_icon.click(function(e){if(e.preventDefault(),i.youtube.isMuted())0==i.info.volume&&(i.info.volume=i.options.volume),i.update_volume(0,i.info.volume);else{var o=i.youtube.getVolume()/100;i.update_volume(0,0),i.info.volume=o}}),i.$controls.share.click(function(e){e.preventDefault(),i.toggle_share()}),i.$controls.youtube.click(function(){i.pause()}),i.$controls.backward.click(function(e){e.preventDefault(),i.backward()}),i.$controls.forward.click(function(e){e.preventDefault(),i.forward()}),i.$controls.fullscreen.click(function(e){e.preventDefault(),i.info.fullscreen?i.exit_fullscreen(!0):i.enter_fullscreen()}),i.$controls.playlist_toggle.click(function(e){e.preventDefault(),i.toggle_playlist()})},i.show_controls=function(){i.$title.stop().animate({opacity:1},250),i.$el.find(".yesp-controls").stop().animate({bottom:0,opacity:1},250),i.options.hide_youtube_logo||i.info.mobile||(i.info.youtube_logo_timer=setTimeout(function(){i.$logo.stop().fadeTo(250,.25,function(){i.$logo.css("opacity","")})},250))},i.hide_controls=function(e){"undefined"!=typeof e&&1==e?i.$el.find(".yesp-controls").stop().animate({bottom:0,opacity:0},250):i.$el.find(".yesp-controls").stop().animate({bottom:-50},250),i.info.youtube_logo_timer!==!1&&clearTimeout(i.info.youtube_logo_timer),i.$el.find(".yesp-youtube-logo").stop().fadeTo(350,0,function(){}),i.info.ios||i.$title.stop().animate({opacity:0},250)},i.play_pause=function(){var e=i.youtube.getPlayerState();2==e?i.play():0==e?(i.youtube.seekTo(0),i.play()):5==e?i.play():i.pause()},i.play=function(){i.youtube.playVideo(),i.$el.find(".yesp-autoposter").hide(),i.$controls.play.removeClass("yesp-icon-play").addClass("yesp-icon-pause").removeClass("yesp-icon-undo")},i.pause=function(){i.youtube.pauseVideo(),i.$controls.play.addClass("yesp-icon-play").removeClass("yesp-icon-pause").removeClass("yesp-icon-undo")},i.stop=function(){i.pause(),i.youtube.stopVideo()},i.forward=function(){i.info.index++,i.info.index>=i.playlist_count&&(i.info.index=0),i.play_video(i.info.index)},i.backward=function(){i.info.index--,i.info.index<0&&(i.info.index=i.playlist_count-1),i.play_video(i.info.index)},i.play_video=function(e,o,t){if(parseFloat(e,10)==e&&parseFloat(e,10)<=i.playlist_items.length)e=parseFloat(e,10);else{var n=e;e=0;for(var s=0;s<i.playlist_items.length;s++)if(i.playlist_items[s].snippet.resourceId.videoId===n){e=s;break}}var l=i.playlist_items[e];if(void 0!=l){"undefined"==typeof t&&(t=!1),i.info.mobile&&!i.info.first_play&&(o=!0);var a=l.snippet.title,r=l.snippet.channelTitle,p="https://www.youtube.com/channel/"+l.snippet.channelId,n=l.snippet.resourceId.videoId,u="https://www.youtube.com/watch?v="+n;if(i.update_title(a,r,p),"undefined"==typeof o||0==o?i.youtube.loadVideoById(n):i.youtube.cueVideoById(n),i.$logo.attr("href",u),i.$controls.youtube.attr("href",u).attr("data-href",u),i.info.current_video_url=u,i.$el.find(".yesp-playlist-video").attr("data-playing","0"),i.$el.find(".yesp-playlist-video[data-index="+e+"]").attr("data-playing","1"),i.$el.find(".yesp-hp-video").attr("data-playing","0"),i.$el.find(".yesp-hp-video[data-index="+e+"]").attr("data-playing","1"),i.$controls.time.html("full"==i.options.time_indicator?"00:00 / 00:00":"00:00"),i.$controls.time_bar_time.css("width",0),i.$controls.time_bar_buffer.css("width",0),i.info.index=e,i.update_scroll_position(t),o!==!0||i.info.mobile)i.$el.find(".yesp-autoposter").hide();else{var c=!1;"undefined"!=typeof l.snippet.thumbnails.maxres?c=l.snippet.thumbnails.maxres.url:"undefined"!=typeof l.snippet.thumbnails.high?c=l.snippet.thumbnails.high.url:"undefined"!=typeof l.snippet.thumbnails.medium?c=l.snippet.thumbnails.medium.url:"undefined"!=typeof l.snippet.thumbnails.standard?c=l.snippet.thumbnails.standard.url:"undefined"!=typeof l.snippet.thumbnails["default"]&&(c=l.snippet.thumbnails["default"].url),c!==!1&&i.$el.find(".yesp-autoposter").css("background-image",'url("'+c+'")').show()}i.options.on_load(l.snippet)}},i.update_scroll_position=function(e,o){if("horizontal"===i.options.playlist_type){var t=160*i.info.index;return"undefined"!=typeof o&&(t=o),void(1==e?(i.$el.find(".yesp-hp").scrollLeft(t),i.$el.find(".yesp-hp").perfectScrollbar("update")):i.$el.find(".yesp-hp").stop().animate({scrollLeft:t},500,function(){i.$el.find(".yesp-hp").perfectScrollbar("update")}))}var t=Math.floor(i.info.playlist_width/16*9)*i.info.index;"undefined"!=typeof o&&(t=o),0>t&&(t=0);var n=i.$el.find(".yesp-playlist").innerHeight(),s=Math.floor(i.info.playlist_width/16*9)*i.playlist_count,l=s-n;i.info.next_page_token&&(l+=50),t>l&&(t=l),1==e?(i.$el.find(".yesp-playlist").scrollTop(t),i.$el.find(".yesp-playlist").perfectScrollbar("update")):i.$el.find(".yesp-playlist").stop().animate({scrollTop:t},500,function(){i.$el.find(".yesp-playlist").perfectScrollbar("update")})},i.toggle_fullscreen=function(){i.info.fullscreen?i.exit_fullscreen(!0):i.enter_fullscreen()},i.enter_fullscreen=function(){i.info.mobile;var o=i.$el.find(".yesp-container")[0].webkitRequestFullScreen||i.$el.find(".yesp-container")[0].requestFullScreen||i.$el.find(".yesp-container")[0].mozRequestFullScreen;if(o){var t=e(window).width(),n=e(window).height();i.info.fullscreen=!0,i.$el.find(".yesp-container, .yesp-container iframe").css({width:"100%",height:"100%"}),i.youtube.setSize(t,n),o.bind(i.$el.find(".yesp-container")[0])()}},i.exit_fullscreen=function(e){"undefined"!=typeof e&&e&&(document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen()),i.info.fullscreen=!1,i.resize()},i.toggle_playlist=function(){"horizontal"===i.options.playlist_type?i.info.horizontal_playlist_shown?i.hide_horizontal_playlist():i.show_horizontal_playlist():(i.info.playlist_shown?i.hide_playlist(!1):i.show_playlist(!1),"auto"!==i.options.show_playlist&&i.resize())},i.show_playlist=function(e,o){if("horizontal"!=i.options.playlist_type&&("undefined"==typeof o&&(o=!0),e=!0,!i.info.playlist_animating)){i.info.playlist_animating=!0;var t=i.$el.find(".yesp-playlist");return i.$el.find(".yesp-icon-list").removeClass("yesp-icon-list").addClass("yesp-icon-align-justify"),e?(t.css("width",i.info.playlist_width),i.info.playlist_shown=!0,i.info.playlist_animating=!1,void(o&&i.resize(!0))):void 0}},i.hide_playlist=function(e,o){if("undefined"==typeof o&&(o=!0),e=!0,!i.info.playlist_animating){i.info.playlist_animating=!0;var t=i.$el.find(".yesp-playlist");return"vertical"==i.options.playlist_type&&i.$el.find(".yesp-icon-align-justify").removeClass("yesp-icon-align-justify").addClass("yesp-icon-list"),e?(t.css("width",0),i.info.playlist_shown=!1,i.info.playlist_animating=!1,void(o&&i.resize(!0))):void 0}},i.show_horizontal_playlist=function(){i.info.horizontal_playlist_shown=!0,i.$el.find(".yesp-hp").show(),i.$el.find(".yesp-icon-list").removeClass("yesp-icon-list").addClass("yesp-icon-align-justify")},i.hide_horizontal_playlist=function(){i.info.horizontal_playlist_shown=!1,i.$el.find(".yesp-hp").hide(),i.$el.find(".yesp-icon-align-justify").removeClass("yesp-icon-align-justify").addClass("yesp-icon-list")},i.set_playlist_width=function(e){i.info.playlist_shown&&(i.info.playlist_width=e);var o=Math.floor(e/16*9);i.$el.find(".yesp-playlist").css({width:e}).find(".yesp-playlist-video").css({width:e,height:o}),i.$el.find(".yesp-playlist .yesp-playlist-current").css("width",e-20),100>=e?(i.$el.find(".yesp-playlist").addClass("yesp-playlist-simple"),i.$el.find(".yesp-playlist .yesp-playlist-current").css("width",10)):i.$el.find(".yesp-playlist").removeClass("yesp-playlist-simple")},i.resize=function(o,t){("undefined"==typeof o||typeof o==typeof{})&&(o=!1);var n=i.$el.innerWidth();"auto"==i.options.show_playlist&&0==o?(660>n&&(1==t||200==i.info.playlist_width)&&(i.set_playlist_width(100),i.update_scroll_position(!0)),500>n&&(1==t||1==i.info.playlist_shown)&&(i.hide_playlist(!1,!1),i.update_scroll_position(!0)),n>=500&&(1==t||0==i.info.playlist_shown)&&(i.show_playlist(!1,!1),i.update_scroll_position(!0)),n>=660&&(1==t||100==i.info.playlist_width)&&(i.set_playlist_width(200),i.update_scroll_position(!0))):0==o&&(t=!0,660>n&&(1==t||200==i.info.playlist_width)&&(i.set_playlist_width(100),i.update_scroll_position(!0)),n>=660&&(1==t||100==i.info.playlist_width)&&(i.set_playlist_width(200),i.update_scroll_position(!0)),0==i.info.playlist_shown&&i.hide_playlist(!0,!1));var s=n-(i.info.playlist_shown?i.info.playlist_width:0),l=s/16*9;i.info.fullscreen&&(n=e(window).width(),s=n,l=e(window).height()),i.$el.find(".yesp-container, .yesp-playlist, .yesp-video").css("height",l),i.$el.find(".yesp-container, .yesp-video").css("width",s),i.$el.find(".yesp-playlist").perfectScrollbar("update"),i.info.width=s,i.info.height=l;var a=s-20;600>s&&"full"==i.options.time_indicator&&(i.options.time_indicator=!0,i.$controls.time.html(i.format_time(i.info.current_time)),i.$controls.time.removeClass("yesp-full-time")),530>s&&(i.options.fwd_bck_control=!1,i.options.youtube_link_control=!1,i.$controls.forward.hide(),i.$controls.backward.hide(),i.$controls.youtube.hide()),400>s&&(i.options.volume_control=!1,i.$controls.volume.hide()),300>s&&(i.options.time_indicator=!1,i.$controls.time.hide(),i.options.share_control=!1,i.$controls.share.hide()),s>=300&&(1==i.options_copy.time_indicator||"full"==i.options_copy.time_indicator)&&(i.options.time_indicator=!0,i.$controls.time.show()),s>=300&&1==i.options_copy.share_control&&(i.options.share_control=!0,i.$controls.share.show()),s>=400&&1==i.options_copy.volume_control&&(i.options.volume_control=!0,i.$controls.volume.show()),s>=530&&1==i.options_copy.fwd_bck_control&&(i.options.fwd_bck_control=!0,i.$controls.forward.show(),i.$controls.backward.show()),s>=530&&1==i.options_copy.youtube_link_control&&(i.options.youtube_link_control=!0,i.$controls.youtube.show()),s>=600&&"full"==i.options_copy.time_indicator&&(i.options.time_indicator="full",i.$controls.time.html(i.format_time(i.info.current_time)+" / "+i.format_time(i.info.duration)),i.$controls.time.addClass("yesp-full-time")),i.options.play_control&&(a-=30),i.options.time_indicator&&(a-=58),"full"==i.options.time_indicator&&(a-=40),i.options.volume_control&&(a-=110),i.options.share_control&&(a-=30),i.options.youtube_link_control&&(a-=30),i.options.fwd_bck_control&&(a-=60),i.options.fullscreen_control&&(a-=30),i.options.playlist_toggle_control&&(a-=30),a-=18,i.$controls.time_bar.css("width",a)},i.init_time_slider=function(){i.$controls.time_bar.on("mousedown",function(e){i.info.time_drag=!0,i.update_time_slider(e.pageX)}),e(document).on("mouseup",function(e){i.info.time_drag&&(i.info.time_drag=!1,i.update_time_slider(e.pageX))}),e(document).on("mousemove",function(e){i.info.time_drag&&i.update_time_slider(e.pageX)})},i.update_time_slider=function(e){if(0!=i.info.duration){var o=i.info.duration,t=e-i.$controls.time_bar.offset().left,n=100*t/i.$controls.time_bar.width();n>100&&(n=100),0>n&&(n=0),i.$controls.time_bar_time.css("width",n+"%"),i.youtube.seekTo(o*n/100),i.options.on_seek(o*n/100)}},i.init_volume_slider=function(){i.$controls.volume_bar.on("mousedown",function(e){i.info.volume_drag=!0,i.$controls.volume_icon.removeClass("yesp-icon-volume-off").addClass("yesp-icon-volume-up"),i.update_volume(e.pageX)}),e(document).on("mouseup",function(e){i.info.volume_drag&&(i.info.volume_drag=!1,i.update_volume(e.pageX))}),e(document).on("mousemove",function(e){i.info.volume_drag&&i.update_volume(e.pageX)})},i.update_volume=function(e,o){var t;if(o)t=100*o;else{var n=e-i.$controls.volume_bar.offset().left;t=100*n/i.$controls.volume_bar.width()}t>100&&(t=100),0>t&&(t=0),i.$controls.volume_amount.css("width",t+"%"),i.youtube.setVolume(t),0==t?i.youtube.mute():i.youtube.isMuted()&&i.youtube.unMute(),0==t?i.$controls.volume_icon.addClass("yesp-icon-volume-off").removeClass("yesp-icon-volume-up"):i.$controls.volume_icon.removeClass("yesp-icon-volume-off").addClass("yesp-icon-volume-up"),i.options.on_volume(t/100)},i.toggle_share=function(){"1"==i.$social.attr("show")?i.hide_share():i.show_share()},i.show_share=function(){i.$social.attr("show","1").stop().animate({right:10},200)},i.hide_share=function(){i.$social.attr("show","0").stop().animate({right:-140},200)},i.set_style=function(){var o=e("<style />"),t={controls_bg:"rgba(0,0,0,.75)",buttons:"rgba(255,255,255,.5)",buttons_hover:"rgba(255,255,255,1)",buttons_active:"rgba(255,255,255,1)",time_text:"#FFFFFF",bar_bg:"rgba(255,255,255,.5)",buffer:"rgba(255,255,255,.25)",fill:"#FFFFFF",video_title:"#FFFFFF",video_channel:"#DFF76D",playlist_overlay:"rgba(0,0,0,.5)",playlist_title:"#FFFFFF",playlist_channel:"#DFF76D",scrollbar:"#FFFFFF",scrollbar_bg:"rgba(255,255,255,.25)",load_more_bg:"#000000",load_more_text:"#FFFFFF"};for(key in i.options.colors)t[key]=i.options.colors[key];
o.html("#"+i.id+".yesp .yesp-controls{background:"+t.controls_bg+"!important}#"+i.id+".yesp .yesp-controls a{color:"+t.buttons+"!important}#"+i.id+".yesp .yesp-controls a:hover{color:"+t.buttons_hover+"!important}#"+i.id+".yesp .yesp-controls a:active{color:"+t.buttons_active+"!important}#"+i.id+".yesp .yesp-time{color:"+t.time_text+"!important}#"+i.id+".yesp .yesp-bar,#"+i.id+".yesp .yesp-volume .yesp-volume-bar{background:"+t.bar_bg+"!important}#"+i.id+".yesp .yesp-bar .yesp-bar-buffer{background:"+t.buffer+"!important}#"+i.id+".yesp .yesp-bar .yesp-bar-time,#"+i.id+".yesp .yesp-volume .yesp-volume-bar .yesp-volume-amount{background:"+t.fill+"!important}#"+i.id+".yesp .yesp-title-wrapper{color:"+t.video_title+"!important}#"+i.id+".yesp .yesp-title a.yesp-subtitle{border-color:"+t.video_title+"!important}#"+i.id+".yesp .yesp-title-wrapper a{color:"+t.video_channel+"!important}#"+i.id+".yesp .yesp-playlist-overlay,#"+i.id+".yesp .yesp-hp-overlay,#"+i.id+".yesp .yesp-playlist-current,#"+i.id+".yesp .yesp-hp-current{background: "+t.playlist_overlay+" !important;}#"+i.id+".yesp .yesp-playlist-overlay .yesp-playlist-title,#"+i.id+".yesp .yesp-hp-overlay .yesp-hp-title,#"+i.id+".yesp .yesp-playlist-current,#"+i.id+".yesp .yesp-hp-current{color: "+t.playlist_title+" !important;}#"+i.id+".yesp .yesp-playlist-overlay .yesp-playlist-channel,#"+i.id+".yesp .yesp-hp-overlay .yesp-hp-channel {color: "+t.playlist_channel+" !important;}#"+i.id+".yesp .ps-scrollbar-y-rail, #"+i.id+".yesp .ps-scrollbar-x-rail {background: "+t.scrollbar_bg+" !important;}#"+i.id+".yesp .ps-scrollbar-y,#"+i.id+".yesp .ps-scrollbar-x {background: "+t.scrollbar+" !important;}#"+i.id+".yesp .yesp-next-page,#"+i.id+".yesp .yesp-hp-next-page {background:"+t.load_more_bg+" !important;color:"+t.load_more_text+" !important;}"),o.appendTo("body")},i.format_time=function(e){var o=Math.floor(e/60)<10?"0"+Math.floor(e/60):Math.floor(e/60),t=Math.floor(e-60*o)<10?"0"+Math.floor(e-60*o):Math.floor(e-60*o);return o+":"+t},i.cut_text=function(e){return function(o,t){var i=t.substr(0,e);return/^\S/.test(t.substr(e))?i.replace(/\s+\S*$/,""):i}},i.share_url=function(){return i.info.current_video_url},i.detect_ie=function(){var e=window.navigator.userAgent,o=e.indexOf("MSIE "),t=e.indexOf("Trident/");if(o>0)return parseInt(e.substring(o+5,e.indexOf(".",o)),10);if(t>0){var i=e.indexOf("rv:");return parseInt(e.substring(i+3,e.indexOf(".",i)),10)}return!1},i.detect_touch=function(){return!!("ontouchstart"in window)||!!("onmsgesturechange"in window)},i.shuffle_array=function(e){for(var o=e.length-1;o>0;o--){var t=Math.floor(Math.random()*(o+1)),i=e[o];e[o]=e[t],e[t]=i}return e},i.init()},e.youtube_video.defaultOptions={playlist:!1,channel:!1,user:!1,videos:!1,player_id:!1,shuffle:!1,api_key:"AIzaSyAuL07vOpwHN0r2E3Sk2_k6KDgni8EjH2Q",max_results:50,pagination:!0,continuous:!0,first_video:0,show_playlist:"auto",playlist_type:"vertical",show_channel_in_playlist:!0,show_channel_in_title:!0,width:!1,show_annotations:!1,now_playing_text:"Now Playing",load_more_text:"Load More",force_hd:!1,hide_youtube_logo:!1,autoplay:!1,play_control:!0,time_indicator:"full",volume_control:!0,share_control:!0,fwd_bck_control:!0,youtube_link_control:!0,fullscreen_control:!0,playlist_toggle_control:!0,volume:!1,show_controls_on_load:!0,show_controls_on_pause:!0,show_controls_on_play:!1,player_vars:{},colors:{},on_load:function(){},on_done_loading:function(){},on_state_change:function(){},on_seek:function(){},on_volume:function(){},on_time_update:function(){}},e.fn.youtube_video=function(o){return this.each(function(){new e.youtube_video(this,o)})},e.fn.youtube_video_play=function(){return this.each(function(){new e.youtube_video_play(this)})},e.youtube_video_play=function(o){var t=e(o),i=t.data("youtube_video");i.play()},e.fn.youtube_video_pause=function(){return this.each(function(){new e.youtube_video_pause(this)})},e.youtube_video_pause=function(o){var t=e(o),i=t.data("youtube_video");i.pause()},e.fn.youtube_video_stop=function(){return this.each(function(){new e.youtube_video_stop(this)})},e.youtube_video_stop=function(o){var t=e(o),i=t.data("youtube_video");i.stop()},e.fn.youtube_video_seek=function(o){return this.each(function(){new e.youtube_video_seek(this,o)})},e.youtube_video_seek=function(o,t){var i=e(o),n=i.data("youtube_video"),s=n.info.duration,l=t/s*100;n.$controls.time_bar_time.css("width",l+"%"),n.youtube.seekTo(s*l/100),n.options.on_seek(t)},e.fn.youtube_video_load=function(o){return this.each(function(){new e.youtube_video_load(this,o)})},e.youtube_video_load=function(o,t){var i=e(o),n=i.data("youtube_video");n.play_video(t)},e.fn.youtube_video_volume=function(o){return this.each(function(){new e.youtube_video_volume(this,o)})},e.youtube_video_volume=function(o,t){var i=e(o),n=i.data("youtube_video");n.update_volume(0,t)},e.fn.youtube_show_controls=function(){return this.each(function(){new e.youtube_show_controls(this)})},e.youtube_show_controls=function(o){var t=e(o),i=t.data("youtube_video");i.show_controls()}}(jQuery);var tag=document.createElement("script");tag.src="https://www.youtube.com/iframe_api";var firstScriptTag=document.getElementsByTagName("script")[0];firstScriptTag.parentNode.insertBefore(tag,firstScriptTag);