

//<![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 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.ie){
		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 TopSettingWithScrollOffset(TopPercent){
	var T = Math.floor(document.getElementsByTagName('body')[0].clientHeight * (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];
	}
	
//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 (document.getElementById('Q_' + CurrQNum + '_Guess') != null){
		document.getElementById('Q_' + CurrQNum + '_Guess').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('Naval operations','Right.  It can also refer to the activities of the department on board a ship that is concerned with the planning and accomplishment of these actions. ',1,100,1);
I[0][3][1]=new Array('Naval Intelligence','Nope.  Naval intelligence gives government and military leaders the information about potential or actual enemies needed to make good decisions. ',0,0,1);
I[0][3][2]=new Array('Naval logistics ','Nope.  Naval logistics provides the means of support for naval operations.',0,0,1);
I[0][3][3]=new Array('Naval communications ','Sorry.  Naval communications is the transmission and reception of military instructions and information by sound, electronics, or visual means. ',0,0,1);
I[0][3][4]=new Array('Naval research and development ','Sorry.  Naval research and development ensures that the Navy operates with the latest technology.',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('Naval intelligence','Right!  It is often an integral part of naval operations, and is transmitted through naval communications. ',1,100,1);
I[1][3][1]=new Array('Naval operations','Sorry.  Naval operations refers to the day-to-day conduct of all actions involving units of the U.S. fleet in the oceans of the world.',0,0,1);
I[1][3][2]=new Array('Naval logistics ','Nope.  Naval logistics provides the means of support for naval operations.',0,0,1);
I[1][3][3]=new Array('Naval communications ','Nope.  Naval communications is the transmission and reception of military instructions and information by sound, electronics, or visual means. ',0,0,1);
I[1][3][4]=new Array('Naval research and development ','Sorry.  Naval research and development ensures that the Navy operates with the latest technology.',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('Naval research and development','Right!  It is the important mission of this area to keep our Naval forces ready for any potential conflict against any possible enemy by providing the very latest technology today and researching the new technologies of tomorrow.',1,100,1);
I[2][3][1]=new Array('Naval intelligence','Sorry.  Naval intelligence gives government and military leaders the information about potential or actual enemies needed to make good decisions. ',0,0,1);
I[2][3][2]=new Array('Naval logistics ','Nope.  Naval logistics provides the means of support for naval operations.',0,0,1);
I[2][3][3]=new Array('Naval communications ','Sorry.  Naval communications is the transmission and reception of military instructions and information by sound, electronics, or visual means. ',0,0,1);
I[2][3][4]=new Array('Naval operations','Sorry.  Naval operations refers to the day-to-day conduct of all actions involving units of the U.S. fleet in the oceans of the world.',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('Naval Strategic Forces','Right!  This strategic force of Navy Nuclear Ballistic Missile Submarines helped prevent a major war between the superpowers during the cold war period. ',1,100,1);
I[3][3][1]=new Array('Naval General Purpose Forces','Sorry.  The primary mission of the Naval general purpose forces is to engage in offensive and defensive combat with enemy forces.',0,0,1);
I[3][3][2]=new Array('Naval Submarine Forces','Sorry.  While portions of the Naval submarine forces are a part of this mission type, a large portion of the submarine force (attack subs, for example) do not.',0,0,1);
I[3][3][3]=new Array('Naval Special Forces','Nope.  Naval special forces are not one of the two general types of Naval Forces, and this is not their primary purpose.',0,0,1);
I[3][3][4]=new Array('Naval Surface Forces','Nope.  Naval surface forces are not one of the two general types of Naval Forces, and this is not their primary purpose. ',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('Auxiliary Craft','Correct!  Smaller ships which handle auxiliary missions are known as Auxiliary Ships or Service Craft, not Auxiliary Craft.',1,100,1);
I[4][3][1]=new Array('Auxiliary Ships','Sorry.  Auxiliary ships provide services to other ships and to overseas stations. ',0,0,1);
I[4][3][2]=new Array('Combatant Ships','Sorry.  Combatants are of three types: warships, amphibious warfare ships, and mine warfare ships. They make up the bulk of the war-fighting capability of U.S. Naval Forces. ',0,0,1);
I[4][3][3]=new Array('Combatant Craft','Nope.  Combatant craft include three types: patrol, amphibious warfare, and mine  warfare. They are a vital part of the overall Naval warfare effort. ',0,0,1);
I[4][3][4]=new Array('Service Craft','Nope.  Service craft include various harbor and support craft that provide the bulk of logistic support to U.S. Naval Forces.',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('Battleships','Correct.  The last of the U.S. Navy\'s battleships was decommissioned in the 1990\'s.',1,100,1);
I[5][3][1]=new Array('Aircraft Carriers','Sorry.  The 12 Aircraft Carriers currently in commissioned service make up the centerpiece of U.S. Naval power projection.',0,0,1);
I[5][3][2]=new Array('Cruisers','Nope.  The current class of Aegis cruisers are a vital part of U.S. Naval power projection.',0,0,1);
I[5][3][3]=new Array('Destroyers ','Nope.  There are more destroyers in commissioned service than any other U.S. Navy warship type.',0,0,1);
I[5][3][4]=new Array('Frigates','Sorry.  Frigates, which are smaller warships with limited but vital Naval combat missions, are still found in the U.S. Navy.',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('Service Craft','Right!  Service craft are various types of harbor and support craft which are generally not designed for nor engaged in combat operations.',1,100,1);
I[6][3][1]=new Array('Patrol Craft','Sorry.  Naval patrol craft provide combat support in riverine and coastal areas.',0,0,1);
I[6][3][2]=new Array('Amphibious Warfare Craft','Sorry.  These craft provide vital support moving troops and equipment ashore during amphibious operations.',0,0,1);
I[6][3][3]=new Array('Mine Warfare Craft','Nope.  Mine warfare craft play an important role in clearing enemy minefields and laying defensive minefields in support of combat operations.',0,0,1);
I[6][3][4]=new Array('All of these are types of U.S. Navy Combatant Craft?','Nope.  There is one listed which is not a Combatant Craft.',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('Third','Right!  The Headquarters of the Third Fleet is in San Diego, California.',1,100,1);
I[7][3][1]=new Array('Second','Nope.  The Second Fleet\'s primary area of responsibility is the Western Atlantic Ocean.',0,0,1);
I[7][3][2]=new Array('Fifth','Sorry.  The Fifth Fleet\'s primary area of responsibility is the Indian Ocean.',0,0,1);
I[7][3][3]=new Array('Seventh','Sorry.  The Seventh Fleet\'s primary area of responsibility is the Western Pacific Ocean.',0,0,1);
I[7][3][4]=new Array('Sixth','Nope.  The Sixth Fleet\'s primary area of responsibility is the Mediterranean Sea.',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('Fifth','Right!  The Fifth Fleet is headquartered inside the Arabian Gulf in Bahrain.',1,100,1);
I[8][3][1]=new Array('Third','Sorry.  The Third Fleet\'s primary area of responsibility is the Eastern Pacific Ocean.',0,0,1);
I[8][3][2]=new Array('Sixth','Nope.  The Sixth Fleet\'s primary area of responsibility is the Mediterranean Sea.',0,0,1);
I[8][3][3]=new Array('Second','Nope.  The Second Fleet\'s primary area of responsibility is the Western Atlantic Ocean.',0,0,1);
I[8][3][4]=new Array('Seventh','Sorry.  The Seventh Fleet\'s primary area of responsibility is the Western Pacific Ocean.',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('Sixth','Right!  The Sixth Fleet is headquartered in Gaeta, Italy.',1,100,1);
I[9][3][1]=new Array('Third','Sorry.  The Third Fleet\'s primary area of responsibility is the Eastern Pacific Ocean.',0,0,1);
I[9][3][2]=new Array('Fifth','Nope.  The Fifth Fleet\'s primary area of responsibility is the Indian Ocean.',0,0,1);
I[9][3][3]=new Array('Second','Nope.  The Second Fleet\'s primary area of responsibility is the Western Atlantic Ocean.',0,0,1);
I[9][3][4]=new Array('Seventh','Sorry.  The Seventh Fleet\'s primary area of responsibility is the Western Pacific Ocean.',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('A Unified Command has forces from two or more Services.  A Specified Command normally has forces from a single Service.','Right.  If there are military personnel from all of the Services assigned it is a Unified Command and is considered a "Joint" tour of duty for them.  The term "Joint" also means there are service members from more than one U.S. Service involved.  The term "Combined" means that military members from more than one country are involved.',1,100,1);
I[10][3][1]=new Array('A Specified Command has forces from two or more Services while a Unified Command normally has forces from a single Service.','Nope.  You\'re on the right track though.  Think of what the word "Unified" normally stands for.',0,0,1);
I[10][3][2]=new Array('Unified Commands are Naval or Marine Corps while Specified Commands are Army or Air Force.','Sorry.  The particular branch of Service doesn\'t play into the designation of a Command as Unified or Specified.',0,0,1);
I[10][3][3]=new Array('Specified Commands are Naval or Marine Corps while Unified Commands are Army or Air Force.','Sorry.  The particular branch of Service doesn\'t play into the designation of a Command as Unified or Specified.',0,0,1);
I[10][3][4]=new Array('There is no significant difference between Unified and Specified Commands.','Nope.  There is one feature in particular which distinguishes between the two types of Commands.',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('Strike','Correct!  Types of naval forces organized to make strikes are carrier, surface, and submarine forces. ',1,100,1);
I[11][3][1]=new Array('Raid','Sorry.  A raid is defined as a sudden destructive attack against a limited area or facility, with no intention of holding the territory invaded.',0,0,1);
I[11][3][2]=new Array('Sweep','Sorry.  A sweep is defined as a series of strikes against several enemy targets in a general area.',0,0,1);
I[11][3][3]=new Array('Sortie','Nope.  A sortie is a single flight mission by a naval aircraft.',0,0,1);
I[11][3][4]=new Array('War','Nope.  The term War is much broader than this and refers to the entire conflict between two countries.',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('World War II','Right!  The initial loss of our battleships at Pearl Harbor required that U.S. Naval planners make the aircraft carrier the centerpiece of Naval Strategy.  The concept of the fast-carrier task force developed from this.',1,100,1);
I[12][3][1]=new Array('World War I','Sorry.  The aircraft carrier wasn\'t developed until after the end of the First World War.',0,0,1);
I[12][3][2]=new Array('The Korean War','Sorry.  While still a developing concept during the Korean War, fast-carrier task forces had been used before this.',0,0,1);
I[12][3][3]=new Array('The first Gulf War','Nope.  There was a long history behind the fast-carrier task force by this time.',0,0,1);
I[12][3][4]=new Array('The Vietnam War','Nope.  While up to as many as five carrier task forces were deployed at a time off Vietnam during this war, this wasn\'t the first time fast-carrier task forces were used.',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('To capture a land area from which air operations can be launched and supported.','Correct!  This is the primary mission of our Naval Amphibious Forces.',1,100,1);
I[13][3][1]=new Array('To provide close air support.','Nope.  Close air support is vital to the success of an amphibious operation, and the carrier striking force is the only force able to accomplish this important task.',0,0,1);
I[13][3][2]=new Array('To strike against remote enemy installations.','Nope.  This is a common and ongoing mission of carrier strike forces.  The strikes in Afghanistan and Iraq are recent examples of this.',0,0,1);
I[13][3][3]=new Array('To protect amphibious forces from enemy attack.','Sorry.  While we haven\'t had to make large-scale amphibious landings in some time, this still remains one of the primary missions of a carrier strike force.  Carrier strike forces are the only way to provide round-the-clock support for amphibious forces if they are required.',0,0,1);
I[13][3][4]=new Array('To seek out and destroy enemy air, surface, and subsurface forces.','Sorry.  This is perhaps the most widely-recognized of the missions assigned to carrier strike forces.  Until they control the seas around them, these forces cannot carry out additional missions in support of U.S. policy.',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('A Sweep','Right.  Sweeps of this nature were first developed and used extensively during World War II.',1,100,1);
I[14][3][1]=new Array('A Raid','Sorry.   A raid is defined as a sudden destructive attack against a limited area or facility, with no intention of holding the territory invaded.',0,0,1);
I[14][3][2]=new Array('A Sortie','Nope.  The term "Sortie" is generally used to describe the flight of a single naval aircraft.',0,0,1);
I[14][3][3]=new Array('A Strikeout','Sorry.  There is no such military term.',0,0,1);
I[14][3][4]=new Array('An Operation','Nope.  The term "Operation" is a generic name given to major military movements and objectives within a war or general conflict.',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('One','Right!  With the capabilities of a modern aircraft carrier, all it takes is one to provide the necessary firepower.',1,100,1);
I[15][3][1]=new Array('Two','Sorry.  While this can occur, it is not the normal number of carriers within a modern carrier battle group.',0,0,1);
I[15][3][2]=new Array('Three','Sorry.  While the recent conflict in Iraq saw three carriers come together in the Persian Gulf, they were not all a part of the same carrier battle group.',0,0,1);
I[15][3][3]=new Array('Four','Nope.  There isn\'t a need, nor are there enough carriers normally in the same geographical region to have this many carriers within a battle group.',0,0,1);
I[15][3][4]=new Array('Five','Nope.  Five aircraft carriers haven\'t worked in the same geographical region since the Vietnam conflict.',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('Protecting the carrier battle group from surprise air attack.','Right!  This is the responsibility of the Combat Air Patrol (CAP) aircraft launched from the carrier.',1,100,1);
I[16][3][1]=new Array('"Mopping Up" operations following the main attack.','Sorry.  This is one of the most common wartime missions of SAGs.',0,0,1);
I[16][3][2]=new Array('Destruction of isolated enemy units.','Sorry.  This was a common mission of SAGs during World War II, when many Japanese-held islands were bypassed by the main U.S. assault forces.',0,0,1);
I[16][3][3]=new Array('Shore Bombardment','Nope.  Shore bombardment has always been a common mission of surface ships.  Think about something that isn\'t common for surface warships to do.',0,0,1);
I[16][3][4]=new Array('Scouting Missions','Nope.  Scouting missions are important to be able to gain intelligence about enemy force composition and disposition.  Carriers are usually too critical an asset to send on such missions, so SAGs are usually employed for such work.',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('Deployment of Forces','Right.  This is a tactical deployment for battle and differs from a normal overseas deployment of ships on a cruise during peacetime. ',1,100,1);
I[17][3][1]=new Array('Surface Action Groups','Sorry.  SAGs, or Surface Action Groups, is the name given to the grouping of ships, not to the maneuvering they do.',0,0,1);
I[17][3][2]=new Array('Mopping Up Operations','Nope.  Mopping Up Operations occur after the main action against the enemy force and this action can employ a wide variety of maneuvers, depending on the size and capability of the enemy forces.',0,0,1);
I[17][3][3]=new Array('Sweeps','Nope.  Sweeps are series of strikes against enemy targets within a general geographical region.',0,0,1);
I[17][3][4]=new Array('Battle Force Composition','Sorry.  When we speak of Battle Force Composition we are talking about the numbers and types of ships and aircraft available to the Battle Group Commander.  This term doesn\'t relate to the maneuvers of those ships or aircraft.',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('The Atlantic Ocean','Right!  That is the "LANT" part in COMNAVAIRLANT.  Now I\'ll bet you know what forces COMNAVAIRPAC is in charge off too!',1,100,1);
I[18][3][1]=new Array('The Pacific Ocean','Nope.  Another Admiral has this responsibility.  Take another look at the acronym COMNAVAIRLANT and see if you can\'t come up with a clue.',0,0,1);
I[18][3][2]=new Array('The Indian Ocean','Sorry.  Take another look at the acronym COMNAVAIRLANT and see if you can\'t come up with a clue.',0,0,1);
I[18][3][3]=new Array('The Arctic Ocean','Sorry.  Although there can be times when COMNAVAIRLANT would control U.S. naval forces in the Arctic Ocean, it isn\'t automatic, as it is in another of the choices.',0,0,1);
I[18][3][4]=new Array('The Arabian Gulf','Nope.  Way off!  Take another look at the acronym COMNAVAIRLANT and see if you can\'t come up with a clue there to help.',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('6 months','Right.  Real-world events can always lengthen the deployment, but it won\'t be less than 6 months.  With the exceptions for the recent conflicts in Afghanistan and Iraq, it has been 6 months as a rule for the past 30 years.',1,100,1);
I[19][3][1]=new Array('3 months','Nope.  3 month deployments are the norm for U.S. Air Force deployments, but not for U.S. Naval deployments.',0,0,1);
I[19][3][2]=new Array('9 months','Sorry.  Up until the late 1970\'s 9 months was the standard length of a deployment.  At that time is was changed to its new value.',0,0,1);
I[19][3][3]=new Array('12 months','Nope.  This was the case for many carrier battle groups during the Vietnam conflict, but that is not the norm now.',0,0,1);
I[19][3][4]=new Array('There is no norm.  It varies each time a battle group goes out.','Sorry.  Although events in the world can extend a battle group deployment, there is a set time that is used for planning purposes.',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('Surface to Surface','Correct!!  This is considered to be Naval Surface Warfare, since it is conflict between two surface forces.',1,100,1);
I[20][3][1]=new Array('Air to Air','Nope.  Air to Air Warfare has to do with the firing of bullets and missiles, as well as the direction of electronic jamming, at enemy air forces by friendly aircraft.',0,0,1);
I[20][3][2]=new Array('Air to Surface','Sorry.  Air to Surface Warfare has to do with the firing of bullets and missiles, as well as the direction of electronic jamming, at enemy forces on the surface of the earth or ocean by friendly aircraft.',0,0,1);
I[20][3][3]=new Array('Surface to Air','Nope.  Surface to Air Warfare has to do with the firing of bullets and missiles, as well as the direction of electronic jamming, at enemy aircraft by friendly ships.',0,0,1);
I[20][3][4]=new Array('These are all classifications of Naval Air Warfare.','Sorry.  One of them is out of place.  Think of the term "Air Warfare" and go over each of the other choices to see if that helps.',0,0,1);
I[21]=new Array();I[21][0]=100;
I[21][1]='';
I[21][2]='0';
I[21][3]=new Array();
I[21][3][0]=new Array('The Navy Tactical Data System (NTDS)','Right!  Through the use of the NTDS system, a battle force commander can be sure that he or she is able to bring the right weapon from the right platform to bear at the precise time it is needed.',1,100,1);
I[21][3][1]=new Array('The Fire Control Center (FCC)','Sorry.  FCC\'s are spaces on each ship which control the use of the various missile and gun systems on that particular ship.',0,0,1);
I[21][3][2]=new Array('The Fire Support Coordination Center (FSCC)','Sorry.  FSCC\'s coordinate and deconflict air support requests during amphibious operations.',0,0,1);
I[21][3][3]=new Array('The Federal Aviation Administration (FAA)','Nope.  The FAA controls domestic and military air traffic within the airspace of the United States.',0,0,1);
I[21][3][4]=new Array('COMNAVAIRPAC','Nope.  This is the name of the organization, run by a Navy Admiral, that is in charge of all Naval Forces in the Pacific Region.',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('Tomahawk ','Right.  The long range and accuracy of these weapons make them the first weapon to go "across the beach" in times of conflict.',1,100,1);
I[22][3][1]=new Array('Harpoon','Sorry.  While the Harpoon missile is fired by naval surface and aircraft, it is an anti-ship missile and not designed to go against land targets in its basic form.',0,0,1);
I[22][3][2]=new Array('Maverick','Sorry.  Maverick missiles are more close-in anti-vehicle missiles fired by aircraft and helicopters.',0,0,1);
I[22][3][3]=new Array('Hellfire','Nope.  The Hellfire missile is a small, in-close missile designed to be fired from a helicopter or unmanned aerial vehicle.',0,0,1);
I[22][3][4]=new Array('HARM','Nope.  The High speed AntiRadiation Missile (HARM) is designed for aircraft to hit enemy radar sites from outside the range of most air defense weapons.',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('To seek out and destroy enemy submarines.','Right.  Working in the same environment as enemy submarines, our nuclear attack submarines are best suited and equipped to find and destroy enemy submarines.',1,100,1);
I[23][3][1]=new Array('To seek out and destroy enemy surface ships.','Nope.  This is still an important mission area, just as it has been for years, but it is no longer the primary mission area of attack submarines.',0,0,1);
I[23][3][2]=new Array('To seek out and destroy enemy aircraft.','Nope.  They would have a hard time doing this while remaining below the surface of the ocean!',0,0,1);
I[23][3][3]=new Array('To perform covert intelligence operations off of enemy coasts.','Sorry.  This is an important mission of attack submarines, but not their primary mission area.',0,0,1);
I[23][3][4]=new Array('To provide important support services allowing scientists to study undersea ecology and oceanography.','Sorry.  While U.S. nuclear submarines have done this sort of work, it is not their primary mission.',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('Polaris','Right!  Launched in 1959, the USS George Washington was the first ship in the Polaris class.  In all, 41 Polaris submarines were built.',1,100,1);
I[24][3][1]=new Array('Trident','Sorry.  The Trident is the latest class of U.S. Navy FBM\'s.',0,0,1);
I[24][3][2]=new Array('Poseidon ','Sorry.  Poseidon was the second class of U.S. Navy FBM\'s.',0,0,1);
I[24][3][3]=new Array('Virginia','Nope.  The Virginia class is the latest class of U.S. nuclear attack submarines, not Fleet Ballistic Missile submarines.',0,0,1);
I[24][3][4]=new Array('Los Angles','Nope.  The Los Angles class of submarines is an attack submarine type, not a ballistic missile type.',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('Poseidon ','Right.  With twice the range of the Polaris missile, this missile/submarine combination was a major step forward for the U.S. during the Cold War.',1,100,1);
I[25][3][1]=new Array('Polaris','Sorry.  Polaris missiles were carried on the earlier Polaris class of submarines, not the Lafayette-class SSBNs which came later.',0,0,1);
I[25][3][2]=new Array('Trident','Sorry.  The Trident missile is the latest missile type and was not developed at the time of the Lafayette-class SSBNs.',0,0,1);
I[25][3][3]=new Array('Tomahawk','Nope.  The Tomahawk is a modern surface to surface missile that was not developed until much later.',0,0,1);
I[25][3][4]=new Array('Harpoon','Nope.  A modern anti-ship missile, the harpoon was not yet developed 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('Sonar','Right.  Sonar, for SOund Navigation And Ranging, was a development of the Second World War.',1,100,1);
I[26][3][1]=new Array('The Directional Hydrophone','Sorry.  This critical development during World War I gave surface ships working together the ability to locate and triangulate the position of an enemy sub while it was submerged.',0,0,1);
I[26][3][2]=new Array('The Convoy ','Nope.  Submarines would avoid warships and go after merchant shipping when they could.  By surrounding merchants with warships, particularly destroyers, it forced the submarines to have to get past these escorts and many subs perished trying.',0,0,1);
I[26][3][3]=new Array('The Depth Charge','Sorry.  The development of the depth charge was critical to the success of antisubmarine warfare because it gave surface ships a weapon to attack submarines when they had submerged.',0,0,1);
I[26][3][4]=new Array('All of the things listed were developed during World War I','Nope.  One of them came later, during World War II.',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('They are all devices currently in use by the Navy to detect and locate submarines.','Right!  In addition to the items listed, infrared detection equipment can be used as a means of electronic detection of the heat emitted from submarines.',1,100,1);
I[27][3][1]=new Array('MAD gear','Sorry.  Standing for Magnetic Anomaly Detection, this equipment detects variations in the Earth&#x2019;s magnetic lines of force created by a submarine',0,0,1);
I[27][3][2]=new Array('Sonobuoys','Nope.  Sonobuoys, most often dropped from aircraft or helicopters, contain a hydrophone and radio transmitter to help locate submarines by transmission of a submarine&#x2019;s noises.',0,0,1);
I[27][3][3]=new Array('Dipping sonar','Sorry.  Dipping sonar is a device that is lowered into the sea from a hovering helicopter to echo-range the location of a submarine.',0,0,1);
I[27][3][4]=new Array('Towed arrays of sensors ','Nope.  This consists of numerous underwater sensors on a platform streamed behind warships to detect low-level sound emitted from submarines at long range.',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('These are all principal objectives of an amphibious operation.','Right.  Each of these can be an important objective of an amphibious operation.  A country may elect to do an amphibious operation for many reasons, but the objectives they have for that landing will fall within one of the four principal objectives listed here.',1,100,1);
I[28][3][1]=new Array('To capture territory from which a land campaign can be launched and supported.','Sorry.  This is the primary objective of most amphibious operations.  To be able to defeat Hitler\'s forces in Europe, for example, we needed to make the landings at Normandy and bring our troops ashore.',0,0,1);
I[28][3][2]=new Array('To capture a land area from which air operations can be launched and supported.','Nope.  This was one of the primary objectives of many of the amphibious operations during World War II, as air and naval support for follow-on operations depended on staging and resupply areas being taken prior to the landing they were to support.',0,0,1);
I[28][3][3]=new Array('To prevent enemy use of selected territory or facilities.','Sorry.  As a wartime campaign moves ahead, places of little or no importance to either side at the start of the war may become important.  When that occurs it is important to seize these places before the enemy has the chance to.',0,0,1);
I[28][3][4]=new Array('To destroy enemy facilities, interrupt their communications, and cause them to spread their forces to try to respond to amphibious raids.','Nope.  While they don\'t get the same amount of publicity as major amphibious landings, amphibious raids are an important part of an overall amphibious campaign.',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('Space Systems','Right!  Spaced-based satellites act as communications relays, navigation aids (GPS), and highly sensitive sensors that can provide intelligence information and/or weather pattern information to our ships at sea around the world.',1,100,1);
I[29][3][1]=new Array('Fiber-Optic Networks','Sorry.  Fiber-Optic Networks are modern enough, but they rely on hard lines, which don\'t work with ships at sea.',0,0,1);
I[29][3][2]=new Array('Land Lines','Nope.  It would be hard to string land lines long enough to reach our ships at sea!',0,0,1);
I[29][3][3]=new Array('Short Wave and High Frequency Communications','Sorry.  For some time in the early to mid 20th century this was the primary means of long-range communications for the U.S. Navy, but not any longer.',0,0,1);
I[29][3][4]=new Array('Signal Flags','Nope.  The Navy hasn\'t had to rely on this form of communications for over a hundred years, and it was only a communications system, not a navigation aid or weather forecasting technology.',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('Periodic, short-duration and continuous, long-dwell','Right!  The continuous type are used over areas of the world we know our forces need to be aware of, and the periodic types are available to provide additional coverage to these areas or to cover areas that were not foreseen as important prior to a particular operation.',1,100,1);
I[30][3][1]=new Array('Periodic, short-duration','Sorry.  This type is used, but some parts of the earth require continuous coverage to ensure that our forces are not surprised.',0,0,1);
I[30][3][2]=new Array('Continuous, long-dwell','Sorry.  This type is used, but there aren\'t enough of them to provide a continuous picture of the entire earth at any given time.',0,0,1);
I[30][3][3]=new Array('Single-use, "Fire & Forget"','Nope.  There are no such type of satellite anymore.',0,0,1);
I[30][3][4]=new Array('The U.S. Navy does not use satellites for intelligence-gathering.','Nope.  These are important assets heavily used by our Navy.  They can provide sustained, covert surveillance of the battlespace to allow timely indications and warning of hostile actions. They can detect, classify, and identify high-interest targets and can help in assessing battle damage. ',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
		}
	}
}



function CheckMCAnswer(QNum, ANum, Btn){
//bail if question doesn't exist or exercise finished
	if ((State[QNum].length < 1)||(Finished == true)){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();
			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();
			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 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][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][0] >= 1){
					CFT++;
				}
			}
			FB += '<br />' + CorrectFirstTime + ' ' + CFT + '/' + State.length;
		}
		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][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);
	}
}










//-->

//]]>


