/* Elliot Barer, ebarer [at] mac [dot] com, XX/YY/2011 */


$(document).ready(function() {
	$('.thumbnails .video').hover(function(){
		$('img', this).animate({'opacity':'0.15'}, 250);
		$('span', this).animate({'opacity':'1'}, 250);
	}, function(){
		$('img', this).animate({'opacity':'1'}, 250);
		$('span', this).animate({'opacity':'0'}, 250);
	});


/* SUBNAV */
	$('#subnav a').click(function(){
		var $id = $(this).attr('id');
		
		$('.subnav').removeClass('active', function(){
			$('#'+$id).addClass('active');
		});
				
		$('.thumbnails, .manage').removeClass('active',300, function(){
			$('#'+$id+', #thumbs_'+$id).addClass('active',150);
			$('.manage').sortable('refresh');
		});
	});
	
	
/* SORTABLE */
	$('.manage').disableSelection();
	$('.manage').sortable({
		cursor:	'move',
		update:	function(){
			var $sort = $(this).sortable('serialize');
			$.post('sort_videos', $sort, function(msg){
				$('#message').html(msg);
			});
		}
	});


/* ON PAGE LOAD */
	$('body').removeClass('no-js');
	$('#commercials, #thumbs_commercials').addClass('active');


});
