var iframeids=["mainFrame"];
var iframehide="no";
var lcId = new Date().getTime();
var flashProxy = new FlashProxy(lcId, "flash_JavaScriptFlashGateway.swf");
var section = getQueryParamValue("section");
var vidId = getQueryParamValue("vidId");
var sectionList = [{code:"wia", url:"/MysteryFabric/WhatIsAMysteryFabric/"},			// What is a Mystery Fabric?
				   {code:"fvf", url:"/MysteryFabric/FashionVictimFirstPerson/"}, 		// Fashion Victim Files
				   {code:"fpe", url:"/MysteryFabric/FashionVictimFirstPerson/"},  		//   --> First person (currently, same as index)
				   {code:"tes", url:"/MysteryFabric/FashionVictimTestimonials/"},		//   --> Testimonials
				   {code:"cot", url:"/MysteryFabric/CaughtOnTape/"},			  		// Caught on Tape
				   {code:"dde", url:"/MysteryFabric/DubiousDevelopers/"},  				// Dubious Developers
				   {code:"fga", url:"/MysteryFabric/FunAndGames/"},			  			// Fun Stuff
				   {code:"fge", url:"/MysteryFabric/FunAndGamesFabricGenerator/"}, 		//   --> Fabric Generator
				   {code:"sga", url:"/MysteryFabric/FunAndGamesShoppingGame/"},  		//   --> Match Game
				   {code:"fqu", url:"/MysteryFabric/FunAndGamesFabricQuiz/"},			//   --> Fabric Quiz
				   {code:"fec", url:"/MysteryFabric/ECards/"},	  				// Fadlib Ecards
				   {code:"sys", url:"/MysteryFabric/SubmitYourStory/"},  				// Submit Your Story
				   {code:"dow", url:"/DownloadMysteryFabric/"},			// Downloads
			   	   {code:"dmy", url:"/DownloadMysteryFabric/"}, 			//   --> Mysterty Fabric (currently, same as index)
				   {code:"dco", url:"/DownloadCotton/"},								//   --> Cotton
				   {code:"mfr", url:"/MysteryFabric/MysteryFabRehab/"},				// Mystery Fab Rehab
				   {code:"mfs", url:"/MysteryFabric/MysteryFabRehab/MysteryFabRehabSteps.htm"},			
				   {code:"fas", url:"/MysteryFabric/FashionQuiz/"},
				   // Mystery Fab Rehab - Interior page shell
				   {code:"gre", url:"/MysteryFabric/CottonGreenQuiz/"}];						// Green Quiz
				   
				   /* {code:"vot", url:"/MFVoteToWin/"};	*/							// Vote to win
				   /* {code:"fas", url:"/MysteryFabric/FashionQuiz/"};	*/				// Fashion Quiz - NO LONGER IN USE!!


// Set the initial section, if none was passed in.
if (!section) section = "mfr";

/**
 * Used to select items in the Flash nav from the HTML pages.
 *
 * @param	secID:String		ID of the section
 */
 
/* function makeNavSelection(secID) {
	flashProxy.call("selectFromJS", {secID:secID});*/
	
function makeNavSelection(secID, stepNum) {
	flashProxy.call("selectFromJS", {secID:secID, stepNum:stepNum});
}


/**
 * Called from flash nav -> directs selected item to be loaded into iframe.
 *
 * @param	pgCode:String		Page code of the selected item.
 */
function loadPage(pgCode, vidId) {
	var pgItem = getElementByProperty(sectionList, "code", pgCode);
	var url = pgItem.url;
	if (vidId) url += "?vidId=" + vidId;
	loadintoIframe("mainFrame", url);
}

function loadFirstPage() {
	loadPage(section, vidId);
}

function loadMysFabRehabStep(pgCode, stepNum) {
	var pgItem = getElementByProperty(sectionList, "code", pgCode);
	var url = pgItem.url;
	if (stepNum) url += "?stepNum=" + stepNum;
	loadintoIframe("mainFrame", url);
}


/**
 * Find an element in an array of objects, based on the value of a specific property.
 *
 * @param	arrToSearch:Array	Array to search through.
 * @param	prop:String			Property to search on.
 * @param	val:Mixed			Value of the property to match.
 */
function getElementByProperty(arrToSearch, prop, val) {
	for (var i in arrToSearch) if(arrToSearch[i][prop] == val) return arrToSearch[i];
	return null;
}


