$(function() {
needstart = true;
	
$f("a.player", "/media/player/flowplayer-3.0.7.swf", {
	// perform custom stuff before default click action
	onBeforeClick: function() {
		if (needstart == false) {
			return false;
		}
		
		// unload previously loaded player
		$f().unload();
		
		// get wrapper element as jQuery object
		var wrap = $(this.getParent());
		
		// hide nested play button
		wrap.find("img").fadeOut(1000);
		
		// start growing animation
		wrap.animate({width:400, height:320}, 1000, 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() {
		// make play button visible again
		$(this.getParent()).find("img").fadeIn(1000);

		$(this.getParent()).animate({width:130, height:97}, 1000);
		needstart = true;
		return false;
	}, 
	
	// when playback finishes perform our custom unload action
	onFinish: function() {
                this.stop();
		this.unload();
		//alert('finish!');
		//$f().unload();
	},


    clip: { 
        onStop: function() { 
		if (needstart == false) {
			return false;
		}

		needstart = false;
		$f().unload();

		return false;
        }
    }, 

    plugins: { 
        controls: {
          stop:true,
          
          backgroundColor: '#846635',
          borderRadius: '10',
          timeColor: '#6e340d',
          durationColor: '#ffffff',
          progressColor: '#a24b10',
          bufferColor: '#e6d499',
          sliderColor: '#6e340d',
          buttonColor: '#c88051',
          buttonOverColor: '#d0946c'
        }
    }
	
});



});

