
   

  $(document).ready(function($)
    {
        videoPlayer = $("#Elite_video_player").Video({           //ALL PLUGIN OPTIONS


	
			instanceName:"player1", 
 instanceTheme: "dark",                  
            autohideControls:3,                     
            hideControlsOnMouseOut:"No", 
          playerLayout: "fitToContainer",
          playlist:"Off",              
		playlistScrollType: "light",	
            responsive:true, 
videoPlayerWidth: 1006,
        videoPlayerHeight: 420,
  lightBox: false,                				        
			playlistScrollType:"inset-2",                
			playlistBehaviourOnPageload:"closed",	
		        autoplay: true,        
			colorAccent:"#cc181e",                 
			vimeoColor:"ea5859",                   
            youtubeControls:"custom controls",		
			youtubeSkin:"dark",                  
            youtubeColor:"red",   
youtubeShowRelatedVideos: "No",                 
			      
            videoPlayerShadow:"effect1",           
	loadRandomVideoOnStart:"No",           
            shuffle: "No",
  posterImg: "",
        onFinish: "Play next video",
        nowPlayingText: "Yes",
    nowPlayingTooltipTxt: "IN RIPRODUZIONE",
playlistBtnClosedTooltipTxt: "Mostra Playlist",
playlistBtnOpenedTooltipTxt: "Nascondi",
  youtubeShowRelatedVideos:"No",

        fullscreen: "Fullscreen native",
        rightClickMenu: true,
        hideVideoSource: false,
        showAllControls: true,
        allowSkipAd: true,
        infoShow: "Yes",
        shareShow: "No",
        facebookShow: "No",
        twitterShow: "No",
        mailShow: "No",
        facebookShareName: "Elite video player",
        facebookShareLink: "http://codecanyon.net/item/elite-video-player-wordpress-plugin/10496434",
        facebookShareDescription: "Elite Video Player is stunning, modern, responsive, fully customisable high-end video player for WordPress that support advertising and the most popular video platforms like YouTube, Vimeo or self-hosting videos (mp4).",
        facebookSharePicture: "https://0.s3.envato.com/files/123866118/preview.jpg",
        twitterText: "Elite video player",
        twitterLink: "http://codecanyon.net/item/elite-video-player-wordpress-plugin/10496434",
        twitterHashtags: "wordpressvideoplayer",
        twitterVia: "Creative media",
        googlePlus: "http://codecanyon.net/item/elite-video-player-wordpress-plugin/10496434",
        logoShow: "Yes",
        logoClickable: "No",
        logoPath: "images/logo/telesmart.png",
        logoGoToLink: "http://codecanyon.net/",
        logoPosition: "bottom-left",
        embedShow: "No",
        embedCodeSrc: "www.yourwebsite.com/videoplayer/index.html",
        embedCodeW: "746",
        embedCodeH: "420",
        embedShareLink: "www.yourwebsite.com/videoplayer/index.html",
        youtubePlaylistID: "",
        youtubeChannelID: "",
            videos:[
          

                
                

            ]
        });
    });



function ChangeYoutubeVideo(youtubeIDpar)
{

debugger;
if(!videoPlayer.videoPlayingAD)

{
           
            
 var url = "https://www.googleapis.com/youtube/v3/videos?part=snippet&id="+youtubeIDpar+"&key=AIzaSyAwG7UOCUX0X9HZcCLORr5fvHk6KZHM_H4"
     $.ajax({
                    url: url,
                    success: function (data) {

                        $.each(data.items, function (i, item) {

                            var feedTitle = item.snippet.title;
                            var feedInfo = item.snippet.description;
                            var authorName = item.snippet.channelTitle;
                            var videoDateTime = new Date(item.snippet.publishedAt);
                            //if (self.options.youtubePlaylistID != "")
                               // var videoID = item.snippet.resourceId.videoId;
                            var thumb;
                            if (item.snippet.thumbnails != undefined)
                                thumb = item.snippet.thumbnails.default.url;
                            else
                                thumb = "";

                            var obj =
                            {
                                id: videoPlayer._playlist.videos_array.length,
                                title: feedTitle,
                                videoType: "youtube",
                                youtubeID: youtubeIDpar,
                                vimeoID:"",
                                video_path_mp4: "",
                                prerollAD: "",
                                prerollGotoLink: "",
                                preroll_mp4: "",
                                prerollSkipTimer: "",
                                midrollAD: "no",
                                midrollAD_displayTime: "5",
                                midrollGotoLink: "",
                                midroll_mp4: "http://creativeinteractivemedia.com/player/videos/Short_Elegant_Logo_Reveal.mp4",
                                midrollSkipTimer: "10",
                                postrollAD: "",
                                postrollGotoLink: "",
                                postroll_mp4: "",
                                postrollSkipTimer: "",
                                popupAdShow: "",
                                popupImg: "",
                                popupAdStartTime: "",
                                popupAdEndTime: "",
                                popupAdGoToLink: "",
                                description: authorName,
                                thumbImg: thumb,
                                info: feedInfo,
                                info_text: feedInfo,
                                videoDate:videoDateTime
                            };



                            videoPlayer._playlist.videos_array.push(obj);
                            videoPlayer._playlist.options.videos.push(obj);
                        });



                    videoPlayer._playlist.videoid = videoPlayer._playlist.videos_array.length-1;
 videoPlayer.setPlaylistItem(videoPlayer._playlist.videos_array.length-1);
               

videoPlayer.playVideoById(videoPlayer._playlist.videos_array.length-1);



  
                    }
                });

    





}
    // var url = new URI(window.location.href).search({ v: youtubeIDpar   });



  //history.pushState(youtubeIDpar, $(document).find("title").text(), url.toString());


scrollToDiv($("#Elite_video_player"),150);
 
}



function scrollToDiv(element,navheight){	
		var offset = element.offset();
		var offsetTop = offset.top;
		var totalScroll = offsetTop-navheight;
		
		jQuery('body,html').animate({
				scrollTop: totalScroll
		}, 500);
	}	
