var printText = new Array();
/********************
*
*	sendVariable
*
*	Function used to send a variable
*	to the flash movie
*
*********************/

function sendVariable(whichVariable, whatValue){
	// Check that the window exists
	if (window){
		// Check that the document exists
		if (window.document){
			// Check that the movie exists
			if (window.document.movie){
				window.document.movie.SetVariable(whichVariable, whatValue);
			}
		}
	}
}


/********************
*
*	FScommand
*
*	Used a method of communication for flash
*	to javascript, this function is
*	called whenever flash wants to either
*	send or request data
*
*********************/

var InternetExplorer = (navigator.appName.indexOf("Microsoft") != -1);
// Hook for Internet Explorer
if (navigator.appName && InternetExplorer && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1){
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub movie_FSCommand(ByVal command, ByVal args)\n');
	document.write('  call movie_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('</SCRIPT\> \n');
}

function movie_DoFSCommand(command, args) {
	command = command.toUpperCase();
	if (command == "CMI.COMPLETION_STATUS")
	{
		doLMSSetValue("cmi.completion_status", args);
	}
	if (command == "CMI.SCORE.SCALED")
	{
		doLMSSetValue("cmi.score.scaled", args);
	}
	if (command == "CMI.SCORE.RAW")
	{
		doLMSSetValue("cmi.score.raw", args);
	}
	if (command == "CMI.SCORE.MIN")
	{
		doLMSSetValue("cmi.score.min", args);
	}
	if (command == "CMI.SCORE.MAX")
	{
		doLMSSetValue("cmi.score.max", args);
	}
	if (command == "CMI.SUCCESS_STATUS")
	{
		doLMSSetValue("cmi.success_status", args);
	}
	if (command == "QUIT")
	{
		this.close();		
	}
	if (command == "ADDTEXTTOPRINT")
	{
		if (args)
		{
			printText.push(args);
		}
		
	}
	if (command == "COMMENCEPRINT")
	{
		if (printText.length > 0)
		{
			$("printDiv").innerHTML = printText.join("");
			print();
			printText = new Array();
		}
	}
}

