

//<![CDATA[

<!--


function Client(){
//if not a DOM browser, hopeless
	this.min = false; if (document.getElementById){this.min = true;};

	this.ua = navigator.userAgent;
	this.name = navigator.appName;
	this.ver = navigator.appVersion;  

//Get data about the browser
	this.mac = (this.ver.indexOf('Mac') != -1);
	this.win = (this.ver.indexOf('Windows') != -1);

//Look for Gecko
	this.gecko = (this.ua.indexOf('Gecko') > 1);
	if (this.gecko){
		this.geckoVer = parseInt(this.ua.substring(this.ua.indexOf('Gecko')+6, this.ua.length));
		if (this.geckoVer < 20020000){this.min = false;}
	}
	
//Look for Firebird
	this.firebird = (this.ua.indexOf('Firebird') > 1);
	
//Look for Safari
	this.safari = (this.ua.indexOf('Safari') > 1);
	if (this.safari){
		this.gecko = false;
	}
	
//Look for IE
	this.ie = (this.ua.indexOf('MSIE') > 0);
	if (this.ie){
		this.ieVer = parseFloat(this.ua.substring(this.ua.indexOf('MSIE')+5, this.ua.length));
		if (this.ieVer < 5.5){this.min = false;}
	}
	
//Look for Opera
	this.opera = (this.ua.indexOf('Opera') > 0);
	if (this.opera){
		this.operaVer = parseFloat(this.ua.substring(this.ua.indexOf('Opera')+6, this.ua.length));
		if (this.operaVer < 7.04){this.min = false;}
	}
	if (this.min == false){
		alert('Your browser may not be able to handle this page.');
	}
	
//Special case for the horrible ie5mac
	this.ie5mac = (this.ie&&this.mac&&(this.ieVer<6));
}

var C = new Client();

//for (prop in C){
//	alert(prop + ': ' + C[prop]);
//}



//CODE FOR HANDLING NAV BUTTONS AND FUNCTION BUTTONS

//[strNavBarJS]
function NavBtnOver(Btn){
	if (Btn.className != 'NavButtonDown'){Btn.className = 'NavButtonUp';}
}

function NavBtnOut(Btn){
	Btn.className = 'NavButton';
}

function NavBtnDown(Btn){
	Btn.className = 'NavButtonDown';
}
//[/strNavBarJS]

function FuncBtnOver(Btn){
	if (Btn.className != 'FuncButtonDown'){Btn.className = 'FuncButtonUp';}
}

function FuncBtnOut(Btn){
	Btn.className = 'FuncButton';
}

function FuncBtnDown(Btn){
	Btn.className = 'FuncButtonDown';
}

function FocusAButton(){
	if (document.getElementById('CheckButton1') != null){
		document.getElementById('CheckButton1').focus();
	}
	else{
		if (document.getElementById('CheckButton2') != null){
			document.getElementById('CheckButton2').focus();
		}
		else{
			document.getElementsByTagName('button')[0].focus();
		}
	}
}




//CODE FOR HANDLING DISPLAY OF POPUP FEEDBACK BOX

var topZ = 1000;

function ShowMessage(Feedback){
	var Output = Feedback + '<br /><br />';
	document.getElementById('FeedbackContent').innerHTML = Output;
	var FDiv = document.getElementById('FeedbackDiv');
	topZ++;
	FDiv.style.zIndex = topZ;
	FDiv.style.top = TopSettingWithScrollOffset(30) + 'px';

	FDiv.style.display = 'block';

	ShowElements(false, 'input');
	ShowElements(false, 'select');
	ShowElements(false, 'object');

//Focus the OK button
	setTimeout("document.getElementById('FeedbackOKButton').focus()", 50);
	
//
}

function ShowElements(Show, TagName){
//Special for IE bug -- hide all the form elements that will show through the popup
	if (C.ie){
		var Els = document.getElementsByTagName(TagName);
		for (var i=0; i<Els.length; i++){
			if (Show == true){
				Els[i].style.display = 'inline';
			}
			else{
				Els[i].style.display = 'none';
			}
		}
	} 
}

function HideFeedback(){
	document.getElementById('FeedbackDiv').style.display = 'none';
	ShowElements(true, 'input');
	ShowElements(true, 'select');
	ShowElements(true, 'object');
	if (Finished == true){
		Finish();
	}
}


//GENERAL UTILITY FUNCTIONS AND VARIABLES

//PAGE DIMENSION FUNCTIONS
function PageDim(){
//Get the page width and height
	this.W = 600;
	this.H = 400;
	this.W = document.getElementsByTagName('body')[0].clientWidth;
	this.H = document.getElementsByTagName('body')[0].clientHeight;
}

var pg = null;

function GetPageXY(El) {
	var XY = {x: 0, y: 0};
	while(El){
		XY.x += El.offsetLeft;
		XY.y += El.offsetTop;
		El = El.offsetParent;
	}
	return XY;
}

function GetScrollTop(){
	if (document.documentElement && document.documentElement.scrollTop){
		return document.documentElement.scrollTop;
	}
	else{
		if (document.body){
 			return document.body.scrollTop;
		}
		else{
			return window.pageYOffset;
		}
	}
}

function GetViewportHeight(){
	if (window.innerHeight){
		return window.innerHeight;
	}
	else{
		return document.getElementsByTagName('body')[0].clientHeight;
	}
}

function TopSettingWithScrollOffset(TopPercent){
	var T = Math.floor(GetViewportHeight() * (TopPercent/100));
	return GetScrollTop() + T; 
}

//CODE FOR AVOIDING LOSS OF DATA WHEN BACKSPACE KEY INVOKES history.back()
var InTextBox = false;

function SuppressBackspace(e){ 
	if (InTextBox == true){return;}
	if (C.ie) {
		thisKey = window.event.keyCode;
	}
	else {
		thisKey = e.keyCode;
	}

	var Suppress = false;

	if (thisKey == 8) {
		Suppress = true;
	}

	if (Suppress == true){
		if (C.ie){
			window.event.returnValue = false;	
			window.event.cancelBubble = true;
		}
		else{
			e.preventDefault();
		}
	}
}

if (C.ie){
	document.attachEvent('onkeydown',SuppressBackspace);
	window.attachEvent('onkeydown',SuppressBackspace);
}
else{
	if (window.addEventListener){
		window.addEventListener('keypress',SuppressBackspace,false);
	}
}

function ReduceItems(InArray, ReduceToSize){
	var ItemToDump=0;
	var j=0;
	while (InArray.length > ReduceToSize){
		ItemToDump = Math.floor(InArray.length*Math.random());
		InArray.splice(ItemToDump, 1);
	}
}

function Shuffle(InArray){
	var Num;
	var Temp = new Array();
	var Len = InArray.length;

	var j = Len;

	for (var i=0; i<Len; i++){
		Temp[i] = InArray[i];
	}

	for (i=0; i<Len; i++){
		Num = Math.floor(j  *  Math.random());
		InArray[i] = Temp[Num];

		for (var k=Num; k < (j-1); k++) {
			Temp[k] = Temp[k+1];
		}
		j--;
	}
	return InArray;
}

function WriteToInstructions(Feedback) {
	document.getElementById('InstructionsDiv').innerHTML = Feedback;

}




function EscapeDoubleQuotes(InString){
	return InString.replace(/"/g, '&quot;')
}

function TrimString(InString){
        var x = 0;

        if (InString.length != 0) {
                while ((InString.charAt(InString.length - 1) == '\u0020') || (InString.charAt(InString.length - 1) == '\u000A') || (InString.charAt(InString.length - 1) == '\u000D')){
                        InString = InString.substring(0, InString.length - 1)
                }

                while ((InString.charAt(0) == '\u0020') || (InString.charAt(0) == '\u000A') || (InString.charAt(0) == '\u000D')){
                        InString = InString.substring(1, InString.length)
                }

                while (InString.indexOf('  ') != -1) {
                        x = InString.indexOf('  ')
                        InString = InString.substring(0, x) + InString.substring(x+1, InString.length)
                 }

                return InString;
        }

        else {
                return '';
        }
}

function FindLongest(InArray){
	if (InArray.length < 1){return -1;}

	var Longest = 0;
	for (var i=1; i<InArray.length; i++){
		if (InArray[i].length > InArray[Longest].length){
			Longest = i;
		}
	}
	return Longest;
}

//UNICODE CHARACTER FUNCTIONS
function IsCombiningDiacritic(CharNum){
	var Result = (((CharNum >= 0x0300)&&(CharNum <= 0x370))||((CharNum >= 0x20d0)&&(CharNum <= 0x20ff)));
	Result = Result || (((CharNum >= 0x3099)&&(CharNum <= 0x309a))||((CharNum >= 0xfe20)&&(CharNum <= 0xfe23)));
	return Result;
}

function IsCJK(CharNum){
	return ((CharNum >= 0x3000)&&(CharNum < 0xd800));
}

//SETUP FUNCTIONS
//BROWSER WILL REFILL TEXT BOXES FROM CACHE IF NOT PREVENTED
function ClearTextBoxes(){
	var NList = document.getElementsByTagName('input');
	for (var i=0; i<NList.length; i++){
		if ((NList[i].id.indexOf('Guess') > -1)||(NList[i].id.indexOf('Gap') > -1)){
			NList[i].value = '';
		}
		if (NList[i].id.indexOf('Chk') > -1){
			NList[i].checked = '';
		}
	}
}

//EXTENSION TO ARRAY OBJECT
function Array_IndexOf(Input){
	var Result = -1;
	for (var i=0; i<this.length; i++){
		if (this[i] == Input){
			Result = i;
		}
	}
	return Result;
}
Array.prototype.indexOf = Array_IndexOf;

//IE HAS RENDERING BUG WITH BOTTOM NAVBAR
function RemoveBottomNavBarForIE(){
	if ((C.ie)&&(document.getElementById('Reading') != null)){
		if (document.getElementById('BottomNavBar') != null){
			document.getElementById('TheBody').removeChild(document.getElementById('BottomNavBar'));
		}
	}
}




//HOTPOTNET-RELATED CODE

var HPNStartTime = (new Date()).getTime();
var SubmissionTimeout = 30000;
var Detail = ''; //Global that is used to submit tracking data

function Finish(){
//If there's a form, fill it out and submit it
	if (document.store != null){
		Frm = document.store;
		Frm.starttime.value = HPNStartTime;
		Frm.endtime.value = (new Date()).getTime();
		Frm.mark.value = Score;
		Frm.detail.value = Detail;
		Frm.submit();
	}
}



//JQUIZ CORE JAVASCRIPT CODE

var CurrQNum = 0;
var CorrectIndicator = ':-)';
var IncorrectIndicator = 'X';
var YourScoreIs = 'Your score is ';
var ContinuousScoring = true;
var CorrectFirstTime = 'Questions answered correctly first time: ';
var ShowCorrectFirstTime = false;
var ShuffleQs = true;
var ShuffleAs = true;
var DefaultRight = 'Correct!';
var DefaultWrong = 'Sorry! Try again.';
var QsToShow = 10;
var Score = 0;
var Finished = false;
var Qs = null;
var QArray = new Array();
var ShowingAllQuestions = false;
var ShowAllQuestionsCaption = 'Show all questions';
var ShowOneByOneCaption = 'Show questions one by one';
var State = new Array();
var Feedback = '';
var TimeOver = false;
var strInstructions = '';

//The following variable can be used to add a message explaining that
//the question is finished, so no further marking will take place.
var strQuestionFinished = '';

function CompleteEmptyFeedback(){
	var QNum, ANum;
	for (QNum=0; QNum<I.length; QNum++){
//Only do this if not multi-select
		if (I[QNum][2] != '3'){
  		for (ANum = 0; ANum<I[QNum][3].length; ANum++){
  			if (I[QNum][3][ANum][1].length < 1){
  				if (I[QNum][3][ANum][2] > 0){
  					I[QNum][3][ANum][1] = DefaultRight;
  				}
  				else{
  					I[QNum][3][ANum][1] = DefaultWrong;
  				}
  			}
  		}
		}
	}
}

function SetUpQuestions(){
	var AList = new Array(); 
	var QList = new Array();
	var i, j;
	Qs = document.getElementById('Questions');
	while (Qs.getElementsByTagName('li').length > 0){
		QList.push(Qs.removeChild(Qs.getElementsByTagName('li')[0]));
	}
	var DumpItem = 0;
	if (QsToShow > QList.length){
		QsToShow = QList.length;
	}
	while (QsToShow < QList.length){
		DumpItem = Math.floor(QList.length*Math.random());
		for (j=DumpItem; j<(QList.length-1); j++){
			QList[j] = QList[j+1];
		}
		QList.length = QList.length-1;
	}
	if (ShuffleQs == true){
		QList = Shuffle(QList);
	}
	if (ShuffleAs == true){
		var As;
		for (var i=0; i<QList.length; i++){
			As = QList[i].getElementsByTagName('ol')[0];
			if (As != null){
  			AList.length = 0;
				while (As.getElementsByTagName('li').length > 0){
					AList.push(As.removeChild(As.getElementsByTagName('li')[0]));
				}
				AList = Shuffle(AList);
				for (j=0; j<AList.length; j++){
					As.appendChild(AList[j]);
				}
			}
		}
	}
	
	for (i=0; i<QList.length; i++){
		Qs.appendChild(QList[i]);
		QArray[QArray.length] = QList[i];
	}

//Show the first item
	QArray[0].style.display = '';
	
//Now hide all except the first item
	for (i=1; i<QArray.length; i++){
		QArray[i].style.display = 'none';
	}		
	SetQNumReadout();
}

function ChangeQ(ChangeBy){
//The following line prevents moving to another question until the current
//question is answered correctly. Uncomment it to enable this behaviour. 
//	if (State[CurrQNum][0] == -1){return;}
	if (((CurrQNum + ChangeBy) < 0)||((CurrQNum + ChangeBy) >= QArray.length)){return;}
	QArray[CurrQNum].style.display = 'none';
	CurrQNum += ChangeBy;
	QArray[CurrQNum].style.display = '';
	SetQNumReadout();
//if there's a textbox, set the focus in it
	if (QArray[CurrQNum].getElementsByTagName('input')[0] != null){
		QArray[CurrQNum].getElementsByTagName('input')[0].focus();
	}
}

function SetQNumReadout(){
	document.getElementById('QNumReadout').innerHTML = (CurrQNum+1) + ' / ' + QArray.length;
}

I=new Array();
I[0]=new Array();I[0][0]=100;
I[0][1]='';
I[0][2]='0';
I[0][3]=new Array();
I[0][3][0]=new Array('Being able to defend a nation\u2019s own sealanes.','Sorry.  This is important but there is more to it than just this.',0,0,1);
I[0][3][1]=new Array('How big a fleet of ships your nation can build and sail into the world\'s oceans.','Nope.  The size of a nation\'s Navy doesn\'t always equal it\'s Sea Power.',0,0,1);
I[0][3][2]=new Array('The ability to deny an enemy the use of the sea in time of war.','Sorry.  This is important but there is more to it than just this.',0,0,1);
I[0][3][3]=new Array('The total volume of trade and goods that can be shipped by a nation given the size of their merchant marine.','Nope.  The volume and type of maritime trade, while important, are not factors in the  definition of Sea Power.',0,0,1);
I[0][3][4]=new Array('Both the ability to defend your sealanes and the ability to deny the enemy the use of the sea in time of war.','Correct.  Good job.',1,100,1);
I[1]=new Array();I[1][0]=100;
I[1][1]='';
I[1][2]='0';
I[1][3]=new Array();
I[1][3][0]=new Array('As protection for merchant ships against armed robbers.','Correct.  Armed robbers in faster ships caused merchants to arm their ships and create navies to patrol against these pirates.',1,100,1);
I[1][3][1]=new Array('To defeat other nation\'s armies during war.','Nope.  Navies had little affect on warring armies in the ancient world.',0,0,1);
I[1][3][2]=new Array('To allow for amphibious operations against enemies.','Nope.  This would come much later.',0,0,1);
I[1][3][3]=new Array('To sink other nation\'s merchant shipping.','Sorry.  Although navies would take on this role later it is not the reason they were first formed.',0,0,1);
I[1][3][4]=new Array('To more quickly move army troops from place to place.','Sorry.  Although navies would take on this role later it is not the reason they were first formed.',0,0,1);
I[2]=new Array();I[2][0]=100;
I[2][1]='';
I[2][2]='0';
I[2][3]=new Array();
I[2][3][0]=new Array('Galleys','Correct.  This was the first type of warship and had several variations of design and function.',1,100,1);
I[2][3][1]=new Array('Brigs','Sorry.  This type of warship came much later.',0,0,1);
I[2][3][2]=new Array('Destroyers','Nope.  Destroyers didn\'t come into being until the early 1900\'s.',0,0,1);
I[2][3][3]=new Array('Frigates','Nope.  This type of warship didn\'t evolve until much later.',0,0,1);
I[2][3][4]=new Array('Sloops','Nope.  This type of warship didn\'t evolve until much later.',0,0,1);
I[3]=new Array();I[3][0]=100;
I[3][1]='';
I[3][2]='0';
I[3][3]=new Array();
I[3][3][0]=new Array('Because Crete was too rugged for farming.','Correct.  Because of this it was natural for them to develop sea trade and sea power.',1,100,1);
I[3][3][1]=new Array('Because Crete had an abundance of goods and needed to trade them with other nations.','Nope.  Crete is rugged and lacks much of the things needed to prosper without sea trade.',0,0,1);
I[3][3][2]=new Array('Because they didn\'t eat meat and so came to rely on the sea from early in their history.','Sorry.  The people of Crete ate meat just like every other civilization.',0,0,1);
I[3][3][3]=new Array('Because they invented the War Galley.','Sorry.  There is no evidence that the first War Galleys were developed on Crete.',0,0,1);
I[3][3][4]=new Array('Because they were the first to use coins and this invention allowed for the development of sea trade.','Nope.  Crete did not invent the use of coins.',0,0,1);
I[4]=new Array();I[4][0]=100;
I[4][1]='';
I[4][2]='0';
I[4][3]=new Array();
I[4][3][0]=new Array('Through the development of an alphabet.','Right!  The Phoenician alphabet became the foundation for many of the world\'s alphabets today.',1,100,1);
I[4][3][1]=new Array('They invented the War Galley','Nope.  The War Galley was already in place before the rise of Phoenician sea power.',0,0,1);
I[4][3][2]=new Array('They discovered North America.','Nope.  This didn\'t occur until much later.',0,0,1);
I[4][3][3]=new Array('They developed steam-powered ships.','Nope.  This didn\'t occur until much later.',0,0,1);
I[4][3][4]=new Array('They were the first nation to sail around the whole of Africa.','Nope.  Although the Phoenicians did sail around much of North Africa, they never sailed around the entire continent.',0,0,1);
I[5]=new Array();I[5][0]=100;
I[5][1]='';
I[5][2]='0';
I[5][3]=new Array();
I[5][3][0]=new Array('Crete','Sorry.  Crete came to power long before the Greeks and were not a significant factor when Greece came to power.',0,0,1);
I[5][3][1]=new Array('Phoenicia','Sorry.  Phoenicia came to power before the Greeks and were not a significant factor when Greece came to power.',0,0,1);
I[5][3][2]=new Array('Persia','Correct!  Persia tried to invade Europe through Greece on a number of occasions.',1,100,1);
I[5][3][3]=new Array('Britain','Nope.  Britain did not rise to power for a long time after this period.',0,0,1);
I[5][3][4]=new Array('Troy','Sorry.  Although the was conflict between Troy and Greece, Troy was not a great Middle Eastern empire.',0,0,1);
I[6]=new Array();I[6][0]=100;
I[6][1]='';
I[6][2]='0';
I[6][3]=new Array();
I[6][3][0]=new Array('Moving his large army overland while having his large fleet guard his flanks and carrying supplies.','Right!  Xerxes knew that his fleet\'s support would be very important to the invasion.',1,100,1);
I[6][3][1]=new Array('To load his army aboard his large fleet and land on the Greek homeland.','Nope.  Xerxes army was much too large to be transported this way.',0,0,1);
I[6][3][2]=new Array('To attack Greece with his navy, ruining the Greek seaports and merchant fleet.','Nope.  Xerxes\'s main forces were his armies.',0,0,1);
I[6][3][3]=new Array('To launch an all-out attack with his armies and ignore the Greek fleet.','Nope.  Xerxes\'s navy was an important part of his overall plans.',0,0,1);
I[6][3][4]=new Array('To use his armies to capture the Greek fleet and use it against them.','Nope.  Greece did not have a significant fleet prior to Xerxes\'s invasion.',0,0,1);
I[7]=new Array();I[7][0]=100;
I[7][1]='';
I[7][2]='0';
I[7][3]=new Array();
I[7][3][0]=new Array('To position their fleet near the island of Salamis to protect the eastern flank of the Greek forces.','Right.  The fleet was being used in a defensive position to aid the Greek armies.',1,100,1);
I[7][3][1]=new Array('To make a surprise attack against the Persian forces.','Nope.  The Persians started the battle.',0,0,1);
I[7][3][2]=new Array('To ferry their land army to another location.','Nope.  The land and sea armies remained separate forces during this battle.',0,0,1);
I[7][3][3]=new Array('To lure the Persian fleet into open waters where they could destroy them.','Sorry.  The narrowness of the strait was just what the Greeks needed to win.',0,0,1);
I[7][3][4]=new Array('To disguise their Triremes as merchant ships to trap the Persian navy.','Nope.  It would have been hard to disguise 300 Triremes!',0,0,1);
I[8]=new Array();I[8][0]=100;
I[8][1]='';
I[8][2]='0';
I[8][3]=new Array();
I[8][3][0]=new Array('The Romans','Correct!  After 200 years of Greek domination, Rome emerged as the new regional power.',1,100,1);
I[8][3][1]=new Array('The Phoenicians','Nope.  The Greek defeat of Persia spelled the end of Phoenician power.',0,0,1);
I[8][3][2]=new Array('The Britons','Nope.  The Britons did not rise to power until much later.',0,0,1);
I[8][3][3]=new Array('The French','Nope.  The French did not rise to power until much later.',0,0,1);
I[8][3][4]=new Array('The Persians','Sorry.  The Persians were ultimately defeated by the Greeks and did not rise to power.',0,0,1);
I[9]=new Array();I[9][0]=100;
I[9][1]='';
I[9][2]='0';
I[9][3]=new Array();
I[9][3][0]=new Array('Actium and Naulochus','Right.  These two battles ensured Roman sea power for many generations.',1,100,1);
I[9][3][1]=new Array('Actium and Salamis','Nope.  Salamis was fought between the Greeks and the Persians.',0,0,1);
I[9][3][2]=new Array('Salamis and Naulochus','Nope.  Salamis was fought between the Greeks and the Persians.',0,0,1);
I[9][3][3]=new Array('Mare Nostrum and Pax Romana','Sorry.  Mare Nostrum was the Roman term for the Mediterranean and the Pax Romana was the period of peace when Rome controlled the seas.',0,0,1);
I[9][3][4]=new Array('The Punic War and Naulochus','Nope.  The Punic Wars were land and sea battles between Rome and Carthage.',0,0,1);
I[10]=new Array();I[10][0]=100;
I[10][1]='';
I[10][2]='0';
I[10][3]=new Array();
I[10][3][0]=new Array('The Dark Ages','Correct.  This was a time of constant turmoil in Europe.',1,100,1);
I[10][3][1]=new Array('The Pax Romana','Sorry.  This was the period of peace and stability following the era of Julius Caesar.',0,0,1);
I[10][3][2]=new Array('The Age of Barbarians','Nope.  Barbarian armies did bring about the fall of Rome, but this period of history was not named after them.',0,0,1);
I[10][3][3]=new Array('The Age of Discovery','Sorry.  This period wouldn\'t come until much later.',0,0,1);
I[10][3][4]=new Array('The Age of Enlightenment','Sorry.  This period wouldn\'t come until much later.',0,0,1);
I[11]=new Array();I[11][0]=100;
I[11][1]='';
I[11][2]='0';
I[11][3]=new Array();
I[11][3][0]=new Array('Venice','Correct.  Venice\'s key location and their sea trade caused them to prosper during the Crusades.',1,100,1);
I[11][3][1]=new Array('Florence','Nope.  They did expand their influence and power, but they were not the greatest commercial and naval power.',0,0,1);
I[11][3][2]=new Array('Naples','Nope.  They did expand their influence and power, but they were not the greatest commercial and naval power.',0,0,1);
I[11][3][3]=new Array('Rome','Nope.  Rome never did regain it\'s status during this time.',0,0,1);
I[11][3][4]=new Array('Pompeii','Nope.  Pompeii was devastated by a volcanic eruption much earlier and did not survive into the time of the Crusades.',0,0,1);
I[12]=new Array();I[12][0]=100;
I[12][1]='';
I[12][2]='0';
I[12][3]=new Array();
I[12][3][0]=new Array('The Hanseatic League','Correct!  This League was comprised of mostly German port cities.',1,100,1);
I[12][3][1]=new Array('The Italian League','Nope.  The various Italian States never did form a long-lasting trading alliance.',0,0,1);
I[12][3][2]=new Array('The Baltic Confederation','Sorry.  There was never such a Confederation.',0,0,1);
I[12][3][3]=new Array('The Ottoman Turks','Nope.  The Ottoman Turks were a nation, not an organization of ports.',0,0,1);
I[12][3][4]=new Array('The Lepanto League','Nope.  There was never such a League.  Lepanto was the site of a major sea battle.',0,0,1);
I[13]=new Array();I[13][0]=100;
I[13][1]='';
I[13][2]='0';
I[13][3]=new Array();
I[13][3][0]=new Array('The battle of Lepanto.','Correct.  After losing this sea battle, the Turks lost control of the Mediterranean Sea.',1,100,1);
I[13][3][1]=new Array('The battle of Salamis.','Sorry.  Tat battle occurred much earlier in history and was between the Greeks and the Persians.',0,0,1);
I[13][3][2]=new Array('The Crusades.','Nope.  The Crusades occurred much earlier than this.',0,0,1);
I[13][3][3]=new Array('The defeat of the Spanish Armada.','Nope.  this event took place well after 1571.',0,0,1);
I[13][3][4]=new Array('The battle of Actium.','Sorry.  The battle of Actium was between Roman navies after the death of Julius  Caesar.',0,0,1);
I[14]=new Array();I[14][0]=100;
I[14][1]='';
I[14][2]='0';
I[14][3]=new Array();
I[14][3][0]=new Array('The expansion of maritime trade with Asia and the new world. ','Right.  As these new markets opened up to maritime trade, the older markets lost some of their  importance.',1,100,1);
I[14][3][1]=new Array('The victory of the Turks put an end to free trade within the Mediterranean Sea.','Nope.  The Turks were defeated at Lepanto and trade within the Mediterranean was safer.',0,0,1);
I[14][3][2]=new Array('Trade shifted to using caravan routes with Asia.','Nope.  These routes were used but they did not impact Mediterranean trade in this way.',0,0,1);
I[14][3][3]=new Array('An earthquake closed off the entrance to the Mediterranean for some time, thus reducing trade.','Nope.  This never happened.',0,0,1);
I[14][3][4]=new Array('Nothing.  The Mediterranean continued to be the center of world maritime interest.','Nope.  It did indeed decline at this time.',0,0,1);
I[15]=new Array();I[15][0]=100;
I[15][1]='';
I[15][2]='0';
I[15][3]=new Array();
I[15][3][0]=new Array('The Portuguese','Correct.  The early Portuguese exploration of trade routes around Africa greatly expanded sea trade.',1,100,1);
I[15][3][1]=new Array('England','Nope.  England was not a major sea power at this time.',0,0,1);
I[15][3][2]=new Array('Spain','Sorry.  Spain was concentrating on the exploration of routes and trade with the new world.',0,0,1);
I[15][3][3]=new Array('France','Nope.  France was not a major sea power at this time.',0,0,1);
I[15][3][4]=new Array('Italy','Nope.  Italy was not a major sea power at this time.',0,0,1);
I[16]=new Array();I[16][0]=100;
I[16][1]='';
I[16][2]='0';
I[16][3]=new Array();
I[16][3][0]=new Array('It became wealthy and a leader within Europe.','Correct.  The vast amount of gold and other goods brought back from the New World quickly elevated Spain\'s status.',1,100,1);
I[16][3][1]=new Array('The government was overthrown and the first true democracy elected to power.','Nope.  This never happened',0,0,1);
I[16][3][2]=new Array('The government of Spain became disinterested in trade and sea power.','Nope.  Quite the opposite, the riches of the New World caused Spain to vastly increase its naval power.',0,0,1);
I[16][3][3]=new Array('No outward changes in Spain occurred due to the discovery of the Americas.','Sorry.  The increased trade and wealth quickly made Spain a world power.',0,0,1);
I[16][3][4]=new Array('Spain had the wealth to build up its armies and attack its neighbors.','Nope.  Although they had the wealth to do so, they did not attack their neighbors with armies, although it did help with the campaign to oust the Moors from Spain.',0,0,1);
I[17]=new Array();I[17][0]=100;
I[17][1]='';
I[17][2]='0';
I[17][3]=new Array();
I[17][3][0]=new Array('England','Correct.',1,100,1);
I[17][3][1]=new Array('France','Nope.  France was primarily a land power at this point in history.',0,0,1);
I[17][3][2]=new Array('Italy','Nope.  Italy was still split into a number of individual city-states, none with real sea power.',0,0,1);
I[17][3][3]=new Array('The United States','Nope.  The United States was not a country in the 16th century.',0,0,1);
I[17][3][4]=new Array('Portugal','Sorry.  While a significant Sea Power, Portugal was more closely allied to Spain and did not oppose her in most things.',0,0,1);
I[18]=new Array();I[18][0]=100;
I[18][1]='';
I[18][2]='0';
I[18][3]=new Array();
I[18][3][0]=new Array('To stop the English raids on Spanish ships and ports.','Right.  English privateering tactics were starting to annoy Spain.',1,100,1);
I[18][3][1]=new Array('To turn England into a Spanish colony.','Nope.  The overall plan was not the occupation of England but the defeat of her Navy and trade.',0,0,1);
I[18][3][2]=new Array('As simply a show of force to intimidate England.','Nope.  While it did intimidate England, it had another specific purpose.',0,0,1);
I[18][3][3]=new Array('To prevent the invasion of Spain by England.','Sorry.  England did not have the power or desire to invade Spain at this time.',0,0,1);
I[18][3][4]=new Array('For a training exercise designed to ready its fleet for combat in the New World.','Nope.  This wasn\'t the reason the Armada sailed.',0,0,1);
I[19]=new Array();I[19][0]=100;
I[19][1]='';
I[19][2]='0';
I[19][3]=new Array();
I[19][3][0]=new Array('The Dutch','Correct.  English victory against the Dutch won them the port of New Amsterdam, now known as New York.',1,100,1);
I[19][3][1]=new Array('Spain','Nope.  While Spain and England did clash over North American colonies, it was not the first to do so.',0,0,1);
I[19][3][2]=new Array('France','Nope.  While France and England did clash over North American colonies, it was not the first to do so.',0,0,1);
I[19][3][3]=new Array('The United States','Sorry.  The United States wasn\'t a country at this point.',0,0,1);
I[19][3][4]=new Array('Italy','Nope.  The Italian states did not have colonies in North America.',0,0,1);
I[20]=new Array();I[20][0]=100;
I[20][1]='';
I[20][2]='0';
I[20][3]=new Array();
I[20][3][0]=new Array('England won control of Canada.','Correct.  France lost this former colony as a result of this conflict.',1,100,1);
I[20][3][1]=new Array('The creation of the United States of America.','Nope.  This wouldn\'t come until after the Revolutionary War.',0,0,1);
I[20][3][2]=new Array('The defeat of the Indians by the French forces.','Nope.  This conflict was between England and France.  Both sides used Indian tribes as allies during the conflict.',0,0,1);
I[20][3][3]=new Array('France won control of Canada.','Sorry.  France lost it\'s holdings in Canada.',0,0,1);
I[20][3][4]=new Array('The birth of the American Navy.','Nope.  This wouldn\'t occur until later, during our Revolutionary War.',0,0,1);
I[21]=new Array();I[21][0]=100;
I[21][1]='';
I[21][2]='0';
I[21][3]=new Array();
I[21][3][0]=new Array('The Moslems.','Correct!',1,100,1);
I[21][3][1]=new Array('The Byzantines.  ','Nope.  They had power in the Western Mediterranean, but not the Eastern.',0,0,1);
I[21][3][2]=new Array('Venice.','Sorry.  Venice\'s power wouldn\'t come until much later.',0,0,1);
I[21][3][3]=new Array('The Spanish.','Sorry.  Venice\'s power wouldn\'t come until much later.',0,0,1);
I[21][3][4]=new Array('Carthage.','Nope.  Carthage had already been defeated by Rome by this time.',0,0,1);
I[22]=new Array();I[22][0]=100;
I[22][1]='';
I[22][2]='0';
I[22][3]=new Array();
I[22][3][0]=new Array('The Byzantine.','Correct!',1,100,1);
I[22][3][1]=new Array('The Roman.','Nope.  That was Rome.',0,0,1);
I[22][3][2]=new Array('The Ottoman Turks.','Nope.  They captured Constantinople but that was not their capital.',0,0,1);
I[22][3][3]=new Array('The Moors.','Sorry.  The Moors were located in North Africa and Spain.',0,0,1);
I[22][3][4]=new Array('The Greeks.','Nope.  The Greeks\' capital cities were mainly Athens and Sparta.',0,0,1);
I[23]=new Array();I[23][0]=100;
I[23][1]='';
I[23][2]='0';
I[23][3]=new Array();
I[23][3][0]=new Array('Pax Romana.','Correct.  This stands for the "Roman Peace".',1,100,1);
I[23][3][1]=new Array('Mare Nostrum.','Sorry.  This term was applied to the Mediterranean Sea during this period.',0,0,1);
I[23][3][2]=new Array('The Golden Age of Athens.','Nope.  This came after the battle of Salamis between the Greeks and Persia.',0,0,1);
I[23][3][3]=new Array('The Crusades.','Sorry.  This was a period of continuous warfare.',0,0,1);
I[23][3][4]=new Array('The Age of Discovery.','Nope.  There were plenty of conflicts during the age of discovery!',0,0,1);
I[24]=new Array();I[24][0]=100;
I[24][1]='';
I[24][2]='0';
I[24][3]=new Array();
I[24][3][0]=new Array('The Phoenicians.','Right!  Phoenicia was a collection of city-states located on the Mediterranean Sea, where Syria and Lebanon now exist. ',1,100,1);
I[24][3][1]=new Array('The Greeks.','Nope.  They are considered the third.',0,0,1);
I[24][3][2]=new Array('The Romans.','Sorry.  They\'re number 4.',0,0,1);
I[24][3][3]=new Array('The Spanish.','Nope.  They came much later.',0,0,1);
I[24][3][4]=new Array('The Carthaginians.','Nope.  They were number 5 or so.',0,0,1);
I[25]=new Array();I[25][0]=100;
I[25][1]='';
I[25][2]='0';
I[25][3]=new Array();
I[25][3][0]=new Array('England and France','Right!  Signed in 1763, this ended The French and Indian Wars.',1,100,1);
I[25][3][1]=new Array('Greece and Persia','Nope.  (There wasn\'t even a Paris then!)',0,0,1);
I[25][3][2]=new Array('Rome and Carthage','Nope.  The area around Paris was still in Barbarian hands then.',0,0,1);
I[25][3][3]=new Array('England and Spain','Nope.  Try again!',0,0,1);
I[25][3][4]=new Array('The Byzantines and the Ottoman Turks','Nope.  The Ottoman Turks overran the Byzantines and there was no peace treaty.',0,0,1);
I[26]=new Array();I[26][0]=100;
I[26][1]='';
I[26][2]='0';
I[26][3]=new Array();
I[26][3][0]=new Array('The Age of Discovery','Correct!',1,100,1);
I[26][3][1]=new Array('The Golden Age of Athens','Nope.  This Age came after the battle of Salamis.',0,0,1);
I[26][3][2]=new Array('Pax Romana','Nope.  This Age came after the battle of Actium.',0,0,1);
I[26][3][3]=new Array('The Renaissance','Nope.  This happened about the time of the Crusades.',0,0,1);
I[26][3][4]=new Array('The Age of the Privateer','Nope.  There was no such age, although privateering did occur during this time.',0,0,1);
I[27]=new Array();I[27][0]=100;
I[27][1]='';
I[27][2]='0';
I[27][3]=new Array();
I[27][3][0]=new Array('The Trojan Wars','Right!  It probably little or nothing to do with Helen of Troy.',1,100,1);
I[27][3][1]=new Array('The Punic Wars','Nope.  This was a Western Mediterranean conflict.',0,0,1);
I[27][3][2]=new Array('The French and Indian Wars','Sorry.  Not even close!',0,0,1);
I[27][3][3]=new Array('The Crusades','Sorry.  Crusaders passed through this area but the site of their battles was the Middle East.',0,0,1);
I[27][3][4]=new Array('The Spanish Armada','Nope.  Not even close!',0,0,1);
I[28]=new Array();I[28][0]=100;
I[28][1]='';
I[28][2]='0';
I[28][3]=new Array();
I[28][3][0]=new Array('Greece','Correct.  The early Greek City-States are the first recorded democracies on record.',1,100,1);
I[28][3][1]=new Array('Rome','Nope.  they improved on some aspects of government, but did democracies came earlier.',0,0,1);
I[28][3][2]=new Array('Venice','Nope.  Much earlier.',0,0,1);
I[28][3][3]=new Array('Carthage','Nope.  Much earlier.',0,0,1);
I[28][3][4]=new Array('Crete','Sorry.  Democracy came later.',0,0,1);
I[29]=new Array();I[29][0]=100;
I[29][1]='';
I[29][2]='0';
I[29][3]=new Array();
I[29][3][0]=new Array('The Age of Discovery.','Right!  The merchant class came into it\'s own during the Age of Discovery.',1,100,1);
I[29][3][1]=new Array('The Golden Age of Athens.','Nope.  Much later.',0,0,1);
I[29][3][2]=new Array('The Punic Wars.','Sorry.  There wasn\'t a Middle Class until much later.',0,0,1);
I[29][3][3]=new Array('The Crusades.','Sorry.  This was still a time of kings and peasants.',0,0,1);
I[29][3][4]=new Array('Pax Romana','Nope.  No Middle Class under the Romans!',0,0,1);
I[30]=new Array();I[30][0]=100;
I[30][1]='';
I[30][2]='0';
I[30][3]=new Array();
I[30][3][0]=new Array('England','Right!  England came away from this treaty with the most dominant fleet in the world.',1,100,1);
I[30][3][1]=new Array('France','Sorry.  They lost that conflict.',0,0,1);
I[30][3][2]=new Array('The Dutch','Nope.  They had lost out to the correct country earlier in the century.',0,0,1);
I[30][3][3]=new Array('The Spanish','Nope.  Spain was not a significant sea power by this time.',0,0,1);
I[30][3][4]=new Array('America','Sorry.  There was no America yet.',0,0,1);
I[31]=new Array();I[31][0]=100;
I[31][1]='';
I[31][2]='0';
I[31][3]=new Array();
I[31][3][0]=new Array('Salamis','Correct!  The Greek victory at Salamis in 480 BC saw the dominant rise of the Greek City-States.',1,100,1);
I[31][3][1]=new Array('Actium','Nope.  This was a Roman engagement.',0,0,1);
I[31][3][2]=new Array('Lepanto','Nope.  This battle ushered in the Age of Discovery.',0,0,1);
I[31][3][3]=new Array('The defeat of the Spanish Armada','Nope.  This happened much later.',0,0,1);
I[31][3][4]=new Array('Constantinople','Nope.  This was a land battle and a city, not a naval battle.',0,0,1);
I[32]=new Array();I[32][0]=100;
I[32][1]='';
I[32][2]='0';
I[32][3]=new Array();
I[32][3][0]=new Array('Mercantile Theory','Right.  In Mercantile Theory, wealth is power .  The key to wealth is to export more than you import.',1,100,1);
I[32][3][1]=new Array('Pax Romana','Nope.  This was the era of peace established by the Romans.',0,0,1);
I[32][3][2]=new Array('Mare Nostrum','Nope.  this was the term given to the Mediterranean Sea by Rome.',0,0,1);
I[32][3][3]=new Array('Hanseatic League','Sorry.  This was an economic alliance of northern European city-states.',0,0,1);
I[32][3][4]=new Array('Privateer Industry','Nope.  I made this up!',0,0,1);
I[33]=new Array();I[33][0]=100;
I[33][1]='';
I[33][2]='0';
I[33][3]=new Array();
I[33][3][0]=new Array('Columbus discovered the New World.','Right!  The discovery of the New World is considered to be this age\'s crowning achievement.',1,100,1);
I[33][3][1]=new Array('The battle of Lepanto.','Nope.  It happened before this!',0,0,1);
I[33][3][2]=new Array('The battle of Actium.','Nope.  This happened way before.',0,0,1);
I[33][3][3]=new Array('The battle of Salamis.','Nope.  This happened way before.',0,0,1);
I[33][3][4]=new Array('The defeat of the Spanish Armada.','Sorry.  The event occurred before this.',0,0,1);
I[34]=new Array();I[34][0]=100;
I[34][1]='';
I[34][2]='0';
I[34][3]=new Array();
I[34][3][0]=new Array('Martin Frobisher','Correct!  This was the term used for English privateers who raided the Spanish coast and the Spanish Main.',1,100,1);
I[34][3][1]=new Array('Bartholomeu Diaz','Nope.  He found the southern tip of Africa.',0,0,1);
I[34][3][2]=new Array('Vasco da Gama','Sorry.  He discovered the passage to India around Africa.',0,0,1);
I[34][3][3]=new Array('Don John','Nope.  He commanded the Christian Fleet at the battle of Lepanto.',0,0,1);
I[34][3][4]=new Array('Agrippa','Sorry.  He commanded the Roman Fleet at the battle of Actium.',0,0,1);


function StartUp(){
	RemoveBottomNavBarForIE();

//If there's only one question, no need for question navigation controls
	if (QsToShow < 2){
		document.getElementById('QNav').style.display = 'none';
	}
	
//Stash the instructions so they can be redisplayed
	strInstructions = document.getElementById('InstructionsDiv').innerHTML;
	

	

	
	CompleteEmptyFeedback();

	SetUpQuestions();
	ClearTextBoxes();
	CreateStatusArray();
	

	
//Check search string for q parameter
	if (document.location.search.length > 0){
		if (ShuffleQs == false){
			var JumpTo = parseInt(document.location.search.substring(1,document.location.search.length))-1;
			if (JumpTo <= QsToShow){
				ChangeQ(JumpTo);
			}
		}
	}
}

function ShowHideQuestions(){
	FuncBtnOut(document.getElementById('ShowMethodButton'));
	document.getElementById('ShowMethodButton').style.display = 'none';
	if (ShowingAllQuestions == false){
		for (var i=0; i<QArray.length; i++){
				QArray[i].style.display = '';
			}
		document.getElementById('Questions').style.listStyleType = 'decimal';
		document.getElementById('OneByOneReadout').style.display = 'none';
		document.getElementById('ShowMethodButton').innerHTML = ShowOneByOneCaption;
		ShowingAllQuestions = true;
	}
	else{
		for (var i=0; i<QArray.length; i++){
				if (i != CurrQNum){
					QArray[i].style.display = 'none';
				}
			}
		document.getElementById('Questions').style.listStyleType = 'none';
		document.getElementById('OneByOneReadout').style.display = '';
		document.getElementById('ShowMethodButton').innerHTML = ShowAllQuestionsCaption;
		ShowingAllQuestions = false;	
	}
	document.getElementById('ShowMethodButton').style.display = 'inline';
}

function CreateStatusArray(){
	var QNum, ANum;
//For each item in the item array
	for (QNum=0; QNum<I.length; QNum++){
//Check if the question still exists (hasn't been nuked by showing a random selection)
		if (document.getElementById('Q_' + QNum) != null){
			State[QNum] = new Array();
			State[QNum][0] = -1; //Score for this q; -1 shows question not done yet
			State[QNum][1] = new Array(); //answers
			for (ANum = 0; ANum<I[QNum][3].length; ANum++){
				State[QNum][1][ANum] = 0; //answer not chosen yet; when chosen, will store its position in the series of choices
			}
			State[QNum][2] = 0; //tries at this q so far
			State[QNum][3] = 0; //incrementing percent-correct values of selected answers
			State[QNum][4] = 0; //penalties incurred for hints
			State[QNum][5] = ''; //Sequence of answers chosen by number
		}
		else{
			State[QNum] = null;
		}
	}
}



function CheckMCAnswer(QNum, ANum, Btn){
//if question doesn't exist, bail
	if (State[QNum].length < 1){return;}
	
//Get the feedback
	Feedback = I[QNum][3][ANum][1];
	
//Now show feedback and bail if question already complete
	if (State[QNum][0] > -1){
//Add an extra message explaining that the question
// is finished if defined by the user
		if (strQuestionFinished.length > 0){Feedback += '<br />' + strQuestionFinished;}
//Show the feedback
		ShowMessage(Feedback);
		return;
	}
	
//Hide the button while processing
	Btn.style.display = 'none';

//Increment the number of tries
	State[QNum][2]++;
	
//Add the percent-correct value of this answer
	State[QNum][3] += I[QNum][3][ANum][3];
	
//Store the try number in the answer part of the State array, for tracking purposes
	State[QNum][1][ANum] = State[QNum][2];
	State[QNum][5] += String.fromCharCode(65+ANum) + ',';
	
//Should this answer be accepted as correct?
	if (I[QNum][3][ANum][2] < 1){
//It's wrong

//Mark the answer
		Btn.innerHTML = IncorrectIndicator;
		
//Remove any previous score unless exercise is finished (6.0.3.8+)
		if (Finished == false){
			WriteToInstructions(strInstructions);
		}	
		
//Check whether this leaves just one MC answer unselected, in which case the Q is terminated
		var RemainingAnswer = FinalAnswer(QNum);
		if (RemainingAnswer > -1){
//Behave as if the last answer had been selected, but give no credit for it
//Increment the number of tries
			State[QNum][2]++;		
		
//Calculate the score for this question
			CalculateMCQuestionScore(QNum);

//Get the overall score and add it to the feedback
			CalculateOverallScore();
			if ((ContinuousScoring == true)||(Finished == true)){
				Feedback += '<br />' + YourScoreIs + ' ' + Score + '%.';
				WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
			}
		}
	}
	else{
//It's right
//Mark the answer
		Btn.innerHTML = CorrectIndicator;
				
//Calculate the score for this question
		CalculateMCQuestionScore(QNum);

//Get the overall score and add it to the feedback
		if (ContinuousScoring == true){
			CalculateOverallScore();
			if ((ContinuousScoring == true)||(Finished == true)){
				Feedback += '<br />' + YourScoreIs + ' ' + Score + '%.';
				WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
			}
		}
	}
	
//Show the button again
	Btn.style.display = 'inline';
	
//Finally, show the feedback	
	ShowMessage(Feedback);
	
//Check whether all questions are now done
	CheckFinished();
}

function CalculateMCQuestionScore(QNum){
	var Tries = State[QNum][2] + State[QNum][4]; //include tries and hint penalties
	var PercentCorrect = State[QNum][3];
	var TotAns = GetTotalMCAnswers(QNum);
	var HintPenalties = State[QNum][4];
	
//Make sure it's not already complete

	if (State[QNum][0] < 0){
//Allow for Hybrids
		if (HintPenalties >= 1){
			State[QNum][0] = 0;
		}
		else{
//This line calculates the score for this question
			if (TotAns == 1){
				State[QNum][0] = 1;
			}
			else{
				State[QNum][0] = ((TotAns-((Tries*100)/State[QNum][3]))/(TotAns-1));
			}
		}
		if (State[QNum][0] < 0){
			State[QNum][0] = 0;
		}
	}
}

function GetTotalMCAnswers(QNum){
	var Result = 0;
	for (var ANum=0; ANum<I[QNum][3].length; ANum++){
		if (I[QNum][3][ANum][4] == 1){ //This is an MC answer
			Result++;
		}
	}
	return Result;
}

function FinalAnswer(QNum){
	var UnchosenAnswers = 0;
	var FinalAnswer = -1;
	for (var ANum=0; ANum<I[QNum][3].length; ANum++){
		if (I[QNum][3][ANum][4] == 1){ //This is an MC answer
			if (State[QNum][1][ANum] < 1){ //This answer hasn't been chosen yet
				UnchosenAnswers++;
				FinalAnswer = ANum;
			}
		}
	}
	if (UnchosenAnswers == 1){
		return FinalAnswer;
	}
	else{
		return -1;
	}
}





function CalculateOverallScore(){
	var TotalWeighting = 0;
	var TotalScore = 0;
	
	for (var QNum=0; QNum<State.length; QNum++){
		if (State[QNum] != null){
			if (State[QNum][0] > -1){
				TotalWeighting += I[QNum][0];
				TotalScore += (I[QNum][0] * State[QNum][0]);
			}
		}
	}
	if (TotalWeighting > 0){
		Score = Math.floor((TotalScore/TotalWeighting)*100);
	}
	else{
//if TotalWeighting is 0, no questions so far have any value, so 
//no penalty should be shown.
		Score = 100; 
	}
}

function CheckFinished(){
	var FB = '';
	var AllDone = true;
	for (var QNum=0; QNum<State.length; QNum++){
		if (State[QNum] != null){
			if (State[QNum][0] < 0){
				AllDone = false;
			}
		}
	}
	if (AllDone == true){
	
//Report final score and submit if necessary
		CalculateOverallScore();
		FB = YourScoreIs + ' ' + Score + '%.';
		if (ShowCorrectFirstTime == true){
			var CFT = 0;
			for (QNum=0; QNum<State.length; QNum++){
				if (State[QNum] != null){
					if (State[QNum][0] >= 1){
						CFT++;
					}
				}
			}
			FB += '<br />' + CorrectFirstTime + ' ' + CFT + '/' + QsToShow;
		}
		WriteToInstructions(FB);
		
		Finished == true;

		TimeOver = true;
		Locked = true;
		


		Finished = true;
		Detail = '<?xml version="1.0"?><hpnetresult><fields>';
		for (QNum=0; QNum<State.length; QNum++){
			if (State[QNum] != null){
				if (State[QNum][5].length > 0){
					Detail += '<field><fieldname>Question #' + (QNum+1) + '</fieldname><fieldtype>question-tracking</fieldtype><fieldlabel>Q ' + (QNum+1) + '</fieldlabel><fieldlabelid>QuestionTrackingField</fieldlabelid><fielddata>' + State[QNum][5] + '</fielddata></field>';
				}
			}
		}
		Detail += '</fields></hpnetresult>';
		setTimeout('Finish()', SubmissionTimeout);
	}
}










//-->

//]]>


