// FancyPlayer.js - A spicy mix of FancyBox and Flowplayer
var flowConfig = {
	key: '#$3faa6f609958f4194e2',
	logo: {
		url: ''
	},
	screen : {
		bottom: 0
	},
	manClip : {
		autoPlay: false,
		autoBuffering: true,
		onStart: function(clip){
			_gaq.push(['_trackEvent', 'Videos', 'Play', clip.url]);
		},
		onPause: function(clip){
			_gaq.push(['_trackEvent', 'Videos', 'Pause', clip.url, parseInt(this.getTime())]);
		},
		onStop: function(clip){
			_gaq.push(['_trackEvent', 'Videos', 'Stop', clip.url, parseInt(this.getTime())]);
		},
		onFinish: function(clip){
			_gaq.push(['_trackEvent', 'Videos', 'Finish', clip.url]);
		}
	},
	autoClip : {
		autoPlay: true,
		autoBuffering: true,
		metaData: false,
		scaling: 'fit',
		onStart: function(clip){
			_gaq.push(['_trackEvent', 'Videos', 'Play', clip.url]);
			if(jQuery('#rotating').children().size() > 0) clearInterval(rotateInterval);
		},
		onPause: function(clip){
			_gaq.push(['_trackEvent', 'Videos', 'Pause', clip.url, parseInt(this.getTime())]);
		},
		onStop: function(clip){
			_gaq.push(['_trackEvent', 'Videos', 'Stop', clip.url, parseInt(this.getTime())]);
		},
		onFinish: function(clip){
			_gaq.push(['_trackEvent', 'Videos', 'Finish', clip.url]);
			if(jQuery('#rotating').children().size() > 0) rotateInterval = setInterval(nextSlide, 8000);
		}
	},
	canvas: {
		backgroundColor: '#000000',
		backgroundGradient: 'none',
		borderRadius: 0
	},
	controls : {
		timeColor : "rgba(106, 106, 106, 1)",
		borderRadius : "0px",
		bufferGradient : "none",
		slowForward : true,
		backgroundColor : "rgba(0, 0, 0, 0.6)",
		volumeSliderGradient : "none",
		slowBackward : false,
		progressGradient : "none",
		time : true,
		height : 26,
		volumeColor : "rgba(0, 175, 239, 1)",
		tooltips : {
			stop : "Stop",
			slowMotionFBwd : "Fast backward",
			previous : "Previous",
			next : "Next",
			play : "Play",
			buttons : true,
			slowMotionFwd : "Slow forward",
			pause : "Pause",
			unmute : "Unmute",
			fullscreen : "Fullscreen",
			slowMotionFFwd : "Fast forward",
			marginBottom : 5,
			fullscreenExit : "Exit fullscreen",
			volume : true,
			scrubber : true,
			slowMotionBwd : "Slow backward",
			mute : "Mute"
		},
		opacity : 1,
		fastBackward : false,
		border : "0px",
		bufferColor : "rgba(106, 106, 106, 1)",
		volumeSliderColor : "rgba(106, 106, 106, 1)",
		buttonColor : "rgba(106, 106, 106, 1)",
		mute : true,
		autoHide : {
			enabled : true,
			hideDelay : 500,
			hideStyle : "fade",
			mouseOutDelay : 500,
			hideDuration : 400,
			fullscreenOnly : false
		},
		backgroundGradient : "none",
		width : "100pct",
		display : "block",
		buttonOverColor : "rgba(255, 255, 255, .8)",
		url : "flowplayer.controls-3.2.5.swf",
		fullscreen : false,
		timeBgColor : "rgba(0, 0, 0, 0)",
		scrubberBarHeightRatio : 0.3,
		bottom : 0,
		stop : false,
		zIndex : 1,
		sliderColor : "#000000",
		scrubberHeightRatio : 0.4,
		tooltipTextColor : "rgba(255, 255, 255, 1)",
		sliderGradient : "none",
		timeBgHeightRatio : 0.3,
		volumeSliderHeightRatio : 0.4,
		name : "controls",
		volumeBarHeightRatio : 0.3,
		left : "50pct",
		tooltipColor : "rgba(106, 106, 106, 1)",
		playlist : false,
		bottom : 0,
		durationColor : "rgba(106, 106, 106, 1)",
		play : true,
		fastForward : true,
		timeBorder : "1px solid rgba(0, 0, 0, 0.3)",
		progressColor : "rgba(0, 175, 239, 1)",
		volume : true,
		scrubber : true,
		builtIn : false
	}
};

var flowAudioConfig = {
	key: '#$3faa6f609958f4194e2',
	logo: {
		url: ''
	},
	clip: {
		autoPlay: false,
		onStart: function(clip){
			_gaq.push(['_trackEvent', 'Audio', 'Play', clip.url]);
		},
		onPause: function(clip){
			_gaq.push(['_trackEvent', 'Audio', 'Pause', clip.url, parseInt(this.getTime())]);
		},
		onStop: function(clip){
			_gaq.push(['_trackEvent', 'Audio', 'Stop', clip.url, parseInt(this.getTime())]);
		},
		onFinish: function(clip){
			_gaq.push(['_trackEvent', 'Audio', 'Finish', clip.url]);
		}
	},
	canvas: {
		backgroundColor: "#000000",
		backgroundGradient: "none",
		borderRadius: 0
	},
	plugins: {
		controls: {
			timeColor : "rgba(106, 106, 106, 1)",
			borderRadius : "0px",
			bufferGradient : "none",
			backgroundColor : "#000000",
			backgroundGradient: "none",
			volumeSliderGradient : "none",
			progressGradient : "none",
			time : true,
			height : 26,
			volumeColor : "rgba(0, 175, 239, 1)",
			height: 26,
			autoHide: false,
			tooltips : {
				buttons : false,
				unmute : "Unmute",
				volume : true,
				scrubber : true
			},
			border : "0px",
			bufferColor : "rgba(106, 106, 106, 1)",
			volumeSliderColor : "rgba(106, 106, 106, 1)",
			buttonColor : "rgba(106, 106, 106, 1)",
			mute : true,
			display : "block",
			buttonOverColor : "rgba(255, 255, 255, .8)",
			fullscreen : false,
			timeBgColor : "rgba(0, 0, 0, 0)",
			scrubberBarHeightRatio : 0.3,
			bottom : 0,
			stop : false,
			zIndex : 1,
			sliderColor : "#000000",
			scrubberHeightRatio : 0.4,
			tooltipTextColor : "rgba(255, 255, 255, 1)",
			sliderGradient : "none",
			timeBgHeightRatio : 0.3,
			timeFontSize: 10,
			volumeSliderHeightRatio : 0.4,
			volumeBarHeightRatio : 0.3,
			tooltipColor : "rgba(106, 106, 106, 1)",
			playlist : false,
			bottom : 0,
			durationColor : "rgba(106, 106, 106, 1)",
			play : true,
			timeBorder : "1px solid rgba(0, 0, 0, 0.3)",
			progressColor : "rgba(0, 175, 239, 1)",
			volume : true,
			scrubber : true,
			builtIn : false
		}
	}
};
/*
jQuery(document).ready(function(){
	
	var videopath = '';
	var videoclip;
	var player;
	var vidid;
	var captions;
	var capShow;
	var ccbutShow;
	var wrap;
	var clipwidth;
	var clipheight;
	var pos;
	
	jQuery(".flowplay").hover(
		function(){
			videoclip = jQuery(this).attr("name");
		},
		function(){}
	);
	
	jQuery(".flowplay").fancybox({
		'titleShow' : false,
		'overlayOpacity' : .6,
		'overlayColor' : '#000',
		'zoomSpeedIn'    : 400,
		'zoomSpeedOut'   : 400,
		'easingIn'		 : 'easeOutBack',
		'easingOut'		 : 'easeInBack',
		'onComplete' : function(){
			player = $f("fancybox-inner",{src: swfplayer, wmode: 'opaque'},{
				play : { opacity: 0 },
				plugins: { controls: flowplayerConfig.controls },
				clip: {
					autoPlay:true,
					autoBuffering:true,
					url:videopath+videoclip+'',
					onStart:function(clip){
						wrap = jQuery(this.getParent());
						clipwidth = clip.metaData.width;
						clipheight = clip.metaData.height + 22;
						pos = jQuery.fn.fancybox.getViewport();
						jQuery("#fancy_outer").css({width:clipwidth+20,height:clipheight+20});
						jQuery("#fancy_outer").css('left', ((clipwidth + 36) > pos[0] ? pos[2] : pos[2] + Math.round((pos[0] - clipwidth	- 36) / 2)));
						jQuery("#fancy_outer").css('top',  ((clipheight + 50) > pos[1] ? pos[3] : pos[3] + Math.round((pos[1] - clipheight - 50) / 2)));
					},
					onFinish:function(){
						jQuery.fancybox.close();
					}
				}
			}); // end player
			player.load();
		},
		'onClosed':function(){
			jQuery("#fancy_content_api").remove();
		}
	});

});
*/
