$(function() {

	// setup overlay actions to buttons
	$("img[rel]").overlay({
		
		// setup exposing (optional operation);
		onBeforeLoad: function() {
			this.expose();	
		},				
		
		onLoad: function(content) {
			// find the player contained inside this overlay and load it
			this.getContent().find("a.player").flowplayer(0).load();
		},
		
		onClose: function(content) {
			$f().unload();
			
			// cloase exposing
			$.expose.close();
		}
	});				
	
	// install flowplayers
	//$f("a.player", "flash/flowplayer-3.1.3.swf", { 
	$("a.player").flowplayer("flash/flowplayer-3.1.3.swf", { 
		// configure both players to use rtmp plugin 
		clip: { 
			provider: 'rtmp'
		}, 
		
		// here is our rtpm plugin configuration 
		plugins: {  
			rtmp: {  
				// use latest RTMP plugin release
				url: 'flash/flowplayer.rtmp-3.1.2.swf',			
				
				netConnectionUrl: 'rtmp://flash.streamingmediahosting.com/pureflix/'  
			},
			
			bwcheck: {
				url: 'flash/flowplayer.bwcheck-3.1.2.swf',
				
				serverType: 'fms',
				
				netConnectionUrl: 'rtmp://flash.streamingmediahosting.com/pureflix/',
				
				bitrates: [250,450,700],
				
				urlPattern: '{0}_{1}',
				
				onBwDone: function(url, chosenBitrate, bitrate) {					
					//alert( "Your speed is: " +bitrate+ "<br />Video file served: " +url );
				}
			}	
		}
	});
});