$(function() {
	
$f("a.player", "/_media/flowplayer/flowplayer-3.0.0.swf", {

        plugins:  { 
            controls: { 
                play:true,  
                scrubber:true,
				timeColor: '#cccccc',
				bufferColor: '#99cc00' 
            }         
        },
		clip: {
			scaling: 'fit'
			},

	// perform custom stuff before default click action
	onBeforeClick: function() {
		
		// unload previously loaded player
		$f().unload();
		
		// get wrapper element as jQuery object
		var wrap = $(this.getParent());
		
		// hide nested play button
		wrap.find("img").fadeOut();
		
		// start growing animation
		wrap.animate({width:400, height:248}, 500, function() {
		
			// when animation finishes we will load our player
			$f(this).load();
			
		});	
		
		// disable default click behaviour (player loading)
		return false; 
	}, 

	// unload action resumes to original state		
	onUnload: function() {
		$(this.getParent()).animate({width:400, height:110}, 500, function()  {
				
			// make play button visible again
			$(this).find("img").fadeIn();		
		});				
	}, 
	
	// when playback finishes perform our custom unload action
	onFinish: function() {
		this.unload();	
	}
	
});

});
