

//<![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.innerWidth){
		return window.innerWidth;
	}
	else{
		return document.getElementsByTagName('body')[0].clientHeight;
	}
}

function TopSettingWithScrollOffset(TopPercent){
	var T = Math.floor(GetViewportHeight() * (TopPercent/100));
	return GetScrollTop() + T; 
}

//CODE FOR AVOIDING LOSS OF DATA WHEN BACKSPACE KEY INVOKES history.back()
var InTextBox = false;

function SuppressBackspace(e){ 
	if (InTextBox == true){return;}
	if (C.ie) {
		thisKey = window.event.keyCode;
	}
	else {
		thisKey = e.keyCode;
	}

	var Suppress = false;

	if (thisKey == 8) {
		Suppress = true;
	}

	if (Suppress == true){
		if (C.ie){
			window.event.returnValue = false;	
			window.event.cancelBubble = true;
		}
		else{
			e.preventDefault();
		}
	}
}

if (C.ie){
	document.attachEvent('onkeydown',SuppressBackspace);
	window.attachEvent('onkeydown',SuppressBackspace);
}
else{
	window.addEventListener('keypress',SuppressBackspace,false);
}

function ReduceItems(InArray, ReduceToSize){
	var ItemToDump=0;
	var j=0;
	while (InArray.length > ReduceToSize){
		ItemToDump = Math.floor(InArray.length*Math.random());
		InArray.splice(ItemToDump, 1);
	}
}

function Shuffle(InArray){
	Temp = new Array();
	var Len = InArray.length;

	var j = Len;

	for (var i=0; i<Len; i++){
		Temp[i] = InArray[i];
	}

	for (i=0; i<Len; i++){
		Num = Math.floor(j  *  Math.random());
		InArray[i] = Temp[Num];

		for (var k=Num; k < j; k++) {
			Temp[k] = Temp[k+1];
		}
		j--;
	}
	return InArray;
}

function WriteToInstructions(Feedback) {
//	Feedback = '<span class="FeedbackText">' + Feedback + '</span>';
	document.getElementById('InstructionsDiv').innerHTML = Feedback;

}




function EscapeDoubleQuotes(InString){
	return InString.replace(/"/g, '&quot;')
}

function FocusAButton(){
	if (document.getElementById('CheckButton1') != null){
		document.getElementById('CheckButton1').focus();
	}
	else{
		document.getElementsByTagName('button')[0].focus();
	}
}

function TrimString(InString){
        var x = 0;

        if (InString.length != 0) {
                while ((InString.charAt(InString.length - 1) == '\u0020') || (InString.charAt(InString.length - 1) == '\u000A') || (InString.charAt(InString.length - 1) == '\u000D')){
                        InString = InString.substring(0, InString.length - 1)
                }

                while ((InString.charAt(0) == '\u0020') || (InString.charAt(0) == '\u000A') || (InString.charAt(0) == '\u000D')){
                        InString = InString.substring(1, InString.length)
                }

                while (InString.indexOf('  ') != -1) {
                        x = InString.indexOf('  ')
                        InString = InString.substring(0, x) + InString.substring(x+1, InString.length)
                 }

                return InString;
        }

        else {
                return '';
        }
}

function FindLongest(InArray){
	if (InArray.length < 1){return -1;}

	var Longest = 0;
	for (var i=1; i<InArray.length; i++){
		if (InArray[i].length > InArray[Longest].length){
			Longest = i;
		}
	}
	return Longest;
}

//UNICODE CHARACTER FUNCTIONS
function IsCombiningDiacritic(CharNum){
	var Result = (((CharNum >= 0x0300)&&(CharNum <= 0x370))||((CharNum >= 0x20d0)&&(CharNum <= 0x20ff)));
	Result = Result || (((CharNum >= 0x3099)&&(CharNum <= 0x309a))||((CharNum >= 0xfe20)&&(CharNum <= 0xfe23)));
	return Result;
}

function IsCJK(CharNum){
	return ((CharNum >= 0x3000)&&(CharNum < 0xd800));
}

//SETUP FUNCTIONS
//BROWSER WILL REFILL TEXT BOXES FROM CACHE IF NOT PREVENTED
function ClearTextBoxes(){
	var NList = document.getElementsByTagName('input');
	for (var i=0; i<NList.length; i++){
		if (NList[i].id.indexOf('Guess') > -1){
			NList[i].value = '';
		}
		if (NList[i].id.indexOf('Chk') > -1){
			NList[i].checked = '';
		}
	}
}

//EXTENSION TO ARRAY OBJECT
function Array_IndexOf(Input){
	var Result = -1;
	for (var i=0; i<this.length; i++){
		if (this[i] == Input){
			Result = i;
		}
	}
	return Result;
}
Array.prototype.indexOf = Array_IndexOf;

//IE HAS RENDERING BUG WITH BOTTOM NAVBAR
function RemoveBottomNavBarForIE(){
	if ((C.ie)&&(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 = '';

//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('All of the Services have research and development programs.','Right!  All of the four listed Services, as well as the U.S. Coast Guard, have active research and development programs.',1,100,1);
I[0][3][1]=new Array('The Marine Corps','Sorry.  The Marine Corps actively participates in R & D programs such as the Advanced Amphibious Assault Vehicle program.',0,0,1);
I[0][3][2]=new Array('The Navy','Sorry.  The Navy is active in R & D programs.  Examples include the SURTASS system and automated mine detection and countermeasures systems.',0,0,1);
I[0][3][3]=new Array('The Army','Nope.  The Army Research Laboratory, along with several other affiliated laboratories, conducts R &#x0026; D on a wide-variety of systems and areas.',0,0,1);
I[0][3][4]=new Array('The Air Force','Nope.  The Air Force is an active participant in R & D projects including such areas as directed energy weapons and aircraft sensor technologies.',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 Secretary of the Navy.','Correct.  Additionally, the Undersecretary of the Navy for Research, Development, and Acquisition is responsible for management and control of R & D matters.',1,100,1);
I[1][3][1]=new Array('The Undersecretary of Defense for Naval Affairs.','Nope.  There is no such Defense Department position as the Undersecretary of Defense for Naval Affairs.',0,0,1);
I[1][3][2]=new Array('The Office of Naval Intelligence.','Nope.  The ONI, as the name implies, is responsible for providing naval-related intelligence to the Navy.  It does not exercise policy control over Navy R & D efforts.',0,0,1);
I[1][3][3]=new Array('The Office of Naval Research.','Sorry.   The Office of Naval Research coordinates, executes, and promotes the science and technology programs of the United States Navy and Marine Corps through schools, universities, government laboratories, and nonprofit and for-profit organizations.  It doesn\'t, however, set policy.',0,0,1);
I[1][3][4]=new Array('The Chief of Naval Operations','Sorry.  The Chief of Naval Operations is certainly involved in the process, but he or she does not have policy control over the Navy R & D organization.',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 Chief of Naval Research.','Right.  He or she also is responsible for the coordinating of all Navy efforts with the systems commands.',1,100,1);
I[2][3][1]=new Array('The Secretary of the Navy','Sorry.  The Secretary of the Navy is, of course, ultimately responsible for the basic research program of the Navy, but he or she is not the individual directly in charge of that program.',0,0,1);
I[2][3][2]=new Array('The Undersecretary of the Navy for research, development and acquisition.','Sorry.  The person in charge of the basic research program in the Navy does report to this Undersecretary though.',0,0,1);
I[2][3][3]=new Array('The Chief of Naval Operations','Nope.  The CNO is involved and engaged with the Navy\'s research programs but he or she is not the one in direct charge of this program.',0,0,1);
I[2][3][4]=new Array('The Director of Naval Intelligence','Nope.  This individual heads up the Navy\'s fundamental intelligence organization, the Office of Naval Intelligence.',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('15 years','Correct.  These objectives are based on the predicted threat, trends in national policy, and the states of the technical arts.',1,100,1);
I[3][3][1]=new Array('25 years','Sorry.  While this is close to the right answer, it is still a bit too far out in the future.',0,0,1);
I[3][3][2]=new Array('50 years','Nope.  50 years is a bit too long to make achievable operational objectives.',0,0,1);
I[3][3][3]=new Array('75 years','Nope.  While 75 years is certainly "long-range", it is a much shorter timeframe.',0,0,1);
I[3][3][4]=new Array('10 years.','Sorry.  This is a long-enough range.',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 stated needs of the operating forces','Right!  The warfighter knows best what they need to win.  Their identified and stated needs form the background for research and development efforts.',1,100,1);
I[4][3][1]=new Array('The desires of the Secretary of Defense','Nope.  While the desires of the Secretary are important, they do not drive the operational requirements for weapon systems and hardware.',0,0,1);
I[4][3][2]=new Array('The recommendations of the Central Intelligence Agency (CIA)','Sorry.  These recommendations will be taken into consideration, but they do not define the general and specific operational requirements for these items.',0,0,1);
I[4][3][3]=new Array('The recommendations of the Defense Intelligence Agency (DIA)','Sorry.  These recommendations will be taken into consideration, but they do not define the general and specific operational requirements for these items.',0,0,1);
I[4][3][4]=new Array('The amount of funding dollars available in any fiscal year','Nope.  While funding can and does play into the number or complexity of weapon systems and hardware, it is not the primary source for the general and specific operational requirements identified by the CNO.',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 Naval Amphibious Warfare Systems Command','Correct.  There is no Naval Amphibious Warfare Systems Command.  Amphibious Warfare falls under either the Marine Corps or the Naval Sea Systems Command in terms of the procurement of equipment and weapons systems.',1,100,1);
I[5][3][1]=new Array('The Naval Air Systems Command','Nope.  This is one of the five Navy Systems Commands that are primary end-users of the equipment and weapons systems developed through the R & D effort.',0,0,1);
I[5][3][2]=new Array('The Naval Sea Systems Command','Nope.  This is one of the five Navy Systems Commands that are primary end-users of the equipment and weapons systems developed through the R & D effort.',0,0,1);
I[5][3][3]=new Array('The Space and Naval Warfare Systems Command','Nope.  This is one of the five Navy Systems Commands that are primary end-users of the equipment and weapons systems developed through the R & D effort.',0,0,1);
I[5][3][4]=new Array('The Marine Corps','Sorry.  The Marine Corps, like the operating forces of the Navy itself, is one of the prime end-users of the equipments and weapons systems developed through the R & D effort.',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('These are all laboratories that became part of the group of Navy R & D facilities.','Right.  These three, and as many as 37 others, continued to perform R & D related to the Navy following World War II.',1,100,1);
I[6][3][1]=new Array('The Naval Electronics Laboratory','Nope.  The Navy Electronics Laboratory was a basic and key research facility that remained dedicated to Naval Electronics Research following World War II.',0,0,1);
I[6][3][2]=new Array('The Underwater Sound Laboratory','Sorry.  This was a critical area of study given the development of the nuclear-powered submarine and the subsequent development of nuclear ballistic missile submarines.',0,0,1);
I[6][3][3]=new Array('The Radiological Defense Laboratory','Nope.  This was a particularly important laboratory following World War II given the nuclear threat of the Cold War era.',0,0,1);
I[6][3][4]=new Array('None of the listed laboratories became a part of the Navy R &#x0026; D group following World War II.','Sorry.  There are laboratories listed that did fall in to this group following World War II.',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 Contract Research Program','Correct!  Through this program, ONR provides technical advice to the CNO and the Secretary of the Navy while working with industry to improve technology manufacturing processes.',1,100,1);
I[7][3][1]=new Array('The Naval Research Initiative','Sorry.  There is no ONR-sponsored program by this name.',0,0,1);
I[7][3][2]=new Array('The University of the Navy','Sorry.  There is no ONR-sponsored program by this name.',0,0,1);
I[7][3][3]=new Array('The Educational Assistance Program','Nope.  There is no ONR-sponsored program by this name.',0,0,1);
I[7][3][4]=new Array('The Science and Technology Endowment Program','Nope.  There is no ONR-sponsored program by this name.',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 Naval Research Laboratory','Right!  This laboratory conducts scientific research and advanced technological development directed toward maritime, atmospheric and space science related technologies.',1,100,1);
I[8][3][1]=new Array('The Naval Electronics Laboratory','Sorry.  This was the name of one of the 40 individual research laboratories which became a part of the group of Naval R & D laboratories formed following World War II.',0,0,1);
I[8][3][2]=new Array('The Underwater Sound Laboratory','Sorry.  This was the name of one of the 40 individual research laboratories which became a part of the group of Naval R & D laboratories formed following World War II.',0,0,1);
I[8][3][3]=new Array('The Radiological Defense Laboratory','Nope.  This was the name of one of the 40 individual research laboratories which became a part of the group of Naval R & D laboratories formed following World War II.',0,0,1);
I[8][3][4]=new Array('The Naval Defense Laboratory','Nope.  There is no such laboratory under ONR.',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('Biological Sciences','Right.  While biology is involved in much of this research, specific studies of the Biological Sciences are not.',1,100,1);
I[9][3][1]=new Array('Physical Sciences','Sorry.  The physical sciences are a major part of the NRL\'s work.',0,0,1);
I[9][3][2]=new Array('Engineering Sciences','Sorry.  Engineering Science is tremendously important to the Navy and the NRL does significant work in this area.',0,0,1);
I[9][3][3]=new Array('Space Sciences','Nope.  Space Science is one of the four major areas of study.',0,0,1);
I[9][3][4]=new Array('Environmental Sciences','Nope.  Environmental Science has been a growing part of NRL research over the past several decades.',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('National Defense','Right.  While several other important areas, such as many of the other answers listed here, are positively impacted by the Navy\'s research in this area, the primary goal of this research is the defense of our nation.',1,100,1);
I[10][3][1]=new Array('Environmental Protection','Sorry.  Advances in understanding the ocean environment and developments in protecting the oceans have come from the Navy\'s research in this area, but it is not the primary purpose of the Navy\'s oceanographic research.',0,0,1);
I[10][3][2]=new Array('Industrial Applications','Sorry.  While there have been several industrial applications that have come about from the Navy\'s oceanographic effort, it is not the purpose of this effort.',0,0,1);
I[10][3][3]=new Array('The Advancement of International Law of the Sea','Nope.  While the results of the Navy\'s oceanographic efforts have an impact on international law of the sea, it is not the purpose of that research.',0,0,1);
I[10][3][4]=new Array('A Complete Mapping of the Seabed.','Nope.  This has been pretty much accomplished already.',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('40%','Right.  Many U.S. agencies perform oceanographic research directly or indirectly.  Our Navy has the largest single part of that overall effort.',1,100,1);
I[11][3][1]=new Array('25%','Sorry.  The Navy\'s percentage is even more than this amount.',0,0,1);
I[11][3][2]=new Array('10%','Nope.  It is quite a bit more than that.',0,0,1);
I[11][3][3]=new Array('50%','Sorry.  You are close, but it isn\'t quite this month.',0,0,1);
I[11][3][4]=new Array('75%','Nope.  It isn\'t nearly that much',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 Scripps Oceanographic Institute','Right.  This is one of the many private oceanographic organizations that carries out research funded by the Navy.',1,100,1);
I[12][3][1]=new Array('The Woods Hole Oceanographic Institute','Sorry.  This important oceanographic institute is located in Massachusetts.',0,0,1);
I[12][3][2]=new Array('The Naval Research Laboratory','Nope.  This laboratory is located in Washington D.C. and is not a private organization.',0,0,1);
I[12][3][3]=new Array('The Alaska Sealife Center','Nope.  That\'s in Alaska, not California.',0,0,1);
I[12][3][4]=new Array('The Point Loma Oceanographic Institute','Sorry.  Although Point Loma is in California, there is no such oceanographic institute.',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('Projects in advanced research','Correct.  This agency concentrates on high-payoff technologies that will enable quantum leaps in U.S. military capabilities.',1,100,1);
I[13][3][1]=new Array('Oceanographic Projects','Sorry.  Some research done by DARPA directly or indirectly relates to oceanography, but this is not the general type of research done by this agency.',0,0,1);
I[13][3][2]=new Array('Space-based vehicle research','Sorry.  While DARPA does do some research in this area, it is not the general type of research carried out by this organization.',0,0,1);
I[13][3][3]=new Array('DARPA is a defense agency and not a research agency.','Nope.  DARPA stands for Defense Advanced Research Projects Agency.  Research is even in their name!',0,0,1);
I[13][3][4]=new Array('Intelligence collection research','Nope.  DARPA is not an intelligence agency or think tank.',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('Ocean, atmospheric and space sciences.','Correct!  Although some DARPA research occurs within these areas, they aren\'t one of the three primary areas of DARPA research.  These things are, however, the primary areas of interest to the Naval Research Laboratory.',1,100,1);
I[14][3][1]=new Array('National-level problems involving threats to U.S. national security','Sorry.  This area concentrates on such things as support for the global war on terrorism and protection against biological warfare.',0,0,1);
I[14][3][2]=new Array('Operational dominance','Sorry.  This area concentrates on projects such as development of advanced manned and unmanned combat systems.',0,0,1);
I[14][3][3]=new Array('High-risk payoff technologies','Sorry.  This area concentrates on such things as advanced networking and brain-machine interface technology.',0,0,1);
I[14][3][4]=new Array('The are all major areas of research within DARPA','Nope.  DARPA\'s program is structured into three major areas.  One of the others is not correct.',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('Advanced <a href="javascript:alert(\'Command, Control, Communications & Computers\')">C4 </a>systems and sensors.','Right.  This area of research within <a href="javascript:alert(\'The Defense Advanced Research Projects Agency\')">DARPA </a>would fall under the Operational Dominance Projects section.',1,100,1);
I[15][3][1]=new Array('Brain-machine interface technology','Sorry.  This is a classic example of the type of research this section of DARPA was created to focus upon.  This important research would be far too costly and risky to attract civilian research, yet significant military and industrial gains can result from this work.',0,0,1);
I[15][3][2]=new Array('Biochemistry and biomagnetics','Sorry.  Both of these areas are being actively explored by DARPA.',0,0,1);
I[15][3][3]=new Array('Micro-electromechanical systems','Nope.  Micro-electromechanical systems are vital to many of the emerging technologies and hardware envisioned for the U.S. Armed Forces of the future.',0,0,1);
I[15][3][4]=new Array('Advanced Networking','Nope.  This is an important area of research both for the Military and for civilian industry.',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('These are all examples of currently R&D projects.','Right.  Several other areas of research also exist, such as Electric and water-jet propulsion systems, pilotless fighter and attach aircraft and superconductor technology research.',1,100,1);
I[16][3][1]=new Array('Automated mine detection and countermeasures systems.','Sorry.  The threat of mines continues to increase in the oceans and waterways of the world.  Improved mine detection and countermeasures systems are designed to meet this growing threat.',0,0,1);
I[16][3][2]=new Array('<a href="javascript:alert(\'Antisatellite\')">ASAT </a>and <a href="javascript:alert(\'Antiballistic missile\')">ABM </a>weapon systems.','Nope.  This is a critical area of Navy force defense and critical to our ability to survive at sea in future conflicts.',0,0,1);
I[16][3][3]=new Array('Catamaran-hulled amphibious transport ships.','Nope.  An example of this technology is the USNS Hayes, one of the Navy\'s more advanced oceanographic ships.',0,0,1);
I[16][3][4]=new Array('<a href="javascript:alert(\'Enhanced Surveillance Towed-Array System\')">SURTASS</a>','Sorry.  This is an important and ongoing area of research for the Navy.',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('Osprey','Correct.  Ultimately some 425 production models of this vertical takeoff and landing aircraft will be procured for the Marine Corps.',1,100,1);
I[17][3][1]=new Array('Hornet','Sorry.  The Hornet has a designation of F/A-18 and performs the in-close fighter and light attack missions for the Navy.',0,0,1);
I[17][3][2]=new Array('Tomcat','Nope.  The Tomcat\'s designation is F-14, and it is a Navy fighter aircraft.',0,0,1);
I[17][3][3]=new Array('Predator','Sorry.  The Predator is a multi-service <a href="javascript:alert(\'Unmanned Aerial Vehicle\')">UAV </a>used primarily for intelligence gathering missions.',0,0,1);
I[17][3][4]=new Array('Intruder','Nope.  The Intruder had a designation of A-6 and was the mainstay of Navy and Marine Corps All-Weather Medium Attack for many years.',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('Airborne replenishment','Correct.  There are no plans currently to have UAV\'s perform logistics functions.',1,100,1);
I[18][3][1]=new Array('Reconnaissance','Nope.  This is currently the primary mission area of UAVs.  The information provided by UAVs was critical during the recent operations in Afghanistan and Iraq.',0,0,1);
I[18][3][2]=new Array('Battle-damage assessment','Sorry.  This is an important mission.  You need to know whether a target that has been attacked has been destroyed or whether it needs to be hit again.  UAVs can perform this mission without putting a human being at risk.',0,0,1);
I[18][3][3]=new Array('Tactical-communications relays','Sorry.  By placing UAVs at high altitudes and using them as communication relays, commanders can place their units farther apart without losing direct command and control.',0,0,1);
I[18][3][4]=new Array('Chemical and biological agent detection. ','Nope.  It makes sense to send an unmanned vehicle into areas suspected to have these threats so that human beings are not being exposed.',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('Virginia','Correct.  The USS Virginia, the first of this class, is currently under construction.  A total of 4 submarines in this class are currently scheduled to be built.',1,100,1);
I[19][3][1]=new Array('Sea Wolf','Sorry.  While the Sea Wolf class is currently the most modern attack submarine class in commission, there is an even newer class that is under construction.',0,0,1);
I[19][3][2]=new Array('Los Angles','Sorry.  While this a current and very capable U.S. Navy attack submarine class, it is actually the oldest attack submarine class in the U.S. inventory.',0,0,1);
I[19][3][3]=new Array('Trident','Nope.  Trident submarines are Nuclear Ballistic Missile Submarines, not Attack Submarines.',0,0,1);
I[19][3][4]=new Array('Sea Shark','Nope.  There has never been a U.S. Navy submarine class with this name.',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('Lockheed Martin','Correct.  The Lockheed Martin design that was selected for this contract has been designated the F-35.',1,100,1);
I[20][3][1]=new Array('Northup Grumman','Sorry.  Northrop Grumman did compete for this contract, but their design was not selected.',0,0,1);
I[20][3][2]=new Array('McDonnell Douglas','Sorry.  McDonnell Douglas was one of the initial competitors for this design but did not get the contract.',0,0,1);
I[20][3][3]=new Array('Boeing','Sorry.  The Boeing prototype (X-32) lost the competition in 2001.',0,0,1);
I[20][3][4]=new Array('Curtis-Wright','Nope.  While at one time a major supplier of warplanes to the U.S. government, this corporation no longer works on these types of contracts.',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';
	}
	

	

	
	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;
		
//Check whether this leaves just one MC answer unselected, in which case the Q is terminated
		var RemainingAnswer = FinalAnswer(QNum);
		if (RemainingAnswer > -1){
//Behave as if the last answer had been selected, but give no credit for it
//Increment the number of tries
			State[QNum][2]++;		
		
//Calculate the score for this question
			CalculateMCQuestionScore(QNum);

//Get the overall score and add it to the feedback
			CalculateOverallScore();
			if ((ContinuousScoring == true)||(Finished == true)){
				Feedback += '<br />' + YourScoreIs + ' ' + Score + '%.';
				WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
			}
		}
	}
	else{
//It's right
//Mark the answer
		Btn.innerHTML = CorrectIndicator;
				
//Calculate the score for this question
		CalculateMCQuestionScore(QNum);

//Get the overall score and add it to the feedback
		if (ContinuousScoring == true){
			CalculateOverallScore();
			if ((ContinuousScoring == true)||(Finished == true)){
				Feedback += '<br />' + YourScoreIs + ' ' + Score + '%.';
				WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
			}
		}
	}
	
//Show the button again
	Btn.style.display = 'inline';
	
//Finally, show the feedback	
	ShowMessage(Feedback);
	
//Check whether all questions are now done
	CheckFinished();
}

function CalculateMCQuestionScore(QNum){
	var Tries = State[QNum][2] + State[QNum][4]; //include tries and hint penalties
	var PercentCorrect = State[QNum][3];
	var TotAns = GetTotalMCAnswers(QNum);
	var HintPenalties = State[QNum][4];
	
//Make sure it's not already complete

	if (State[QNum][0] < 0){
//Allow for Hybrids
		if (HintPenalties >= 1){
			State[QNum][0] = 0;
		}
		else{
			State[QNum][0] = ((TotAns-(Tries-1))/TotAns)*(PercentCorrect/(100*Tries));
		}
		if (State[QNum][0] < 0){
			State[QNum][0] = 0;
		}
	}
}

function GetTotalMCAnswers(QNum){
	var Result = 0;
	for (var ANum=0; ANum<I[QNum][3].length; ANum++){
		if (I[QNum][3][ANum][4] == 1){ //This is an MC answer
			Result++;
		}
	}
	return Result;
}

function FinalAnswer(QNum){
	var UnchosenAnswers = 0;
	var FinalAnswer = -1;
	for (var ANum=0; ANum<I[QNum][3].length; ANum++){
		if (I[QNum][3][ANum][4] == 1){ //This is an MC answer
			if (State[QNum][1][ANum] < 1){ //This answer hasn't been chosen yet
				UnchosenAnswers++;
				FinalAnswer = ANum;
			}
		}
	}
	if (UnchosenAnswers == 1){
		return FinalAnswer;
	}
	else{
		return -1;
	}
}





function CalculateOverallScore(){
	var TotalWeighting = 0;
	var TotalScore = 0;
	
	for (var QNum=0; QNum<State.length; QNum++){
		if (State[QNum] != null){
			if (State[QNum][0] > -1){
				TotalWeighting += I[QNum][0];
				TotalScore += (I[QNum][0] * State[QNum][0]);
			}
		}
	}
	Score = Math.floor((TotalScore/TotalWeighting)*100);
}

function CheckFinished(){
	var FB = '';
	var AllDone = true;
	for (var QNum=0; QNum<State.length; QNum++){
		if (State[QNum] != null){
			if (State[QNum][0] < 0){
				AllDone = false;
			}
		}
	}
	if (AllDone == true){
	
//Report final score and submit if necessary
		CalculateOverallScore();
		FB = YourScoreIs + ' ' + Score + '%.';
		if (ShowCorrectFirstTime == true){
			var CFT = 0;
			for (QNum=0; QNum<State.length; QNum++){
				if (State[QNum] != null){
					if (State[QNum][0] >= 1){
						CFT++;
					}
				}
			}
			FB += '<br />' + CorrectFirstTime + ' ' + CFT + '/' + QsToShow;
		}
		WriteToInstructions(FB);
		
		Finished == true;

		TimeOver = true;
		Locked = true;
		


		Finished = true;
		Detail = '<?xml version="1.0"?><hpnetresult><fields>';
		for (QNum=0; QNum<State.length; QNum++){
			if (State[QNum] != null){
				if (State[QNum][5].length > 0){
					Detail += '<field><fieldname>Question #' + (QNum+1) + '</fieldname><fieldtype>question-tracking</fieldtype><fieldlabel>Q ' + (QNum+1) + '</fieldlabel><fieldlabelid>QuestionTrackingField</fieldlabelid><fielddata>' + State[QNum][5] + '</fielddata></field>';
				}
			}
		}
		Detail += '</fields></hpnetresult>';
		setTimeout('Finish()', SubmissionTimeout);
	}
}










//-->

//]]>


