

//<![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('Domestic reforms.','Right!  Progressivism dominated American politics of this era.',1,100,1);
I[0][3][1]=new Array('Building up the Army and Navy to be ready for war.','Nope.  Domestic concerns were of more importance than International concerns to Americans at this time.',0,0,1);
I[0][3][2]=new Array('Diplomatic treaties to ensure America\'s neutrality.','Sorry.  While neutrality overseas would be important to both the Taft and  Wilson administrations, it was not the main focus.',0,0,1);
I[0][3][3]=new Array('Diplomatic treaties to align America with Great Britain.','Nope.  Domestic affairs were more important and International Relations were marked by neutrality.',0,0,1);
I[0][3][4]=new Array('Diplomatic treaties to align America with Germany.','Nope.  Domestic affairs were more important and International Relations were marked by neutrality.',0,0,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('The Triple Entente ','Right.  They were also known as the Allied Powers.',1,100,1);
I[1][3][1]=new Array('The Axis Powers','Nope.  This was the name of one of the sides in World War II.',0,0,1);
I[1][3][2]=new Array('The Central Powers','Nope.  This group consisted of Germany, Austria-Hungary and later, the Ottoman Empire.',0,0,1);
I[1][3][3]=new Array('The Western Powers','Nope.  This term was not used.',0,0,1);
I[1][3][4]=new Array('NATO','Nope.  The North Atlantic Treaty Organization did not come into being until after World War II.',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('Germany and Britain','Correct.  The German High Seas Fleet and the British Home Fleet.',1,100,1);
I[2][3][1]=new Array('America and Germany','Sorry.  While the U.S. Navy did participate to a limited degree, the U.S. was not a  principal naval power at this time.',0,0,1);
I[2][3][2]=new Array('Japan and America','Nope.  Japan was not involved in this conflict and the U.S. was not a principal naval power at this time.',0,0,1);
I[2][3][3]=new Array('Britain and Japan','Nope.  Japan was not involved in this conflict.',0,0,1);
I[2][3][4]=new Array('France and Britain','Nope.  France did not have a leading naval role in this conflict.',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('The North Sea','Right.  This was the only way the German navy could make it into the Atlantic.',1,100,1);
I[3][3][1]=new Array('The Mediterranean Sea','Nope.  The German Navy was never able to make it into the Mediterranean Sea.',0,0,1);
I[3][3][2]=new Array('The English Channel','Sorry.  Although this area was the objective of the German Navy, they never made it that far.',0,0,1);
I[3][3][3]=new Array('The Red Sea','Nope.  This body of water was never a focus of naval power during World War I.',0,0,1);
I[3][3][4]=new Array('The Caribbean Sea','Nope.  This body of water was never a focus of naval power during World War I.',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('Their ships had to go through the North Sea to get into the Atlantic.','Correct.  The German navy would have to fight its way out in order to be effective in the conflict.',1,100,1);
I[4][3][1]=new Array('They were absolutely dependent on imported foodstuffs for survival.','Nope.  The Central Powers controlled the best agricultural land in Europe.',0,0,1);
I[4][3][2]=new Array('They were geographically separated and lacked adequate communications. ','Nope.  The Central Power nations all bordered each other, making communications easier.',0,0,1);
I[4][3][3]=new Array('They had an excellent railroad system designed to be able to shift forces quickly between fronts.','Sorry.  This was one of their advantages, not a disadvantage.',0,0,1);
I[4][3][4]=new Array('They controlled the central agricultural areas of Europe.','Sorry.  This was one of their advantages, not a disadvantage.',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('It was absolutely dependent on imported foodstuffs for survival.','Correct.  England did not produce enough food to feed its people, so sea trade was essential for survival.',1,100,1);
I[5][3][1]=new Array('It had an outdated railroad system which was unable to move forces quickly around the country.','Sorry.  Britain\'s rail system was never an issue in the War.',0,0,1);
I[5][3][2]=new Array('It had an old and outdated Navy.','Nope.  Britain had the world\'s finest navy at the start of the War.',0,0,1);
I[5][3][3]=new Array('It had a significant lack of merchant shipping to carry goods.','Nope.  Britain could lay claim to half of the world\'s total merchant shipping at the start of the War.',0,0,1);
I[5][3][4]=new Array('Britain did not have any allies at the start of the War.','Nope.  Britain was one of the four Allied Powers, which included France, Russia, and Serbia.',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('To defeat and occupy France while keeping the High Seas Fleet intact to bargain with at later negotiations.','Right.  The German Navy would harass British shipping and combatants whenever possible, but defeat of the British navy was never a primary goal.',1,100,1);
I[6][3][1]=new Array('To defeat the British Navy and blockade England.','Nope.  Germany realized that the British Navy was to powerful to do this.',0,0,1);
I[6][3][2]=new Array('To mount an amphibious assault to defeat and occupy England.','Nope.  The Germans never planned this operation.',0,0,1);
I[6][3][3]=new Array('To drag on the war in France until the Allied Powers gave in to a favorable peace settlement.','Sorry.  Germany counted a swift and complete victory in France early  in the war.',0,0,1);
I[6][3][4]=new Array('To place a minefield around England to prevent England from being resupplied.','Nope.  Minefields were used in the North Sea and English Cannels, but they were laid by the British to prevent the German Navy from operations around England.',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('The landings at Gallipoli ','Correct.  This massive amphibious operation was a failure which is studied in detail even today to demonstrate how not to conduct an amphibious operation.',1,100,1);
I[7][3][1]=new Array('The landings at Normandy','Nope.  This occurred in World War II.',0,0,1);
I[7][3][2]=new Array('The landings in North Africa','Nope.  This occurred in World War II.',0,0,1);
I[7][3][3]=new Array('The landings in Sicily','Nope.  This occurred in World War II.',0,0,1);
I[7][3][4]=new Array('The landings in Italy','Nope.  This occurred in World War II.',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('Vice Admiral Von Spee','Right.  At the outbreak of the war he commanded half a dozen German cruisers in the Pacific. ',1,100,1);
I[8][3][1]=new Array('Vice Admiral Scheer','Nope.  He commanded the German High Seas Fleet.',0,0,1);
I[8][3][2]=new Array('Vice Admiral Bismarck','Sorry.  No such German naval officer existed.',0,0,1);
I[8][3][3]=new Array('Vice Admiral Donitz','Sorry.  Admiral Donitz controlled German submarine forces in World War II.',0,0,1);
I[8][3][4]=new Array('Vice Admiral Goering','Nope.  No such German naval officer existed.',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('The Falkland Islands','Right.  Von Spee wanted to take the coaling base at Port Stanley, but was surprised by a superior British naval force.',1,100,1);
I[9][3][1]=new Array('Chile','Nope.  The German Pacific Fleet had visited Chile, but this was not the site of the final engagement.',0,0,1);
I[9][3][2]=new Array('Easter Island','Nope.  This is where the final elements of the German Pacific joined up, but not the site of the engagement.',0,0,1);
I[9][3][3]=new Array('Brazil','Sorry.  This was the main operating area of the British naval forces, but not the site of the engagement.',0,0,1);
I[9][3][4]=new Array('The Caroline Islands ','Nope.  this had been the primary base for the German Pacific Fleet, but was not the site of its final  engagement.',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('1916 in the North Sea','Correct.  This battle was fought to a draw in terms of tactics and losses, but was a strategic victory for the British.',1,100,1);
I[10][3][1]=new Array('1916 in the English Channel','Nope.  Right year, wrong place.',0,0,1);
I[10][3][2]=new Array('1915 in the North Sea','Sorry.  Right place, wrong year.',0,0,1);
I[10][3][3]=new Array('1915 in the English Channel','Nope.  Wrong year and wrong place.',0,0,1);
I[10][3][4]=new Array('1917 in the Mediterranean Sea','Nope.  Wrong year and wrong place.',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('It was the final great naval action to be fought between surface forces in the Age of Steam.','Right.  This was the only major naval action of World War I.',1,100,1);
I[11][3][1]=new Array('It was a decisive victory for Britain.','Nope.  Britain actually lost more ships than Germany.',0,0,1);
I[11][3][2]=new Array('It was a decisive victory for Germany.','Nope.  Germany could not break out of the British North Sea blockade.',0,0,1);
I[11][3][3]=new Array('It brought the United States into World War I.','Nope.  This battle had nothing to do with the U.S. decision to enter the war.',0,0,1);
I[11][3][4]=new Array('It resulted in the collapse of Russia.','Sorry.  The Russian government did collapse in 1917, but it had nothing to do with the Battle of Jutland.',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 Zimmermann telegram to Mexico urging an invasion of the U.S. in return for German support for Mexico.','Right.  When the British revealed this captured telegram to the U.S. all congressional support for Germany ended.',1,100,1);
I[12][3][1]=new Array('The German announcement of unrestricted submarine warfare.','Sorry.  While this was a major event on the path to U.S. involvement, there was still congressional support for Germany even after the announcement.',0,0,1);
I[12][3][2]=new Array('The Battle of Jutland.','Nope.  This event did not influence U.S. congressional support one way or the other.',0,0,1);
I[12][3][3]=new Array('The "Sussex Pledge".','Nope.  This earlier pledge by Germany to follow international law in submarine warfare prevented the U.S. from getting in to the war earlier.',0,0,1);
I[12][3][4]=new Array('The sinking of the British passenger liner Lusitania.','Nope. While this event in 1915 helped swing U.S. public opinion against Germany, it was not the event which eliminated German support within the U.S. Congress.',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 use of convoys by the allies.','Right.  Adoption of the convoy system was a key factor in saving Britain from defeat in World War I.',1,100,1);
I[13][3][1]=new Array('The use of faster merchant ships, designed to outrun submarines.','Nope.  This was never tired and probably not possible, as submarines could lie in wait.',0,0,1);
I[13][3][2]=new Array('The dramatic reduction in merchant shipping to England.','Nope.  There were still plenty of merchant ships to move supplies.',0,0,1);
I[13][3][3]=new Array('The lack of German replacement submarines.','Nope.  The Germans had plenty of submarines during this time.',0,0,1);
I[13][3][4]=new Array('Stronger hulled merchant ships which could withstand torpedo hits.','Nope.  This was not an option.',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('Depth charges','Right.  Designed by the British, this weapon allowed destroyers to sink submerged submarines.',1,100,1);
I[14][3][1]=new Array('Torpedoes','Nope.  Torpedoes were the primary weapon used by submarines against surface ships.',0,0,1);
I[14][3][2]=new Array('Mines','Nope.  Mines were not a primary antisubmarine weapon and had been around for many years by this time.',0,0,1);
I[14][3][3]=new Array('Hedgehogs','Nope.   This antisubmarine weapon was developed during World War II.',0,0,1);
I[14][3][4]=new Array('Antisubmarine rockets','Nope.  This antisubmarine weapon wasn\'t developed until after World War II.',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('Mines','Right.  Extensive minefields were used by both sides to restrict surface and submarine movement in the North Sea.',1,100,1);
I[15][3][1]=new Array('Torpedoes','Nope.  Torpedoes were not an effective antisubmarine weapon at this time.',0,0,1);
I[15][3][2]=new Array('Aircraft','Nope.  Aircraft could not stop submerged submarines from escaping.',0,0,1);
I[15][3][3]=new Array('New naval guns','Nope.  Guns on naval surface forces could not prevent the escape of submerged submarines.',0,0,1);
I[15][3][4]=new Array('Depth charges','Sorry.  Although effective when a submarine was detected, depth charges weren\'t the primary means used to prevent escape of German submarines.',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('The Submarine Chaser.','Correct.  The quick and nimble sub chasers were very effective against submarines.',1,100,1);
I[16][3][1]=new Array('The Destroyer.','Nope.  Destroyers, while effective against submarines, had been around awhile and were not invented by the U.S.',0,0,1);
I[16][3][2]=new Array('The Aircraft Carrier.','Nope.  While the Aircraft Carrier was developed during World War I, it was by the British and was not a primary antisubmarine weapon in World War I.',0,0,1);
I[16][3][3]=new Array('The Cruiser.','Nope.  This was neither a U.S. invention nor primarily an antisubmarine platform.',0,0,1);
I[16][3][4]=new Array('The Patrol Boat.','Nope.  Patrol Boats were mainly used in World War II against surface combatants.',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('The North Sea Mine Barrage','Correct.  When finished, the field had 70,200 mines.',1,100,1);
I[17][3][1]=new Array('The English Channel Mine Barrage','Nope.  While extensive, it was not the largest.',0,0,1);
I[17][3][2]=new Array('The U.S. East Coast Mine Barrage','Nope.  No such mine barrage existed.',0,0,1);
I[17][3][3]=new Array('The Dover Strait Mine Barrage ','Nope.  While extensive and very effective, this mine barrage was not the largest.',0,0,1);
I[17][3][4]=new Array('The Mediterranean Mine Barrage','Nope.  No such mine barrage existed.',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 patrol and convoy troops and supplies to Europe.','Right.  The U.S. Navy did not see major surface action during the War.',1,100,1);
I[18][3][1]=new Array('To engage and defeat the German High Seas Fleet.','Nope.  This type of engagement never occurred.',0,0,1);
I[18][3][2]=new Array('To engage and defeat the German Pacific Fleet.','Nope.  This type of engagement never occurred.',0,0,1);
I[18][3][3]=new Array('To lay minefields off the East Coast of the U.S.','Nope.  This never occurred.',0,0,1);
I[18][3][4]=new Array('To lay defensive minefields in the North Sea.','Sorry.  While the U.S. Navy did much of the mine laying in the North Sea, this was not its principal role.',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('On November 11, 1918 in a railway car near Paris.','Right.  The eleventh hour on the eleventh day of the month.',1,100,1);
I[19][3][1]=new Array('On November 11, 1917, in Paris','Nope.  Wrong year.',0,0,1);
I[19][3][2]=new Array('On December 11, 1918, in Berlin','Nope.  Wrong time and place.',0,0,1);
I[19][3][3]=new Array('On December 11, 1917, in London','Sorry.  Wrong time place.',0,0,1);
I[19][3][4]=new Array('On November 11, in Washington D.C.','Sorry.  Wrong place.',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('Depth charges','Excellent.  They were designed and first used by England during World War I.',1,100,1);
I[20][3][1]=new Array('Mines','Nope.  Mines are not set to detonate at present depths.',0,0,1);
I[20][3][2]=new Array('Torpedoes','Sorry.  This isn\'t how torpedoes are constructed.',0,0,1);
I[20][3][3]=new Array('Sub Chasers','Nope.  These are ships, not canisters of TNT.',0,0,1);
I[20][3][4]=new Array('Hedgehogs','Sorry.  Hedgehogs are a delivery system for depth charges invented during World War II.',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('Wilson','Excellent.  President Wilson had tried hard to keep the U.S. out of the war at first.',1,100,1);
I[21][3][1]=new Array('Taft','Nope.  President Taft had left office the year before the war began.',0,0,1);
I[21][3][2]=new Array('Roosevelt','Nope.  President Teddy Roosevelt held office much earlier, and Franklin Roosevelt much later.',0,0,1);
I[21][3][3]=new Array('Churchill','Sorry.  Winston Churchill was never President of the United States',0,0,1);
I[21][3][4]=new Array('Harding','Sorry.  President Harding didn\'t take office until 1921',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('Scheer','Excellent!  Scheer was more aggressive and wanted to directly engage the British Fleet.',1,100,1);
I[22][3][1]=new Array('Von Spee','Sorry.  Von Spee was a German Admiral, but he commanded the German Pacific naval forces.',0,0,1);
I[22][3][2]=new Array('Jutland','Nope.  This was the name of the sea battle fought by this Admiral.',0,0,1);
I[22][3][3]=new Array('Sims','Sorry.  Sims was a U.S. Admiral',0,0,1);
I[22][3][4]=new Array('Jellicoe','Sorry.  Jellicoe commanded the British Grand Fleet.',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('Germany','Right!  The U-boat was the only weapon available to the Germans to stop food and supplies from reaching England.',1,100,1);
I[23][3][1]=new Array('America','Sorry.  We had them but they did not participate significantly in World War I.',0,0,1);
I[23][3][2]=new Array('Russia','Nope.  Russia did not have U-Boats.',0,0,1);
I[23][3][3]=new Array('France','Nope.  France did not use U-Boats.',0,0,1);
I[23][3][4]=new Array('England','Sorry.  England did not significantly use U-Boats during World War I.',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('Greece','Excellent.  Greece attempted to remain neutral in the conflict.',1,100,1);
I[24][3][1]=new Array('Bulgaria','Sorry.  Bulgaria entered the war on the side of the Central Powers following the unsuccessful invasion of Gallipoli.',0,0,1);
I[24][3][2]=new Array('The Ottoman Empire','Nope.  They were one of the Central Powers.',0,0,1);
I[24][3][3]=new Array('Germany','Nope.  They were one of the Central Powers.',0,0,1);
I[24][3][4]=new Array('Austria-Hungary','Nope.  They were one of the Central Powers.',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('The Central Powers','Right!  This was the "breadbasket" of Europe, and allowed unbroken lines of communication.',1,100,1);
I[25][3][1]=new Array('The Allied Powers','Sorry.  The Allies did not hold central Europe.',0,0,1);
I[25][3][2]=new Array('The Axis Powers','Sorry.  The Axis Powers fought during World War II.',0,0,1);
I[25][3][3]=new Array('The Triple Entente','Nope.  This was another name for the Allied Powers.',0,0,1);
I[25][3][4]=new Array('The European Powers','Nope.  There wasn\'t a group called "The European Powers" at this time.',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('To allow British troops and supplies to go to France.','Right.  Without this line of supply the Allied army would quickly dissolve.',1,100,1);
I[26][3][1]=new Array('To allow French troops and supplies to go to England.','Sorry.  French troops did not go to England during the War.',0,0,1);
I[26][3][2]=new Array('To allow American troops and supplies to go to England.','Nope.  Although American troops did go to England, they did not arrive via the English Channel.',0,0,1);
I[26][3][3]=new Array('To allow German troops and supplies to go to England.','Nope.  German troops did not go to England during the war.',0,0,1);
I[26][3][4]=new Array('To allow British troops and supplies to go to America.','Nope.  British troops did not go to America during the war.',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('England','Right.  The German Pacific naval force was destroyed off of the Falkland Islands.',1,100,1);
I[27][3][1]=new Array('America','Sorry.  America was not involved in this naval engagement.',0,0,1);
I[27][3][2]=new Array('France','Sorry.  French naval forces were not involved.',0,0,1);
I[27][3][3]=new Array('Japan','Nope.  Japan had threatened to attack German naval forces in the Pacific, but did not do so.',0,0,1);
I[27][3][4]=new Array('Chile','Nope.  German Pacific naval forces considered Chile a friendly nation and were able to refuel there.',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('Germany','Excellent!  This was a major setback to the Allied cause.',1,100,1);
I[28][3][1]=new Array('France','Sorry.  France was on the same side as Russia in World War I.',0,0,1);
I[28][3][2]=new Array('England','Sorry.  England was on the same side as Russia in World War I.',0,0,1);
I[28][3][3]=new Array('America','Nope.  America was on the same side as Russia in World War I.',0,0,1);
I[28][3][4]=new Array('Japan','Nope.  Although they had fought each other earlier in the century, they were not fighting against  each other in World War I.',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('1914','Correct.  In August of 1914.',1,100,1);
I[29][3][1]=new Array('1917','Nope.  this was the year the U.S. entered the war.',0,0,1);
I[29][3][2]=new Array('1913','Nope.  The war hadn\'t started yet.',0,0,1);
I[29][3][3]=new Array('1916','Sorry.  This was the year the battle of Jutland occurred.',0,0,1);
I[29][3][4]=new Array('1918','Sorry.  This was the year the war ended.',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('1917','Correct.  The German announcement of unrestricted submarine warfare enraged the U.S.',1,100,1);
I[30][3][1]=new Array('1916','Nope.  This was the year of the battle of Jutland.',0,0,1);
I[30][3][2]=new Array('1914','Nope.  This was the year the war began, but not the year the U.S. entered the war.',0,0,1);
I[30][3][3]=new Array('1918','Nope.  This was the year the war ended.',0,0,1);
I[30][3][4]=new Array('1915','Nope.  The U.S. hadn\'t entered the war 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('1917','Excellent!  This came about after terrible defeats on the western front.',1,100,1);
I[31][3][1]=new Array('1916','Nope.  This was the year of the battle of Jutland.',0,0,1);
I[31][3][2]=new Array('1918','Nope.  This was the year the war ended.',0,0,1);
I[31][3][3]=new Array('1914','Nope.  This was the year the war began.',0,0,1);
I[31][3][4]=new Array('1919','Sorry.  World War I was over by this time.',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('Sims','Excellent.  Admiral Simms\' had to lobby the British to adopt this system, and it paid off.',1,100,1);
I[32][3][1]=new Array('Jellicoe','Sorry.  Admiral Jellicoe was the British Admiral in charge of the Grand Fleet at the battle of Jutland.',0,0,1);
I[32][3][2]=new Array('Zimmermann','Nope.  Arthur Zimmermann was Germany\'s foreign secretary.',0,0,1);
I[32][3][3]=new Array('Daniels','Sorry.  Josephus Daniels was the U.S. Secretary of the Navy during World War I.',0,0,1);
I[32][3][4]=new Array('George','Nope.  David Lloyd George was the British prime minister during World War I.',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('The Lusitania','Excellent!  Americans were outraged, but not yet ready to go to war at this point.',1,100,1);
I[33][3][1]=new Array('The Sussex','Sorry.  The Sussex was a French steamer sunk in 1916.  3 Americans were wounded in this incident.',0,0,1);
I[33][3][2]=new Array('The Dreadnought','Nope.  This was a revolutionary British battleship.',0,0,1);
I[33][3][3]=new Array('The Jutland','Nope.  This was the major naval engagement of World War I.',0,0,1);
I[33][3][4]=new Array('The Titanic','Nope.  The Titanic went down due to an iceberg before World War I.',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('Germany','Correct.  They pledged international law would be followed in regards to submarine warfare.',1,100,1);
I[34][3][1]=new Array('England','Nope.  England was not responsible for the Sussex pledge.',0,0,1);
I[34][3][2]=new Array('France','Nope.  Although the Sussex had been a French ship, France did not issue the Sussex Pledge.',0,0,1);
I[34][3][3]=new Array('America','Sorry.  The country in question did, however, issue the Pledge in response to American protests about the Sussex incident.',0,0,1);
I[34][3][4]=new Array('Russia','Nope.  Russia was not involved in the Sussex Pledge.',0,0,1);
I[35]=new Array();I[35][0]=100;
I[35][1]='';
I[35][2]='0';
I[35][3]=new Array();
I[35][3][0]=new Array('Josephus Daniels','Correct.  He was initially opposed to any U.S. naval build-up in the years before the war.',1,100,1);
I[35][3][1]=new Array('Woodrow Wilson','Sorry.  He was the U.S. President during the war.',0,0,1);
I[35][3][2]=new Array('William Sims','Nope.  Sims was the U.S. Admiral who established the convoy system.',0,0,1);
I[35][3][3]=new Array('John Jellicoe','Sorry.  Admiral Jellicoe was the British naval officer in charge of the British Grand Fleet during the battle of Jutland.',0,0,1);
I[35][3][4]=new Array('David Lloyd George','Nope.  George was the British Prime Minister during the war.',0,0,1);
I[36]=new Array();I[36][0]=100;
I[36][1]='';
I[36][2]='0';
I[36][3]=new Array();
I[36][3][0]=new Array('The hydrophone','Right!  By getting three lines of bearing, a group of destroyers could locate a submarine.',1,100,1);
I[36][3][1]=new Array('The depth charge','Nope.  This was a device designed to destroy, not find submarines.',0,0,1);
I[36][3][2]=new Array('Sonar','Sorry.  Sonar wouldn\'t be around until World War II.',0,0,1);
I[36][3][3]=new Array('Radar','Nope.  Radar wouldn\'t be around until World War II.',0,0,1);
I[36][3][4]=new Array('Torpedoes','Sorry.  Triangulation was not a technique used with torpedoes.',0,0,1);
I[37]=new Array();I[37][0]=100;
I[37][1]='';
I[37][2]='0';
I[37][3]=new Array();
I[37][3][0]=new Array('None','Correct.  The convoy system proved extremely effective once it was adopted.',1,100,1);
I[37][3][1]=new Array('100','Nope.  It was far fewer than this.',0,0,1);
I[37][3][2]=new Array('500','Nope.  It was far fewer than this.',0,0,1);
I[37][3][3]=new Array('47','Sorry.  Think even lower.',0,0,1);
I[37][3][4]=new Array('13','Sorry.  Although this would have been a good number as well, it wasn\'t 13.',0,0,1);
I[38]=new Array();I[38][0]=100;
I[38][1]='';
I[38][2]='0';
I[38][3]=new Array();
I[38][3][0]=new Array('Wood','Excellent.  This made them faster and more maneuverable.',1,100,1);
I[38][3][1]=new Array('Iron','Nope.  Iron had gone out of style for ship construction.',0,0,1);
I[38][3][2]=new Array('Steel','Nope.  Steel hulls would make them more vulnerable to mines.',0,0,1);
I[38][3][3]=new Array('Fiberglass','Sorry.  fiberglass hadn\'t been invented yet.',0,0,1);
I[38][3][4]=new Array('Carbon','Sorry.  Carbon hull construction had not been invented yet.',0,0,1);
I[39]=new Array();I[39][0]=100;
I[39][1]='';
I[39][2]='0';
I[39][3]=new Array();
I[39][3][0]=new Array('The battle of Jutland','Right.  The size and scope of the battle, and the real threat of the German Navy, was finally obvious to Congress.',1,100,1);
I[39][3][1]=new Array('The failure of the invasion of Gallipoli','Nope.  This wasn\'t the event that caused Congress to act.',0,0,1);
I[39][3][2]=new Array('Germany\'s declaring war on England','Nope.  This was expected due to the defense agreements at the start of World War I.',0,0,1);
I[39][3][3]=new Array('Germany\'s declaring war on America','Sorry.  It was already well underway by this time.',0,0,1);
I[39][3][4]=new Array('The naval battle of the Falkland Islands.','Sorry.  This was a British victory and not a cause for concern in the U.S.',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);
	}
}










//-->

//]]>


