/*
 * LiquidPlumr.com FlowPlayer Video Parameters
 * Video: Liquid-Plumr Videos 2010	
 * Updated: 7/28/2010
 * 
 */
 
$(document).ready(function() {

	var video1 = document.getElementsByTagName('video')[0];
	var video2 = document.getElementsByTagName('video')[1];
	var video3 = document.getElementsByTagName('video')[2];

	
	$('a.videoPlayer').flowplayer({src: '/swf/flowplayer.commercial-3.0.7.swf', wmode: 'opaque'},  { 
			<!-- Licences: Needed to remove Flowplayer logo from player  -->
			 key: '@5fdd8e99a593a5f6ba7',	 <!-- liquidplumr.com Licence. Comment out when testing in Staging -->
			<!-- key: '#@5fdd8e99a593a5f6ba7',   -->		//<!--staging.liquidplumr.com Licence. Comment out when going Live -->
		
			// default clip
			clip:{ 
				autoPlay: true,
				autoBuffering: true

			},											
	
			canvas: {backgroundColor: '#FFFFFF'},
						
			plugins: {
				controls: {
					timeColor: '#f28b07',
					buttonOverColor: '#728B94',
					bufferColor: '#6c9cbc',
					backgroundColor: '#106C9A',
					buttonColor: '#0c50ac',
					sliderColor: '#2d378b',
					durationColor: '#f98e06',
					borderRadius: '23',
					progressGradient: 'medium',
					backgroundGradient: [0.6,0.3,0,0,0],
					sliderGradient: 'none',
					bufferGradient: 'none',
					progressColor: '#0b1484',
					fullscreen: false,
					opacity:1.0
				}
			}

	});

	// Initiate 1st Modal Video (Popup)
	$('#ugPopup1').overlay({
		target: 'div#video1',
		
		// IE6/7 fix: in order to make video play and then stop playing inside
		// of an overlay in IE, we need to manually play & stop the flowplayer
		// using the onLoad & onClose handlers

		onLoad: function(content) {
			if (jQuery.browser.msie) {
				$f('video-player1').play();
			} else {
				video1.currentTime = 0;
				video1.play();
				var curr_time = video1.currentTime ;		
			}
		},
		
		onClose: function(content) {
			if (jQuery.browser.msie) {
				$f('video-player1').stop();
			} else {		
				video1.pause();
			}
		}
	});
	
	// Track the plays of 1st video in Google analytics
	$('#ugPopup1').click(function() { 
		id = $(this).parent().attr("id");
		//alert(id);
		$clxcommon.trackAnalyticsPageView('clorox-video', id);
	});
	
	// Initiate 2nd Modal Video (Popup)
	$('#ugPopup2').overlay({
		target: 'div#video2',
	
		// IE6/7 fix: in order to make video play and then stop playing inside
		// of an overlay in IE, we need to manually play & stop the flowplayer
		// using the onLoad & onClose handlers

		onLoad: function(content) {
			if (jQuery.browser.msie) {
				$f('video-player2').play();
			} else {
				video2.currentTime = 0;
				video2.play();
				var curr_time = video2.currentTime ;		
			}
		},
		
		onClose: function(content) {
			if (jQuery.browser.msie) {
				$f('video-player2').stop();
			} else {
				video2.pause();
			}
		}
	});
	
	// Track the plays of 2nd video in Google analytics
	$('#ugPopup2').click(function() { 
		id = $(this).parent().attr("id");
		//alert(id);
		$clxcommon.trackAnalyticsPageView('clorox-video', id);
	});
	
	// Initiate 3rd Modal Video (Popup)
	$('#ugPopup3').overlay({
		target: 'div#video3',
	
		// IE6/7 fix: in order to make video play and then stop playing inside
		// of an overlay in IE, we need to manually play & stop the flowplayer
		// using the onLoad & onClose handlers

		onLoad: function(content) {
			if (jQuery.browser.msie) {
				$f('video-player3').play();
			} else {
				video3.currentTime = 0;
				video3.play();
				var curr_time = video3.currentTime ;		
			}
		},
		
		onClose: function(content) {
			if (jQuery.browser.msie) {
				$f('video-player3').stop();
			} else {
				video3.pause();
			}
		}
	});
	
	// Track the plays of 3rd video in Google analytics
	$('#ugPopup3').click(function() { 
		id = $(this).parent().attr("id");
		//alert(id);
		$clxcommon.trackAnalyticsPageView('clorox-video', id);
	});
	

});



