/*******************************************************************************
** This software is provided "AS IS," without a warranty of any kind.  
** ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
** IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-
** INFRINGEMENT, ARE HEREBY EXCLUDED.  VIRTUAL COLLEGE GROUP LTD AND ITS LICENSORS 
** SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, 
** MODIFYING OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES.  IN NO EVENT
** WILL VIRTUAL COLLEGE GROUP LTD OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, 
** PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR 
** PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, 
** ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF VIRTUAL COLLEGE
** GROUP LTD HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
** 		
**
** COPYRIGHT © 2006 Virtual College Group LTD. ALL RIGHTS RESERVED
** HTTP://WWW.VIRTUAL-COLLEGE.CO.UK
*******************************************************************************/
// Highest error = 117
/*

Structural Refernence- 
	0. vars and objects etc.
	1. Start and Finish functions  - these are what are called by the content on load and on Unload, so are the main rountines.
	2. Communication support rountines - debug methods, variable passing.
	3. Navigation Support - controlling of the  page functions i.e. forward, backward, load page 
	4. Event Handlers - functions that are called directly by the navigation move - ie goNext is called when the next button is pressed by the user
	5. Yours Notes Control
	6. Glossary Control.
	10. Content functions
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
###################   0               #####################################################################################################
*****************************  Variables ********************************************************************************************************************************************************
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*/

//LMS Vars
var hasLMS = false;
 
//set by us
//score maybe overridden by LMS value
var scoScore = 0;
var startSessionTime;

//Nav
var navSupportedFlags;
var navLogicVersion;
var navLoaded = false;
var navGlossary = false;
var navHelp = false;
var navComments = false;
var navJumpPage = false;
var navFatMode = true;
var lowVisionMode = false;
var notesWindowOpen = false;
var navHeight = 80;

//content
var contentLoaded = false;
var sound = true;
var text = true;
var volumePercent = 70;
var demoMode;
var allPassed;
var errorLog ="";


/*
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
###################    1                                            ############################################################################################
*****************************   Start and Finish Functions ******************************************************************************************************************************************
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*/
//Created by Simon Crozier - 26 April 2006
//constructor method
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function start()
{	
	/*
	Start LMS() intitally trys to start communciation with the LMS
	if it is successfull 
		It changes hasLMS to indicate this and LMS communication is enabled for all functions.
		it then gets all the student information such as bookmark, studentName and student prefences like sound etc.
	if its is unsuccessfull 
		It changes hasLMS to false - no further LMS communcation is attempted
		It then sets any values we would expect to recieve from the LMS
		and will go into demo if the nav file says demoDefault is true
	*/
	//parent.document.title = name;
	window.document.title = name;
	
	scorm_start();
	if ((demoDefault) && (!hasLMS)) demoMode = true;		
	getGlossary();
	writeFlashNav();
	pageJump();
	
	//when the nav bar loads it automatically call flashstart() any necessary processing that involves flash should be placed in there not here else the code will get object reference errors becuase the flash
	document.getElementById("courseName").innerHTML = name; 
	document.getElementById("courseID").innerHTML = courseID; 
	document.getElementById("scoID").innerHTML = scoID; 
	document.getElementById("scoName").innerHTML = scoName; 
}

function navStarted()
{	sco_debug(3,"navLoadStart(): NavStarted has loaded therefore the FlashNav must have activated");
	loadPage(pages[currentPage]);
	if (hasLMS) 
		{
		navPassVar("lmsConnectedFlag","true");
		document.getElementById("conntectionStat").innerHTML = "<p><b>LMS Connection found</b></p>"; 
		document.getElementById("conntectionStat").style.color ="green";	
		document.getElementById("conntectionStat").style.backgroundColor ="white";			
		}
	else
		{
		navPassVar("lmsNotConnectedFlag","true");
		document.getElementById("conntectionStat").innerHTML = "<p><b>LMS Connection NOT found</b></p>"; 
		document.getElementById("conntectionStat").style.color ="red";		
		document.getElementById("conntectionStat").style.backgroundColor ="white";		
		}
}
	
//Created by Simon Crozier - 26 April 2006
//deconstructor method synch with LMS if necessary, also has several option for how it exit based on what a series of switches in the nav.js are set to
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function finish()
{	sco_debug(4,"finish(): SCO has finished");
	if (notesWindowOpen != false) notesChild.close;
	if(hasLMS) scorm_finish();
	//not much else to do so close window or redirect depnding on nav.js
	if(closeWin) parent.close();
	if(redirect != false) location = redirect;
	}

/*
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
###################    2                                        #############################################################################################
*****************************   Communication Support ********************************************************************************************************************************************
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*/
//Created by Simon Crozier - 24 March 2006
//sends an alert message out only if debug level is lower than value passed 
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit

//SIMON, 28-11-07 speeding up the append system changed from
//document.getElementById("debug_info").innerHTML = "<p>"+msg+"</p>"+document.getElementById("debug_info").innerHTML;
//to using append element as string processing is very slow.
function sco_debug(level,msg) 
{	if (sco_debug_level >= level) alert(msg);
	//document.getElementById("debug_info").innerHTML = "<p>"+msg+"</p>"+document.getElementById("debug_info").innerHTML;
	var newp=document.createElement("p")
	var newtext=document.createTextNode(msg)
	newp.appendChild(newtext) //append text to new div
	document.getElementById("debug_info").appendChild(newp) //append text to new div
}

//Created by Simon Crozier - 18 July 2006
//Outputs alert message directly from the content movie using the SCO_debug function- just encase the method needed changing later.
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function content_debug(msg) 
{	sco_debug(3,msg);
}

//Created by Simon Crozier - 24 March 2006
//sends variables flash Navigation movie
//NOTE: there is a seperate function for sending variables to content swf at parent.frames[1].frames[0].navPassVar();
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function navPassVar(a,b)
{  	//no flag checking on nav - can be done by logicVersion but if nav changed then really this file should travel with it
	sco_debug(4,"navPassVar(): Sending variables to Nav " + a + " " + b);
	if (navSupportFlags.indexOf(a) != -1) document.getElementById("navMovie").SetVariable(a,b);
	else 
		{
		sco_debug(1,"navPassVar(): *** ERROR *** flag not in supported flag list for nav version: flag " + a + " value " + b+" sending variable anyway");
		reportError("116","navnavPassVar(): *** ERROR *** flag not in supported flag list for nav version: flag " + a + " value " + b+" sending variable anyway");
		document.getElementById("navMovie").SetVariable(a,b);
		}
}

//Created by Simon Crozier - 18 July 2006
//Send variable to the content - used player.js to comminicate with the content flash movie
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function contentPassVar(a,b)
{	sco_debug(4,"contentPassVar(): Sending variables to Content " + a + " " + b);
	if (contentSupportFlags.indexOf(a) != -1) document.getElementById("contentMovie").SetVariable(a,b);
	else 
		{
		sco_debug(1,"contentPassVar(): *** ERROR *** flag not in supported flag list for Content: flag " + a + " value " + b+" sending variable anyway");
		reportError("117","contentPassVar(): *** ERROR *** flag not in supported flag list for Content: flag " + a + " value " + b+" sending variable anyway");
		document.getElementById("contentMovie").SetVariable(a,b);
		}
}

function reportError(a,b)
{	errorLog = errorLog+"/"+ a;
}

//Created by Simon Crozier - 18 July 2006
//Show or hides a specific div as instructed by player.js
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function showHide(item)
{	content_debug("showHide: "+item);
	if (document.getElementById(item).style.display == "none")	document.getElementById(item).style.display = "block";
	else if (document.getElementById(item).style.display == "block") document.getElementById(item).style.display = "none";
	else document.getElementById(item).style.display = "block";
	
	if (document.getElementById(item+"Shadow"))
	{	if (document.getElementById(item+"Shadow").style.display == "none")	document.getElementById(item+"Shadow").style.display = "block";
		else if (document.getElementById(item+"Shadow").style.display == "block") document.getElementById(item+"Shadow").style.display = "none";
		else document.getElementById(item+"Shadow").style.display = "block";
	}
}

/*
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
###################    3                                ################################################################################################
*****************************   Navigation Support ************************************************************************************************************************************************
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*/
//Created by Simon Crozier - 24 March 2006
//allows a left nav to call a page of the SCO (primiarly for NON-LMS use
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function callPage(index)
{	sco_debug(4,"Callpage: index = " +index);
	sco_debug(5,"Callpage: processing - "+pageDetails[language][index].src);
	currentPage = index;
	loadPage(pages[index]);	
}
 
//Created by Simon Crozier - 24 March 2006
//set Nav bar info, then call show page
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function loadPage(page)
{	sco_debug(4,"loadPage(): started");
	
	sco_debug(5,"loadPage(): processing page...");
	//set page title in Naviation movie
	sco_debug(5,"loadPage(): page name is "+pageDetails[language][currentPage].name);
	navPassVar("displayTitle",pageDetails[language][currentPage].name);
	
	//set text title in flash movie
	pageNumberText = ((currentPage+1));
	if (pages.length > 1) pageNumberText = pageNumberText+(" / " + pages.length);
	navPassVar("displayPage",pageNumberText);
	
	navJumpPage = false;
	sco_debug(4,"loadPages(): switching off jumpPage");
	navPassVar("jumpPageOffStateFlag",true);
	document.getElementById("pageJumpShadow").style.display = "none";
	document.getElementById("pageJump").style.display = "none";
	sco_debug(4,"loadPages(): switching off completion page");
	document.getElementById("completionShadow").style.display = "none";
	document.getElementById("completion").style.display = "none";
	
	updateNotes();

	
	if (volumePercent == 0) navPassVar("audioToggleOnStateFlag","true");
	
	//disable forward and back - goSceneEnd will re-enable these buttons
	if ((!currentPage == 0) && (pages[currentPage].complete == "passed"))
		{	
		sco_debug(5,"loadPage: setting back to enabled");
		navPassVar("enableBackFlag","true");	
		}
	else{
		sco_debug(5,"loadPage(): setting back to disabled");
		navPassVar("disableBackFlag","true");
		}
	
	if ((currentPage < pages.length-1) && (pages[currentPage].complete == "passed"))
		{
		sco_debug(5,"loadPage: setting next to enabled");
		navPassVar("enableForwardFlag","true");
		}
	else{
		sco_debug(5,"loadPage(): setting next to disabled");
		navPassVar("disableForwardFlag","true");
		}

	sco_debug(5,"loadPage(): setting end to disabled");
	navPassVar("disableEndFlag","true");
	
	
	//show the page in the content window
	sco_debug(5,"loadPage(): page address is " + pageDetails[language][currentPage].src);
	showPage(pageDetails[language][currentPage].src);
	
	//set the lesson location if in scorm
	if (inLMS()) setLMSLessonLocation(currentPage);

}

//Created by Simon Crozier - 24 March 2006
//display change the content window to the requested page
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function showPage(src)
{	sco_debug(5,"showPage(): loading page " + src);
	sco_debug(5,"showPage(): parent " +location.href);
	contentUrl=src;
	writeFlashContent();
}

//Created by Simon Crozier - 18 July 2006
//called by each sco page when it has finished doing its bits
//also set the change flags on in the flash to let the watcher know which thing to change
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goSceneEnd(status)
{	sco_debug(4,"goSceneEnd: function called " + status);
		//if value isn't a good value throw a wobbler.
	if ((status.toLowerCase() !="passed") && (status.toLowerCase() !="failed"))
	{
		sco_debug(0,"goSceneEnd: goScene end been called with a dodgy value");
		reportError("001","goScene end been called with a dodgy value");
	}
	
	//set the page complete
	pages[currentPage].complete = status;

	if (!currentPage == 0)
	{	sco_debug(5,"goSceneEnd: setting back to enabled");
		navPassVar("enableBackFlag","true");	
	}
	
	if (currentPage < pages.length-1)
	{	sco_debug(5,"goSceneEnd: setting next to enabled");
		navPassVar("enableForwardFlag","true");
	}
	
	if (inLMS()) 
	{	sco_debug(5,"goSceneEnd(): setting lessonStatus");
		
		//do this each time so as soon as the user has passed we get a commit so if there is a problem we can recover the lesson as best as possible.
		//its would be alot more efficent just to do this in LMSFinish rountine only but that risks data loss.
		decideLessonStatus();
		setLMSLessonStatus();
		Commit();
	}
	pageJump();
	if (allPassed){
		sco_debug(5,"goSceneEnd: setting end to enabled");
		navPassVar("enableEndFlag","true");	
	}
}

//Created by Simon Crozier - 18 July 2006
//called by goScendEnd and decides current status for the SCO. 
//If something has already set it to true this doesn't touch it. If all Scenes/Pages have their flag set to true this will alter the  SCOstatus to passed
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function decideLessonStatus()
{	sco_debug(4,"decideLessonStatus(): current status ="+scoStatus);
	if ((!(scoStatus == "passed")) && (scoLessonMode == "normal"))
	{	
		allPassed = true;
		//for each page, check status equals true if not then change allPassed flag to false
		for (k = 0;k < pages.length; k++) 
			{
			if (pages[k].complete == "na") allPassed = false;
			if (pages[k].complete == "failed") allPassed = false;		
			}
		sco_debug(5,"decideLessonStatus(): all passed = "+allPassed);

		// if for credit and not in browse mode act normally
		if ((scoCredit) && (scoLessonMode != "browse"))
			{
			if (allPassed)
				{
				scoStatus = "completed";
				//send user the completeion message
				}
			else scoStatus = "incomplete";
			}
		//end for credit and no broswe
			
		else
			{
			//deal with users in browse
			if ((scoLessonMode == "browse") != (scoCredit)) scoStatus = "browsed"; //end browse check 
			//so the remianing people are in not for credit and not in browse
			else{
				if (allPassed)
					{
					scoStatus = "completed";
					//send user the completeion message
					}
				else scoStatus = "incomplete";
				} //not for credit 
			}//end credit check	
			
		sco_debug(4,"decideLessonStatus(): setting status to = "+scoStatus);	
		}//end  dont alter pass
	else
	{ 	sco_debug(4,"decideLessonStatus(): SCO already passed so not going to alter state;");
	}
	//do a commit 
	Commit();
}

//Created by Simon Crozier - 01 Aug 2007
//can be called by the content flash movie at any time.
//This set an item in the suspendData array, at the location A with a value of B. 
// This will will in turn will be stored in the LMS when the system exits. Items must not be stored in postiion 0 as this is reserved.
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function setSuspendData(a,b)
{	
	if (a != 0)	scoSuspendData[a] = b;
	document.getElementById("suspendData");
	for (k = 1; k < scoSuspendData.length;k++) document.getElementById("suspendData").innerHTML = document.getElementById("suspendData").innerHTML+ "<p>"+scoSuspendData[k]+"</p>";
	Commit();
}

//Created by Simon Crozier - 01 Aug 2007
//can be called by the content flash movie at any time.
//This will recover the value of the item in position A of the suspendData array and pass it to the flash in a variable called B
//If the system is running outside of an LMS the system will pass back "NoAPI"
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function getSuspendData(a,b)
{	if (hasLMS)	contentPassVar(b,scoSuspendData[a]);
	else contentPassVar(b,"NoAPI");
	for (k = 1; k < scoSuspendData.length;k++) document.getElementById("suspendData").innerHTML = document.getElementById("suspendData").innerHTML+ "<p>"+scoSuspendData[k]+"</p>";

}

/*
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
###################    4                       ###################################################################################################
*****************************   Event Handles ****************************************************************************************************************************************************
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*/
		
//Created by Simon Crozier - 18 July 2006
//calls showHide from the content window passing it pageJump , which hides/unhides the pageJump div
//also set the change flags on in the flash to let the watcher know which thing to change
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goJumpPage()
{	sco_debug(4,"goJumpPage: button clicked");
	//pageJump();
	showHide("pageJump");
	if (navJumpPage)
	{
		navJumpPage = false;
		sco_debug(5,"goJumpPage(): sending pageJumpOffStateFlag");
		navPassVar("jumpPageOffStateFlag","true");
	}
	else 
	{	navJumpPage  = true; 
		sco_debug(5,"goJumpPage(): sending pageJumpOnStateFlag");
		navPassVar("jumpPageOnStateFlag","true");
	}
}

//Created by Simon Crozier - 31 May 2006
//calls showHide from the content window passing it glossary, which hides/unhides the glossary div
//also set the change flags on in the flash to let the watcher know which thing to change
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goComments()
{	if (notesWindowOpen == false)
	{
		sco_debug(4,"goComments: button clicked");
		if (navComments)
		{	navComments = false;
			navPassVar("commentsOffStateFlag","true");
			showHide("comments");	
		}
		else 
		{	navComments = true; 
			navPassVar("commentsOnStateFlag","true");
			showHide("comments");	
		}
	}
	else 
	{
		notesChild.focus();
		navPassVar("commentsOnStateFlag","true");
	}
		
	updateNotes();
}

//Created by Simon Crozier - 24 March 2006
//Print page ... send message to content which - koreapagelogic.as catches and launches a print as bitmap command
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goPrint()
{	sco_debug(4,"print clicked");
	//parent.frames[0].window.print();
	contentPassVar("printFlag", "true");
}


//Created by Simon Crozier - 31 May 2006
//calls showHide from the content window passing it glossary, which hides/unhides the glossary div
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goHelp()
{	sco_debug(4,"goHelp: button clicked");
	showHide("help");
	if (navHelp)
	{
		navHelp = false;
		navPassVar("helpOffStateFlag","true");
	}
	else 
	{	navHelp = true; 
		navPassVar("helpOnStateFlag","true");
	}
}

function goShowDebug()
{
	sco_debug(4,"goShowDebug: started");
	if (document.getElementById("help").style.display == "block") showHide("help");
	showHide("debug");
}

//Created by Simon Crozier - 24 March 2006
//calc the previous page and call load page
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goPrev()
{	if (currentPage > 0)
		{
		sco_debug(4,"prevPage(): started");
		sco_debug(5,"prevPage(): current page is " + currentPage);
		currentPage--;
		sco_debug(5,"prevPage(): new page is "+ currentPage);
		loadPage(pages[currentPage]);	
		}
	else
		{
		sco_debug(0,"*** Error **** Sorry, you are already at the first page");
		reportError("113","* Error * Sorry, you are already at the first page");
		}
	
}

//Created by Simon Crozier - 24 March 2006
//calc the next page and call load page
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goNext()
{	if (currentPage < pages.length-1)
		{
		sco_debug(4,"nextPage(): started");
		sco_debug(5,"nextPage(): current page is " + currentPage);
		currentPage++;
		sco_debug(5,"nextPage(): new page is "+ currentPage);
		loadPage(pages[currentPage]);
		}
	else 
		{
		sco_debug(0,"*** Error *** Sorry, you are already on the last page");
		reportError("114","* Error * Sorry, you are already at the first page");
		}
	if (hasLMS) scorm_save();		
}

//Created by Simon Crozier - 10 May2006
//toggles sound using goSoundOff and goSoundOn
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goSoundToggle()
{	sco_debug(4,"goSoundToggle(): sound toggle clicked");
	sco_debug(5,"goSoundToggle(): sound = "+ sound);
	if (sound) goSoundOff();
	else goSoundOn();
}

//Created by Simon Crozier - 24 March 2006
//toggles sound in the content, by setting soundmsg variable - there is a watcher in the koreapageLogic.as file kiwObject
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goSoundOn()
{	sco_debug(4,"sound on clicked");
	sound = true;
	contentPassVar("soundStatus","true");
	contentPassVar("narrationFile",pageDetails[language][currentPage].soundFile);
	contentPassVar("soundChangeFlag","true");
	//this is a mute button so sound on mean mute is off
	navPassVar("audioToggleOffStateFlag","true");
	if (inLMS()) setLMSSoundPref();
}

//Created by Simon Crozier - 24 March 2006
//toggles sound in the content, by setting soundmsg variable - there is a watcher in the koreapageLogic.as file kiwObject
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goSoundOff()
{	sco_debug(4,"sound off clicked");
	sound = false;
	contentPassVar("soundStatus", "false");
	contentPassVar("narrationFile","");
	contentPassVar("soundChangeFlag","true");
	//this is a mute button so sound on mean mute is off
	navPassVar("audioToggleOnStateFlag","true");
	if (inLMS()) setLMSSoundPref();
}

//Created by Simon Crozier - 26 July 2006
//This function should start and stop sound, first it switches the gotoAndStop var to stop then swaps it to play this will cause the content to stop its sound then restart it from beginign
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goReplaySound()
{	sco_debug(4,"goReplaySound(): sound restarting");
	sound = true;
	contentPassVar("soundStatus","true");
	contentPassVar("soundChangeFlag","true");
}

//Created by Simon Crozier - 26 May 2006
//nav SWF calls go volume when the volume slide is changed. It then passes the value to the content to make it change its volume to that
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goVolume(volume)
{	//if volume coming in from navigation flash is different to current setting tell the content flash of the change
	sco_debug(4,"goVolume(): setting volume to "+volume +" volumePercent ="+volumePercent);
	
	//set the volume in the content
	contentPassVar("volumePercent", volume);	
	contentPassVar("volumeChangeFlag","true");
	
	// if the our old level was 0 restart the sound
	if ((sound == false) && (volumePercent == 0) && (volume > 1)) goSoundOn();
	// if the new level is less than 1 stop the sound
	if (volume<1) goSoundOff();
	
	//synch up our old variable with what the content now has...
	volumePercent = volume;
	if (inLMS()) setLMSSoundPref();
}

function goEndButton()
{	sco_debug(4,"end clicked");
decideLessonStatus();
	if (((scoStatus = "completed") || (scoStatus = "passed")) && (hasLMS)) goCompletion();
	else finish();
}

//Created by Simon Crozier - 24 March 2006
//calls LMS commit, LMSFinish and the send the user back to the LMS
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goEndSession()
{	sco_debug(4,"quit clicked");
if (((scoStatus = "completed") || (scoStatus = "passed")) && (hasLMS)) goCompletion();
	else finish();
	location = "_shared/exit.htm"
}

//Created by Simon Crozier - 31 May 2006
//calls showHide from the content window passing it glossary, which hides/unhides the glossary div
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goGlossary()
{	sco_debug(4,"goGlossary: button clicked");
	showHide("glossary");
	if (navGlossary)
	{
		navGlossary = false;
		navPassVar("glossaryOffStateFlag","true");
	}
	else 
	{	navGlossary = true; 
		navPassVar("glossaryOnStateFlag","true");
	}
}

// Below function to allow textbox to toggle on and off which has now been removed as a button in the nav so is no longer needed.

//Created by Simon Crozier - 24 March 2006
//toggles text in the  content.. by setting soundmsg variable - there is a watcher in the koreapageLogic.as file kiwObject
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goText()
{	if (text == "text:true") goTextOff();
	else goTextOn();
}

//Created by Simon Crozier - 24 March 2006
//toggles text in the  content.. by setting soundmsg variable - there is a watcher in the koreapageLogic.as file kiwObject
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goTextOn()
{	sco_debug(4,"goTextOn(): text clicked");
	text = true;
	contentPassVar("textChangedFlag","true");
	contentPassVar("textStatus", "text");
	if (inLMS()) setLMSTextPref();
}

//Created by Simon Crozier - 24 March 2006
//toggles text in the  content.. by setting soundmsg variable - there is a watcher in the koreapageLogic.as file kiwObject
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goTextOff()
{	sco_debug(4,"goTextOff() text off clicked");
	text = false
	contentPassVar("textChangedFlag", "true");
	contentPassVar("textStatus", text);
	if (inLMS()) setLMSTextPref();
}

//Created by Simon Crozier - 24 March 2006
//toggles  the completion window in the  content.. by setting soundmsg variable - there is a watcher in the koreapageLogic.as file kiwObject
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goCompletion()
{	sco_debug(4,"goCompletion(): toggling completion");
	pagesForReview();
	showHide("completion");
	sco_debug(5,"goCompletion(): swapping nav mode");
	navHeight = 80;
	window.document.getElementById('vc_nav').style.height = "14%";
	window.document.getElementById('content').style.height = "85%";
	navPassVar("swapToFatFlag","true");
	navFatMode = false;
}

//Created by Simon Crozier - 18 August 2006
//Called by the nav to make the navigation swich into smaller (slim) mode 
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goNavMode()
{	sco_debug(4,"goNavMode():");
	if (navFatMode) 
	{	sco_debug(5,"goNavMode(): shrinking");
		navHeight = 25;
		window.document.getElementById('vc_nav').style.height = "4%";
		window.document.getElementById('content').style.height = "95%";
		navPassVar("swapToSlimFlag","true");
	}
	
	else
	{	sco_debug(5,"goNavMode(): showing");
		navHeight = 80;
		window.document.getElementById('vc_nav').style.height = "14%";
		window.document.getElementById('content').style.height = "85%";
		navPassVar("swapToFatFlag","true");
	}
	navFatMode = !navFatMode;
}

//Created by Simon Crozier - 18 August 2006
//Called by the nav to make the navigation swich into smaller (slim) mode 
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goLowVision()
{	sco_debug(4,"goLowVision():");
	if (!lowVisionMode) 
	{	sco_debug(5,"goNavMode(): simplifying");
		navHeight = 80;
		window.document.getElementById('vc_nav').style.height = "14%";
		window.document.getElementById('content').style.height = "85%";
		navPassVar("swapToLowVisionFlag","true");
	}
	
	else
	{	sco_debug(5,"goLowVision(): showing all");
		navHeight = 80;
		window.document.getElementById('vc_nav').style.height = "14%";
		window.document.getElementById('content').style.height = "85%";
		navPassVar("swapToHighVisionFlag","true");
	}
	lowVisionMode = !lowVisionMode;
	//writeFlashContent();
}

//Created by Simon Crozier - 18 August 2006
//User given option to print notes by the completion screen and notes div 
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function goPrintNotes()
{	sco_debug(4,"goPrintNotes()");
	sco_debug(5,"goPrintNotes(): switching off jumpPage");
	navPassVar("jumpPageOffStateFlag","true");
	document.getElementById("pageJumpShadow").style.display = "none";
	document.getElementById("pageJump").style.display = "none";
	
	sco_debug(5,"goPrintNotes(): switching off completion page");
	document.getElementById("completionShadow").style.display = "none";
	document.getElementById("completion").style.display = "none";
	
	sco_debug(5,"goPrintNotes(): switching off glossary");
	navPassVar("glossaryOffStateFlag","true");
	document.getElementById("glossaryShadow").style.display = "none";
	document.getElementById("glossary").style.display = "none";
	
	sco_debug(5,"goPrintNotes(): switching off help page");
	navPassVar("helpOffStateFlag","true");
	document.getElementById("helpShadow").style.display = "none";
	document.getElementById("help").style.display = "none";
	
	sco_debug(5,"goPrintNotes(): switching on comments page");
	navPassVar("commentsOnStateFlag","true");
	document.getElementById("commentsShadow").style.display = "block";
	document.getElementById("comments").style.display = "block";
	navComments = true; 
	window.print();
}

function goSave()
{
	sco_debug(4,"goSave(): saving/setting");
	if (hasLMS) scorm_save();
}

function goLanguage(requestedLanguage)
{	sco_debug(4,"goLanguage(): changing to "+requestedLanguage);
	if (requestedLanguage == "uk") language = 1;
	else if (requestedLanguage == "french") language = 2;
	else if (requestedLanguage == "german") language = 3;
	else if (requestedLanguage == "russian") language = 4;
	else {
		sco_debug(1,"goLanguage() *** error *** unrecognised language requested: "+requestedLanguage);
		reportError("115","* Error * Sorry, you are already at the first page");
		}
	callPage(currentPage);
}

function goConnectionStat()
{	sco_debug(4,"ConnectionStat: button clicked");
	showHide("connection");
}

/*
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
###################   5                                   ###############################################################################################
*****************************   Notes 			  **********************************************************************************************************************************************
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*/
//Created by Simon Crozier - 18 July 2006
//set the notes in content.htm from this file's local variable.
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function addNote()
{ 	sco_debug(4,"addNote(): adding note");
	if ((document.getElementById("commentsFromUser").value != "Type your notes here and click the \'ADD Note\' link below") && (document.getElementById("commentsFromUser").value != ""))
		scoCommentsFromUser.push("page " +(currentPage+1) +": "+ document.getElementById("commentsFromUser").value);

	document.getElementById("commentsFromUser").value = "";
	updateNotes();
}

//Created by Simon Crozier - 18 July 2006
//set the notes in content.htm from this file's local variable.
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function addNoteFromChild(a)
{	 
	//alert("holla back yoall");
	sco_debug(4,"addNoteFromChild()");
	if (a != "") scoCommentsFromUser.push("page " +(currentPage+1) +": "+a);
	if (notesWindowOpen) notesChild.document.getElementById("commentsFromUser").value = "";
	updateNotes();
}

//Created by Simon Crozier - 10 Dec 2006
//Opens the note function in a seperate window so the user can continue with their training.
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function openNotesWindow()
{	sco_debug(4,"openNotesWindow()");
	if (notesWindowOpen == false)
		{
		sco_debug(5,"openNotesWindow(): Opening window");
		notesChild = window.open("_shared/notes.htm", "", "height=350, width=500,resize=1");
		notesChild.moveTo(10,0);
		notesWindowOpen = true;
		showHide("comments");	
		}
	else
		{
		sco_debug(5,"openNotesWindow(): window already open sending it focus");
		notesChild.focus();
		}
}

//Created by Simon Crozier - 10 Jan 2006
//Closes the notes windows
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function closeNoteWindow()
{	if (notesWindowOpen != false)
		{
		notesWindowOpen = false;
		notesChild.close();
		navPassVar("commentsOffStateFlag","true");
		}
}

//Created by Simon Crozier - 10 Dec 2006
//Updates both the full notes section and the page relievant notes. 
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
// EDIT simon crozier, 10 Jan 2007 - lesley asked for the notes to both be for the entire SCO
function updateNotes()
{	sco_debug(4,"updateNotes()");
	// lesley's change - stop notes being per page 01/11/2006.
	/*
	var a ="";
	for (k = 0; k < lmsCommentsFromUser.length;k++)
		if (lmsCommentsFromUser[k].match("page "+(currentPage+1)+":")) a = a + lmsCommentsFromUser[k] +"\n";
	for (k = 0; k < scoCommentsFromUser.length;k++)
		if (scoCommentsFromUser[k].match("page "+(currentPage+1)+":")) a = a + scoCommentsFromUser[k] +"\n";
	//document.getElementById("pageNotesArea").value = a;
	*/
	
	var a ="";
	for (k = 0; k < lmsCommentsFromUser.length;k++) a = a + lmsCommentsFromUser[k] +"\n";
	for (k = 0; k < scoCommentsFromUser.length;k++) a = a + scoCommentsFromUser[k] +"\n";
	document.getElementById("pageNotesArea").value = a;
	//end lesley's change
	
	var b ="";
	for (k = 0; k < lmsCommentsFromUser.length;k++) b = b + "<p>"+lmsCommentsFromUser[k] +"</p>\n";
	for (k = 0; k < scoCommentsFromUser.length;k++) b = b + "<p>"+scoCommentsFromUser[k] +"</p>\n";
	document.getElementById("fullNotesArea").innerHTML = b;	
	document.getElementById("NotesTranscript").innerHTML = b;	
	sco_debug(4,"updateNotes()");
	if (notesWindowOpen != false) notesChild.document.getElementById("pageNotesArea").value = a;
}

//Created by Simon Crozier - 10 Dec 2006
//Emptys the last note from the note input box
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function clearNotes()
{ 	if (document.getElementById("commentsFromUser").value == "Type your notes here and click the 'ADD Note' link below") document.getElementById("commentsFromUser").value = "";
}



/*
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
###################   6                                 ###############################################################################################
*****************************  Glossary control       ***********************************************************************************************************************************************
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*/

//Created by Simon Crozier - 09 Jan 2007
//Outputs the glosssary div by processing the NAV file's array
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function getGlossary()
{	sco_debug(4,"getGlossary()");
	var glossary = new Array;
	for(k =0; k<defs.length;k++)
		{
		sco_debug(5,"getGlossary() writing term - "+defs[k].term);
		glossary.push('<div id=\"'+defs[k].term.replace(" ","_").replace("'","_")+'\"><a href=\"#\" onclick=\"showHide(\''+defs[k].term.replace(" ","_").replace("'","_")+'_def\'\)\; return false\;\">'+defs[k].term+'</a></div>\n');
		glossary.push('<div id=\"'+defs[k].term.replace(" ","_").replace("'","_")+'_def\" class=\"definition\">'+defs[k].definition+'</div>\n');
		}
	var glossaryContcat = glossary.join("");
	document.getElementById("definitions").innerHTML = glossaryContcat;
}

//Created by Simon Crozier - 09 Jan 2007
//searches the glosssary
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function search()
{
	//if there are no definitions this script would try and alter a non exisitng element so only run if we have some defs
	if (defs.length > 1)
	{
		var searchTerm = (String(document.getElementById("keyword").value)).toLowerCase();

		for (var k = 0; k< defs.length; k++)
		{	
		if (searchTerm != "")
			{
			if (defs[k].term.toLowerCase().indexOf(searchTerm) > -1) 
				{
				document.getElementById(defs[k].term.replace(" ","_").replace("'","_")).style.display = "block";
				document.getElementById(defs[k].term.replace(" ","_").replace("'","_")+'_def').style.display = "none";
				}
			else 
				{
				document.getElementById(defs[k].term.replace(" ","_").replace("'","_")).style.display = "none";
				document.getElementById(defs[k].term.replace(" ","_").replace("'","_")+'_def').style.display = "none";
				}
			}
		else document.getElementById(defs[k].term.replace(" ","_").replace("'","_")).style.display = "block";
		}
	}
}
 
/*
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
###################   6                                 ###############################################################################################
*****************************  Jumo To Page           ***********************************************************************************************************************************************
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*/

//Created by Simon Crozier - 18 July 2006
//Outputs the Content's jump list - to allow the user to navigate to another page in the SCO
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function pageJump()
{	sco_debug(4,"pageJump()");
	var pageStatusText = new Array;
	if (currentPage != null)
		{	
		pageStatusText.push("\n<div class=\"pages\">\n"); 
		pageStatusText.push("<div class=\"pageStatus\">Status</div><div class=\"pageTitle\">Page</div>\n");
		pageStatusText.push("<div class=\"pageItems\">\n");
		if (!demoMode)
			{
			for (k = 0; k < pages.length; k++)
				{
				sco_debug(5,"pageJump()- page "+k+" is "+pages[k].complete);			
				if (pages[k].complete == "passed")
					{	
					sco_debug(5,"pageJump()- page "+k+" is passed");
					pageStatusText.push("<div class=\"pagePassed\">\n");
					pageStatusText.push("<div class=\"pageStatus\">Passed</div>\n");
					pageStatusText.push("<div class=\"pageTitle\"><img src=\"_shared/Passed.gif\" title=\"You have passed this page\" alt=\"You have passed this page\"><a href=\"#\" onclick=\"callPage("+k+"); return false;\" title=\""+pageDetails[language][k].synopsis+"\" alt=\"Click here to go to page "+k+"\">"+(k+1)+": "+pageDetails[language][k].name+"</a></div>\n");
					pageStatusText.push("</div>\n");
					}
				if (pages[k].complete == "passed - but needs reviewing")
					{	
					sco_debug(5,"pageJump()- page "+k+" is passed review");
					pageStatusText.push("<div class=\"pageReview\">");
					pageStatusText.push("<div class=\"pageStatus\">Passed - but needs reviewing</div>");
					pageStatusText.push("<div class=\"pageTitle\"><img src=\"_shared/Review.gif\" title=\"You have passed this page but it may require reviewing\"  alt=\"You have passed this page but it may require reviewing\"><a  href=\"#\" onclick=\"callPage("+k+"); return false;\" title=\""+pageDetails[language][k].synopsis+"\" alt=\"Click here to go to page "+k+"\">"+(k+1)+": "+pageDetails[language][k].name+"</a></div>");
					pageStatusText.push("</div>");
					}
				if (pages[k].complete == "failed")
					{
					sco_debug(5,"pageJump()- page "+k+" is failed");
					pageStatusText.push("<div class=\"pageFailed\">");
					pageStatusText.push("<div class=\"pageStatus\">Completed - Failed</div>");
					pageStatusText.push("<div class=\"pageTitle\"><img src=\"_shared/Failed.gif\" title=\"Sorry you have not passed this page\"  alt=\"Sorry you have not passed this page\"><a  href=\"#\" onclick=\"callPage("+k+"); return false;\" title=\""+pageDetails[language][k].synopsis+"\" alt=\"Click here to go to page "+k+"\">"+(k+1)+": "+pageDetails[language][k].name+"</a></div>");
					pageStatusText.push("</div>");
					}
				if (pages[k].complete == "na")
					{
					sco_debug(5,"pageJump()- page "+k+" is na");
					pageStatusText.push("<div class=\"pageNA\">\n");
					pageStatusText.push("<div class=\"pageStatus\">Not Started</div>\n");
					pageStatusText.push("<div class=\"pageTitle\"><img src=\"_shared/NA.gif\" title=\"You have not attempted this page\"  alt=\"You have not attempted this page\"><a  href=\"#\" onclick=\"callPage("+k+"); return false; \" title=\""+pageDetails[language][k].synopsis+"\" alt=\"Click here to go to page "+k+"\">"+(k+1)+": "+pageDetails[language][k].name+"</a></div>\n");
					pageStatusText.push("</div>\n");
					}
				}
			pageStatusText.push("</div></div>");
			pageStatusText.push("<div class=\"key\"><p>Passed - <img src=\"_shared/Passed.gif\" title=\"You have passed this page\" alt=\"You have passed this page\"></p>");
			pageStatusText.push("<p>Passed but may need reviewing - <img src=\"_shared/Review.gif\" title=\"You have passed this page but it may require reviewing\"  alt=\"You have passed this page but it may require reviewing\"></p>");
			pageStatusText.push("<p>Not passed - <img src=\"_shared/Failed.gif\" title=\"Sorry you have not passed this page\"  alt=\"Sorry you have not passed this page\"></p>");
			pageStatusText.push("<p>Not yet visited - <img src=\"_shared/NA.gif\" title=\"You have not attempted this page\"  alt=\"You have not attempted this page\"></p></div>");
			var pageStatusTextContcat = pageStatusText.join("");
			document.getElementById("pageStatusInfo").innerHTML = pageStatusTextContcat;		
			}
		else //write a jump to page menu that highlghts the available pages but doesn't include links
			{
			for (k = 0; k < pages.length; k++)
				{
				sco_debug(5,"pageJump()- page "+k+" is na");
				pageStatusText.push("<div class=\"pageNA\">\n");
				pageStatusText.push("<div class=\"pageStatus\">Not Started</div>\n");
				pageStatusText.push("<div class=\"pageTitle\"><img src=\"_shared/NA.gif\" title=\"You have not attempted this page\"  alt=\"You have not attempted this page\"><a href=\"#\"  title=\""+pageDetails[language][k].synopsis+"\" onclick=\"alert('Sorry this function is not available in demo mode. If you would like to buy this course please visit www.ukvirtual-college.co.uk'); return false;\">"+(k+1)+": "+pageDetails[language][k].name+"</a></div>\n");
				pageStatusText.push("</div>\n");
				}
			pageStatusText.push("</div></div>");
			pageStatusText.push("<div class=\"key\"><p>Passed - <img src=\"_shared/Passed.gif\" title=\"You have passed this page\" alt=\"You have passed this page\"></p>");
			pageStatusText.push("<p>Passed but may need reviewing - <img src=\"_shared/Review.gif\" title=\"You have passed this page but it may require reviewing\"  alt=\"You have passed this page but it may require reviewing\"></p>");
			pageStatusText.push("<p>Not passed - <img src=\"_shared/Failed.gif\" title=\"Sorry you have not passed this page\"  alt=\"Sorry you have not passed this page\"></p>");
			pageStatusText.push("<p>Not yet visited - <img src=\"_shared/NA.gif\" title=\"You have not attempted this page\"  alt=\"You have not attempted this page\"></p></div>");
			var pageStatusTextContcat = pageStatusText.join("");
			document.getElementById("pageStatusInfo").innerHTML = pageStatusTextContcat;	
			}
		}
}

//Created by Simon Crozier - 18 July 2006
//Outputs the Content's jump list - to allow the user to navigate to another page in the SCO
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function pagesForReview()
{	sco_debug(4,"pagesForReview()");
	var pageStatusText = new Array;
	var counter = 0;
	if (currentPage != null)
		{
		pageStatusText.push("<h2>Pages you may need to review</h2>\n");
		pageStatusText.push("<p>The results of your user challenges indicated the following pages may need reviewed.</p>\n");
		pageStatusText.push("<p>This does not mean that the pages are incomplete, just that it maybe worth your while reviewing their contents again.</p>\n");
		pageStatusText.push("\n<div class=\"pages\">\n"); 
		pageStatusText.push("<div class=\"pageStatus\">Status</div><div class=\"pageTitle\">Page</div>\n");
		pageStatusText.push("<div class=\"pageItems\">\n");
		for (k = 0; k < pages.length; k++)
			{
			sco_debug(5,"pageJump()- page "+k+" is "+pages[k].complete);			
			if (pages[k].complete == "passed - but needs reviewing")
				{
				counter++;
				sco_debug(5,"pageJump()- page "+k+" is passed review");
				pageStatusText.push("<div class=\"pageReview\">");
				pageStatusText.push("<div class=\"pageStatus\">Passed - but needs reviewing</div>");
				pageStatusText.push("<div class=\"pageTitle\"><img src=\"_shared/Review.gif\" title=\"You have passed this page but it may require reviewing\"  alt=\"You have passed this page but it may require reviewing\"><a  href=\"#\" onclick=\"callPage("+k+"); return false;\" title=\""+pages[k].synopsis+"\" alt=\"Click here to go to page "+k+"\">"+(k+1)+": "+pages[k].name+"</a></div>");
				pageStatusText.push("</div>");
				}
			}
		pageStatusText.push("</div></div>");
		var pageStatusTextContcat = pageStatusText.join("");
		if (counter > 0) document.getElementById("comp_pageStatusInfo").innerHTML = pageStatusTextContcat;
		}
}

//Created by Simon Crozier - 18 July 2006
//Allows the Quiz to set pages as passed but in need of review.
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function setPageForReview(page)
{	sco_debug(4,"setPageForReview(page)");
	page = page-1;
	sco_debug(3,"setPageForReview(): attempting to set page "+page+" as needing reviewed");
	sco_debug(3,"setPageForReview(): page status for page "+page+" is currently "+pages[page].complete);
	if (pages[page].complete == "passed")
		{
		sco_debug(3,"setPageForReview(): settting page status");
		pages[page].complete = "passed - but needs reviewing";
		pageJump();
		}
}

/*
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
###################   7                                 ###############################################################################################
*****************************  Content Movies         ***********************************************************************************************************************************************
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*/

//Created by Simon Crozier - 18 July 2006
//Outputs the Content flash object whilst passing it variables from player.js
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function writeFlashContent()
{	sco_debug(4,"writeFlashContent()");
	if (currentPage != null)
	{
	sco_debug(5,"getPageSrc(): "+contentUrl);
	// Conditionally create object elements depending on browser
	// IE supports ActiveX, so create an object element that supports ActiveX
	// Mozilla supports MIME type, so if Mozilla, create an object element that supports MIME type
	if ((window.ActiveXObject) && 
		  (navigator.userAgent.indexOf("MSIE")!= -1) && (navigator.userAgent.indexOf("Windows") != -1))
		{
		var contentMovie = new Array;
		sco_debug(3,"writeFlashNav(): IE started");
		contentMovie.push('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
		contentMovie.push(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"');
		contentMovie.push(' width="100%" height="100%" id="contentMovie">');
		contentMovie.push(' <param name="movie" value="'+contentUrl +'">');
		contentMovie.push(' <param name="quality" value="high">');
		contentMovie.push(' <param name="allowScriptAccess" value="sameDomain" />');	
		if (!lowVisionMode) contentMovie.push('<PARAM NAME=FlashVars VALUE="textStatus='+text+'&soundStatus='+sound+'&synopsis='+pageDetails[language][currentPage].synopsis+'&narrationFile='+pageDetails[language][currentPage].soundFile+'&volumePercent='+volumePercent+'">');
		else contentMovie.push('<PARAM NAME=FlashVars VALUE="synopsis='+pageDetails[language][currentPage].synopsis+'&narrationFile='+pageDetails[language][currentPage].transcript+'&volumePercent='+volumePercent+'">');
		//<PARAM NAME=FlashVars" VALUE="synopsis='++'&narrationFile='+pages[currentPage].soundFile+'&previousSessionTime='+scoPreviousSessionTime+'&volumePercent='+volumePercent+'">');
		contentMovie.push(' <param name="swliveconnect" value="true"><PARAM NAME="wmode" VALUE="Transparent"><param name="allowScriptAccess" value="always" />');
		contentMovie.push('<' + '/object>');
		var contentMovieContcat = contentMovie.join("");
		document.getElementById("content").innerHTML = contentMovieContcat;
		document.getElementById("pageID").innerHTML = pageDetails[language][currentPage].motherPageID;
		document.getElementById("movieID").innerHTML = pageDetails[language][currentPage].motherMovieID;
		document.getElementById("soundID").innerHTML = pageDetails[language][currentPage].motherSoundID;
		document.getElementById("content").focus();
		}

	else
		{
		var contentMovie = new Array;
		sco_debug(3,"writeFlashNav(): FF started");
		contentMovie.push('<object id="contentMovie" data="'+contentUrl +'" type="application/x-shockwave-flash"');
		contentMovie.push(' width="100%" height="100%">');
		contentMovie.push('<param name="movie" value="'+contentUrl +'">');
		contentMovie.push(' <param name="motherID" value="'+pageDetails[language][currentPage].motherID+'">');
		if (!lowVisionMode) contentMovie.push('< param name="quality" value="high"><PARAM NAME="FlashVars" VALUE="textStatus='+text+'&soundStatus='+sound+'&synopsis='+pageDetails[language][currentPage].synopsis+'&narrationFile='+pageDetails[language][currentPage].soundFile+'&volumePercent='+volumePercent+'">');
		else contentMovie.push('< param name="quality" value="high"><PARAM NAME="FlashVars" VALUE="synopsis='+pageDetails[language][currentPage].synopsis+'&narrationFile='+pageDetails[language][currentPage].transcript+'&volumePercent='+volumePercent+'">');
		contentMovie.push('<param name="swliveconnect" value="true">');    	
		contentMovie.push('<PARAM NAME="wmode" VALUE="Transparent"><param name="allowScriptAccess" value="always" /><' + '/object>'); 
		var contentMovieContcat = contentMovie.join("");
		document.getElementById("content").innerHTML = contentMovieContcat;
		document.getElementById("pageID").innerHTML = pageDetails[language][currentPage].motherPageID;
		document.getElementById("movieID").innerHTML = pageDetails[language][currentPage].motherMovieID;
		document.getElementById("soundID").innerHTML = pageDetails[language][currentPage].motherSoundID;
		document.getElementById("content").focus();
		}
	}
	else
	{
	document.write('<h1>No Content specified</h1>');
	}
}//end function


//Created by Simon Crozier - 18 July 2006
//Outputs the navigation object whilst passing it variables from player.js
//AUDIT LOG - Edited by :name, On: date, Because: Reason for edit
function writeFlashNav()
{
	// Conditionally create object elements depending on browser
	// IE supports ActiveX, so create an object element that supports ActiveX
	// Mozilla supports MIME type, so if Mozilla, create an object element that supports MIME type
	sco_debug(4,"writeFlashNav()");
	if ((window.ActiveXObject) && 
	      (navigator.userAgent.indexOf("MSIE")!= -1) && (navigator.userAgent.indexOf("Windows") != -1))
		{
		var navMovie = new Array;
		sco_debug(5,"writeFlashNav(): IE started");
		navMovie.push('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
		navMovie.push(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,65,0"');
		navMovie.push(' width="100%" height="100%" id="navMovie">');
		navMovie.push(' <param name="movie" value="_shared/nav.swf">');
		navMovie.push(' <param name="quality" value="high"> <PARAM NAME=FlashVars VALUE="textStatus='+text+'&soundStatus='+sound+'&previousSessionTime='+scoPreviousSessionTime+'&volumePercent='+volumePercent+'&languages='+pageDetails[0][0]+'">');
		navMovie.push(' <param name="swliveconnect" value="true"><PARAM NAME="wmode" VALUE="Transparent"><param name="allowScriptAccess" value="always" />');
		navMovie.push('<object>');
		var navMovieContcat = navMovie.join("");
		document.getElementById("vc_nav").innerHTML = navMovieContcat;
		
		}

	else
		{
		var navMovie = new Array;
		sco_debug(5,"writeFlashNav(): FF started");
		navMovie.push('<object id="navMovie" data="_shared/nav.swf" type="application/x-shockwave-flash"');
		navMovie.push(' width="100%" height="100%">');
		navMovie.push('<param name="movie" value="_shared/nav.swf">');
		navMovie.push('<param name="quality" value="high"><PARAM NAME="FlashVars" VALUE="textStatus='+text+'&soundStatus='+sound+'&previousSessionTime='+scoPreviousSessionTime+'&volumePercent='+volumePercent+'&languages='+pageDetails[0][0]+'">');
		navMovie.push('<param name="swliveconnect" value="true">');   
		navMovie.push('<PARAM NAME="wmode" VALUE="Transparent"><param name="allowScriptAccess" value="always" />'); 		
		navMovie.push('</object>'); 		
		//navMovie.push('<PARAM NAME="wmode" VALUE="Transparent"><' + '/object>'); 
		var navMovieContcat = navMovie.join("");
		document.getElementById("vc_nav").innerHTML = navMovieContcat;
		}
}




