function blink(obj) {
	obj.animate({opacity: 0},{queue:true});
	obj.animate({opacity: 1},{queue:true});
	obj.animate({opacity: 0},{queue:true});
	obj.animate({opacity: 1},{queue:true});
}

// Youtube player stuff
function handle_state(s) {
	if (s == 1) 
		blink($('a.movie-ctrl'));
}

function onYouTubePlayerReady(id) {
	$('#movie-div-'+id+' object')[0]
		.addEventListener("onStateChange","handle_state");
}	

$(function(){
	$('.movie').prepend('<a href="#" class="movie-ctrl">Bigger</a>');
	$('.movie a.movie-ctrl').click(function(event){
		event.preventDefault();
		var ctrl = $(this);
		var movie = ctrl.parent();
		if (ctrl.html() == 'Bigger') {
			ctrl.html('Smaller');
			movie.animate({left:'-=447px'},{queue:true});
			movie.animate({width:500,height:400},{queue:true});
		} else {
			ctrl.html('Bigger');
			movie.animate({width:189,height:167},{queue:true});
			movie.animate({left:'+=447px'},{queue:true});
		}
	});
});
