/* -------------------------------------------------------------- 

Video player js by AREA 17

Relies on :
- flowplayer.js 3.1.2. The Flowplayer API
- flowplayer.controls.js 3.0.2. Flowplayer JavaScript plugin

Version date: 27th Sept 2009
Version 0.1 Alpha

-------------------------------------------------------------- */

var videoPlayerId = "videoPlayer";
var videoControlsId = 'videoControls';
var videoControlsBgId = 'videoControlsBg';

var myVideoControlsId = $('#' + videoControlsId);
var myVideoControlsBgId = $('#' + videoControlsBgId);

var intervalId = 0;
var controls = false;
var playing = false;

function showControls() {
	if (!controls) {
		controls = true;
		myVideoControlsId.fadeTo("slow", 1.0);
		myVideoControlsBgId.fadeTo("slow", 0.5);
	}

}

function hideControls() {
	if (controls) {
		clearTimeout(intervalId);
		myVideoControlsId.fadeTo("slow", 0);
		myVideoControlsBgId.fadeTo("slow", 0);
		controls = false;
	}
}

window.onload = function() { 
	
	if ($('#videoPlayer')[0]) {
	
	    $f(videoPlayerId, { src : "/assets/swf/flowplayer.commercial-3.1.5.swf", wmode : "transparent", allowscriptaccess : "always" }, { 

			key: '#$12e944facb3060813f3',
			
			play: { 
				opacity: 0
			},
			
	        clip: {
	            autoBuffering: false,
	
		        onStart: function(clip) {  
					pageTracker._trackEvent("Videos", "Play", clip.url); 
		        },  
		
		        onPause: function(clip) { 
		            pageTracker._trackEvent("Videos", "Pause", clip.url, parseInt(this.getTime())); 
		        }, 
		
		        onResume: function(clip) {  
		            pageTracker._trackEvent("Videos", "Resume", clip.url, parseInt(this.getTime())); 
		        }, 
		  
		        onSeek: function(clip) {  
		            pageTracker._trackEvent("Videos", "Seek", clip.url, parseInt(this.getTime())); 
		        },
		
		        onStop: function(clip) {  
		            pageTracker._trackEvent("Videos", "Stop", clip.url, parseInt(this.getTime())); 
		        },
		
		        onFinish: function(clip) { 
		            pageTracker._trackEvent("Videos", "Finish", clip.url); 
		        }
			
	        }, 

			onLoad: function() {
				$("#videoControlsWrap").css('z-index', '100');
				myVideoControlsId.append('<div class="slash">/</div>');
				showControls();
				intervalId = setTimeout(hideControls, 4000);
			},

			onMouseOut: function() {
				hideControls();
			},
	
			onMouseOver: function() {
				showControls();
				intervalId = setTimeout(hideControls, 4000);
			},
			
			plugins: { controls: null }
	

	    }).controls(videoControlsId, {duration: 0}); 
	
		$('div.track').css('width', '455px');
		
	}
}; 


