var VideoPlayer = Class.create();
VideoPlayer.prototype = {

initialize : function() {
}, // End initialize().

loadFlash : function() {

	var url = window.location.href;

	// Get the starting video ID from the URL.
	var startingVideoId = '';
	var hashPos = url.indexOf( '#' );
	if ( hashPos >= 0 ) startingVideoId = url.substr( hashPos + 1 );

	// Get the console parameter from the URL.
	var urlParams = url.toQueryParams();
	var showConsole = ( urlParams.showConsole == "true" );

	var flashvars = {
		flashDir        : '../flash/media/tv-commercials/',
		startingVideoId : startingVideoId,
		useJavaScript   : 'true',
		showConsole     : '' + showConsole
	};

	var params = {
		menu    : 'false',
		wmode   : 'transparent',
		bgcolor : '#ffffff'
	};

	swfobject.embedSWF( '../flash/media/tv-commercials/tv-commercials.swf',
			'my_flashContent', '940', '620', '8.0.0',
			null, flashvars, params, null );

}, // End loadFlash().

updateUrl : function( videoId ) {

	window.location.href = '#' + videoId;

}, // End updateUrl().

trackPath : function( path ) {

	pageTracker._trackPageview( '/media/tv-commercials/tracking/' + path );

} // End trackPath().

} // End class VideoPlayer.

var videoPlayer = new VideoPlayer();

// ---- Functions called from the Flash movie. ----

function updateUrl( videoId ) {
	videoPlayer.updateUrl( videoId );
} // End updateUrl().

function trackPath( path ) {
	videoPlayer.trackPath( path );
} // End trackPath().
