

//<![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');
	ShowElements(false, 'object');
	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');
	ShowElements(true, 'object');
	if (Finished == true){
		Finish();
	}
}


//GENERAL UTILITY FUNCTIONS AND VARIABLES

//PAGE DIMENSION FUNCTIONS
function PageDim(){
//Get the page width and height
	this.W = 600;
	this.H = 400;
	this.W = document.getElementsByTagName('body')[0].clientWidth;
	this.H = document.getElementsByTagName('body')[0].clientHeight;
}

var pg = null;

function GetPageXY(El) {
	var XY = {x: 0, y: 0};
	while(El){
		XY.x += El.offsetLeft;
		XY.y += El.offsetTop;
		El = El.offsetParent;
	}
	return XY;
}

function GetScrollTop(){
	if (document.documentElement && document.documentElement.scrollTop){
		return document.documentElement.scrollTop;
	}
	else{
		if (document.body){
 			return document.body.scrollTop;
		}
		else{
			return window.pageYOffset;
		}
	}
}

function GetViewportHeight(){
	if (window.innerHeight){
		return window.innerHeight;
	}
	else{
		return document.getElementsByTagName('body')[0].clientHeight;
	}
}

function TopSettingWithScrollOffset(TopPercent){
	var T = Math.floor(GetViewportHeight() * (TopPercent/100));
	return GetScrollTop() + T; 
}

//CODE FOR AVOIDING LOSS OF DATA WHEN BACKSPACE KEY INVOKES history.back()
var InTextBox = false;

function SuppressBackspace(e){ 
	if (InTextBox == true){return;}
	if (C.ie) {
		thisKey = window.event.keyCode;
	}
	else {
		thisKey = e.keyCode;
	}

	var Suppress = false;

	if (thisKey == 8) {
		Suppress = true;
	}

	if (Suppress == true){
		if (C.ie){
			window.event.returnValue = false;	
			window.event.cancelBubble = true;
		}
		else{
			e.preventDefault();
		}
	}
}

if (C.ie){
	document.attachEvent('onkeydown',SuppressBackspace);
	window.attachEvent('onkeydown',SuppressBackspace);
}
else{
	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) {
	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].id.indexOf('Gap') > -1)){
			NList[i].value = '';
		}
		if (NList[i].id.indexOf('Chk') > -1){
			NList[i].checked = '';
		}
	}
}

//EXTENSION TO ARRAY OBJECT
function Array_IndexOf(Input){
	var Result = -1;
	for (var i=0; i<this.length; i++){
		if (this[i] == Input){
			Result = i;
		}
	}
	return Result;
}
Array.prototype.indexOf = Array_IndexOf;

//IE HAS RENDERING BUG WITH BOTTOM NAVBAR
function RemoveBottomNavBarForIE(){
	if ((C.ie)&&(document.getElementById('Reading') != null)){
		if (document.getElementById('BottomNavBar') != null){
			document.getElementById('TheBody').removeChild(document.getElementById('BottomNavBar'));
		}
	}
}




//HOTPOTNET-RELATED CODE

var HPNStartTime = (new Date()).getTime();
var SubmissionTimeout = 30000;
var Detail = ''; //Global that is used to submit tracking data

function Finish(){
//If there's a form, fill it out and submit it
	if (document.store != null){
		Frm = document.store;
		Frm.starttime.value = HPNStartTime;
		Frm.endtime.value = (new Date()).getTime();
		Frm.mark.value = Score;
		Frm.detail.value = Detail;
		Frm.submit();
	}
}



//JQUIZ CORE JAVASCRIPT CODE

var CurrQNum = 0;
var CorrectIndicator = ':-)';
var IncorrectIndicator = 'X';
var YourScoreIs = 'Your score is ';
var ContinuousScoring = true;
var CorrectFirstTime = 'Questions answered correctly first time: ';
var ShowCorrectFirstTime = false;
var ShuffleQs = true;
var ShuffleAs = true;
var DefaultRight = 'Correct!';
var DefaultWrong = 'Sorry! Try again.';
var QsToShow = 10;
var Score = 0;
var Finished = false;
var Qs = null;
var QArray = new Array();
var ShowingAllQuestions = false;
var ShowAllQuestionsCaption = 'Show all questions';
var ShowOneByOneCaption = 'Show questions one by one';
var State = new Array();
var Feedback = '';
var TimeOver = false;
var strInstructions = '';

//The following variable can be used to add a message explaining that
//the question is finished, so no further marking will take place.
var strQuestionFinished = '';

function CompleteEmptyFeedback(){
	var QNum, ANum;
	for (QNum=0; QNum<I.length; QNum++){
//Only do this if not multi-select
		if (I[QNum][2] != '3'){
  		for (ANum = 0; ANum<I[QNum][3].length; ANum++){
  			if (I[QNum][3][ANum][1].length < 1){
  				if (I[QNum][3][ANum][2] > 0){
  					I[QNum][3][ANum][1] = DefaultRight;
  				}
  				else{
  					I[QNum][3][ANum][1] = DefaultWrong;
  				}
  			}
  		}
		}
	}
}

function SetUpQuestions(){
	var AList = new Array(); 
	var QList = new Array();
	var i, j;
	Qs = document.getElementById('Questions');
	while (Qs.getElementsByTagName('li').length > 0){
		QList.push(Qs.removeChild(Qs.getElementsByTagName('li')[0]));
	}
	var DumpItem = 0;
	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('Public Affairs','Correct.  While there will be a Public Affairs Officers or assistants assigned aboard ship, they work for the Executive Officer as executive assistants and are not a separate department.',1,100,1);
I[0][3][1]=new Array('Operations','Sorry.  The Operations Department is concerned with the ship\'s radar and electronic warfare, aircraft assigned to the ship, collection and dissemination of intelligence as well as the planning and execution of operations plans and training schedules.',0,0,1);
I[0][3][2]=new Array('Combat Systems','Sorry.  The Combat Systems Department is concerned with the operation and maintenance of the ship\'s armament and fire-control equipment.',0,0,1);
I[0][3][3]=new Array('Engineering','Nope.  This basic shipboard department is concerned with the operation, care and maintenance of all propulsion and auxiliary machinery, electrical-power generators, switchboards, and wiring.',0,0,1);
I[0][3][4]=new Array('Supply','Nope.  The Supply Department is the basic shipboard department that runs the general mess, snack bar, ship\'s stores as well as the ship\'s laundry, barber and tailor shop.',0,0,1);
I[1]=new Array();I[1][0]=100;
I[1][1]='';
I[1][2]='0';
I[1][3]=new Array();
I[1][3][0]=new Array('The Executive Officer','Right!  Orders issued by the XO have the same force as if issued by the CO.',1,100,1);
I[1][3][1]=new Array('The Commanding Officer','Sorry.  While the CO is ultimately responsible for everything that goes on onboard the ship, he or she has another officer that directly works with the department heads.',0,0,1);
I[1][3][2]=new Array('The Operations Officer','Sorry.  The Operations Officer is one of the ship\'s department head.  Although he or she would work closely with the other department heads in the conduct of training and drills, it is not their responsibility to coordinate all aspects of this training.',0,0,1);
I[1][3][3]=new Array('The Navigator','Nope.  The Navigator\'s primary responsibilities deal with maintaining the ship\'s plot and keeping the Co and Xo advised of the ship\'s location at all times.',0,0,1);
I[1][3][4]=new Array('The Damage Control Assistant','Nope.  The DCA does work closely with the ship\'s department heads to coordinate and conduct damage control training, but this is just for damage control items, not overall combat readiness.',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 bridge','Correct.  On the bridge the XO is in a position to closely follow combat operations and quickly assume control of the ship in cases where the CO is killed or injured.',1,100,1);
I[2][3][1]=new Array('In the Combat Information Center (CIC)','Sorry.  This is normally the location of the Commanding Officer during combat operations, not the Executive Officer.',0,0,1);
I[2][3][2]=new Array('On the deck of the ship','Nope.  In modern times, personnel are not needed on the ship\'s deck during combat operations.',0,0,1);
I[2][3][3]=new Array('In the main machinery spaces','Sorry.  The XO needs to be located in a position where he or she can take over control of the ship in case the CO is injured or killed.',0,0,1);
I[2][3][4]=new Array('In the weapons department spaces','Nope.  The XO needs to be located in a position where he or she can take over control of the ship in case the CO is injured or killed.',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 Navigator','Right.  In addition to this the navigator is responsible for the care and maintenance of all navigation equipment on the ship as well as for the bridge, pilot house and chart room.',1,100,1);
I[3][3][1]=new Array('The Executive Officer','Sorry.  While this could be a responsibility of the XO in cases where the ship is small, it is generally not the case.',0,0,1);
I[3][3][2]=new Array('The Reactor Officer','Nope.  The Reactor Officer is in charge of the nuclear reactor onboard nuclear-powered ships.',0,0,1);
I[3][3][3]=new Array('The First Lieutenant','Nope.  The First Lieutenant is in charge of the Deck Division and is not involved with navigation.',0,0,1);
I[3][3][4]=new Array('The Senior Watch Officer (SWO)','Sorry.  The SWO is responsible for the assignment of all deck watches both underway and in port.',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('The Command Master Chief','Correct!  The Command Master Chief does not work for the XO and has direct access to the CO on matters that affect the welfare, morale and well-being of the enlisted crew.',1,100,1);
I[4][3][1]=new Array('The Personnel Officer','Sorry.  The personnel officer is an executive assistant and is responsible to assign enlisted personnel according to the ship\'s bills.  He or she is also responsible for the enlisted service records.',0,0,1);
I[4][3][2]=new Array('The Chaplain','Sorry.  The chaplain is an executive assistant and his or her primary responsibility is to meet the spiritual needs of ship\'s personnel and to help with personal counseling.',0,0,1);
I[4][3][3]=new Array('The Legal Officer','Nope.  The legal officer is an executive assistant and often serves as an investigator for the XO on disciplinary charges.',0,0,1);
I[4][3][4]=new Array('The Special Services Officer','Nope.  This officer works directly for the XO and organizes all the welfare, recreational and athletic activities of the ship.',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('The Chief Master-At-Arms','Right!  He or she is also in charge of supervising most working parties and is responsible for the security and welfare of any prisoners in the ship\'s brig.',1,100,1);
I[5][3][1]=new Array('The Legal Officer','Sorry.  While the legal officer could be responsible for the enforcing regulations in a courtroom, the maintenance of good order and discipline in the ship\'s spaces on a daily basis is the responsibility of another one of the personnel listed.',0,0,1);
I[5][3][2]=new Array('The Senior Watch Officer','Sorry.  The SWO is responsible for the assignment of all deck watches both underway and in port.',0,0,1);
I[5][3][3]=new Array('The Combat Cargo Officer','Nope.  This officer is normally found on amphibious ships and is in charge of the loading and unloading of troops, billeting and messing of troops, and the loading, stowage, and unloading of cargo.',0,0,1);
I[5][3][4]=new Array('The First Lieutenant','Nope.  The First Lieutenant is in charge of the Deck Division and is not directly involved with the enforcement of rules and the maintenance of good order and discipline.',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('Navigation','Correct.  The Navigator is the officer directly responsible to the CO for the safe navigation and position plotting for the ship.  He or she is not considered to be a department head nor is there an actual Navigation Department.',1,100,1);
I[6][3][1]=new Array('Operations','Sorry.  The Operations Department is the major ship department concerned with the ship\'s radar and electronic warfare, aircraft assigned to the ship, collection and dissemination of intelligence as well as the planning and execution of operations plans and training schedules.',0,0,1);
I[6][3][2]=new Array('Engineering','Nope.  This major shipboard department is concerned with the operation, care and maintenance of all propulsion and auxiliary machinery, electrical-power generators, switchboards, and wiring.',0,0,1);
I[6][3][3]=new Array('Supply','Nope.  The Supply Department is the major shipboard department that runs the general mess, snack bar, ship\'s stores as well as the ship\'s laundry, barber and tailor shop.',0,0,1);
I[6][3][4]=new Array('Air','Sorry.  While not all ships have an Air Department, on ships that do it is considered to be a major department.',0,0,1);
I[7]=new Array();I[7][0]=100;
I[7][1]='';
I[7][2]='0';
I[7][3]=new Array();
I[7][3][0]=new Array('The Commanding Officer','Correct.  This allows the CO to have direct access to precise knowledge as to matters of concern among the enlisted personnel.',1,100,1);
I[7][3][1]=new Array('The Executive Officer','Sorry.  The CMC does not work for or primarily advise the XO.',0,0,1);
I[7][3][2]=new Array('The Department Heads','Sorry.  While the CMC will work closely with the Department Heads and the senior enlisted CPO within that Department, he is not that Department Head\'s principal enlisted adviser.',0,0,1);
I[7][3][3]=new Array('The Chief of Naval Operations','Nope.  The Master Chief Petty Officer of the Navy (MCPON) is the principal enlisted adviser to the CNO.',0,0,1);
I[7][3][4]=new Array('The Officer of the Deck','Nope.  The CMC does not deal directly with the Officer who is standing duty as the Officer of the Deck.',0,0,1);
I[8]=new Array();I[8][0]=100;
I[8][1]='';
I[8][2]='0';
I[8][3]=new Array();
I[8][3][0]=new Array('The Supply Officer','Right!  Supply Corps Officers are not Line Officers.  Normally a Supply Corps Officer would run the Supply Department.',1,100,1);
I[8][3][1]=new Array('The Operations Officer','Sorry.  The Operations Officer is always a Line Officer and on aircraft carriers will usually be a post-command Naval Aviator or Naval Flight Officer.',0,0,1);
I[8][3][2]=new Array('The Air Officer','Sorry.  The Air Officer is always a Line Officer and on aircraft carriers will usually be a post-command Naval Aviator or Naval Flight Officer.',0,0,1);
I[8][3][3]=new Array('The Combat Systems Officer','Nope.  The Combat Systems Officer runs the Combat Systems Department and will always be a Line Officer.',0,0,1);
I[8][3][4]=new Array('The Weapons Officer','Nope.  The Weapons Officer is in charge of the Weapons Department on board smaller ships and is normally a Line Officer.',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('Line Officers are eligible for command in the event of the loss of his or her superior officer.','Right!  Line Officers have been trained in combat operations and so it makes sense that they assume command when superiors are disabled.',1,100,1);
I[9][3][1]=new Array('Line Officers are Officers who have "Crossed the Line" (Sailed over the equator)','Nope.  Crossing the Line (what sailing over the equator is called) is not the same thing as being a Line Officer.',0,0,1);
I[9][3][2]=new Array('Line Officers have "Lineal Numbers" attached to their ranks to indicate their relative seniority.','Sorry.  All Officers have lineal numbers which give them their relative seniority when compared against Officers of the same rank.',0,0,1);
I[9][3][3]=new Array('There is no special designation of a "Line Officer".','Nope.  There certainly is such a designation, and it is an important one.',0,0,1);
I[9][3][4]=new Array('Line Officers are Officers in line for early promotion.','Sorry.  Promotion eligibility does not play in to the designation of "Line Officer".',0,0,1);
I[10]=new Array();I[10][0]=100;
I[10][1]='';
I[10][2]='0';
I[10][3]=new Array();
I[10][3][0]=new Array('The Operations Officer','Correct!  He or she is also responsible for the operation of the ship and assigned airborne aircraft.',1,100,1);
I[10][3][1]=new Array('The Communications Officer','Sorry.  The Communications Officer is not a Department Head, but instead a Division Officer within the Operations Department.  ',0,0,1);
I[10][3][2]=new Array('The Combat Systems Officer','Sorry.  Don\'t let the term "combat" fool you here.  The Combat Systems Officer is responsible for the operation and maintenance of the ship\'s armament and fire-control equipment.',0,0,1);
I[10][3][3]=new Array('The Weapons Officer','Nope.  Weapons Officers serve on smaller ships in place of the Combat Systems Officer, but the duties are the same.  They are responsible for the operation and maintenance of the ship\'s armament and fire-control equipment.',0,0,1);
I[10][3][4]=new Array('The Engineer Officer','Nope.  The Engineering Officer is concerned with the ship\'s power plant, not combat information.',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('The Operations Officer','Right!  Seamanship evolutions involve operating the ship through various maneuvers.  These would have to be planned and coordinated through the Operations Department.',1,100,1);
I[11][3][1]=new Array('The First Lieutenant','Sorry.  The First Lieutenant runs the deck department and so might be interested in such evolutions, but he or she would not be responsible for the planning of such evolutions.',0,0,1);
I[11][3][2]=new Array('The Engineer Officer','Nope.  The Engineering Officer is concerned with the ship\'s power plant, not seamanship evolutions.',0,0,1);
I[11][3][3]=new Array('The Weapons Officer','Nope.  Weapons Officers serve on smaller ships in place of the Combat Systems Officer, but the duties are the same.  They are responsible for the operation and maintenance of the ship\'s armament and fire-control equipment.',0,0,1);
I[11][3][4]=new Array('The Navigator','Sorry.  The Navigator would be interested in such evolutions but he or she is not a Department Head.',0,0,1);
I[12]=new Array();I[12][0]=100;
I[12][1]='';
I[12][2]='0';
I[12][3]=new Array();
I[12][3][0]=new Array('The Communications Officer','Correct.  This is a very important part of what a Communications Officer does, since most of our vital  communications are encrypted.',1,100,1);
I[12][3][1]=new Array('The Executive Officer','Sorry.  The XO is concerned with all correspondence, and much of this is encrypted.  He or she is not, however, directly involved in the supervision of such operations.',0,0,1);
I[12][3][2]=new Array('The Commanding Officer','Nope.  The CO cannot do everything by himself or herself.  This is a function that is delegated down to one of the Divisions within one of the Departments.',0,0,1);
I[12][3][3]=new Array('The Operations Officer','Sorry.  While it does generally occur within the Operations Department on smaller ships, the task of supervision of these operations is delegated to another Officer.',0,0,1);
I[12][3][4]=new Array('The Combat Systems Officer','Nope.  While the CSO would certainly use cryptographic materials as a part of his or her job, they would not supervise these type of operations.',0,0,1);
I[13]=new Array();I[13][0]=100;
I[13][1]='';
I[13][2]='0';
I[13][3]=new Array();
I[13][3][0]=new Array('The Deck Department','Right.  Deck Departments are led by the First Lieutenant, who is assisted by a weapons or gunnery officer.',1,100,1);
I[13][3][1]=new Array('The Weapons Department','Sorry.  Older ships may have a Weapons Department instead of a Combat Systems Department, but not newer ships.',0,0,1);
I[13][3][2]=new Array('The Operations Department','Sorry.  The Operations Department is a part of every ship, even those with Combat Systems Department.',0,0,1);
I[13][3][3]=new Array('The Supply Department','Nope.  The Supply Department is a completely separate Department from the Combat Systems Department.',0,0,1);
I[13][3][4]=new Array('The Air Department','Nope.  The Air Department is always called the Air Department.  There will be an Air Department on any ship that has manned aircraft assigned.',0,0,1);
I[14]=new Array();I[14][0]=100;
I[14][1]='';
I[14][2]='0';
I[14][3]=new Array();
I[14][3][0]=new Array('The Combat Systems Department','Correct!  In ships that have a Deck Department, such as amphibious ships, the Aviation Unit would be assigned there.  In either case it would be called the Aviation Division.',1,100,1);
I[14][3][1]=new Array('The Operations Department','Sorry.  While this might seem to make sense due to the fact that aviation units are operational in nature and are normally concerned with air assets when they are aloft around the ship, it isn\'t the case here.  Aviation Units are normally assigned to another one of the Departments.',0,0,1);
I[14][3][2]=new Array('The Supply Officer','Nope.  The Supply Department is concerned with such things as keeping supplies of food and equipment stocked on the ship.  It wouldn\'t be the logical choice to place an aviation unit.',0,0,1);
I[14][3][3]=new Array('The Engineering Department','Nope.  The Engineering Department is concerned with the power plant of the ship and not with aviation assets or maintenance.',0,0,1);
I[14][3][4]=new Array('The Weapons Department','Sorry.  Weapons Departments only exist in smaller, older ships which are incapable of handling manned aircraft.',0,0,1);
I[15]=new Array();I[15][0]=100;
I[15][1]='';
I[15][2]='0';
I[15][3]=new Array();
I[15][3][0]=new Array('The First Lieutenant','Right!  He or she is also responsible to see that all gear about the weather decks is properly secured.',1,100,1);
I[15][3][1]=new Array('The Engineer Officer','Nope.  The Engineering Officer is concerned with the ship\'s power plant, not survival equipment.',0,0,1);
I[15][3][2]=new Array('The Weapons Officer','Nope.  Not even on the older ships where you would ',0,0,1);
I[15][3][3]=new Array('The Operations Officer','Sorry.  While it might seem like this would make sense given the fact that the Operations Officer is involved in all aspects of ship\'s operations, he or she is not the one that looks out for this equipment.',0,0,1);
I[15][3][4]=new Array('The Navigator','Sorry.  This isn\'t one of the Navigator\'s responsibilities.',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('Engineering','Correct.  Usually, the Damage Control Officer is the Ship\'s Engineer Officer.',1,100,1);
I[16][3][1]=new Array('Operations','Sorry.  Damage Control does not fall within the primary responsibilities  of the Operations Department.',0,0,1);
I[16][3][2]=new Array('First Lieutenant','Sorry.  The First Lieutenant Department is in charge of deck evolutions and repair and care of the ship\'s exterior.',0,0,1);
I[16][3][3]=new Array('Communications','Nope.  While Communications Department personnel may be an active part of Damage Control Repair Parties, the Divisions within this Department are not the ones that are responsible for Damage Control itself.',0,0,1);
I[16][3][4]=new Array('Supply','Nope.  Damage Control is not the primary responsibility of the Supply Department.',0,0,1);
I[17]=new Array();I[17][0]=100;
I[17][1]='';
I[17][2]='0';
I[17][3]=new Array();
I[17][3][0]=new Array('The Air Department','Right!  The Air Officer is in charge of all aspects of launching and landing aircraft and with their handling on deck.',1,100,1);
I[17][3][1]=new Array('The First Lieutenant Department','Sorry.  While the First Lieutenant Department is in charge of gear on the exposed decks, it does not work on or maintain the catapults.  On carriers, the First Lieutenant organization is actually a Division under the Combat Systems Department.',0,0,1);
I[17][3][2]=new Array('The Operations Department','Nope.  Operations is closely associated with the aircraft after they get airborne and away from the ship, but that Department is not involved in the steps required to get the aircraft off the deck.',0,0,1);
I[17][3][3]=new Array('The Combat Systems Department','Nope.  Catapults launch aircraft but they are not considered a weapons delivery system that falls under the control of the Combat Systems Department.',0,0,1);
I[17][3][4]=new Array('The Engineering Department','Sorry.  While you might thing there is a lot of engineering things going on with the catapults (and you\'d be right!), it isn\'t the Engineering Department that cares for and maintains these pieces of equipment.',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('Aviation Officer','Correct.  This Aviation Officer is generally a Lieutenant Commander.',1,100,1);
I[18][3][1]=new Array('Air Wing Commander','Nope.  The Air Wing Commander or CAG (Carrier AirwinG) Commander, is in charge of all of the squadrons embarked onboard an aircraft carrier.',0,0,1);
I[18][3][2]=new Array('Squadron Commander','Sorry.  Generally these detachments do not include the Squadron Commanding Officer, but instead use an OIC (Officer in Charge) to run the detachment.;',0,0,1);
I[18][3][3]=new Array('Air Officer','Sorry.  The Air Officer is the Department Head of the Air Department.  Nonaviation-type ships do not have Air Departments.',0,0,1);
I[18][3][4]=new Array('Air Boss','Nope.  This is the common nickname given to the Air Officer on aircraft carriers.',0,0,1);
I[19]=new Array();I[19][0]=100;
I[19][1]='';
I[19][2]='0';
I[19][3]=new Array();
I[19][3][0]=new Array('The Supply Officer','Right.  He or she additionally operates the ship\'s store and snack bar as well as having responsibility for the handling of all stores, food and spare parts.',1,100,1);
I[19][3][1]=new Array('The Operations Officer','Nope.  The Operations Officer is responsible for operations of the ship and assigned airborne aircraft.',0,0,1);
I[19][3][2]=new Array('The Special Services Officer','Sorry.  The Special Services Officer is the officer who organizes all the welfare, recreational, and athletic activities of the ship.',0,0,1);
I[19][3][3]=new Array('The Public Affairs Officer','Nope.  The Public Affairs Officer is the executive assistant who keeps the CO and XO informed on public relations matters and prepares articles and photography for release to the news media.',0,0,1);
I[19][3][4]=new Array('The Medical Officer','Sorry.  The Medical Officer is responsible for the health of personnel of the command and advises the CO in all matters of health.',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('Divisions','Correct!  These Divisions are further subdivided into sections or watches.  The Division is the basic unit of personnel on board ship.',1,100,1);
I[20][3][1]=new Array('Branches','Sorry.  While the term "Branches" is used to describe some small maintenance sub groups, that is not the name used for the major subunit of a ship Department.',0,0,1);
I[20][3][2]=new Array('Sections','Nope.  In Naval Aviation terminology, a section is two aircraft flying together.',0,0,1);
I[20][3][3]=new Array('Units','Sorry.  Individual Squadrons or Ships are sometimes referred to as Units, but this is not a subsection of Departments.',0,0,1);
I[20][3][4]=new Array('Quarters','Nope.  "Quarter" is a nautical term used for direction.  It indicates something aft of the beam of the ship.',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('A Division','Right!  The number of divisions in a department varies depending upon the size and function of the ship.',1,100,1);
I[21][3][1]=new Array('A Watch','Sorry.  While Watches do exist at all times on board ship, a watch is too small a grouping.  The basic unit of personnel is larger.',0,0,1);
I[21][3][2]=new Array('A Section','Sorry.  While Sections of personnel do exist, a section is too small a grouping.  The basic unit of personnel is larger.',0,0,1);
I[21][3][3]=new Array('A Fire Party','Nope.  A Fire Party is simply a group of personnel designated to be on a firefighting watch for a specified period of time.',0,0,1);
I[21][3][4]=new Array('An Element','Nope.  There is no such term used to describe groups of personnel.',0,0,1);
I[22]=new Array();I[22][0]=100;
I[22][1]='';
I[22][2]='0';
I[22][3]=new Array();
I[22][3][0]=new Array('The Ship\'s Organization and Regulations Manual','Correct.  It contains the administrative, operational, and emergency bills necessary to handle almost anything that could happen.',1,100,1);
I[22][3][1]=new Array('The Battle Organization Manual','Sorry.  This important document sets out the ship\'s organization for battle conditions, not for normal responsibilities.',0,0,1);
I[22][3][2]=new Array('Navy Regulations','Nope.  Navy Regulations provide general guidance, but specific details need to be published for each Department and Division.',0,0,1);
I[22][3][3]=new Array('The Watch, Quarter, and Station Bill','Sorry.  While each Division will have one of these Bills published, it is only for use at the Division level and not the Department level.  It also would not get in to the level of detail necessary for Divisions and Department normal operations.',0,0,1);
I[22][3][4]=new Array('The Plan of the Day','Nope.  While an important document and required reading for all hands, this is not the way that the normal responsibilities of these organizations are published.',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('The Battle Organization Manual','Right!  This book has four chapters showing battle organization, conditions of readiness, battle bill, and interior communications systems.',1,100,1);
I[23][3][1]=new Array('The Ship\'s Organization and Regulations Manual','Sorry.  It contains the administrative, operational, and emergency bills necessary to handle almost anything that could happen, but for routine operations, not combat operations.,',0,0,1);
I[23][3][2]=new Array('Navy Regulations','Nope.  Navy Regulations provide general guidance, but specific combat instructions and details need to be published for each Department and Division.',0,0,1);
I[23][3][3]=new Array('The Watch, Quarter, and Station Bill','Sorry.  While each Division will have one of these Bills published, it is only for use at the Division level and not the Department level.  It also would not get in to the level of detail necessary for Divisions and Department combat operations.',0,0,1);
I[23][3][4]=new Array('The Plan of the Day','While an important document and required reading for all hands, this is not the tool that the CO uses to prepare the ship for combat.',0,0,1);


function StartUp(){
	RemoveBottomNavBarForIE();

//If there's only one question, no need for question navigation controls
	if (QsToShow < 2){
		document.getElementById('QNav').style.display = 'none';
	}
	
//Stash the instructions so they can be redisplayed
	strInstructions = document.getElementById('InstructionsDiv').innerHTML;
	

	

	
	CompleteEmptyFeedback();

	SetUpQuestions();
	ClearTextBoxes();
	CreateStatusArray();
	

	
//Check search string for q parameter
	if (document.location.search.length > 0){
		if (ShuffleQs == false){
			var JumpTo = parseInt(document.location.search.substring(1,document.location.search.length))-1;
			if (JumpTo <= QsToShow){
				ChangeQ(JumpTo);
			}
		}
	}
}

function ShowHideQuestions(){
	FuncBtnOut(document.getElementById('ShowMethodButton'));
	document.getElementById('ShowMethodButton').style.display = 'none';
	if (ShowingAllQuestions == false){
		for (var i=0; i<QArray.length; i++){
				QArray[i].style.display = '';
			}
		document.getElementById('Questions').style.listStyleType = 'decimal';
		document.getElementById('OneByOneReadout').style.display = 'none';
		document.getElementById('ShowMethodButton').innerHTML = ShowOneByOneCaption;
		ShowingAllQuestions = true;
	}
	else{
		for (var i=0; i<QArray.length; i++){
				if (i != CurrQNum){
					QArray[i].style.display = 'none';
				}
			}
		document.getElementById('Questions').style.listStyleType = 'none';
		document.getElementById('OneByOneReadout').style.display = '';
		document.getElementById('ShowMethodButton').innerHTML = ShowAllQuestionsCaption;
		ShowingAllQuestions = false;	
	}
	document.getElementById('ShowMethodButton').style.display = 'inline';
}

function CreateStatusArray(){
	var QNum, ANum;
//For each item in the item array
	for (QNum=0; QNum<I.length; QNum++){
//Check if the question still exists (hasn't been nuked by showing a random selection)
		if (document.getElementById('Q_' + QNum) != null){
			State[QNum] = new Array();
			State[QNum][0] = -1; //Score for this q; -1 shows question not done yet
			State[QNum][1] = new Array(); //answers
			for (ANum = 0; ANum<I[QNum][3].length; ANum++){
				State[QNum][1][ANum] = 0; //answer not chosen yet; when chosen, will store its position in the series of choices
			}
			State[QNum][2] = 0; //tries at this q so far
			State[QNum][3] = 0; //incrementing percent-correct values of selected answers
			State[QNum][4] = 0; //penalties incurred for hints
			State[QNum][5] = ''; //Sequence of answers chosen by number
		}
		else{
			State[QNum] = null;
		}
	}
}



function CheckMCAnswer(QNum, ANum, Btn){
//if question doesn't exist, bail
	if (State[QNum].length < 1){return;}
	
//Get the feedback
	Feedback = I[QNum][3][ANum][1];
	
//Now show feedback and bail if question already complete
	if (State[QNum][0] > -1){
//Add an extra message explaining that the question
// is finished if defined by the user
		if (strQuestionFinished.length > 0){Feedback += '<br />' + strQuestionFinished;}
//Show the feedback
		ShowMessage(Feedback);
		return;
	}
	
//Hide the button while processing
	Btn.style.display = 'none';

//Increment the number of tries
	State[QNum][2]++;
	
//Add the percent-correct value of this answer
	State[QNum][3] += I[QNum][3][ANum][3];
	
//Store the try number in the answer part of the State array, for tracking purposes
	State[QNum][1][ANum] = State[QNum][2];
	State[QNum][5] += String.fromCharCode(65+ANum) + ',';
	
//Should this answer be accepted as correct?
	if (I[QNum][3][ANum][2] < 1){
//It's wrong

//Mark the answer
		Btn.innerHTML = IncorrectIndicator;
		
//Remove any previous score unless exercise is finished (6.0.3.8+)
		if (Finished == false){
			WriteToInstructions(strInstructions);
		}	
		
//Check whether this leaves just one MC answer unselected, in which case the Q is terminated
		var RemainingAnswer = FinalAnswer(QNum);
		if (RemainingAnswer > -1){
//Behave as if the last answer had been selected, but give no credit for it
//Increment the number of tries
			State[QNum][2]++;		
		
//Calculate the score for this question
			CalculateMCQuestionScore(QNum);

//Get the overall score and add it to the feedback
			CalculateOverallScore();
			if ((ContinuousScoring == true)||(Finished == true)){
				Feedback += '<br />' + YourScoreIs + ' ' + Score + '%.';
				WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
			}
		}
	}
	else{
//It's right
//Mark the answer
		Btn.innerHTML = CorrectIndicator;
				
//Calculate the score for this question
		CalculateMCQuestionScore(QNum);

//Get the overall score and add it to the feedback
		if (ContinuousScoring == true){
			CalculateOverallScore();
			if ((ContinuousScoring == true)||(Finished == true)){
				Feedback += '<br />' + YourScoreIs + ' ' + Score + '%.';
				WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
			}
		}
	}
	
//Show the button again
	Btn.style.display = 'inline';
	
//Finally, show the feedback	
	ShowMessage(Feedback);
	
//Check whether all questions are now done
	CheckFinished();
}

function CalculateMCQuestionScore(QNum){
	var Tries = State[QNum][2] + State[QNum][4]; //include tries and hint penalties
	var PercentCorrect = State[QNum][3];
	var TotAns = GetTotalMCAnswers(QNum);
	var HintPenalties = State[QNum][4];
	
//Make sure it's not already complete

	if (State[QNum][0] < 0){
//Allow for Hybrids
		if (HintPenalties >= 1){
			State[QNum][0] = 0;
		}
		else{
//This line calculates the score for this question
			if (TotAns == 1){
				State[QNum][0] = 1;
			}
			else{
				State[QNum][0] = ((TotAns-((Tries*100)/State[QNum][3]))/(TotAns-1));
			}
		}
		if (State[QNum][0] < 0){
			State[QNum][0] = 0;
		}
	}
}

function GetTotalMCAnswers(QNum){
	var Result = 0;
	for (var ANum=0; ANum<I[QNum][3].length; ANum++){
		if (I[QNum][3][ANum][4] == 1){ //This is an MC answer
			Result++;
		}
	}
	return Result;
}

function FinalAnswer(QNum){
	var UnchosenAnswers = 0;
	var FinalAnswer = -1;
	for (var ANum=0; ANum<I[QNum][3].length; ANum++){
		if (I[QNum][3][ANum][4] == 1){ //This is an MC answer
			if (State[QNum][1][ANum] < 1){ //This answer hasn't been chosen yet
				UnchosenAnswers++;
				FinalAnswer = ANum;
			}
		}
	}
	if (UnchosenAnswers == 1){
		return FinalAnswer;
	}
	else{
		return -1;
	}
}





function CalculateOverallScore(){
	var TotalWeighting = 0;
	var TotalScore = 0;
	
	for (var QNum=0; QNum<State.length; QNum++){
		if (State[QNum] != null){
			if (State[QNum][0] > -1){
				TotalWeighting += I[QNum][0];
				TotalScore += (I[QNum][0] * State[QNum][0]);
			}
		}
	}
	if (TotalWeighting > 0){
		Score = Math.floor((TotalScore/TotalWeighting)*100);
	}
	else{
//if TotalWeighting is 0, no questions so far have any value, so 
//no penalty should be shown.
		Score = 100; 
	}
}

function CheckFinished(){
	var FB = '';
	var AllDone = true;
	for (var QNum=0; QNum<State.length; QNum++){
		if (State[QNum] != null){
			if (State[QNum][0] < 0){
				AllDone = false;
			}
		}
	}
	if (AllDone == true){
	
//Report final score and submit if necessary
		CalculateOverallScore();
		FB = YourScoreIs + ' ' + Score + '%.';
		if (ShowCorrectFirstTime == true){
			var CFT = 0;
			for (QNum=0; QNum<State.length; QNum++){
				if (State[QNum] != null){
					if (State[QNum][0] >= 1){
						CFT++;
					}
				}
			}
			FB += '<br />' + CorrectFirstTime + ' ' + CFT + '/' + QsToShow;
		}
		WriteToInstructions(FB);
		
		Finished == true;

		TimeOver = true;
		Locked = true;
		


		Finished = true;
		Detail = '<?xml version="1.0"?><hpnetresult><fields>';
		for (QNum=0; QNum<State.length; QNum++){
			if (State[QNum] != null){
				if (State[QNum][5].length > 0){
					Detail += '<field><fieldname>Question #' + (QNum+1) + '</fieldname><fieldtype>question-tracking</fieldtype><fieldlabel>Q ' + (QNum+1) + '</fieldlabel><fieldlabelid>QuestionTrackingField</fieldlabelid><fielddata>' + State[QNum][5] + '</fielddata></field>';
				}
			}
		}
		Detail += '</fields></hpnetresult>';
		setTimeout('Finish()', SubmissionTimeout);
	}
}










//-->

//]]>


