/*
	Software Copyright (c) 1985-2006 Information Transfer LLP
	Seminar 6.0

	5 Apr 2005

	delivery-target: 0 = standalone web, 1 = SCORM, 2 = NETg

	score-detail: 0 = none, 1 = module, 2 = sections, 3 = questions, 4 = elements

	conditionType: 0 = none, 1 = moduleLessThan, 2 = moduleAtLeast, 3 = sectionLessThan, 4 = sectionAtLeast

	run-mode: 0 = Learning, 1 = Assessment, 2 = Exam, 3 = Survey
*/


var currentPage = null;
var startPage = null;

var presentWindow = parent.presentWindow;
var controlWindow = parent.controlWindow;
var	scoreWindow = parent.scoreWindow;
var deliveryTarget = 0;

var	user = new Object();
	user.firstName = "";
	user.lastName = "";
	user.additional1 = "";
	user.additional2 = "";
	user.additional3 = "";
	user.signedOn = false;

var refStack = new Array();
var controlEjecting = false;
var controlPageLoading = false;
var controlFinishing = false;


function debugLocations()
{
	alert("controlWindow.location=" + controlWindow.location + "\n" + "presentWindow.location=" + presentWindow.location);
}

function debugCurrentPage()
{
	if(currentPage)	alert("currentPage.filename=" + currentPage.filename)
	else alert("currentPage=null");
}

function debugTraceLn(s)
{
	parent.spareWindow.document.writeln(s + "<br>");
}

function debugClearTrace()
{
	parent.spareWindow.location = "blank.html";
	parent.spareWindow.document.write("<span style='font-family:Courier New;font-size:8pt;color:#000000'>");
}

function debugDumpSectionArray(aSection)
{
	debugTraceLn("Title=" + aSection.title);
	debugTraceLn("Start=" + aSection.startPage.filename);
	debugTraceLn("Link=" + aSection.linkKind);
	for(var p = 0; p < aSection.pages.length; p++)
	{
		var page = aSection.pages[p];
		if(page.nextPage) debugTraceLn("[" + p + "] " + page.filename + " -> " + page.nextPage.filename);
		else debugTraceLn("[" + p + "] " + page.filename + " -> null");
	}
}

function debugDumpSectionSequence(aSection)
{
	debugTraceLn("Title=" + aSection.title);
	debugTraceLn("Start=" + aSection.startPage.title);
	debugTraceLn("Link=" + aSection.linkKind);
	var page = aSection.startPage;
	var p = 0;
	while(page)
	{
		p++;
		if(page.nextPage) debugTraceLn("[" + p + "] " + page.title + " -> " + page.nextPage.title);
		else debugTraceLn("[" + p + "] " + page.title + " -> null");
		page = page.nextPage;
	}
}

function debugDumpSequence()
{
	for(var i = 0; i < sections.length; i++) debugDumpSectionSequence(sections[i]);
}

function controlStartOver()
{
	scoreWindow.location = "scoreform.html";
	if(!startPage) startPage = sections[0].startPage;
//alert("startPage=" + startPage);
	controlLoadPage(startPage);
}

function controlFinish()
{
	controlFinishing = true;
	if(deliveryTarget == 1) controlFinishSCORM();
	else if(deliveryTarget == 2) controlFinishNETg();
		else controlFinishSimple();
}

function controlFinishSimple()
{
	if(scoreDetail > 0)
	{
		if(scoreVersion == "Five") var scoreData = controlAssembleScoreData5();
		else var scoreData = controlAssembleScoreData6();
		controlSendScores(scoreScript,scoreFilename,scoreData);
	}
	top.close();
}

function controlFinishSCORM()
{
	controlCheckSectionComplete();
	scormCloseDown();
	top.close();
}

function controlFinishNETg()
{
	var wsvmHome = wsvmCloseDown();
	if(parent.opener)
	{
		parent.opener.location = wsvmHome;
		top.close();
	}
	else parent.location = wsvmHome;
}

function controlPrevPage(aPage)
{
	var prevPage = null;
	if(aPage) prevPage = aPage.prevPage;
	else prevPage = currentPage.prevPage;
	if(prevPage.ismenu)
	{
		controlLoadPage(menuPage);
	}
	else
	{
		if(prevPage)
		{
			if(controlCanLoad(prevPage)) controlLoadPage(prevPage);
			else controlPrevPage(prevPage);
		}
		else controlFinish();
	}
}

function controlNextPage(aPage)
{
	var nextPage = null;
	if(aPage) thePage = aPage;
	else thePage = currentPage;
	nextPage = thePage.nextPage;
	if(nextPage)
	{
		if(nextPage.ismenu)	controlLoadPage(menuPage);
		else
		{
			if(controlCanLoad(nextPage)) controlLoadPage(nextPage);
			else controlNextPage(nextPage);
/*	
			if(controlCanLoad(nextPage)) 
			{
				debugTraceLn("controlCanLoad");
				controlLoadPage(nextPage);
			}
			else 
			{
				debugTraceLn("control CANT load");
				controlNextPage(nextPage);	
			}
*/
		}
	}
	else controlFinish();
}

function controlGotoSection(sectionIndex)
{
	newPage = sections[sectionIndex].startPage;
	controlLoadPage(newPage);
}

function controlEject()
{
	controlEjecting = true;
	if(menuPage) controlLoadPage(menuPage)
	else controlFinish();
	controlEjecting = false;
}

function controlCheckSectionComplete()
{
	if(currentPage) if(currentPage.section >= 0) 
	{
		var aSection = sections[currentPage.section];
		controlCalcSectionComplete(aSection);
	}
}

function controlLoadPage(aPage)
{
	if(!controlPageLoading)
	{
		controlPageLoading = true;
		controlCheckSectionComplete();
		if(deliveryTarget == 1) scormBookmark(aPage);
		currentPage = aPage;
		currentPage.loaded = true;
		presentWindow.location = aPage.filename;
		controlEjecting = false;
	}
}

// 	conditionType: 0 = none, 1 = moduleLessThan, 2 = moduleAtLeast, 3 = sectionLessThan, 4 = sectionAtLeast
function controlCanLoad(aPage)
{
	var score = 0;
	if(aPage.conditionType)
	switch(aPage.conditionType)
	{
		case 0: return true;
		case 1: score = controlGetModuleScore();
				if(score < aPage.conditionValue) return true;
				else return false;
		case 2: score = controlGetModuleScore();		
				if(score >= aPage.conditionValue) return true;
				else return false;
		case 3: score = controlGetSectionScoreN(aPage.section);
//				alert("sectionLessThan: score =" + score + " condition=" + aPage.conditionValue);
				if(score < aPage.conditionValue) return true;
				else return false;
		case 4: score = controlGetSectionScoreN(aPage.section);
//				alert("sectionAtLeast: score =" + score + " condition=" + aPage.conditionValue);
				if(score >= aPage.conditionValue) return true;
				else return false;
	}
	else return true;
}

function controlPushPage(aPage)
{
	refStack.push(aPage);
	return aPage;
}

function controlPushCurrentPage()
{
	refStack.push(currentPage);
	return currentPage;
}

function controlPopPage()
{
	return refStack.pop();
}

function controlFindPageByID(aID)
{
	for(var s = 0; s < sections.length; s++)
	{
		for(var p = 0; p < sections[s].pages.length; p++)
		{
			if(sections[s].pages[p].pageID == aID) return sections[s].pages[p];
		}
	}
	return null;
}

function controlFindRefByID(aID)
{
	if(refPages)
	{
		for(var r = 0; r < refPages.length; r++)
			if(refPages[r].pageID == aID) return refPages[r];
	}
	return null;
}

function controlFindPrevSection(aSection)
{
	var t = null;
	for(var i = 0; i < sections.length; i++)
	{
		if(sections[i] == aSection) return t;
		else t = sections[i];
	}
	return t;
}

function controlShuffleArray(arr,ofs)
{
	for (var i = 0; i < arr.length; i++) arr[i] = i + ofs;
	for (var i = arr.length - 1; i > 0; i--)
	{
		var j = Math.floor((i + 1) * Math.random());
		var t = arr[i];
		arr[i] = arr[j];
		arr[j] = t;
	}
//	for(var i = 0; i < arr.length; i++) debugTraceLn(i + " " + arr[i]);
}

function controlApplyShuffleArray(arr,aSection,aFirst,aLast,aCount)
{
//	debugTraceLn("controlApplyShuffleArray(" + arr + "\n," + aFirst + ", " + aLast +", " + aCount +")");

//	This copes where aCount = 1
	aPage = aSection.pages[arr[0]];
	aPage.nextPage = null;
/*
	aNextPage = aSection.pages[arr[1]];
	aPage.nextPage = aNextPage;
	aNextPage.nextPage = null;
*/
//	This copes where aCount = 1 (end)

	for(var i = 0; i < aCount-1; i++)
	{
		aPage = aSection.pages[arr[i]];
		aNextPage = aSection.pages[arr[i+1]];
/*
	debugTraceLn("(" + aPage.title + ")->(" + aNextPage.title + ")");
*/
		aPage.nextPage = aNextPage;
		aNextPage.nextPage = null;
	}

	for(var i = aCount; i < arr.length; i++) aSection.pages[arr[i]].isQuestionCount = false;

/*
	aSection.questionCount = 0;
	for(var i = 0; i < aSection.pages.length; i++) 
	{
		if(aSection.pages[i].isQuestionCount) aSection.questionCount++;
	}
*/

	if(aFirst == 0) aSection.startPage = aSection.pages[arr[0]];
	else aSection.pages[aFirst-1].nextPage = aSection.pages[arr[0]];

	if(aLast < aSection.pages.length-1)
	{
/*
		debugTraceLn("LastRand (" + aNextPage.title + ")");
		debugTraceLn("Static (" + aSection.pages[aLast+1].title + ")");
*/
		aNextPage.nextPage = aSection.pages[aLast+1];
	}
}

function debugDumpRandom(aSection)
{
	var p = 0;
	var aPage = aSection.startPage;
	while(aPage)
	{
		if(aPage.nextPage) debugTraceLn(p + " " + aPage.title + " =>>");
		else debugTraceLn(p + " " + aPage.title + " (null)");
		aPage = aPage.nextPage;
		p++;
	}
}

function controlShufflePages(aSection,aFirst,aLast,aCount)
{
	var arr = new Array((aLast-aFirst)+1);
	controlShuffleArray(arr,aFirst);
	controlApplyShuffleArray(arr,aSection,aFirst,aLast,aCount);
/*
	debugDumpRandom(aSection);
	debugDumpSectionSequence(sections[0]);
*/
}

function controlFixLink(aSection,nextSection)
{
/*
	if(nextSection) alert(aSection.title + " LK=" + aSection.linkKind + " Next=" + nextSection.title);
	else alert(aSection.title + " LK=" + aSection.linkKind + " Next=null");
*/
    switch(aSection.linkKind)
	{
		case 0: return null;
		case 1: if(nextSection) return nextSection.startPage
				else return null;
		case 2: return menuPage;
	}
}

function controlUnlinkedLast(aSectionIndex)
{
	var	ok = true;
	var page = sections[aSectionIndex].startPage;
	var	temp = null;
	while(page && ok)
	{
		if(page.section == aSectionIndex)
		{
			temp = page;
			page = page.nextPage;
			if(page) page.prevPage = temp;
		}
		else ok = false;
		if(menuPage && page == menuPage) 
		{
			page = null;
			temp = null;
			ok = false;
		}
	}
	return temp;
}

function controlFixupPageLinks()
{
	var page = null;
	var lastPage = null;
	for(var s = 0; s < sections.length; s++)
	{
		lastPage = controlUnlinkedLast(s);
/*
		if(lastPage) debugTraceLn("lastPage=" + lastPage.title);
		else debugTraceLn("lastPage=null");
*/
		if(lastPage)
		{
			if(s+1 < sections.length) lastPage.nextPage = controlFixLink(sections[s],sections[s+1]);
			else lastPage.nextPage = controlFixLink(sections[s],null);
		}
	}
}

// pnNumber = 0, pnSame = 1, pnReset = 2	  

function controlCalcPageNumbers()
{
	var page = null;
	var prev = null;
	var pageNo = 1;
	for(var i = 0; i < sections.length; i++)
	{
		page = sections[i].startPage;
		while(page && page.section == i)
		{
			if(page.pageNumberKind == 2) pageNo = 1;
			page.pageNumber = pageNo;
			if(page.pageNumberKind != 1) pageNo++;
			prev = page;
			page = page.nextPage;
		}
		sections[i].lastPage = prev;
	}
	var totalPages = 0;
	for(var i = sections.length-1; i >= 0; i--)
	{
		page = sections[i].lastPage;
		while(page && page.section == i)
		{
			if(totalPages == 0) totalPages = page.pageNumber;
			page.totalPages = totalPages;
			if(page.pageNumberKind == 2) totalPages = 0;
			page = page.prevPage;
		}
	}
}

function controlPrintScore()
{
	window.print();
}

function controlPageIsQuestion(sectionIndex,pageIndex)
{
	if(sections[sectionIndex].pages[pageIndex].correct) return true
	else return false;
}

function controlGetPagePoints(aPage)
{
	if(aPage.percent) return aPage.percent;
	else
	{
		var lc = aPage.correct.length;
		var ls = aPage.student.length;
		var	r = 0;
		for(var i = 0; i < lc; i++)
		{
			if(i <= ls)
			{
				if(aPage.correct.charAt(i) == aPage.student.charAt(i)) r++
			}
		}
		if(lc) r = Math.round((r/lc) * 100);
		return r;
	}
}

function controlGetPageByFilename(aFilename)
{
	if(aFilename == "menu.html") return menuPage;
	else
	{
		for(var s = 0; s < sections.length; s++)
		{
			for(var p = 0; p < sections[s].pages.length; p++)
			{
				if(sections[s].pages[p].filename == aFilename) return sections[s].pages[p];
			}
		}
	}
	return null;
}

function getPageByIndex(pageIndex)
{
	var n = 0;
	var	p = 0;
	for(var i = 0; i < sections.length; i++)
	{
		for(p = 0; p < sections[i].pages.length; p++)
		{
			if(n == pageIndex) return sections[i].pages[p];
			n++;
		}
	}
	return null;
}

function getQuestionByIndex(questionIndex)
{
	var n = 0;
	var	p = 0;
	var	aPage = null;
	for(var i = 0; i < sections.length; i++)
	{
		for(p = 0; p < sections[i].pages.length; p++)
		{
			if(sections[i].pages[p].isQuestion)
			{
				if(n == questionIndex) return sections[i].pages[p];
				n++;
			}
		}
	}
	return null;
}

function controlGetQuestionTitleN(questionNum)
{
	var aPage = getQuestionByIndex(questionNum);
	if(aPage) return aPage.title;
	else return "";
}

function controlGetQuestionScoreN(questionNum)
{
	var aPage = getQuestionByIndex(questionNum);
	if(aPage) return controlGetPagePoints(aPage)
	else return 0;
}

function controlGetQuestionDurationN(questionNum)
{
	var aPage = getQuestionByIndex(questionNum);
	if(aPage) return aPage.duration;
	else return 0;
}

function controlGetSectionAttemptedCount(aSection)
{
	var	r = 0;
	var aPage = null;
	for(var i = 0; i < aSection.pages.length; i++)
	{
		aPage = aSection.pages[i];
		if(aPage.isQuestionCount)
		{
			if(aPage.attempted) r++;
		}
	}
	return r;
}

function controlGetSectionAttemptedCountN(sectionNum)
{
	return controlGetSectionAttemptedCount(sections[sectionNum]);
}

function controlGetSectionPoints(aSection)
{
	var	r = 0;
	var aPage = null;
	for(var i = 0; i < aSection.pages.length; i++)
	{
		aPage = aSection.pages[i];
		if(aPage.isQuestion) r += controlGetPagePoints(aPage);
	}
	return r;
}

function controlGetSectionScore(aSection)
{
	if(aSection.questionCount)
	{
		var p = controlGetSectionPoints(aSection);
		return Math.round(p/aSection.questionCount);
	}
	else return 0;
}

function controlGetSectionScoreN(sectionNum)
{
	return controlGetSectionScore(sections[sectionNum]);
}

function controlGetSectionDuration(aSection)
{
	var r = 0;
	for(var i = 0; i < aSection.pages.length; i++) r += aSection.pages[i].duration;
	return r;
}

function controlGetSectionDurationN(sectionNum)
{
	return controlGetSectionDuration(sections[sectionNum]);
}

function controlGetSectionTitleN(sectionNum)
{
	return sections[sectionNum].title;
}

function controlGetSectionQuestionCountN(sectionNum)
{
	return sections[sectionNum].questionCount;
}

function controlCalcLearningComplete(aSection)
{
	var count = 0;
	var loaded = 0;
	var temp = false;
	for(var i = 0; i < aSection.pages.length; i++)
	{
		if(!aSection.pages[i].conditionType)
		{
			count++;
			if(aSection.pages[i].loaded) loaded++;
		}
	}
	if(count == loaded) temp = true;
	else temp = false;
	aSection.completed = temp;
	return temp;
}

function controlCalcLearningCompleteN(sectionNum)
{
	return controlCalcLearningComplete(sections[sectionNum]);
}

function controlCalcSectionComplete(aSection)
{
	var temp = false;
	if(aSection.runMode == 0 || aSection.runMode == 3) temp = controlCalcLearningComplete(aSection)
	else
	{
		if(controlGetSectionAttemptedCount(aSection) >= aSection.questionsReq) temp = true;
		else temp = false;
	}
	aSection.completed = temp;
	return temp;
}

function controlGetModuleComplete()
{
	for(var i = 0; i < sections.length; i++)
	{
		var aSection = sections[i];
		if(!aSection.optional) if(controlCalcSectionComplete(aSection)) return false;
	}
	return true;
}

function controlCalcModuleComplete()
{
	var temp = true;
	var tempS = true;
	for(var i = 0; i < sections.length; i++)
	{
		var aSection = sections[i];
		if(!aSection.optional) 
		{
			tempS = controlCalcSectionComplete(aSection);
			if(!tempS) temp = false;
		}
	}
	return temp;
}

function controlGetSectionInc(aSection)
{
	var gs = false;
	if(moduleAssessment)
	{
		if(aSection.runMode == 1 || aSection.runMode == 2) gs = true;
		else gs = false;
	}
	else gs = true;
	return gs;
}

function controlCountSectionsWithQuestions()
{
	var tmp = 0;
	for(var i = 0; i < sections.length; i++)
	{
		if(sections[i].questionCount) tmp++;
	}
	return tmp;
}

function controlGetModulePoints()
{
	var r = 0;
	for(var i = 0; i < sections.length; i++)
	{
		aSection = sections[i];
		if(controlGetSectionInc(aSection)) r += controlGetSectionPoints(aSection);
	}
	return r;
}

function controlGetModuleQuestionCount()
{
	var r = 0
	for(var i = 0; i < sections.length; i++)
	{
		aSection = sections[i];
		if(controlGetSectionInc(aSection)) r += aSection.questionsReq;
	}
	return r;
}

function controlGetModuleAttemptedCount()
{
	var r = 0
	for(var i = 0; i < sections.length; i++)
	{
		aSection = sections[i];
		if(controlGetSectionInc(aSection)) r += controlGetSectionAttemptedCount(aSection);
	}
	return r;
}

function controlGetModuleScore()
{
	var c = controlGetModuleQuestionCount();
	var p = controlGetModulePoints();
	if(c)return Math.round(p/c);
	else return 0;
}

function controlGetModuleStatus()
{
	if(controlCalcModuleComplete())
	{
		if(moduleAssessment)
		{
			if(controlGetModuleScore() >= modulePassmark) return "P";
			else return "F";
		}
		else return "C";
	}
	else return "I";
}

function controlExpandModuleStatus(cStatus)
{
	switch(cStatus)
	{
		case "C": return "completed";
		case "F": return "failed";
		case "I": return "incomplete";
		case "P": return "passed";
	}
}

function controlGetModuleDurationSeconds()
{
	var r = 0
	var aSection = null;
	for(var i = 0; i < sections.length; i++) r += controlGetSectionDuration(sections[i]);
	return r;
}

function controlFormatDateTime(aDate)
{
	var tmp = aDate.getFullYear();
	n = aDate.getMonth();
	n++;
	if(n <= 9) tmp = tmp + "-0" + n;
	else tmp = tmp + "-" + n;
	n = aDate.getDate();
	if(n <= 9) tmp = tmp + "-0" + n;
	else tmp = tmp + "-" + n;
	n = aDate.getHours();
	if(n <= 9) tmp = tmp + " 0" + n;
	else tmp = tmp + " " + n;
	n = aDate.getMinutes();
	if(n <= 9) tmp = tmp + ":0" + n;
	else tmp = tmp + ":" + n;
	return tmp;
}

function controlGetSignonData5()
{
	var tmp = "";
	if(user.signedOn)
	{
		tmp = '"' + user.lastName + '",';
		tmp = tmp + '"' + user.firstName + '",';
		tmp = tmp + '"' + user.additional1 + '",';
		tmp = tmp + '"' + user.additional2 + '",';
		tmp = tmp + '"' + user.additional3 + '",';
		tmp = tmp + controlFormatDateTime(new Date());
	}
	else tmp = '"","","","","","",0000-00-00 00:00';
	return tmp;
}

function controlGetSectionScoreData5(aSection)
{
	var	tmp = '"' + aSection.title + '",';
	tmp = tmp + controlGetSectionAttemptedCount(aSection) + ',';
	tmp = tmp + aSection.questionCount + ',';
	tmp = tmp + controlGetSectionDuration(aSection) + ',';
	tmp = tmp + controlGetSectionScore(aSection) + '%';
	return tmp;
}

function controlGetPageScoreData(aPage)
{
	var tmp = '"' + aPage.title + '",';
	tmp = tmp + aPage.duration + ',';
	tmp = tmp + '"' + aPage.student + '",';
	tmp = tmp + controlGetPagePoints(aPage) + "%";
	return tmp;
}

function controlGetModuleScoreData5()
{
	var tmp = controlGetSignonData5();
	tmp = tmp + "," + controlGetModuleAttemptedCount();
	tmp = tmp + "," + controlGetModuleQuestionCount();
	tmp = tmp + "," + controlGetModuleDurationSeconds();
	tmp = tmp + "," + controlGetModuleScore() + "%";
	return tmp;
}

function controlAssembleScoreData5()
{
	controlCalcModuleComplete();
	var tmp = controlGetModuleScoreData5();
	if(scoreDetail >= 2)
	{
		var i = 0;
		for(i = 0; i < sections.length; i++)
		{
			aSection = sections[i];
			tmp = tmp + "," + controlGetSectionScoreData5(aSection);
			if(scoreDetail >= 3)
			{
				var p = 0;
				for(p = 0; p < aSection.pages.length; p++)
				{
					aPage = aSection.pages[p];
					if(aPage.isQuestion) tmp = tmp + "," + controlGetPageScoreData(aPage);
				}
			}
		}
	}
	return tmp;
}

function controlGetSignonData6()
{
	var tmp = "";
	if(user.signedOn)
	{
		tmp = '"' + user.firstName + '",';
		tmp = tmp + '"' + user.lastName + '",';
		tmp = tmp + '"' + user.additional1 + '"';
		if(scoreRevision == "B")
		{
			tmp = tmp + ',"' + user.additional2 + '",';
			tmp = tmp + '"' + user.additional3 + '"';
		}
	}
	else if(scoreRevision == "B") tmp = '"","","","",""';
		 else tmp = '"","",""';
	return tmp;
}

function controlAssembleScoreData6()
{
	controlCalcModuleComplete();
	var numSections = 0;
	if(scoreRevision == "B") var tmp = 'AB,"' + controlWindow.moduleID +'"';
	else var tmp = 'AA,"' + controlWindow.moduleID +'"';
	tmp = tmp + "," + controlGetSignonData6();
	tmp = tmp + "," + controlFormatDateTime(new Date());
	tmp = tmp + "," + controlGetModuleStatus();
	tmp = tmp + "," + controlGetModuleDurationSeconds();
	tmp = tmp + "," + controlGetModuleScore();
	if(scoreDetail >= 2) numSections = controlCountSectionsWithQuestions();
	tmp = tmp + "," + numSections;
	if(scoreRevision != "B") tmp = tmp + ",0";
	if(scoreDetail >= 2)
	{
		for(var s = 0; s < sections.length; s++)
		{
			aSection = sections[s];
			if(aSection.questionCount > 0)
			{
				tmp = tmp + "," + controlGetSectionDuration(aSection);
				tmp = tmp + "," + controlGetSectionScore(aSection);
				if(scoreDetail >= 3)
				{
					tmp = tmp + "," + aSection.questionCount;
					for(var p = 0; p < aSection.pages.length; p++)
					{
						aPage = aSection.pages[p];
						if(aPage.isQuestion)
						{
							if(aPage.attempted)
							{
							tmp = tmp + "," + aPage.duration;
							tmp = tmp + "," + controlGetPagePoints(aPage);
							tmp = tmp + ',"' + aPage.student + '"';
							}
							else tmp = tmp + ",,,";
						}
					}
				}
				else tmp = tmp + ",0";
			}
		}
	}
	return tmp;
}

function controlSendScores(aScript,aFilename,aScoreData)
{
	scoreWindow.scoreForm.filename.value = aFilename;
	scoreWindow.scoreForm.data.value = aScoreData;
	scoreWindow.scoreForm.debug.value = scoreDebug;
	scoreWindow.scoreForm.action = aScript;
	scoreWindow.scoreForm.submit();
}


