
$(function() {
	
$f("a.player", {
	src: '/scripts/flowplayer-3.1.5.swf', 
	bgcolor:'#ebebeb', 
	wmode: 'opaque',
     onFail: function() { 
	 	//$f(0).unload();
	 	document.getElementById("player").innerHTML ='';
		$("a.player").animate({width:965, height:125}, 1000);       
        //alert( "You need the latest Flash version to see MP4 movies. " +  "Your version is " + this.getVersion()); 
    }
	}, {
	canvas: { 
        backgroundColor:'#ebebeb', 
		backgroundGradient: 'none' 
    },	  
	
	screen: { 
        height:260, 
        top:0         
    },

	plugins:  { 
   	 	controls: {             
       		backgroundGradient: 'none',
			backgroundColor: 'transparent',
			all:false,
			mute: false,
            onBeforeShowed: function(host, hostIndex  ) { 
				alert("onBeforeShowed host : " +host );
			
                //var el = document.getElementById("info"); 
                //el.innerHTML = "Your speed is: " +bitrate+ " Video file served: " +url; 
            },
			autoHide: 'always' 
             
        },

		bwcheck: {  
		    url: '/scripts/flowplayer.bwcheck-3.1.3.swf',  
		    netConnectionUrl: '/scripts/bw-check.swf',
			//netConnectionUrl: '/scripts/flowplayer-3.1.0.swf'
		    defaultBitrate: 250,
			//rememberBitrate: false,
		    bitrates: [250,500,1000],
			//bitrates: { low: 250, mid: 500, high: 1000 } 
		     //{0} is filename, {1} is bitrate, {2} is extension
		    urlPattern: '{0}-{1}.{2}',
            onConnect: function(host, hostIndex  ) { 
				//alert("onConnect : " +host );
			
                //var el = document.getElementById("info"); 
                //el.innerHTML = "Your speed is: " +bitrate+ " Video file served: " +url; 
            },
            onConnectFailed: function(host, hostIndex  ) { 
				//alert("onConnectFailed host : " +host );
			
                //var el = document.getElementById("info"); 
                //el.innerHTML = "Your speed is: " +bitrate+ " Video file served: " +url; 
            },

            onBwDone: function(url, mappedBitrate, detectedBitrate ) { 
				//alert("Your speed is: " +detectedBitrate + "\nchosenBitrate: " +mappedBitrate+ "\nVideo file served: " +url);
                //var el = document.getElementById("info"); 
                //el.innerHTML = "Your speed is: " +bitrate+ " Video file served: " +url; 
            } 

		}


	},

   clip: { 
		onStart: function() {
			//alert("onStart");	
		},
		urlResolvers: 'bwcheck',
		//autoPlay: true,
		autoBuffering: true
    },

	// 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:965, height:260}, 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() {
		$(this.getParent()).animate({width:965, height:125}, 1000, function()  {
				
			// make play button visible again
			$(this).find("img").fadeIn();		
		});				
	}, 
	
	// when playback finishes perform our custom unload action
	onLoad : function() {
		//alert("onLoad : " );
	},

	onPause: function() {
		this.unload();	
	},
	onFinish: function() {
		this.unload();	
	},
	onError: function(errorMessage,errorCode ) {
		//alert(errorMessage);	
	}

});



});


