document.observe('dom:loaded',function(){		
	var whitebox;
		
	$$('#cinema-adverts, #country-road-test, .panel.cinema-adverts, .panel.interactive-test').each(function(i) {
		i.observe('click', function(event){
			event.preventDefault();
			
			if(event.element().id == 'country-road-test') {				
				try {
					pageTracker._trackEvent('DrivingGame', 'Entry')
				} catch(err) {}				
			}
			
			window.location = $(this).down('a').href;			
		});
	});	
	
	$$('.share').each(function(i) {
		i.down('a').observe('click', function(event) {
			event.preventDefault();
		})
	})	
	
	if($('interactive-test')) {
			var params = {
				'allowscriptaccess':'always',
				'allowfullscreen':'true',
				'wmode':'transparent'
			}
			
			swfobject.embedSWF("/release/includes/flash/countryroadsinteractive680x470.swf", "interactive-test", 680, 470, "9.0.0", "", false, params);
	}
	
	$$('.video-link').each(function(j) {
		j.observe('click', function(event){
			if(player) {
				player.sendEvent('STOP');
			}
			hideVideos();
			var targetVideo = $(this).down('a').readAttribute("href").replace("#", "");
			var targetLink = "video-" + targetVideo;
			$(targetLink).appear();
		});
	});
	
	if($("video-1")) {
		
		hideVideos();
		$("content-main").setStyle({height: "685px"});
		$("video-1").setStyle({display:"block"});
		$$("div.video-link a").invoke("observe", "click", function(a){ 
			if(player) {
				player.sendEvent('STOP');
			}
			hideVideos();
			var targetVideo = this.readAttribute("href").replace("#", "");
			var targetLink = "video-" + targetVideo;
			$(targetLink).appear();
			a.stop();
		})
	};
	
});

function hideVideos() {
	$$("div.video").each(function(vid) {
		vid.hide();
	});
};
