/***********************************
Static Properties
***********************************/


/***********************************
Properties
***********************************/

var requiredMajorVersion = 9; // Major version of Flash required
var requiredMinorVersion = 0; // Minor version of Flash required
var requiredRevision = 124; // Revision of Flash required

var goNutsHTML = ""; // html code for embedding the go nuts game - taken from the initial page

/***********************************
Functions
***********************************/

/*

*/

function initCommon()
	{
		window.onload = function()
			{
				carousel.collectContent([
					"contentHome",
					"contentGames",
					"contentNessyFair",
					"contentInUse",
					"contentRules"
				]);
				carousel.init();
				setNavForCarousel();
			};
	}

/*
Resets the locations of the links to alter the position of the carousel.
*/

function setNavForCarousel()
	{
		$(".navigation .home").attr("href", "javascript:onNavSelected(0);");
		$(".navigation .games").attr("href", "javascript:onNavSelected(1);");
		$(".navigation .nessyFair").attr("href", "javascript:onNavSelected(2);");
		$(".navigation .inUse").attr("href", "javascript:onNavSelected(3);");
		$(".navigation .rules").attr("href", "javascript:onNavSelected(4);");
	}

/*
Called when one of the navigation buttons is clicked.
Sets the carousel position and scrolls to the top of the page.
*/

function onNavSelected(id)
	{
		carousel.setItem(id);
		scroll(0, 0);
	}

/*
Called by Flash when the nuggets are clicked in the lower animation.
Can occur on any page.
Begins by rebuilding the flash movie for the go nuts game as it may have been cleared away.
*/

function nuggetsClicked()
	{
		if (document.getElementById("goNutsGame").innerHTML == "") rebuildGoNutsMovie();

		// container is already being positioned in javascript popup version
		$(".standaloneContentGoNutsGame").css("left", 0);
		$(".standaloneContentGoNutsGame").css("top", 0);

		$("#goNutsGame").fancybox({
			'titleShow': false,
			'onStart': stopMedia,
			'onClosed': goNutsClosed
		}).trigger('click');
	}

/*
Called when the go nuts game lightbox is closed.
Clears the game movie and restarts any current media.
*/

function goNutsClosed()
	{
		clearGoNutsMovie();
		startMedia();
	}

/*
Rebuilds the flash movie for the go nuts game as it may have been cleared away.
*/

function rebuildGoNutsMovie()
	{
		$("#goNutsGame").html(goNutsHTML);
	}

/*
Rebuilds the flash movie for the go nuts game as it may have been cleared away.
*/

function clearGoNutsMovie()
	{
		goNutsHTML = document.getElementById("goNutsGame").innerHTML;
		$("#goNutsGame").html("");
	}

/*
Restarts the current page's media.
*/

function startMedia()
	{
		carousel.startMedia();
	}

/*
Restarts the current page's media.
*/

function stopMedia()
	{
		carousel.stopMedia();
	}


/***********************************
Initiation
***********************************/

initCommon();
