

//********************************************************************************************************************************

//********************************************************************************************************************************

// Communication with the flash and vice versa.
// Tony Conti

//********************************************************************************************************************************
//********************************************************************************************************************************


var bReady = false;

//*******************************************************************************

	/**
	 * First page load
	 */
	function firstload()
	{
		bReady = true
	} // END FUNCTION firstload


	/**
	 * Sometimes javascipt is not available to register a callBack before flash is..
	 * Flash calls this funciton to see if this file has been loaded.
	 */
	function isJavaReady()
	{
		return bReady;
	}


//******************************************************************************

	/**
	 * Returns the flashMovie
	 */
 	function whatFlashMovie(movieName)
	{
		if (window.document[movieName])
		{
		  return window.document[movieName];
		}
		if (navigator.appName.indexOf("Microsoft Internet")== -1)
		{
			if (document.embeds && document.embeds[movieName])
				return document.embeds[movieName];
			else
				return document.getElementById(movieName);
		}
		else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
		{
			return document.getElementById(movieName);
		}
     } // END FUCTION whatFlashMovie


//******************************************************************************


	/**
	 * Called by Cube, to know where to animate to.
	 */
	function loaderType()
	{
		try
		{
			// Name of the Flash Movie
			var cube = whatFlashMovie("cube");

			// Get the width and height of the window so the cube and loader accordingly.
			var myWidth = 960, myHeight = 600;
			if( typeof( window.innerWidth ) == 'number' )
			{
				//Non-IE
				myWidth = window.innerWidth;
				myHeight = window.innerHeight;
			}
			else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
			{
				//IE 6+ in 'standards compliant mode'
				myWidth = document.documentElement.clientWidth;
				myHeight = document.documentElement.clientHeight;
			} // END IF

			cube.screenSize([myWidth, myHeight])
			// Loader Types - grid, cube, top, bottom, left, right, back, front

			$.ajax({
				type: "POST",
				url: "../flash/cube/cube.php",
				data: "action=getCurrentFace",
				success: function(response){
					cube.loaderType(response);
				}
			});

			//cube.loaderType("grid");
		}
		catch(er)
		{
			alert(er + " Flash Communication Error: ");
		}
	} // END FUNCTION talkToFlash

	function faceSelected(selected, faceName){
		var $pageTitle = $('.page-title');
		switch(faceName){
			case 'top':
				$pageTitle.html('<h1>news</h1><p>Keep up with the latest company news and find archived press releases.</p>').fadeIn();
				break;
			case 'bottom':
				$pageTitle.html('<h1>what we do</h1><p>Despite the way it looks, we actually spend a lot of our time doing work. Which we love. See the outputs of our inputs here.</p>').fadeIn();
				break;
			case 'back':
				$pageTitle.html('<h1>our content</h1><p>Read about our expertise and passion through blogs, tweets, comic strips and more.</p>').fadeIn();
				break;
			case 'right':
				$pageTitle.html('<h1>for our<br/>people</h1><p>This section was made just for employees. Try to beat our VP of Finance in a game of pong or win something mysterious from the Employee Vault.</p>').fadeIn();
				break;
			case 'left':
				$pageTitle.html('<h1>jobs</h1><p>Find everything you need to know about joining our team. Watch the video, it\'s inspiring.</p>').fadeIn();
				break;
			case 'front':
				$pageTitle.html('<h1>about</h1><p>See inside our culture, meet the people in our building, and find out if you\'re compatible.</p>').fadeIn();
				break;
		}
	}
//*******************************************************************************
//*******************************************************************************

