// ------------------------- DO NOT TOUCH -------------------------------
// ------------------------- DO NOT TOUCH -------------------------------
// ------------------------- DO NOT TOUCH -------------------------------
// ------------------------- DO NOT TOUCH -------------------------------


// ---- GLOSSARY FUNCTION ----
function BuildGlossaryAlphabet(sAlph)
{
	ALPH  = new Array('',"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
	sAlph = sAlph.toUpperCase();

	document.write("<p style='font-weight:bold;font-size:8pt'>");
	for(x=1;x<ALPH.length;x++)
	{
		if(x+1 < ALPH.length){ sSeperate= "<span style='font-size:8pt;color:"+POPUP_TITLE_BACKGROUD_COLOR+"'>&nbsp;|&nbsp;</span>"; }
		else			     { sSeperate= "";    }

		if(sAlph.indexOf(ALPH[x])>-1)
		{ document.write("<a href='#"+ALPH[x]+"'>"+ALPH[x]+"</a>" + sSeperate); }
		else
		{ document.write("<i><span style='color:#A0A0A0;font-size:8pt'>"+ALPH[x]+"</span></i>" + sSeperate); }
	}
	document.write("</p>");
}

// ---- RESOURCES FUNCTION 01 ----
function BuildResourcesModuleNav()
{
	for(x=0;x<arguments.length;x++)
	{
		sSeperator = "";
		if(x+1 < arguments.length)
		{ sSeperator = " &nbsp;|&nbsp; "; }

		if(MODULES[arguments[x]])
		{ document.write("<a href='#MOD"+arguments[x]+"'>"+MODULE_TERMINOLOGY+" "+arguments[x]+"</a>" + sSeperator); }
	}
}

// ---- RESOURCES FUNCTION 01 ----
function BuildResourcesModuleDivider(iMod)
{
		if(MODULES[iMod])
		{ document.write("<a name=MOD"+iMod+"><table width=100% class='ResourcesModDivider' cellpadding=4 cellspacing=0><tr><td class='ResourcesModDivider'>"+MODULES[iMod][0]+"</td><td class='ResourcesModDivider' align=right><a class='ResourcesModDivider' href='#TOP'>back to top</a></td></tr></table>"); }
}


// --- BUILD MODULES ARRAY ---
function NameModule(iNum,sMod)
{
	MODULES[iNum]    = new Array();
	MODULES[iNum][0] = sMod;
}



// ------------------------- DO NOT TOUCH -------------------------------
// ------------------------- DO NOT TOUCH -------------------------------
// ------------------------- DO NOT TOUCH -------------------------------
// ------------------------- DO NOT TOUCH -------------------------------
 STUDENT_NUMCORRECT            = 0;

function BuildQuestion(iQuestion,sText,iModule)
{
	Q_AND_A[iQuestion]  = new Object();
	Q_AND_A[iQuestion].Question = sText; 
	Q_AND_A[iQuestion].Module   = iModule; 
}

function SetAnswer(iQuestion,sText,bCorrect)
{
	Q_AND_A[iQuestion].Answers = (!Q_AND_A[iQuestion].Answers) ? new Array() : Q_AND_A[iQuestion].Answers;
	iOrder = Q_AND_A[iQuestion].Answers.length;
	Q_AND_A[iQuestion].Answers[iOrder]		   = new Object();
	Q_AND_A[iQuestion].Answers[iOrder].Text	   = sText;
	Q_AND_A[iQuestion].Answers[iOrder].Correct = bCorrect;
}

function DisplayTest()
{
	Q_AND_A_copy = Q_AND_A;

	if(RANDOMIZE_QUESTIONS){ Q_AND_A_copy.randomize(); }

	document.write("<OL>");
	for(q=1;q<Q_AND_A_copy.length;q++)
	{
		document.write("<li><b>"+Q_AND_A_copy[q].Question+"</b><br><table>");
		for(a=0;a<Q_AND_A_copy[q].Answers.length;a++)
		{
			document.write("<tr><td valign=top>&nbsp;&nbsp;&nbsp;<input type=radio name='q"+q+"' value='"+((Q_AND_A_copy[q].Answers[a].Correct) ? 1 : 0)+"_"+Q_AND_A_copy[q].Module+"'></td><td>"+Q_AND_A_copy[q].Answers[a].Text+"</td></tr>");
		}
		document.write("</table><br>");
	}
	document.write("</OL>");
}









Array.prototype.randomize = function(start, stop) 
{ 
    start=start||1; stop=stop||this.length; 
    var copy=this.slice(start,stop); 
    while(copy.length) 
        this[start++]=copy.splice( Math.floor( Math.random()*copy.length ),1)[0]; 
    return this; 
}