

//<![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';
//IE can't focus a hidden div; Moz needs to focus before display to avoid jumping
	if (C.gecko){
		document.getElementById('FeedbackOKButton').focus();
	}
	FDiv.style.display = 'block';

	ShowElements(false, 'input');
	ShowElements(false, 'select');

	if (C.ie){
		document.getElementById('FeedbackOKButton').focus();
	}
	
//
}

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');
	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.innerWidth){
		return window.innerWidth;
	}
	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{
	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){
	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; k++) {
			Temp[k] = Temp[k+1];
		}
		j--;
	}
	return InArray;
}

function WriteToInstructions(Feedback) {
	Feedback = '<span class="FeedbackText">' + Feedback + '</span>';
	document.getElementById('InstructionsDiv').innerHTML = Feedback;

}




function EscapeDoubleQuotes(InString){
	return InString.replace(/"/g, '&quot;')
}

function FocusAButton(){
	if (document.getElementById('CheckButton1') != null){
		document.getElementById('CheckButton1').focus();
	}
	else{
		document.getElementsByTagName('button')[0].focus();
	}
}

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].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){
		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 = '';

function CompleteEmptyFeedback(){
	var QNum, ANum;
	for (QNum=0; QNum<I.length; QNum++){
		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;
	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){
	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('Tactics','Right!  It has always held a different meaning than "Strategy" in the military sense.  Tactics is more "down in the weeds" than Strategy, which deals will many other non-military issues.',1,100,1);
I[0][3][1]=new Array('Strategy','Sorry.  Strategy is concerned with the politics, economies, and planning that goes on in the prelude to battle.',0,0,1);
I[0][3][2]=new Array('Warfare','Sorry.  Warfare itself is defined as the waging of war against an enemy.  This has to do with fighting, but not with the art and science of fighting battles.',0,0,1);
I[0][3][3]=new Array('Conflict','Nope.  Conflict is defined as a state of open, often prolonged fighting.  This does deal with fighting, but not the art and science of fighting battles.',0,0,1);
I[0][3][4]=new Array('Siege','Nope.  A siege is defined as the surrounding and blockading of a city, town, or fortress by an army attempting to capture it.  This is certainly about fighting battles, but it is not the art and science of fighting battles.',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('Strategy','Correct.  Strategy is also concerned with the politics, economies, and planning that goes on before the war starts as well.',1,100,1);
I[1][3][1]=new Array('Tactics','Sorry.  Tactics deals with individual battles and engagements, not with the overall disposition of forces and direction of campaigns.',0,0,1);
I[1][3][2]=new Array('Logistics','Sorry.  Logistics, the art and science of keeping an Army or Navy resupplied, is an important aspect of any campaign, but this is not the term used to describe the movements and direction of a campaign.',0,0,1);
I[1][3][3]=new Array('Mobility','Nope.  Mobility does consider the movements of large forces but this is not the term used when describing the overall direction of campaigns.',0,0,1);
I[1][3][4]=new Array('Amphibious Warfare','Nope.  Amphibious Warfare does deal with large movements and the disposition of forces, but only in the limited sense of amphibious operations.  It is not about the overall campaign.',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('The need to keep naval fleets connected with logistic support while they were forward supporting amphibious landings.','Right.  It was recognized that to win a Pacific War, we would need to make several amphibious landings.  These landings would need to be supported with men, weapons and supplies.  The MLSF was designed to meet that need.',1,100,1);
I[2][3][1]=new Array('The need to build up our defenses in the Pacific prior to the invasion of these spots by Japan.','Sorry.   The MLSF fleet was designed to support offensive, not defensive actions.',0,0,1);
I[2][3][2]=new Array('It came about due to the aggressive nature of German U-Boats in the Atlantic.','Sorry.  The creation of the MLSF came about due to events in the Pacific, not the Atlantic.',0,0,1);
I[2][3][3]=new Array('The recognized need that the U.S. be able to support its allies in the Atlantic and Pacific Theatres.','Nope.  While logistic support for our allies was important, this wasn\'t the reason that the MLSF was created.',0,0,1);
I[2][3][4]=new Array('It was known early on that everything required to fight the Japanese would need to be brought from the U.S. as there were no forward bases overseas.','Nope.  While many things were required to be brought from the U.S., there were several forward bases in use throughout the war.',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 Navy and the Marine Corps','Correct!  Recognizing that it would take numerous amphibious landings to regain lost ground in the Pacific, the Marine Corps and the Navy developed this doctrine prior to the war and refined it during the war.',1,100,1);
I[3][3][1]=new Array('The Navy and the Army','Sorry.  While the Navy and the Army worked closely together in amphibious warfare during World War II, these weren\'t the two Services who developed the doctrine prior to the war.',0,0,1);
I[3][3][2]=new Array('The Marine Corps and the Army','Nope.  While both of these Service were actively involved in Amphibious Warfare during World War II, only one of them was involved in developing this doctrine prior to World War II.',0,0,1);
I[3][3][3]=new Array('The Air Force and the Marine Corps','Nope.  The Air Force didn\'t exist as a separate Service until after World War II.  ',0,0,1);
I[3][3][4]=new Array('The Navy and the Coast Guard','Sorry.  At this point the Coast Guard wasn\'t involved in these war plans.  The Navy was the sea-based component.  What was the land-based component.',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('Amphibious Operations','Right!  Neither the Japanese nor the Germans were ever able to mount a successful defense against it.',1,100,1);
I[4][3][1]=new Array('Defensive Beach Emplacements','Sorry.  It proved impossible to adequately defend beaches as amphibious operations became more and more successful.',0,0,1);
I[4][3][2]=new Array('Paratroop landings behind enemy lines','Nope.  While these were successfully accomplished, they were in more of a supporting role than in the major role of a tactical operation.',0,0,1);
I[4][3][3]=new Array('Vertical Envelopment','Nope.  The development of the tactic of vertical envelopment came only after the use of helicopters in the military, and this didn\'t occur until after World War II.',0,0,1);
I[4][3][4]=new Array('Urban Warfare','Sorry.  While urban warfare tactics were required and did improve during this war, they were not the most successful tactical operations of the war.',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('Helicopters','Right.  Helicopters would not see action until the Korean War.',1,100,1);
I[5][3][1]=new Array('Armored columns of tanks','Nope.  This was the primary land tactic used by both sides in the war in Europe.',0,0,1);
I[5][3][2]=new Array('Recoilless artillery','Sorry.  Recoilless artillery pieces were used by both the Allies and the Germans during this war.',0,0,1);
I[5][3][3]=new Array('Nuclear Bombs','Nope.  The U.S. used two nuclear weapons at the end of World War II to bring about the surrender of Japan.',0,0,1);
I[5][3][4]=new Array('Missiles','Sorry.  World War II was the first war that saw the use of missiles.',0,0,1);
I[6]=new Array();I[6][0]=100;
I[6][1]='';
I[6][2]='3';
I[6][3]=new Array();
I[6][3][0]=new Array('Infantry body armor.','Partially correct.  This new form of body armor, using plastics, reduced chest and abdominal wounds by about 65 percent.  What is the other tactical development?',1,100,1);
I[6][3][1]=new Array('Combat helicopters','Partially correct.  This allowed the first use of the tactic of vertical envelopment.  What is the other tactical development?',1,100,1);
I[6][3][2]=new Array('Missiles','Sorry.  Missiles saw their first combat use during World War II.',0,0,1);
I[6][3][3]=new Array('Recoilless artillery','Sorry.  Recoilless artillery was used by both sides during World War II.',0,0,1);
I[6][3][4]=new Array('Fast-carrier task forces','Nope.  This tactic had been developed during World War II and used to defeat the Japanese Navy.',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('Spearheading breaks in enemy lines.','Right.  This is the tactic first used by armored columns during World War II.',1,100,1);
I[7][3][1]=new Array('Vertical Envelopment','Nope.  The Korean War saw the start of the tactic of vertical envelopment, using helicopters to quickly move troops behind enemy defensive lines.',0,0,1);
I[7][3][2]=new Array('Logistics Support','Sorry.  Movement of supplies and wounded personnel via helicopter got its start during the Korean War.',0,0,1);
I[7][3][3]=new Array('Gunfire Support','Nope.  Combat helicopters have had this as a mission from the very beginning.',0,0,1);
I[7][3][4]=new Array('Insertion of special forces','Sorry.  This was, and still is, a common use for helicopters.',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('Dispersal','Right.  Keeping your forces dispersed means that a single nuclear blast would affect only a smaller portion of your overall force.',1,100,1);
I[8][3][1]=new Array('Body armor','Sorry.  Body armor is designed to help reduce the number and severity of small arms fire wounds, but offer very little protection against the blast of a nuclear device.',0,0,1);
I[8][3][2]=new Array('Helicopter mobility','Nope.  Nuclear weapons have as much of an impact on vehicles and helicopters as they do on military personnel.  ',0,0,1);
I[8][3][3]=new Array('Chemical, Biological and Radiological (CBR) equipment','Sorry.  While CBR gear can help maintain the health and effectiveness of our military forces after a nuclear attack, it doesn\'t help their survival during the blast.',0,0,1);
I[8][3][4]=new Array('Forward basing','Nope.  While the basing of our troops forward would mean that an nuclear attack on those troops wouldn\'t occur on our home soil, it doesn\'t help the survival of those military forces.',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('Pentomic','Right!  This tactic, and the built-in rapid mobility of newer Army Divisions, greatly increases the combat effectiveness of the Divisions when faced with a nuclear attack.',1,100,1);
I[9][3][1]=new Array('Triad dispersal','Sorry.  Dispersal is the tactic used to split up your forces to make them less vulnerable to nuclear attack, but "Triad" stands for three, and they are split up into more sections than that.',0,0,1);
I[9][3][2]=new Array('Forward strategy','Sorry.  The U.S. has a forward strategy, meaning we deploy our forces overseas near the world\'s "Hot Spots", but this is not a tactic of dividing up Army Divisions.',0,0,1);
I[9][3][3]=new Array('"Smart" deployment','Nope.  Although it is "smart" to disperse your forces up when faced with a nuclear threat, this is not the term used.',0,0,1);
I[9][3][4]=new Array('Defensive dispersal','Nope.  There is no such term.  This is the general concept however.',0,0,1);
I[10]=new Array();I[10][0]=100;
I[10][1]='';
I[10][2]='3';
I[10][3]=new Array();
I[10][3][0]=new Array('Programmable cruise missiles','Partially correct.  This is one of the two "smart" weapons listed.  What is the other one?  You must check the box next to both of them.',1,100,1);
I[10][3][1]=new Array('Laser-guided bombs','Partially correct.  This is one of the two "smart" weapons listed.  What is the other one?  You must check the box next to both of them.',1,100,1);
I[10][3][2]=new Array('5-inch, 54-caliber gun mounts','Nope.  These gun mounts, when modified, have the ability to shoot some smart weapons, but they are not smart weapons in and of themselves.',0,0,1);
I[10][3][3]=new Array('GPS receivers','Sorry.  Many smart weapons use GPS receivers for guidance but these receivers are not "smart weapons" themselves.',0,0,1);
I[10][3][4]=new Array('Combat Helicopters','Sorry.  While combat helicopters can fire and guide smart weapons, they are not considered "smart weapons" themselves.',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('30 percent','Right.  This percentage of our Armed Forces are deployed forward and are in an operationally combat-ready status.',1,100,1);
I[11][3][1]=new Array('40 percent','Sorry.  This is percentage that are operationally ready during peacetime, but assigned to fleets working out of U.S. ports.',0,0,1);
I[11][3][2]=new Array('50 percent','Nope.  During times of tensions prior to war, and during war itself, it can go this high, but this is not the normal peacetime percentage of forces forward based.',0,0,1);
I[11][3][3]=new Array('25 percent','Sorry.  You are close, but it is a higher percentage than 25.',0,0,1);
I[11][3][4]=new Array('85 percent','Nope.  This is far too high a number.  This could occur during a war-time period, but this would be far too costly for the U.S. during peacetime.',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('50 percent','Right!  This would be for short-periods only, unless the U.S. did go to war.',1,100,1);
I[12][3][1]=new Array('85 percent','Nope.  This is percentage of the Fleet that can be deployed during wartime, such as was the case in World War II.',0,0,1);
I[12][3][2]=new Array('30 percent','Sorry.  This is the percentage normally deployed forward in a combat-ready status during peacetime.',0,0,1);
I[12][3][3]=new Array('40 percent','Sorry.  This is the percentage that is operationally ready, but assigned to fleets working out of U.S. ports.',0,0,1);
I[12][3][4]=new Array('25 percent','Nope.  The percentage of forces deployed forward is more than this even during peacetime.',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('They can rely on allied sea ports for resupply items.','Correct!  Our mobile logistics fleet ensures that we do not have to rely on our allies to resupply our naval forces and allow them to stay on station for extended periods of time.',1,100,1);
I[13][3][1]=new Array('Naval forces carry most of their own supplies.','Sorry.  Our naval ships are designed to carry most of the items necessary to fight and stay on station.  Our mobile logistics fleet ensures that we can resupply our naval forces on station, so they can remain and fight for long periods of time.',0,0,1);
I[13][3][2]=new Array('They operate in international waters and so are immune to many political difficulties.','Nope.  The fact that ocean areas outside of 13 nautical miles are considered international waters allows our naval forces to operate over most of the surface of the earth without having to ask permission, as a land army might have to.',0,0,1);
I[13][3][3]=new Array('They can often operate outside of the range of enemy countermeasures.','Sorry.  This is a key advantage.  Because we generally have longer-range weapons systems, we can stand off outside of the range of enemy systems while still attacking.',0,0,1);
I[13][3][4]=new Array('Their mobility complicates enemy detection and targeting problems.','Nope.  This is in fact the case.  Since our ships can move, and attack on the move, it makes it very difficult for the enemy to find them and target them.',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('Offensive Power','Correct!  The Navy\'s presence in the theater must be credible to allies for defense and to potential enemies for deterrence.',1,100,1);
I[14][3][1]=new Array('Defensive Strength','Sorry.  This capability focuses on the ability of our naval forces to defend themselves against hostile forces when attacked.  The question asks for the other side of the coin, that of attacking enemy forces, vice defending against them.',0,0,1);
I[14][3][2]=new Array('The Ability to Project Power Ashore','Sorry.  This capability focuses on the naval force\'s ability to project power ashore by gunfire, missiles, carrier-based aircraft or amphibious landings.  It doesn\'t cover another major capability, that of at-sea warfare.',0,0,1);
I[14][3][3]=new Array('Logistic Independence','Nope.  This capability allows our forward-based naval forces to remain on station for extended periods of time.',0,0,1);
I[14][3][4]=new Array('Command and Control','Nope.  Command and Control is the system which provides key links in the chain of command that connect forward-deployed naval forces with one another, the supporting shore establishment, forces of other services and nations, and government and nongovernmental agencies.',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('Defensive Strength','Right!  These systems allow our naval forces to maximize the time they have to react to and defeat the modern offensive weapons systems that might be directed against them.',1,100,1);
I[15][3][1]=new Array('The Ability to Project Power Ashore','Sorry.  This capability focuses on the naval force\'s ability to project power ashore by gunfire, missiles, carrier-based aircraft or amphibious landings.  It doesn\'t cover another major capability, that of at-sea warfare.',0,0,1);
I[15][3][2]=new Array('Logistic Independence','Nope.  This capability allows our forward-based naval forces to remain on station for extended periods of time.',0,0,1);
I[15][3][3]=new Array('Command and Control','Nope.  Command and Control is the system which provides key links in the chain of command that connect forward-deployed naval forces with one another, the supporting shore establishment, forces of other services and nations, and government and nongovernmental agencies.',0,0,1);
I[15][3][4]=new Array('Offensive Power','Sorry.  Offensive Power capability focuses on offensive weapons systems and not on defensive systems such as those listed.',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('Long-range, early warning radar.','Right!  This is an important tool for defensive operations, since it gives the ship or battle group the greatest detection range against enemy threats and therefore increases available reaction time.',1,100,1);
I[16][3][1]=new Array('Gunfire','Sorry.  Naval gunfire remains a critical element of power projection operations and with the new naval gunfire systems of the future, it will remain so for quite some time.',0,0,1);
I[16][3][2]=new Array('Missiles','Nope.  Missiles, such as the Navy\'s Tactical Land Attack Missile (TLAM) are usually the first thing used by the naval forces in the power projection mission.',0,0,1);
I[16][3][3]=new Array('Carrier-based aircraft','Sorry.  Carrier-based aircraft are a major part of the naval power projection mission today.',0,0,1);
I[16][3][4]=new Array('Amphibious landings','Nope.  This is the primary method used to move U.S. Infantry forces ashore during power projection operations.',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('Coordination','Correct.  While coordination between all agencies is essential to a successful operation, it is not a separate component of the C4I process.',1,100,1);
I[17][3][1]=new Array('Intelligence','Sorry.  Accurate and timely intelligence is essential in order for a commander to intelligently and decisively deploy his or her forces.',0,0,1);
I[17][3][2]=new Array('Communications','Sorry.  Communications is an absolutely essential part of the C4I Command and Control process.  This area includes all methods a commander uses to keep in touch with and direct his subordinate forces.',0,0,1);
I[17][3][3]=new Array('Control','Nope.  Command and Control is the primary area of C4I.  It is how the tactical commander is able to communicate and control his subordinate forces.',0,0,1);
I[17][3][4]=new Array('Computers','Nope.  Computers have become such an integral part of our weapons and intelligence gathering systems that it must be included within the overall C4I process.',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('C4I','Right.  The five subdivisions include Command, Control, Communications, Computers and Intelligence.',1,100,1);
I[18][3][1]=new Array('Pentomic','Sorry.  This term refers to the dispersing of Army Divisions into five units to allow them to better survive in the event of a nuclear attack.',0,0,1);
I[18][3][2]=new Array('Strategic Triad','Nope.  This term refers the U.S. nuclear strike options, including land-based ICBMs, sub-launched ballistic missiles and air-delivered nuclear bombs and missiles.',0,0,1);
I[18][3][3]=new Array('Information Weapons Systems','Nope.  There is no such subdivision of naval command and control.',0,0,1);
I[18][3][4]=new Array('Ocean surveillance','Nope.  Ocean surveillance refers to the observation of ocean areas to detect, locate, and classify potential aerospace, surface, and subsurface targets.',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('Naval warfare','Right!  As long as there is a naval element in the conflict, it is referred to as Naval Warfare.',1,100,1);
I[19][3][1]=new Array('Offensive warfare','Sorry.  This refers to a naval force\'s ability to conduct offensive combat operations either against a sea-based enemy or a land-based enemy.',0,0,1);
I[19][3][2]=new Array('Defensive warfare','Sorry.  This refers to a naval force\'s ability to defend itself when attacked by any type of enemy force.',0,0,1);
I[19][3][3]=new Array('Mine warfare','Nope.  This term refers to the use of mines and mine countermeasures.',0,0,1);
I[19][3][4]=new Array('Amphibious warfare','Nope.  This type of warfare refers to attacks launched from the sea by naval forces and landing forces embarked in ships and craft designed to make a landing on a hostile shore.',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('These are all primary areas of Naval Warfare','Right!  You have to be able to conduct both offensive and defensive operations under the sea, on top of the sea and above it.',1,100,1);
I[20][3][1]=new Array('Subsurface','Sorry.  Submarines are a major part of the Navy, and this is the area of Naval Warfare in which they work.',0,0,1);
I[20][3][2]=new Array('Aerospace','Sorry.  While aerospace sounds like it wouldn\'t be a primary area of Naval Warfare, Air Warfare is an important area to the Navy.  It includes both near-Earth space as well as the air areas around the operating naval force.',0,0,1);
I[20][3][3]=new Array('Surface','Nope.  Operating on the surface of the ocean is the most common area of Naval Warfare.',0,0,1);
I[20][3][4]=new Array('None of the areas listed are primary areas of Naval Warfare.','Nope.  It would be hard to operate as a Navy if you couldn\'t work on the surface, subsurface or in the air!',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('Special warfare','Correct.  This is a supporting warfare task and focuses on naval operations that are unconventional in nature.',1,100,1);
I[21][3][1]=new Array('Air warfare','Sorry.  This fundamental task focuses on the destruction of enemy air platforms and airborne weapons systems.',0,0,1);
I[21][3][2]=new Array('Surface warfare','Sorry.  This is the fundamental task that focuses on the destruction or neutralization of enemy surface combatants and merchant ships.',0,0,1);
I[21][3][3]=new Array('Strike warfare','Nope.  This fundamental task focuses on the destruction or neutralization of enemy targets ashore through the use of conventional or nuclear weapons.',0,0,1);
I[21][3][4]=new Array('Space Warfare','Nope.  This is an important and fundamental task for the Navy.  It refers to the use or denial of space-based navigation and weapons systems.',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('Mine warfare','Right!  The fundamental warfare area also focuses on the laying minefields and countering enemy mine warfare through the destruction or neutralization of hostile minefields.',1,100,1);
I[22][3][1]=new Array('Undersea warfare','Sorry.  This fundamental task of naval warfare focuses on the destruction or neutralization of enemy submarines, mines, and other undersea forces.',0,0,1);
I[22][3][2]=new Array('Surface warfare','Sorry.  This is the fundamental task that focuses on the destruction or neutralization of enemy surface combatants and merchant ships.',0,0,1);
I[22][3][3]=new Array('Strike warfare','Nope.  This fundamental task focuses on the destruction or neutralization of enemy targets ashore through the use of conventional or nuclear weapons.',0,0,1);
I[22][3][4]=new Array('Amphibious warfare','Nope.  Amphibious warfare deals with attacks launched from the sea by naval forces and landing forces embarked in ships and craft designed to make a landing on a hostile shore.',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('Amphibious Warfare','Correct!  Close air support and shore bombardment make up for the initial lack of artillery support for infantry forces involved in an amphibious landing.',1,100,1);
I[23][3][1]=new Array('Strike Warfare','Nope.  This fundamental task focuses on the destruction or neutralization of enemy targets ashore through the use of conventional or nuclear weapons.',0,0,1);
I[23][3][2]=new Array('Surface Warfare','Sorry.  This is the fundamental task that focuses on the destruction or neutralization of enemy surface combatants and merchant ships.',0,0,1);
I[23][3][3]=new Array('Air Warfare','Sorry.  This fundamental warfare area focuses on the destruction of enemy air platforms and airborne weapons.',0,0,1);
I[23][3][4]=new Array('Space Warfare','Nope.  Space Warfare refers to the use or denial of space-based navigation and weapons systems.',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('Surface Warfare','Correct!  This is the fundamental task area that focuses on the destruction or neutralization of enemy surface combatants and merchant ships.',1,100,1);
I[24][3][1]=new Array('Amphibious Warfare','Nope.  Amphibious warfare deals with attacks launched from the sea by naval forces and landing forces embarked in ships and craft designed to make a landing on a hostile shore.',0,0,1);
I[24][3][2]=new Array('Strike Warfare','Nope.  This fundamental task focuses on the destruction or neutralization of enemy targets ashore through the use of conventional or nuclear weapons.',0,0,1);
I[24][3][3]=new Array('Air Warfare','Sorry.  This fundamental warfare area focuses on the destruction of enemy air platforms and airborne weapons.',0,0,1);
I[24][3][4]=new Array('Space Warfare','Nope.  Space Warfare refers to the use or denial of space-based navigation and weapons systems.',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('Space Warfare','Right!  Space Warfare is a fundamental naval warfare task.  It focuses on the use or denial of space-based navigation and weapons systems.',1,100,1);
I[25][3][1]=new Array('Ocean Surveillance','Sorry.  this supporting warfare task concerns the observation of ocean areas to detect, locate, and classify potential aerospace, surface, and subsurface targets.',0,0,1);
I[25][3][2]=new Array('Special Warfare','Nope.  This is a supporting warfare task and focuses on naval operations that are unconventional in nature.',0,0,1);
I[25][3][3]=new Array('Electronic Warfare','Nope.  Electronic Warfare is a supporting warfare task that has, as a primary objective, the effective use of the electromagnetic spectrum by friendly forces, while determining, exploiting, reducing, or denying its use by an enemy.',0,0,1);
I[25][3][4]=new Array('Intelligence','Sorry.  This is the supporting warfare task that focuses on the assessment and management of information obtained via surveillance, reconnaissance, and other means.',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('Logistics','Right!  This is the supporting task that focuses on the resupply of combat consumables to combatant forces in the theater of operations.',1,100,1);
I[26][3][1]=new Array('Electronic Warfare','Nope.  Electronic Warfare is a supporting warfare task that has, as a primary objective, the effective use of the electromagnetic spectrum by friendly forces, while determining, exploiting, reducing, or denying its use by an enemy.',0,0,1);
I[26][3][2]=new Array('Intelligence','Sorry.  This is the supporting warfare task that focuses on the assessment and management of information obtained via surveillance, reconnaissance, and other means.',0,0,1);
I[26][3][3]=new Array('Special Warfare','Nope.  This is a supporting warfare task and focuses on naval operations that are unconventional in nature.',0,0,1);
I[26][3][4]=new Array('Ocean Surveillance.','Sorry.  this supporting warfare task concerns the observation of ocean areas to detect, locate, and classify potential aerospace, surface, and subsurface targets.',0,0,1);
I[27]=new Array();I[27][0]=100;
I[27][1]='';
I[27][2]='3';
I[27][3]=new Array();
I[27][3][0]=new Array('Combatants','Partially right!  Combatants include vessels classified as warships, such as aircraft carriers, surface combatants, submarines, and amphibious warfare ships.  What is the other category?',1,100,1);
I[27][3][1]=new Array('Auxiliaries','Partially right!  Auxiliaries include primarily mobile logistic and support ships, such as oilers and repair ships.  What is the other category?',1,100,1);
I[27][3][2]=new Array('Surface ','Sorry.  There are different categories of naval surface ships.',0,0,1);
I[27][3][3]=new Array('Subsurface','Sorry.  All of our naval subsurface forces fall within a single category, along with some surface ships as well.',0,0,1);
I[27][3][4]=new Array('Logistics','Nope.  This is a supporting naval warfare task are, not a category of naval ships.',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('Auxiliaries','Correct!  This category also includes mobile logistic ships and other support-type ships, including repair ships.',1,100,1);
I[28][3][1]=new Array('Combatants','Sorry.  Combatant category ships are made up of ships classified as warships.  Oilers are not considered warships.',0,0,1);
I[28][3][2]=new Array('Support','Nope.  Support is not one of the two categories of major naval ships.',0,0,1);
I[28][3][3]=new Array('Logistics','Nope.  This is a supporting naval warfare task are, not a category of naval ships.',0,0,1);
I[28][3][4]=new Array('Resupply','Nope.  Resupply is not one of the two categories of major naval ships.',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('Tactical Force Organization','Right!  Naval units are operationally deployed in task organizations designed for the completion of specific jobs.',1,100,1);
I[29][3][1]=new Array('Pentomic Organization','Sorry.  Army Divisions are set-up in Pentomic (5 subdivisions) style to better protect them from the threat of a nuclear attack.',0,0,1);
I[29][3][2]=new Array('The Strategic Triad','Sorry.  The strategic triad refers to the strategic nuclear forces of the U.S., including land-based ICBMs, sub-launched ballistic missiles and air-dropped bombs and missiles.',0,0,1);
I[29][3][3]=new Array('Forward Strategy','Nope.  Forward Strategy is the policy of the U.S. to base and operate military forces overseas, near the sites of tension, and use the vast ocean areas as a buffer to the United States.',0,0,1);
I[29][3][4]=new Array('Vertical Envelopment','Nope.  This is the tactic of using helicopters to insert infantry troops behind enemy lines as a part of an amphibious operation.',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('Special Warfare Group','Right.  Naval Special Warfare Units are incorporated into existing Tactical Force Organization as required.  They are not organized into separate tactical forces.',1,100,1);
I[30][3][1]=new Array('Undersea Warfare Task Group','Nope.  Undersea Warfare Task Groups are designed to locate and defeat enemy submarines.',0,0,1);
I[30][3][2]=new Array('Carrier Battle Group','Nope.  This is the most common and recognized form of Tactical Force Organization to most people.',0,0,1);
I[30][3][3]=new Array('Amphibious Warfare Group','Sorry.  Amphibious Warfare Groups consist of ships and forces tailored to conduct amphibious operations anywhere in the world.',0,0,1);
I[30][3][4]=new Array('Underway Replenishment Group','Sorry.  This is the term used for Auxiliary ships organized and deployed to support a naval combatant group deployed forward.',0,0,1);


function StartUp(){
	RemoveBottomNavBarForIE();
	

	

	
	CompleteEmptyFeedback();

	SetUpQuestions();
	ClearTextBoxes();
	CreateStatusArray();
	

	
}

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){
		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;
		
//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{
			State[QNum][0] = ((TotAns-(Tries-1))/TotAns)*(PercentCorrect/(100*Tries));
		}
		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 CheckMultiSelAnswer(QNum){
//bail if question doesn't exist or exercise finished
	if ((State[QNum].length < 1)||(Finished == true)){return;}

//Increment the tries for this question
	State[QNum][2]++;
	
	var ShouldBeChecked;
	var Matches = 0;
	State[QNum][5] += '|';
	
//Check if there are any mismatches
	Feedback = '';
	var CheckBox = null;
	for (var ANum=0; ANum<I[QNum][3].length; ANum++){
		CheckBox = document.getElementById('Q_' + QNum + '_' + ANum + '_Chk');
		if (CheckBox.checked == true){
			State[QNum][5] += 'Y';
		}
		else{
			State[QNum][5] += 'N';
		}
		ShouldBeChecked = (I[QNum][3][ANum][2] == 1);
		if (ShouldBeChecked == CheckBox.checked){
			Matches++;
		}
		else{
			Feedback = I[QNum][3][ANum][1];
		}
	}
//Add the hit readout
	Feedback = Matches + ' / ' + I[QNum][3].length + '<br />' + Feedback;
	if (Matches == I[QNum][3].length){
//It's right
		CalculateMultiSelQuestionScore(QNum);
		if (ContinuousScoring == true){
			CalculateOverallScore();
			if ((ContinuousScoring == true)||(Finished == true)){
				Feedback += '<br />' + YourScoreIs + ' ' + Score + '%.';
				WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
			}
		}
	}
//If it's wrong, no need to do anything but show the feedback
	ShowMessage(Feedback);
}

function CalculateMultiSelQuestionScore(QNum){
	var Tries = State[QNum][2];
	var TotAns = State[QNum][1].length;
	
//Make sure it's not already complete
	if (State[QNum][0] < 0){
		State[QNum][0] = (TotAns - (Tries-1)) / TotAns;
		if (State[QNum][0] < 0){
			State[QNum][0] = 0;
		}
	}
}



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]);
			}
		}
	}
	Score = Math.floor((TotalScore/TotalWeighting)*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);
	}
}










//-->

//]]>


