$(document).ready(function(){

	$(document).ready(function(){

		var x = 0;	// counter variable for the films arrays
		var currFilmIndex = 0;	// stores the index of the current film

		var filmsArray = new Array();
		filmsArray[0] = "/projects/britannica/mp4/SHOWstudio_ritesnrituals_Britannica_low.mp4";
		filmsArray[1] = "/projects/britannica/mp4/SHOWstudio_interview_Britannica_low.mp4";

		$('.VideoPlayer').attr('href', '/swf/mediaplayer_white.swf?file='+ filmsArray[0] + '&backcolor=0xffffff&frontcolor=0x000000&screencolor=0xffffff&autostart=true');	
		$('.VideoPlayer').media( {   width: 640, height: 382, params:{allowFullScreen:true}, bgColor:'#0F0F0F', flashVersion:'9'  });											

		selectSecond();

		// initialize google Stats
		$.gaTracker('UA-7210865-1');
		$.fn.media.defaults.flashvars = { plugins:'googlytics-1'};

		// when clicking the individual films load the corresponding player
		$('#VideoThumbnails a:first').mousedown(function() {
				currFilmIndex = $(this).attr("href").substring(1);
				loadCurrentFilm();
				selectFirst();	
		});

		// when clicking the individual films load the corresponding player
		$('#VideoThumbnails a:last').mousedown(function() {
				currFilmIndex = $(this).attr("href").substring(1);
				loadCurrentFilm();
				selectSecond();
		});

		function loadCurrentFilm(){
				$('.VideoPlayer').attr('href', '/swf/mediaplayer_white.swf?file='+ filmsArray[currFilmIndex] + '&backcolor=0xffffff&frontcolor=0x000000&screencolor=0xffffff&autostart=true');	
				$('.VideoPlayer').media( {   width: 640, height: 382, params:{allowFullScreen:true}, bgColor:'#0F0F0F', flashVersion:'9'  });											
		}

		function selectFirst()		{
			$('#VideoThumbnails a:first').addClass("selected");
			$('#VideoThumbnails a:last').removeClass("selected");		
		}

		function selectSecond()		{
			$('#VideoThumbnails a:first').removeClass("selected");
			$('#VideoThumbnails a:last').addClass("selected");	
		}

		function removeSelectedNav()		{
				$('#VideoThumbnails a').removeClass("selected");			
		}

	});

});


