var closePlaylist = function() {
    $('#video_playlist').css('top','5000px');
    $('#bc_player').css('top','47px');
    $('#bc_nowplaying .see_all').show();
}
var showPlaylist = function(){
    $('#video_playlist').css('top','47px');
    $('#bc_player').css('top','5000px');
    $('#bc_nowplaying .see_all').hide();
}

$(document).ready(function() { 
    $('#video_playlist .close-button').click(closePlaylist);
    $('#bc_nowplaying .see_all').click(showPlaylist);
    $('#player_wrapper').show();
    
	$('.scroll_section_video').jScrollPane({showArrows:true, scrollbarWidth: 27});
    if (typeof handleShowVideo != 'undefined') handleShowVideo();
    
    $(VideoPlayer).bind('playerLoaded', function(){
		VideoPlayer.cueVideo($("#video_playlist .list-set .list .item:first").attr("rel"));
	});
    
	$('#video_playlist .scroll_section').jScrollPane({showArrows:true, scrollbarWidth: 27});
    $('#video_playlist .list-set .set .list ul li').click(function() {
        $('#video_playlist .close-button').click();
    });
    
	$("#video_playlist .list-set .list .item").click(function() {
		video_id = $(this).attr("rel");
		VideoPlayer.playVideo(video_id);
	});
});


$(VideoPlayer).bind('videoChanged', function() {    
    var vid = VideoPlayer.getCurrentVideo();
    $('#bc_nowplaying').slideDown();
    $('#bc_nowplaying .title').text(vid.displayName);
    $('#bc_nowplaying .desc').text(vid.shortDescription).truncateText({length: '110'});    
});