/*




Flowplayer.js 
version 1.0
8/24/09






*/
function CreateFlowPlayer(v,p,a,img){
	
	if (typeof img == 'undefined'){
		var img = '/images/blk-vid.jpg';	
	}
	
$f("container", {src: '/flash/flowplayer-3.1.2.swf', wmode: 'opaque'}, { 
   
   clip:{autoPlay:a, url:'mp4:' + v, provider:p},
   
   
   canvas: { 
        backgroundImage: 'url(' + img + ')' 
    },
	
	
	log: { level: 'debug', filter: 'org.flowplayer.bwcheck.*' },
	
   plugins: { 
			
			// bandwidth check plugin 
        bwcheck: { 
            url: '/flash/flowplayer.bwcheck-3.1.1.swf', 
 
            // Influxis uses Flash Media Servers 
            serverType: 'fms', 
 
            // Use this connection for bandwidth detection 
            netConnectionUrl: 'rtmp://fms.calvaryftl.org/flvplayer/activeword', 
 
            // available bitrates for file names 
            bitrates: [56, 150, 700], 
 
            // use a customized urlPattern for file names 
            urlPattern: '{0}_{1}kb', 
 
            // this method is called when the bandwidth check is done 
            onBwDone: function(url, chosenBitrate, bitrate) { 
              //alert($f("container").getConfig().plugins.bwcheck.bitrates);
			  //$f("container").getConfig().plugins.bwcheck.bitrates = '700';
               //alert($f("container").getConfig().plugins.bwcheck.bitrates);
                var el = document.getElementById("info");
				var speed = "";
				if (bitrate <= 56) {
					speed = "low";	
					}
				if (bitrate > 56) {
					speed = "medium";	
					}					
				if (bitrate > 150){
					speed = "high";
				}

				el.innerHTML = "Bandwidth: " + speed + "<br />Video file served: " +url;
            } , 
			
			// called when stream is switched dynamically
			onStreamSwitch: function(bitrate, newUrl, oldUrl) {
				var el = document.getElementById("info");
				el.innerHTML = "Switched to stream: " + newUrl + "<br />current bitrate: " + bitrate;
			}
		},

			cca:{  url: '/flash/flowplayer.rtmp-3.1.1.swf',
			          netConnectionUrl: 'rtmp://fms.calvaryftl.org/flvplayer/cca'
				   },

			extend:{  url: '/flash/flowplayer.rtmp-3.1.1.swf',
			          netConnectionUrl: 'rtmp://fms.calvaryftl.org/flvplayer/activeword/extend'
				   },
			radio:{  url: '/flash/flowplayer.rtmp-3.1.1.swf',
			          netConnectionUrl: 'rtmp://fms.calvaryftl.org/flvplayer/activeword/radio'
				   },
		    tv:{  url: '/flash/flowplayer.rtmp-3.1.1.swf',
			          netConnectionUrl: 'rtmp://fms.calvaryftl.org/flvplayer/activeword/tv'
				   },
			announcements:{
				url: '/flash/flowplayer.rtmp-3.1.1.swf',
			          netConnectionUrl: 'rtmp://fms.calvaryftl.org/flvplayer/calvary/90-seconds'
			}
		
		     }
   
});

}

function CreateFlowPlayerNoBW(v,p,a,img){

	if (typeof img == 'undefined'){
		var img = '/images/blk-vid.jpg';	
	}
	
$f("container", {src: '/flash/flowplayer-3.1.2.swf', wmode: 'opaque'}, { 
   
   clip:{autoPlay:a,  url:'mp4:' + v, provider:p},
   
   
   canvas: { 
        backgroundImage: 'url(' + img + ')' 
    },
	
	
   plugins: { 
			
 
			cca:{  url: '/flash/flowplayer.rtmp-3.1.1.swf',
			          netConnectionUrl: 'rtmp://fms.calvaryftl.org/flvplayer/cca'
				   },
			extend:{  url: '/flash/flowplayer.rtmp-3.1.1.swf',
			          netConnectionUrl: 'rtmp://fms.calvaryftl.org/flvplayer/activeword/extend'
				   },
			radio:{  url: '/flash/flowplayer.rtmp-3.1.1.swf',
			          netConnectionUrl: 'rtmp://fms.calvaryftl.org/flvplayer/activeword/radio'
				   },
		    tv:{  url: '/flash/flowplayer.rtmp-3.1.1.swf',
			          netConnectionUrl: 'rtmp://fms.calvaryftl.org/flvplayer/activeword/tv'
				   },
			announcements:{
				url: '/flash/flowplayer.rtmp-3.1.1.swf',
			          netConnectionUrl: 'rtmp://fms.calvaryftl.org/flvplayer/calvary/90-seconds'
			}
		
		     }
   
});

}

// v = video to play, p = provider, or the location of the video
function playit(v,p){
//	$f("container").getPlugin("bwcheck").dynamic(true);
	$f("container").play({url:'mp4:' + v , provider:p});	
}

function setBitrate(b){
	//alert($f("container").getPlugin("bwcheck"));
	//$f("container").getPlugin("bwcheck").bitrates = '';
		//alert($f("container").getPlugin("bwcheck").bitrates);
	$f("container").getPlugin("bwcheck").setBitrate(b);
}

function playRadio(v,p){
//	alert($f("container").getConfig().plugins.bwcheck.bitrates);
  // 	$f("container").getConfig().plugins.bwcheck.bitrates = '46';
	//alert($f("container").getConfig().plugins.bwcheck.bitrates);
//alert($f("container").getPlugin("bwcheck").getBitrate);
//	$f("container").getPlugin("bwcheck").dynamic(false);

//$f("container").getPlugin("bwcheck").setBitrate(56);
$f("container").play({url:'mp4:' + v , provider:p});



//var x = $f("container").getPlugin("bwcheck").getBitrate;
//alert(x);
}