//This is the playlist code. When a video finsihes playing, play the next one.
$(document).ready( function(){
	console.log( "ready" );
	$("video-js").bind("play", function()
	{
		console.log( "video play" );
	});
	$("video-js").bind("ended", function()
	{
		console.log( "video ended" );
	});
	$("video-js").bind("onended", function()
	{
		console.log( "video onended" );
		/*
		alert( "video ended" );
		var playlistLength = $('.video-playlist ul li').size() - 1;
		var currentEl = $('.video-playlist ul li.current').index();
		nextEl = (currentEl+1) % playlistLength;
		alert( currentEl + " -> " + nextEl );
		*/
	});
});

/*
$('video-js').bind('ended', function() 
{   
	//jQuery .size() starts counting at 1, so we need to subtract 1 to get the list to add up correctly with the way jQeury .eg() works.
	var listLength = $('.thumb-list').size() - 1;

	var currentEl = $(this).attr('id');
	var nextVideo = document.getElementById(currentEl);

	var n = $(this).attr('rel');
	n = parseInt(n);


	if (n < listLength) {
		n++;    
		var nextSrc = $('.thumb-list').children('li').children('a').eq(n).attr('href');             
		nextVideo.pause();
		nextVideo.currentTime = 0;
		nextVideo.src = nextSrc;
		nextVideo.load();
		nextVideo.play();
		$(this).attr('rel', n);
	} else {
		nextVideo.pause();
		nextVideo.currentTime = 0;
	}

});
*/
