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/", frameH:702},			// What is a Mystery Fabric?
				   {code:"fvf", url:"/MysteryFabric/FashionVictimFirstPerson/", frameH:914}, 		// Fashion Victim Files
				   {code:"fpe", url:"/MysteryFabric/FashionVictimFirstPerson/", frameH:914},  		//   --> First person (currently, same as index)
				   {code:"tes", url:"/MysteryFabric/FashionVictimTestimonials/", frameH:1550},		//   --> Testimonials
				   {code:"cot", url:"/MysteryFabric/CaughtOnTape/", frameH:830},			  		// Caught on Tape
				   {code:"dde", url:"/MysteryFabric/DubiousDevelopers/", frameH:748},  				// Dubious Developers
				   {code:"fga", url:"/MysteryFabric/FunAndGames/", frameH:702},			  			// Fun Stuff
				   {code:"fge", url:"/MysteryFabric/FunAndGamesFabricGenerator/", frameH:702}, 		//   --> Fabric Generator
				   {code:"sga", url:"/MysteryFabric/FunAndGamesShoppingGame/", frameH:841},  		//   --> Shopping Game
				   {code:"fqu", url:"/MysteryFabric/FunAndGamesFabricQuiz/", frameH:701},			//   --> Fabric Quiz
				   {code:"fec", url:"/MysteryFabric/ECards/", frameH:702},	  						// Mystery Word Ecards
				   {code:"sys", url:"/MysteryFabric/SubmitYourStory/", frameH:703},  				// Submit Your Story
				   {code:"dow", url:"/DownloadMysteryFabric/", frameH:796},							// Downloads
			   	   {code:"dmy", url:"/DownloadMysteryFabric/", frameH:796}, 						//   --> Mysterty Fabric (currently, same as index)
				   {code:"dco", url:"/MysteryFabric/DownloadCotton/", frameH:796},					//   --> Cotton
				   {code:"mfr", url:"/MysteryFabric/MysteryFabRehab/", frameH:713},				// Mystery Fab Rehab
				   {code:"mfs", url:"/MysteryFabric/MysteryFabRehab/MysteryFabRehabSteps.htm", frameH:1048},			
				   																		// Mystery Fab Rehab - Interior page shell
				   {code:"gre", url:"/MysteryFabric/CottonGreenQuiz/", frameH:826}];						// Do You Know Green?

				   /* {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, 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;
	var frameH = pgItem.frameH;
	if (vidId) url += "?vidId=" + vidId;
	loadintoIframe("mainFrame", url, frameH);
}

function loadFirstPage() {
	loadPage(section, vidId);
}

function loadMysFabRehabStep(pgCode, stepNum) {
	var pgItem = getElementByProperty(sectionList, "code", pgCode);
	var url = pgItem.url;
	var frameH = pgItem.frameH;
	if (stepNum) url += "?stepNum=" + stepNum;
	loadintoIframe("mainFrame", url, frameH);
}



/**
 * 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;
}

