/*
 * Clorox2.com FlowPlayer Video Parameters
 * Video: Clorox2 Advert Video 2009	
 * Updated: 08/04/2010
 * 
 */

$(document).ready(function() {

	// set first li to be selected
	$('#video_bleach_nursery').css('background-color', '#e7f3ff');
		
	// play each video when the corresponding link is clicked
	$('li.playVideo').each( function(index) {
		
		$(this).click( function() { 
		    videoname = $(this).children('a').attr('href');    
		    $('li.playVideo').css('background-color', '');
		    $(this).css('background-color', '#e7f3ff');
		    
		    // play the clip specified in href- attribute with the first visible Flowplayer 
		    $f("*").each(function() { 
				
				playerEl = this.getParent();
	
				// find the first visible player
				if ($(playerEl).is (':visible') && $(playerEl).parents (':hidden').length == 0) {
		    		this.play(videoname);
		    		return false;	// found one! stop trying to find a visible player
				}
			});
		    
		    /***** show corresponding video title/description set *****/		    
		    var videoDescSetJQuery = $(playerEl).siblings('div.videoDesc');
		    
		    // hide all first
		    videoDescSetJQuery.hide();
		    
		    // show the one with the index
		    $(videoDescSetJQuery.get(index)).show();
		         
		    // by returning false normal link behaviour is skipped 
		    return false;
		});
		
	});

	
	// stop the flowplayer if a tab is clicked. this is mainly needed for IE
	// as FireFox etc. stops the flowplayer automatically
//	$('div.tabs ul.containerNav a').click(function () {
//	    
//	    if (jQuery.browser.msie) {
//		    if ($('div#videoPlayerStandardWashers object').length > 0)
//		            $f('videoPlayerStandardWashers').stop();
//		
//		    if ($('div#videoPlayerHEWashers object').length > 0)
//		            $f('videoPlayerHEWashers').stop();
//		
//		    if ($('div#videoPlayerPS object').length > 0)
//		            $f('videoPlayerPS').stop();
//			  	
//		    if ($('div#videoPlayerCarson object').length > 0)
//		            $f('videoPlayerCarson').stop();
//	    }
//
//	});

	
	
	// check if element exists before trying to initialize player
	if( $('div#videoPlayerCLB').length ) {
		$('div#videoPlayerCLB').flowplayer({src: '/swf/flowplayer.commercial-3.0.7.swf', wmode: 'opaque'},  { 
		
			<!-- Licences: Needed to remove Flowplayer logo from player  -->
			<!-- key: '@fa943acd24518e30046', -->	//<!-- clorox.com Licence. Comment out when testing in Staging -->
			key: '#@fa943acd24518e30046',  		//<!--staging.clorox.com Licence. Comment out when going Live -->
		
			// default clip
			clip:{ 
				url: '/swf/products/flv/video-nurseries.flv',
				autoPlay: true,
				autoBuffering: true,
				
				// track start event for this clip
				onStart: function(clip) { 
					_gaq.push(['_trackEvent', 'videoplayback', 'play', clip.url]);
				}, 
				// track pause event for this clip. time (in seconds) is also tracked 
				onPause: function(clip) { 
					_gaq.push(['_trackEvent', 'videoplayback', 'pause', clip.url, parseInt(this.getTime())]);
				}, 
				// track stop event for this clip. time is also tracked 
				onStop: function(clip) { 
					_gaq.push(['_trackEvent', 'videoplayback', 'stop', clip.url, parseInt(this.getTime())]);
				}, 
				// track finish event for this clip 
				onFinish: function(clip) { 
					_gaq.push(['_trackEvent', 'videoplayback', 'finish', clip.url]);
				} 
			},											
			
			// canvas: { backgroundImage: 'url(/img/video.jpg)' },
			
			plugins: {
				controls: {
					timeColor: '#f28b07',
					buttonOverColor: '#728B94',
					bufferColor: '#6c9cbc',
					backgroundColor: '#0162da',
					buttonColor: '#0c50ac',
					sliderColor: '#2d378b',
					durationColor: '#f98e06',
					progressGradient: 'medium',
					backgroundGradient: [0.6,0.3,0,0,0],
					sliderGradient: 'none',
					bufferGradient: 'none',
					progressColor: '#0b1484',
					fullscreen: false,
					opacity:1.0
				}
			}
		});
	}// if
	
	
	
	
	
		

});

	
