<!--

if (g_bLMS)
{
	document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2' SRC='lms/lms.js' TYPE='text/javascript'><\/SCR" + "IPT>");
}

function debug()
{
}

function SendQuiz()  
{
	g_strQuizResults = g_strQuizResults.replace(/'/g,"&#39;");

	var sHTML = "";
	sHTML += '<FORM id="formQuiz" method="POST" action="mailto:' + g_strEmail + '?subject=' + g_strSubject + '" enctype="text/plain">';
	sHTML += '<INPUT TYPE="hidden" NAME="Quiz Results" VALUE=\'' + g_strQuizResults.replace(/\\n/g,"\n") + '\'>';
	sHTML += '<br><input type="submit"><br>';
	sHTML += '</FORM>';
	document.getElementById("divQuiz").innerHTML = sHTML;
	document.getElementById("divQuiz").document.getElementById("formQuiz").submit();
}


////////////////////////////////////////////////////////////////////////////////
// Results Screen Code
////////////////////////////////////////////////////////////////////////////////

var g_arrResults = new Array();
var g_oQuizResults = new Object();

function QuestionResult(nQuestionNum, strQuestion, strResult, strCorrectResponse, strStudentResponse, nPoints)
{
	if (nPoints < 0)
	{
		nPoints = 0;
	}
	if (strCorrectResponse == "")
	{
		strCorrectResponse = "&nbsp;";
	}

	this.nQuestionNum = nQuestionNum
	this.strQuestion = strQuestion;
	this.strCorrectResponse = strCorrectResponse;
	this.strStudentResponse = strStudentResponse;
	this.strResult = strResult;
	this.nPoints = nPoints;
	this.bFound = false;
}

function StoreResult(args)
{
	args = args.replace(/\|\$s\$\|/g,";")

	var arrParams = args.split("|$:$|");
	var oQuestionResult = new QuestionResult(parseInt(arrParams[0]) + 1, arrParams[1], arrParams[2], arrParams[3], arrParams[4] ,arrParams[5]);
	var nIndex = g_arrResults.length;

	// Lets see if we have answered the question before

	for (var i = 0; i < g_arrResults.length; i++)
	{
		if (g_arrResults[i].nQuestionNum == oQuestionResult.nQuestionNum)
		{
			nIndex = i;
			break;
		}
	}

	g_arrResults[nIndex] = oQuestionResult;

}

function StoreQuizResult(args)
{
	var arrParams = args.split("|$:$|");

	g_oQuizResults.dtmFinished = new Date();
	g_oQuizResults.strResult = arrParams[0];
	g_oQuizResults.strScore = arrParams[1];
	g_oQuizResults.strPassingScore = arrParams[2]; 
}

function ShowResult(args)
{
	var arrData = args.split("|$s$|");
	
	g_oQuizResults.oOptions = new Object();

	g_oQuizResults.oOptions.bShowUserScore = (arrData[0] == "1");
	g_oQuizResults.oOptions.bShowPassingScore = (arrData[1] == "1");
	g_oQuizResults.oOptions.bShowShowPassFail = (arrData[2] == "1");
	g_oQuizResults.oOptions.bShowQuizReview = (arrData[3] == "1");
	g_oQuizResults.oOptions.strResult = arrData[4];
	g_oQuizResults.oOptions.strName = arrData[5];

	window.open(GetBasePath() + "report.html", "Reports")
}

////////////////////////////////////////////////////////////////////////////////
// Attachment code
////////////////////////////////////////////////////////////////////////////////


function GetBasePath()
{
	var strFullPath = document.location.href;
	var nPos1 = -1;
	var nPos2 = -1;

	nPos1 = strFullPath.lastIndexOf("\\");
	nPos2 = strFullPath.lastIndexOf("/");

	if (nPos2 > nPos1)
	{
		nPos1 = nPos2;
	}

	if (nPos1 >= 0)
	{
		strFullPath = strFullPath.substring(0, nPos1 + 1);
	}

	return(strFullPath);
}

var g_strAttachment = "";
function OpenAttachment()
{
	if (IESP2)
	{
		window.open('../js/attach.html?' + GetBasePath() + g_strAttachment,"attach")
	}
	else
	{
		window.open(GetBasePath() + g_strAttachment);
	}
}

////////////////////////////////////////////////////////////////////////////////
// Zoom code
////////////////////////////////////////////////////////////////////////////////

var g_oZoomInfo = new Object();
var g_wndZoom;

function PopZoomImage(strFileName, nWidth, nHeight)
{
	var strScroll = "0";
	g_oZoomInfo.strFileName = strFileName;
	g_oZoomInfo.nWidth = parseInt(nWidth);
	g_oZoomInfo.nHeight = parseInt(nHeight);

	if (g_oZoomInfo.nWidth > screen.availWidth)
	{
		g_oZoomInfo.nWidth = screen.availWidth;
		strScroll = "1";
	}

	if (g_oZoomInfo.nHeight > screen.availHeight)
	{
		g_oZoomInfo.nHeight = screen.availHeight;
		strScroll = "1";
	}


	var strOptions = "width=" + g_oZoomInfo.nWidth +",height=" + g_oZoomInfo.nHeight + ", status=0, toolbar=0, location=0, menubar=0, scrollbars=" + strScroll;

	if (g_wndZoom)
	{
		try
		{
			g_wndZoom.close()
		}
		catch (e)
		{
		}
	}

	g_wndZoom = window.open(GetBasePath() + "../js/zoom.html", "Zoom", strOptions);
}

////////////////////////////////////////////////////////////////////////////////

function CloseWindow()
{
	window.close();
}

function player_DoFSCommand(command, args) 
{
	args = String(args);

	args = args.replace(/%_q_%/g,"\"")
	args = args.replace(/;/g,"|$s$|")
	args = args.replace(/%_s_%/g,";")

	command = String(command);
	var F_intData = args.split("|$s$|");

	switch (command)
	{
    		case "ART_CloseAndExit":
			if (!g_bLMS)
			{
	       			 //QM customized//
				if (FF)
				{
					setTimeout("CloseWindow()", 100);
				}
				else
				{
					window.close();
				}
			}
			break;

		//Email//
		case "emailEmail":
			g_strEmail = args;
			break;

		case "QuizResults":
		case "Quiz Results":
			var strTemp = args.replace(/\|\$s\$\|/g,";");
			g_strQuizResults = strTemp;
			break;

		case "emailSubject":
			g_strSubject = args;
			break;

		case "emailSubmit":
			SendQuiz();
			break;
		case "StoreQuestionResult":
			StoreResult(args);
			break;
		case "StoreQuizResult":
			StoreQuizResult(args);
			break;
		case "DisplayPrintScreen":
			ShowResult(args);
			break;
		case "ART_QMAttachment":
			g_strAttachment = args;
			if (IESP2)
			{
				OpenAttachment()
			}
			else
			{
				setTimeout("OpenAttachment()", 100)
			}
			break;
		case "QM_ZoomImage":
			PopZoomImage(F_intData[0], F_intData[1], F_intData[2]);
			break;

	}


	if (g_bLMS)
	{
		customFScommandHandler(command, args);
	}
}

//-->
