

//<![CDATA[

<!--


function Client(){
//if not a DOM browser, hopeless
	this.min = false; if (document.getElementById){this.min = true;};

	this.ua = navigator.userAgent;
	this.name = navigator.appName;
	this.ver = navigator.appVersion;  

//Get data about the browser
	this.mac = (this.ver.indexOf('Mac') != -1);
	this.win = (this.ver.indexOf('Windows') != -1);

//Look for Gecko
	this.gecko = (this.ua.indexOf('Gecko') > 1);
	if (this.gecko){
		this.geckoVer = parseInt(this.ua.substring(this.ua.indexOf('Gecko')+6, this.ua.length));
		if (this.geckoVer < 20020000){this.min = false;}
	}
	
//Look for Firebird
	this.firebird = (this.ua.indexOf('Firebird') > 1);
	
//Look for Safari
	this.safari = (this.ua.indexOf('Safari') > 1);
	if (this.safari){
		this.gecko = false;
	}
	
//Look for IE
	this.ie = (this.ua.indexOf('MSIE') > 0);
	if (this.ie){
		this.ieVer = parseFloat(this.ua.substring(this.ua.indexOf('MSIE')+5, this.ua.length));
		if (this.ieVer < 5.5){this.min = false;}
	}
	
//Look for Opera
	this.opera = (this.ua.indexOf('Opera') > 0);
	if (this.opera){
		this.operaVer = parseFloat(this.ua.substring(this.ua.indexOf('Opera')+6, this.ua.length));
		if (this.operaVer < 7.04){this.min = false;}
	}
	if (this.min == false){
		alert('Your browser may not be able to handle this page.');
	}
	
//Special case for the horrible ie5mac
	this.ie5mac = (this.ie&&this.mac&&(this.ieVer<6));
}

var C = new Client();

//for (prop in C){
//	alert(prop + ': ' + C[prop]);
//}



//CODE FOR HANDLING NAV BUTTONS AND FUNCTION BUTTONS

//[strNavBarJS]
function NavBtnOver(Btn){
	if (Btn.className != 'NavButtonDown'){Btn.className = 'NavButtonUp';}
}

function NavBtnOut(Btn){
	Btn.className = 'NavButton';
}

function NavBtnDown(Btn){
	Btn.className = 'NavButtonDown';
}
//[/strNavBarJS]

function FuncBtnOver(Btn){
	if (Btn.className != 'FuncButtonDown'){Btn.className = 'FuncButtonUp';}
}

function FuncBtnOut(Btn){
	Btn.className = 'FuncButton';
}

function FuncBtnDown(Btn){
	Btn.className = 'FuncButtonDown';
}

function FocusAButton(){
	if (document.getElementById('CheckButton1') != null){
		document.getElementById('CheckButton1').focus();
	}
	else{
		if (document.getElementById('CheckButton2') != null){
			document.getElementById('CheckButton2').focus();
		}
		else{
			document.getElementsByTagName('button')[0].focus();
		}
	}
}




//CODE FOR HANDLING DISPLAY OF POPUP FEEDBACK BOX

var topZ = 1000;

function ShowMessage(Feedback){
	var Output = Feedback + '<br /><br />';
	document.getElementById('FeedbackContent').innerHTML = Output;
	var FDiv = document.getElementById('FeedbackDiv');
	topZ++;
	FDiv.style.zIndex = topZ;
	FDiv.style.top = TopSettingWithScrollOffset(30) + 'px';

	FDiv.style.display = 'block';

	ShowElements(false, 'input');
	ShowElements(false, 'select');
	ShowElements(false, 'object');

//Focus the OK button
	setTimeout("document.getElementById('FeedbackOKButton').focus()", 50);
	
//
}

function ShowElements(Show, TagName){
//Special for IE bug -- hide all the form elements that will show through the popup
	if (C.ie){
		var Els = document.getElementsByTagName(TagName);
		for (var i=0; i<Els.length; i++){
			if (Show == true){
				Els[i].style.display = 'inline';
			}
			else{
				Els[i].style.display = 'none';
			}
		}
	} 
}

function HideFeedback(){
	document.getElementById('FeedbackDiv').style.display = 'none';
	ShowElements(true, 'input');
	ShowElements(true, 'select');
	ShowElements(true, 'object');
	if (Finished == true){
		Finish();
	}
}


//GENERAL UTILITY FUNCTIONS AND VARIABLES

//PAGE DIMENSION FUNCTIONS
function PageDim(){
//Get the page width and height
	this.W = 600;
	this.H = 400;
	this.W = document.getElementsByTagName('body')[0].clientWidth;
	this.H = document.getElementsByTagName('body')[0].clientHeight;
}

var pg = null;

function GetPageXY(El) {
	var XY = {x: 0, y: 0};
	while(El){
		XY.x += El.offsetLeft;
		XY.y += El.offsetTop;
		El = El.offsetParent;
	}
	return XY;
}

function GetScrollTop(){
	if (document.documentElement && document.documentElement.scrollTop){
		return document.documentElement.scrollTop;
	}
	else{
		if (document.body){
 			return document.body.scrollTop;
		}
		else{
			return window.pageYOffset;
		}
	}
}

function GetViewportHeight(){
	if (window.innerHeight){
		return window.innerHeight;
	}
	else{
		return document.getElementsByTagName('body')[0].clientHeight;
	}
}

function TopSettingWithScrollOffset(TopPercent){
	var T = Math.floor(GetViewportHeight() * (TopPercent/100));
	return GetScrollTop() + T; 
}

//CODE FOR AVOIDING LOSS OF DATA WHEN BACKSPACE KEY INVOKES history.back()
var InTextBox = false;

function SuppressBackspace(e){ 
	if (InTextBox == true){return;}
	if (C.ie) {
		thisKey = window.event.keyCode;
	}
	else {
		thisKey = e.keyCode;
	}

	var Suppress = false;

	if (thisKey == 8) {
		Suppress = true;
	}

	if (Suppress == true){
		if (C.ie){
			window.event.returnValue = false;	
			window.event.cancelBubble = true;
		}
		else{
			e.preventDefault();
		}
	}
}

if (C.ie){
	document.attachEvent('onkeydown',SuppressBackspace);
	window.attachEvent('onkeydown',SuppressBackspace);
}
else{
	if (window.addEventListener){
		window.addEventListener('keypress',SuppressBackspace,false);
	}
}

function ReduceItems(InArray, ReduceToSize){
	var ItemToDump=0;
	var j=0;
	while (InArray.length > ReduceToSize){
		ItemToDump = Math.floor(InArray.length*Math.random());
		InArray.splice(ItemToDump, 1);
	}
}

function Shuffle(InArray){
	var Num;
	var Temp = new Array();
	var Len = InArray.length;

	var j = Len;

	for (var i=0; i<Len; i++){
		Temp[i] = InArray[i];
	}

	for (i=0; i<Len; i++){
		Num = Math.floor(j  *  Math.random());
		InArray[i] = Temp[Num];

		for (var k=Num; k < (j-1); k++) {
			Temp[k] = Temp[k+1];
		}
		j--;
	}
	return InArray;
}

function WriteToInstructions(Feedback) {
	document.getElementById('InstructionsDiv').innerHTML = Feedback;

}




function EscapeDoubleQuotes(InString){
	return InString.replace(/"/g, '&quot;')
}

function TrimString(InString){
        var x = 0;

        if (InString.length != 0) {
                while ((InString.charAt(InString.length - 1) == '\u0020') || (InString.charAt(InString.length - 1) == '\u000A') || (InString.charAt(InString.length - 1) == '\u000D')){
                        InString = InString.substring(0, InString.length - 1)
                }

                while ((InString.charAt(0) == '\u0020') || (InString.charAt(0) == '\u000A') || (InString.charAt(0) == '\u000D')){
                        InString = InString.substring(1, InString.length)
                }

                while (InString.indexOf('  ') != -1) {
                        x = InString.indexOf('  ')
                        InString = InString.substring(0, x) + InString.substring(x+1, InString.length)
                 }

                return InString;
        }

        else {
                return '';
        }
}

function FindLongest(InArray){
	if (InArray.length < 1){return -1;}

	var Longest = 0;
	for (var i=1; i<InArray.length; i++){
		if (InArray[i].length > InArray[Longest].length){
			Longest = i;
		}
	}
	return Longest;
}

//UNICODE CHARACTER FUNCTIONS
function IsCombiningDiacritic(CharNum){
	var Result = (((CharNum >= 0x0300)&&(CharNum <= 0x370))||((CharNum >= 0x20d0)&&(CharNum <= 0x20ff)));
	Result = Result || (((CharNum >= 0x3099)&&(CharNum <= 0x309a))||((CharNum >= 0xfe20)&&(CharNum <= 0xfe23)));
	return Result;
}

function IsCJK(CharNum){
	return ((CharNum >= 0x3000)&&(CharNum < 0xd800));
}

//SETUP FUNCTIONS
//BROWSER WILL REFILL TEXT BOXES FROM CACHE IF NOT PREVENTED
function ClearTextBoxes(){
	var NList = document.getElementsByTagName('input');
	for (var i=0; i<NList.length; i++){
		if ((NList[i].id.indexOf('Guess') > -1)||(NList[i].id.indexOf('Gap') > -1)){
			NList[i].value = '';
		}
		if (NList[i].id.indexOf('Chk') > -1){
			NList[i].checked = '';
		}
	}
}

//EXTENSION TO ARRAY OBJECT
function Array_IndexOf(Input){
	var Result = -1;
	for (var i=0; i<this.length; i++){
		if (this[i] == Input){
			Result = i;
		}
	}
	return Result;
}
Array.prototype.indexOf = Array_IndexOf;

//IE HAS RENDERING BUG WITH BOTTOM NAVBAR
function RemoveBottomNavBarForIE(){
	if ((C.ie)&&(document.getElementById('Reading') != null)){
		if (document.getElementById('BottomNavBar') != null){
			document.getElementById('TheBody').removeChild(document.getElementById('BottomNavBar'));
		}
	}
}




//HOTPOTNET-RELATED CODE

var HPNStartTime = (new Date()).getTime();
var SubmissionTimeout = 30000;
var Detail = ''; //Global that is used to submit tracking data

function Finish(){
//If there's a form, fill it out and submit it
	if (document.store != null){
		Frm = document.store;
		Frm.starttime.value = HPNStartTime;
		Frm.endtime.value = (new Date()).getTime();
		Frm.mark.value = Score;
		Frm.detail.value = Detail;
		Frm.submit();
	}
}



//JQUIZ CORE JAVASCRIPT CODE

var CurrQNum = 0;
var CorrectIndicator = ':-)';
var IncorrectIndicator = 'X';
var YourScoreIs = 'Your score is ';
var ContinuousScoring = true;
var CorrectFirstTime = 'Questions answered correctly first time: ';
var ShowCorrectFirstTime = false;
var ShuffleQs = true;
var ShuffleAs = true;
var DefaultRight = 'Correct!';
var DefaultWrong = 'Sorry! Try again.';
var QsToShow = 10;
var Score = 0;
var Finished = false;
var Qs = null;
var QArray = new Array();
var ShowingAllQuestions = false;
var ShowAllQuestionsCaption = 'Show all questions';
var ShowOneByOneCaption = 'Show questions one by one';
var State = new Array();
var Feedback = '';
var TimeOver = false;
var strInstructions = '';

//The following variable can be used to add a message explaining that
//the question is finished, so no further marking will take place.
var strQuestionFinished = '';

function CompleteEmptyFeedback(){
	var QNum, ANum;
	for (QNum=0; QNum<I.length; QNum++){
//Only do this if not multi-select
		if (I[QNum][2] != '3'){
  		for (ANum = 0; ANum<I[QNum][3].length; ANum++){
  			if (I[QNum][3][ANum][1].length < 1){
  				if (I[QNum][3][ANum][2] > 0){
  					I[QNum][3][ANum][1] = DefaultRight;
  				}
  				else{
  					I[QNum][3][ANum][1] = DefaultWrong;
  				}
  			}
  		}
		}
	}
}

function SetUpQuestions(){
	var AList = new Array(); 
	var QList = new Array();
	var i, j;
	Qs = document.getElementById('Questions');
	while (Qs.getElementsByTagName('li').length > 0){
		QList.push(Qs.removeChild(Qs.getElementsByTagName('li')[0]));
	}
	var DumpItem = 0;
	if (QsToShow > QList.length){
		QsToShow = QList.length;
	}
	while (QsToShow < QList.length){
		DumpItem = Math.floor(QList.length*Math.random());
		for (j=DumpItem; j<(QList.length-1); j++){
			QList[j] = QList[j+1];
		}
		QList.length = QList.length-1;
	}
	if (ShuffleQs == true){
		QList = Shuffle(QList);
	}
	if (ShuffleAs == true){
		var As;
		for (var i=0; i<QList.length; i++){
			As = QList[i].getElementsByTagName('ol')[0];
			if (As != null){
  			AList.length = 0;
				while (As.getElementsByTagName('li').length > 0){
					AList.push(As.removeChild(As.getElementsByTagName('li')[0]));
				}
				AList = Shuffle(AList);
				for (j=0; j<AList.length; j++){
					As.appendChild(AList[j]);
				}
			}
		}
	}
	
	for (i=0; i<QList.length; i++){
		Qs.appendChild(QList[i]);
		QArray[QArray.length] = QList[i];
	}

//Show the first item
	QArray[0].style.display = '';
	
//Now hide all except the first item
	for (i=1; i<QArray.length; i++){
		QArray[i].style.display = 'none';
	}		
	SetQNumReadout();
}

function ChangeQ(ChangeBy){
//The following line prevents moving to another question until the current
//question is answered correctly. Uncomment it to enable this behaviour. 
//	if (State[CurrQNum][0] == -1){return;}
	if (((CurrQNum + ChangeBy) < 0)||((CurrQNum + ChangeBy) >= QArray.length)){return;}
	QArray[CurrQNum].style.display = 'none';
	CurrQNum += ChangeBy;
	QArray[CurrQNum].style.display = '';
	SetQNumReadout();
//if there's a textbox, set the focus in it
	if (QArray[CurrQNum].getElementsByTagName('input')[0] != null){
		QArray[CurrQNum].getElementsByTagName('input')[0].focus();
	}
}

function SetQNumReadout(){
	document.getElementById('QNumReadout').innerHTML = (CurrQNum+1) + ' / ' + QArray.length;
}

I=new Array();
I[0]=new Array();I[0][0]=100;
I[0][1]='';
I[0][2]='0';
I[0][3]=new Array();
I[0][3][0]=new Array('71%','Right!  Fresh water makes approximately another 4%.',1,100,1);
I[0][3][1]=new Array('75%','Sorry.  This would be the percentage if you included fresh water as well as salt water.',0,0,1);
I[0][3][2]=new Array('50%','Nope.  This is too low a percentage.',0,0,1);
I[0][3][3]=new Array('90%','Sorry.  It isn\'t that much.',0,0,1);
I[0][3][4]=new Array('82%','Nope.  It isn\'t that much.',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('Oceanography','',1,100,1);
I[1][3][1]=new Array('Geopolitics','Sorry.  This is the study of the effect of geography on politics.',0,0,1);
I[1][3][2]=new Array('Geography','Nope.  Basically, this is the overall study of where things are on Earth.',0,0,1);
I[1][3][3]=new Array('Navigation','Sorry.  Navigation is concerned with going from one point to another.',0,0,1);
I[1][3][4]=new Array('Geology','Nope.  Geology studies the substances which make up the Earth.',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('Antarctic','Correct.  There is no major ocean basin here.',1,100,1);
I[2][3][1]=new Array('Arctic','Sorry.  This is the smallest of the six major ocean basins.',0,0,1);
I[2][3][2]=new Array('North Pacific','Sorry.  This is in fact the second largest of the six major ocean basins.',0,0,1);
I[2][3][3]=new Array('Indian','Nope.  The Indian ocean basin is the third-largest.',0,0,1);
I[2][3][4]=new Array('South Atlantic','Nope.  The South Atlantic, although the second smallest, is a major ocean basin.',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('Sound','Correct.  Like Long Island Sound off New York.',1,100,1);
I[3][3][1]=new Array('Bay','Sorry.  Bays are large bodies of water opening into a sea, such as the Chesapeake Bay.',0,0,1);
I[3][3][2]=new Array('Gulf','Sorry.  Gulfs are pockets of the seas that reach into the continents.  The Persian gulf is an example.',0,0,1);
I[3][3][3]=new Array('Waterway','Nope.  That isn\'t the term.',0,0,1);
I[3][3][4]=new Array('Ocean','Nope.  Oceans are much, much larger bodies of water.',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('Gulfs','Correct.  The Gulf of Mexico is an example.',1,100,1);
I[4][3][1]=new Array('Sound','Sorry.  A sound connects two or more inlets or parts of a sea, such as Long Island Sound off New York.',0,0,1);
I[4][3][2]=new Array('Bay','Sorry.  Bays are large bodies of water opening into a sea, such as the Chesapeake Bay.',0,0,1);
I[4][3][3]=new Array('Waterway','Nope.  That isn\'t the term.',0,0,1);
I[4][3][4]=new Array('Ocean','Nope.  Oceans are much, much larger bodies of water.',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 Atlantic','Correct.  The main shipping lanes go between the East Coast of the U.S. and Western Europe.',1,100,1);
I[5][3][1]=new Array('The Pacific','Sorry.  Though it\'s the largest, it\'s sea lanes are not the most heavily traveled.',0,0,1);
I[5][3][2]=new Array('The Arctic','Sorry.  This is actually one of the least traveled oceans.',0,0,1);
I[5][3][3]=new Array('The Indian','Nope.  While a significant ocean in terms of trade, it is not the most traveled.',0,0,1);
I[5][3][4]=new Array('The Antarctic','Nope.  There is no Antarctic Ocean.',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('The Persian Gulf','Correct.  This is primarily oil cargo from the Persian Gulf-area oil fields.',1,100,1);
I[6][3][1]=new Array('The Gulf of Mexico','Sorry.  Although there is significant bulk cargo traffic in the Gulf of Mexico, it isn\'t the heaviest in the world.',0,0,1);
I[6][3][2]=new Array('The Gulf of Aden','Nope.   Although there is significant bulk cargo traffic in the Gulf of Aden, it isn\'t the heaviest in the world.',0,0,1);
I[6][3][3]=new Array('The Gulf of Riga','Sorry.  The Gulf of Riga does not have significantly heavy bulk cargo traffic.',0,0,1);
I[6][3][4]=new Array('The Gulf of Sidra','Nope.  The Gulf of Sidra does not have significantly heavy bulk cargo traffic.',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('Iceland','',1,100,1);
I[7][3][1]=new Array('England','Sorry.  England is not situated along the Mid-Atlantic Ridge.',0,0,1);
I[7][3][2]=new Array('Ireland','Sorry.  Ireland is not situated along the Mid-Atlantic Ridge.',0,0,1);
I[7][3][3]=new Array('Ascension Island','Nope.  Ascension Island is located on the Mid-Atlantic Ridge in the South Atlantic.',0,0,1);
I[7][3][4]=new Array('Tristan da Cunha','Nope.  Tristan da Cunha is located on the Mid-Atlantic Ridge in the South Atlantic.',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('Mining for sands and gravels along the Atlantic seaboard of the U.S.','',1,100,1);
I[8][3][1]=new Array('Mining for diamonds along the Eastern coast of Mexico.','Nope.  There are no such diamond mining operations.',0,0,1);
I[8][3][2]=new Array('Mining for gold off the East Coast of Brazil.','Nope.  There are no such gold mining operations.',0,0,1);
I[8][3][3]=new Array('Mining for zinc off the East Coast of Canada.','Nope.  Zinc is not mined off the coast of Canada.',0,0,1);
I[8][3][4]=new Array('Mining for phosphates off the coast of Iceland.','Sorry.  Although this is done, it is not done in large quantities.',0,0,1);
I[9]=new Array();I[9][0]=100;
I[9][1]='';
I[9][2]='0';
I[9][3]=new Array();
I[9][3][0]=new Array('The Bahamas.','Correct.  Aragonite sands in Ocean Cay.',1,100,1);
I[9][3][1]=new Array('Iceland','Sorry.  Although sand-shells are mined for a cement industry here, it is not the largest mining operation.',0,0,1);
I[9][3][2]=new Array('Texas','Sorry.  Although oil is brought up in significant quantities, this is not the site of the largest mining operation.',0,0,1);
I[9][3][3]=new Array('Norway','Sorry.  Although oil is brought up in significant quantities, this is not the site of the largest mining operation.',0,0,1);
I[9][3][4]=new Array('Brazil','Nope.  There are no significantly large mining operations off the coast of Brazil.',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('Miami','Right.  although a significant port, it is not one of the major U.S. Atlantic ports.',1,100,1);
I[10][3][1]=new Array('Boston','Sorry.  Boston has been one of the major U.S. ports for the entire history of the U.S.',0,0,1);
I[10][3][2]=new Array('New York','Sorry.  New York has been one of the major U.S. ports for the entire history of the U.S.',0,0,1);
I[10][3][3]=new Array('Baltimore','Sorry.  Baltimore has been one of the major U.S. ports for the entire history of the U.S.',0,0,1);
I[10][3][4]=new Array('Norfolk','Nope.  Norfolk is one of our major ports for both the military and commercial interests.',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('Antwerp, Belgium','',1,100,1);
I[11][3][1]=new Array('Southampton, England','Sorry.  While an important English port, it isn\'t the largest and busiest in the Atlantic.',0,0,1);
I[11][3][2]=new Array('Liverpool, England','Sorry.  While an important English port, it isn\'t the largest and busiest in the Atlantic.',0,0,1);
I[11][3][3]=new Array('Rotterdam, Holland','Nope.  While a significant and important Western European port, Rotterdam isn\'t the largest.',0,0,1);
I[11][3][4]=new Array('Hamburg, Germany','Nope.  While a significant and important Western European port, Hamburg isn\'t the largest.',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('Skagerrak','Correct.  Also Kattegat.',1,100,1);
I[12][3][1]=new Array('Gibraltar','Sorry.  Gibraltar connects the Atlantic Ocean and the Mediterranean Sea.',0,0,1);
I[12][3][2]=new Array('Turkish Straits','Nope.  These straits connect the Mediterranean Sea and the Black Sea.',0,0,1);
I[12][3][3]=new Array('Malacca','Nope.  This narrow passage between Sicily and Italy is located within the Mediterranean Sea.',0,0,1);
I[12][3][4]=new Array('Hormuz','Sorry.  This is the passage between the Indian Ocean and the Persian Gulf.',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('Oil','Correct.  Both the Venezuelan oil fields and those offshore off of Louisiana and Texas.',1,100,1);
I[13][3][1]=new Array('Gold','Sorry.  Significant amounts of gold have not been found here.',0,0,1);
I[13][3][2]=new Array('Iron','Sorry.  Significant amounts of iron have not been found here.',0,0,1);
I[13][3][3]=new Array('Aluminum','Nope.  Aluminum has not been found in significant quantities here.',0,0,1);
I[13][3][4]=new Array('Aragonite','Nope.  Aragonite has not been found in significant quantities here.',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 U.S. and Mexican Gulf Coasts.','',1,100,1);
I[14][3][1]=new Array('The Mexican and Venezuelan Gulf Coasts.','Sorry.  Venezuela does not catch large amounts of shrimp.',0,0,1);
I[14][3][2]=new Array('The Alaskan Coast','Nope.  Shrimp are not caught off the coast of Alaska.',0,0,1);
I[14][3][3]=new Array('The Northeastern U.S. Seacoast','Sorry.  While lobsters are caught in significant quantities here, shrimp are not.',0,0,1);
I[14][3][4]=new Array('Off the coast of Iceland','Nope.  This is not where they are caught.',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('There are no major U.S. naval bases on the Gulf Coast.','Correct.  Ingleside is the only installation that would fall into the major category.  This is an update from the book, that incorrectly says there are no major U.S. naval bases on the Gulf Coast.',1,100,1);
I[15][3][1]=new Array('Pensacola','Sorry.  Pensacola hosts a naval air station, but not a significant naval base.',0,0,1);
I[15][3][2]=new Array('Mobile','Nope.  There are no significant naval facilities at Mobile.',0,0,1);
I[15][3][3]=new Array('Galveston','Sorry.  Galveston is a major Gulf port, but the U.S. Navy does not have a base there.',0,0,1);
I[15][3][4]=new Array('Tampa','Sorry.  Tampa is a major Gulf port, but the U.S. Navy does not have a base there.',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('Kings Bay','Correct.  This U.S. Navy submarine base is in Georgia, on the Atlantic coast.',1,100,1);
I[16][3][1]=new Array('Guantanamo Bay','Sorry.  The U.S. maintains a key naval base at Guantanamo Bay, Cuba.',0,0,1);
I[16][3][2]=new Array('Pensacola','Nope.  Pensacola is the home of a Naval Air Station.',0,0,1);
I[16][3][3]=new Array('Corpus Christi','Sorry.  Corpus Christi hosts a small naval facility.',0,0,1);
I[16][3][4]=new Array('Roosevelt Roads','Sorry.  The U.S. maintains a key naval base at Roosevelt Roads, Puerto Rico.',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('1999','',1,100,1);
I[17][3][1]=new Array('1990','Sorry.  This wasn\u2019t\' the year.',0,0,1);
I[17][3][2]=new Array('1890','Sorry.  This wasn\u2019t\' the year.',0,0,1);
I[17][3][3]=new Array('1945','Sorry.  This wasn\u2019t\' the year.',0,0,1);
I[17][3][4]=new Array('1978','Sorry.  This wasn\u2019t\' the year.',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 USS Nautilus','',1,100,1);
I[18][3][1]=new Array('The USS Neptune','Sorry.  There wasn\'t a USS Neptune.',0,0,1);
I[18][3][2]=new Array('The USS Ohio','Sorry.  The USS Ohio was the first Trident Submarine, but not the first U.S. Sub to reach the North Pole.',0,0,1);
I[18][3][3]=new Array('The USS Enterprise','Nope.  The USS Enterprise is an aircraft carrier, not a submarine.',0,0,1);
I[18][3][4]=new Array('The USS Scorpion','Nope.  The USS Scorpion was a World War II U.S. Submarine.',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 Black Sea','Correct.  Only the surface layers of this Sea can sustain life.',1,100,1);
I[19][3][1]=new Array('The Red Sea','Nope.  This sea is rich in life and not located near the Mediterranean.',0,0,1);
I[19][3][2]=new Array('The Yellow Sea','Sorry.  This sea is located in the Pacific Ocean near China.',0,0,1);
I[19][3][3]=new Array('The Dead Sea','Nope.  The Dead Sea, located in Israel, does not have excessively high mineral content.',0,0,1);
I[19][3][4]=new Array('The Sea of Marmara','Sorry.  The Sea of Marmara, located between the Black Sea and the Mediterranean Sea, does not have a high mineral content.',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('Gaeta, Italy','Right.  About halfway between Naples and Rome.',1,100,1);
I[20][3][1]=new Array('Naples, Italy','Sorry.  It is close to Naples, but further up the Italian coast.',0,0,1);
I[20][3][2]=new Array('Norfolk, Virginia','Nope.  The U.s. Sixth Fleet is located within the Mediterranean Sea.',0,0,1);
I[20][3][3]=new Array('Izmir, Turkey','Nope.  While a major base is located here, this is not the homeport of the Sixth Fleet.',0,0,1);
I[20][3][4]=new Array('Toulon, France','Sorry.  This is the major French Mediterranean naval base.',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('It destroyed the fishing industry at the mouth of the Nile river.','Correct.  An industry that had been around since the very start of civilization was ended.',1,100,1);
I[21][3][1]=new Array('It caused the fishing industry off the coast of Egypt to flourish.','Nope.  Quite the opposite.',0,0,1);
I[21][3][2]=new Array('It had no effect one way or another.','Sorry.  It did have a quick and significant impact.',0,0,1);
I[21][3][3]=new Array('It caused the mineral content of the Mediterranean Sea to double.','Nope.  Mineral levels did not change greatly.',0,0,1);
I[21][3][4]=new Array('It greatly reduced the mineral content of the Mediterranean Sea.','Sorry.  It did not have an effect on mineral levels.',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 Suez canal','',1,100,1);
I[22][3][1]=new Array('The Panama canal','Nope.  The Panama canal is located in Central America.``',0,0,1);
I[22][3][2]=new Array('The Dead Sea','Sorry.  This isn\'t the waterway.',0,0,1);
I[22][3][3]=new Array('The Black Sea','Nope.  The Black Sea is located North of Turkey.',0,0,1);
I[22][3][4]=new Array('The Sea of Marmara','Nope.  The Sea of Marmara connects the Black Sea and the Mediterranean Sea.',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 Eastern and Western','',1,100,1);
I[23][3][1]=new Array('The Northern and Southern','Nope.  These aren\'t the two.',0,0,1);
I[23][3][2]=new Array('The Eastern and Southern','Sorry.  One right, one wrong.',0,0,1);
I[23][3][3]=new Array('The Northern and Western','Sorry.  One right, one wrong.',0,0,1);
I[23][3][4]=new Array('The Lower and Upper','Nope.  These aren\'t the two.',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('Bremerhaven','Correct.  The other port is Antwerp.',1,100,1);
I[24][3][1]=new Array('Murmansk','Nope.  Murmansk is an important Russian North Seas Fleet port.',0,0,1);
I[24][3][2]=new Array('Liverpool','Sorry.  Liverpool is in England and too far away to provide support for U.S. forces in Germany.',0,0,1);
I[24][3][3]=new Array('Riga','Sorry.  While a significant Baltic Sea port, Riga is not used to support U.S. forces in Germany.',0,0,1);
I[24][3][4]=new Array('Toulon','Sorry.  Toulon is an important French Naval base in the Mediterranean.',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('Cuba','Right.  the communist government of Fidel Castro has been at odds with the U.S. for over 40 years.',1,100,1);
I[25][3][1]=new Array('Puerto Rico','Nope.  Puerto Rico is a U.S. territory.',0,0,1);
I[25][3][2]=new Array('Grenada','Sorry.  While the site of a brief U.S. action in the 1980\'s, Grenada hasn\'t played an important role since.',0,0,1);
I[25][3][3]=new Array('The Dominican Republic','Nope.  This was a problem area in the early 1960\'s, but not since.',0,0,1);
I[25][3][4]=new Array('Jamaica','Sorry.  Jamaica hasn\'t been a significant problem for the U.S.',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('Arctic','Right.  Only just over 4,7000,000 square miles.',1,100,1);
I[26][3][1]=new Array('Atlantic','Nope.  The Atlantic is not the largest, but not the smallest either.',0,0,1);
I[26][3][2]=new Array('Pacific','Sorry.  The Pacific is the largest.',0,0,1);
I[26][3][3]=new Array('Indian','Sorry.  There is another one smaller than the Indian Ocean.',0,0,1);
I[26][3][4]=new Array('Antarctic','Nope.  There is no such thing as an Antarctic Ocean.',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('Arctic','Correct.  Just above Alaska and Canada.',1,100,1);
I[27][3][1]=new Array('Pacific','Nope.  It isn\'t in the Pacific.',0,0,1);
I[27][3][2]=new Array('Atlantic','Nope.  It isn\'t in the Atlantic.',0,0,1);
I[27][3][3]=new Array('Indian','Nope.  It isn\'t in the Indian.',0,0,1);
I[27][3][4]=new Array('Antarctic','Nope.  There is no such thing as an Antarctic Ocean.',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('The Gulf of Alaska','Right.  Off of the port of Valdez in 1989.',1,100,1);
I[28][3][1]=new Array('The Persian Gulf','Nope.  This is an area of high oil tanker traffic, but not the site of this spill.',0,0,1);
I[28][3][2]=new Array('The Gulf of Sidra','Sorry.  The Gulf of Sidra is off the coast of Libya and was not the site of this disaster.',0,0,1);
I[28][3][3]=new Array('The Gulf of Mexico','Sorry.  This spill was not located here.',0,0,1);
I[28][3][4]=new Array('The Gulf of Aden','Sorry.  It wasn\'t in the Gulf of Aden.',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('Greenland and Canada','',1,100,1);
I[29][3][1]=new Array('The U.S. and Russia','Sorry.  Baffin Bay lies in the Atlantic Ocean.',0,0,1);
I[29][3][2]=new Array('Greenland and Iceland','Nope.  But your close.',0,0,1);
I[29][3][3]=new Array('Canada and the U.S.','Sorry.  You have one of the countries right.',0,0,1);
I[29][3][4]=new Array('Mexico and the U.S.','Nope.  This is way too far south.',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('The Hellenic Trough','',1,100,1);
I[30][3][1]=new Array('The Abyssal Plain','Sorry.  This plain is located in the Arctic Ocean.',0,0,1);
I[30][3][2]=new Array('The Cayman Trench','Nope.  This trench is located in the Caribbean Sea.',0,0,1);
I[30][3][3]=new Array('The Puerto Rico Trench','Sorry.  This trench is located in the Atlantic Ocean.',0,0,1);
I[30][3][4]=new Array('The South Sandwich Trench','Sorry.  This trench is located in the Southern Atlantic Ocean.',0,0,1);
I[31]=new Array();I[31][0]=100;
I[31][1]='';
I[31][2]='0';
I[31][3]=new Array();
I[31][3][0]=new Array('Because the Russian Northern Fleet would need to go through this area to get to the Atlantic sealanes.','Correct.  NATO forces would likely have to fight in these waters.',1,100,1);
I[31][3][1]=new Array('Because they would need to take large amphibious forces through these waters.','Nope.  Amphibious landings north of these waters would not be anticipated.',0,0,1);
I[31][3][2]=new Array('Because it is the deepest part of the Atlantic ocean.','Sorry.  It isn\'t.',0,0,1);
I[31][3][3]=new Array('Because of the large number of Russian naval ports in this area.','Sorry.  These countries are members of NATO.',0,0,1);
I[31][3][4]=new Array('This gap is not of importance to NATO planners.','Nope.  It plays in significantly to NATO war plans.',0,0,1);
I[32]=new Array();I[32][0]=100;
I[32][1]='';
I[32][2]='0';
I[32][3]=new Array();
I[32][3][0]=new Array('Martinique','',1,100,1);
I[32][3][1]=new Array('Puerto Rico','Sorry.  It isn\'t on Puerto Rico.',0,0,1);
I[32][3][2]=new Array('Cuba','Nope.  It\'s not on Cuba.',0,0,1);
I[32][3][3]=new Array('Grenada','Sorry.  It isn\'t on Grenada.',0,0,1);
I[32][3][4]=new Array('Haiti','Nope.  It\'s not on Haiti.',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);
	}
}










//-->

//]]>


