$(function(){
		setTimeout ( 'fadeHome();', 5000 );
	});

function fadeHome() {

	$('#home-intro').fadeOut( 250, function() {
			$('#home-mission').fadeIn( function () {
					$('#home-image-map-tvc').click( function () {
						});
				});
		});
	
	$('#masthead h1#masthead-home-title').fadeIn(1250, function() {
		});
	
}

function kickTVC() {

	
	$('#home-footer').hide();

	$('#home-mission').fadeOut( function () {

			var s = '';
			s += '<a href="/" id="home-video-close"><span>Close</span></a>';
			s += '<div id="home-video-player"></div>';
			$('#home-video').html(s);

			$('#home-video').fadeIn( function () {
					var ord = Math.random()*100000000000;
					swfobject.embedSWF(
									   "/tvc/MediaPlayer.swf?" + ord, 
									   "home-video-player", 
									   "480", 
									   "270", 
									   "9.0.0", 
									   false, 
									   { mediaURL: '/tvc/tvc.flv', autoplay: '1', showTimer: 0 },
									   { wmode: "transparent", bgcolor: "#ffffff" } 
									   );
				});

			$('#home-video-close').click( function() { 
					$(this).blur();
					killTVC(); 
					return false; 
				});

		});


}

function killTVC() {

	$('#home-video').html('');
	$('#home-video-close').unbind('click');
	$('#home-video').fadeOut( function () {
			$('#home-mission').fadeIn();
			$('#home-footer').show();
		});
	return false;
}


function MediaPlayerReceiver ( message )
{

	// receiving and handle ExternalInterface message from flash

	if ( message == 'stopped' ) {

	}

	if ( message == 'complete' ) {
		$('#home-video').hide();
 		killTVC();
	}

}
