

//<![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('START II','Correct.  Its terms called for both sides to reduce long-range nuclear arsenals to between 3,000 to 3,500 warheads.',1,100,1);
I[0][3][1]=new Array('START I','Nope.  This was a more limited agreement signed with the Soviet Union during the Cold War.',0,0,1);
I[0][3][2]=new Array('START III','Sorry.  There hasn\'t been a START III treaty.',0,0,1);
I[0][3][3]=new Array('The Nuclear Non-proliferation Treaty','Nope.  This was another agreement signed by all the nuclear powers of the world.',0,0,1);
I[0][3][4]=new Array('The Nuclear Nonaggression Pact','Nope.  No such pact exists.',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 Czech Republic, Hungary, and Poland ','Right.  This would have been unthinkable just 10 years before.',1,100,1);
I[1][3][1]=new Array('The Czech Republic, Bulgaria and Poland','Nope.  Bulgaria was not offered membership.',0,0,1);
I[1][3][2]=new Array('Bulgaria, Poland and Hungary','Nope.  Bulgaria was not offered membership.',0,0,1);
I[1][3][3]=new Array('Hungary, Bulgaria and the Czech Republic','Nope.  Bulgaria was not offered membership.',0,0,1);
I[1][3][4]=new Array('Bulgaria, Albania and Poland','Nope.  Bulgaria  and Albania were not offered membership.',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 invasion of Kuwait by Iraq.','Right.  This led to the U.S.-led coalition to oust Iraq from Kuwait.',1,100,1);
I[2][3][1]=new Array('The invasion of Saudi Arabia by Iraq.','Nope.  Except for a small incursion in a Saudi border town, Saudi Arabia did not get invaded.',0,0,1);
I[2][3][2]=new Array('The invasion of Iran by Iraq.','Nope.  This was the cause of the Iran - Iraq War in the 1980\'s.',0,0,1);
I[2][3][3]=new Array('The invasion of Turkey by Iraq.','Nope.  This never happened.',0,0,1);
I[2][3][4]=new Array('The invasion of Iraq by Kuwait.','Nope.  Kuwait had a very small army and could not have mounted such an invasion.',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('Desert Shield','Correct.  These forces were the "Shield" of Saudi Arabia.',1,100,1);
I[3][3][1]=new Array('Desert Storm','Nope.  This was the name of the actual conflict.',0,0,1);
I[3][3][2]=new Array('Desert Blitz','Nope.  This was not the name.',0,0,1);
I[3][3][3]=new Array('Vigilant Warrior','Nope.  This limited operation occurred about three years later.',0,0,1);
I[3][3][4]=new Array('','Nope.  This was not the name.',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('Maritime Sealift','Correct.  As was the case in World Wars I and II, as well as Korea and Vietnam, Maritime Sealift far and away provided the bulk of military supplies.',1,100,1);
I[4][3][1]=new Array('Heavy Lift Air Force aircraft','Sorry.  Air Force transport aircraft brought a large number of troops but only a small fraction of the supplies and equipment.',0,0,1);
I[4][3][2]=new Array('Railroad cars from Israel','Nope.  This wasn\'t an option and did not happen.',0,0,1);
I[4][3][3]=new Array('The troops themselves on transport ships.','Sorry.  The amount of supplies and equipment carried by the troops was very small.',0,0,1);
I[4][3][4]=new Array('The Aircraft Carriers sent to the region.','Nope.  Transportation of equipment and supplies for the Army is not one of the jobs of an Aircraft Carrier.',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('To prevent the suppression of ethnic Shiite Moslems in southern Iraq.','Correct.  Iraq was using helicopters and jets to punish the Shiites for their lack of support during Desert Storm.',1,100,1);
I[5][3][1]=new Array('To hurt the Iraqi economy by ending their commercial flights','Nope.  This was never a large part of the Iraqi economy.',0,0,1);
I[5][3][2]=new Array('To ensure that friendly aircraft would not be shot down.','Sorry.  The Iraqi\'s then and now attempt to shoot down Allied aircraft in the no-fly zone.',0,0,1);
I[5][3][3]=new Array('To permanently ground the aircraft at airbases in the south.','Nope.  Iraq moved those aircraft to bases farther north and continued to fly them.',0,0,1);
I[5][3][4]=new Array('To prevent the Iraqi military from using the bombing ranges in the south for training.','Nope.  This was not the reason the no-fly zone was imposed.',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('For economic reasons and due to cultural and ethnic differences.','Correct.  The Ethnic differences, in particular, fueled the various wars in the Balkans over the next 5  years.',1,100,1);
I[6][3][1]=new Array('Due to pressure from the Russian Republic.','Nope.  Russia did not destabilize the region.',0,0,1);
I[6][3][2]=new Array('Due to pressure from the United States.','Sorry.  The U.S. only became involved after the problems began.',0,0,1);
I[6][3][3]=new Array('Due to pressure from Italy.','Sorry.  Italy did nothing to start the breakup of Yugoslavia.',0,0,1);
I[6][3][4]=new Array('Because of communist agitation in many of the Republics.','Nope.  This did not happen.',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('October 1992','Correct.  This had more of an impact than the economic sanctions tried earlier.',1,100,1);
I[7][3][1]=new Array('April 1992','Nope.  Right year, wrong month.',0,0,1);
I[7][3][2]=new Array('October 1994','Sorry.  Right month, wrong year.',0,0,1);
I[7][3][3]=new Array('April 1994','Sorry.  Wrong on both counts.',0,0,1);
I[7][3][4]=new Array('July, 1993','Nope.  Wrong on both counts.',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('Somalia','Right.  This was as a part of the UN relief effort Operation Restore Hope.',1,100,1);
I[8][3][1]=new Array('Egypt','Nope.  The U.s. maintained friendly relations with Egypt throughout this period.',0,0,1);
I[8][3][2]=new Array('Syria','Nope.  While not a friendly nation, Syria was not the site of U.S. military action in the 1990s.',0,0,1);
I[8][3][3]=new Array('Yemen','Nope.  The U.S. had friendly relations with Yemen in the 1990\'s.',0,0,1);
I[8][3][4]=new Array('Morocco','Nope.  There were no U.S. actions involving Morocco in the 1990\'s.',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('Somalia','Right.  Designed to bring aid to the people of Somalia, it became a quagmire for U.S. troops.',1,100,1);
I[9][3][1]=new Array('Iraq','Nope.  Iraq has had many operations directed against it, but this was not one of them.',0,0,1);
I[9][3][2]=new Array('Iran','Nope.  That isn\'t the place.',0,0,1);
I[9][3][3]=new Array('Saudi Arabia','Sorry.  you\'re thinking of Operation Desert Shield.',0,0,1);
I[9][3][4]=new Array('Egypt','Nope.  We haven\'t had any operations against Egypt.',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('India and Pakistan each exploded nuclear test devices.','Correct.  This raised the stakes in this part of the world since these two countries are traditional enemies.',1,100,1);
I[10][3][1]=new Array('When Middle Eastern terrorists made off with 100lb of nuclear material from Russia.','Nope.  This never happened.',0,0,1);
I[10][3][2]=new Array('when Israel announced that it had acquired nuclear weapons.','Sorry.  While believed to have nuclear weapons, Israel has never publicly confirmed this.',0,0,1);
I[10][3][3]=new Array('The sale of a small nuclear device to a Columbian drug lord.','Nope.  This never happened.',0,0,1);
I[10][3][4]=new Array('The joint announcement by the U.S. and Russia that some 500 lbs of nuclear material was unaccounted for world-wide.','Nope.  This never happened.',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('Kenya and Tanzania ','Correct.  Terrorists targeted these embassies due to lax security and the ease of moving in these countries.',1,100,1);
I[11][3][1]=new Array('Lebanon and Israel','Nope.  Our embassies in these countries were not attacked.',0,0,1);
I[11][3][2]=new Array('Yemen and Somalia','Sorry.  The U.S. does not have an embassy in Somalia.',0,0,1);
I[11][3][3]=new Array('Cuba and Egypt','Nope.  The U.S. does not have an embassy in Cuba.',0,0,1);
I[11][3][4]=new Array('Libya and Pakistan','Sorry.   Our embassies in these countries were not attacked.',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('Afghanistan and Sudan ','Correct.  Terrorist training camps in Afghanistan and a chemical production facility in Sudan were targeted.',1,100,1);
I[12][3][1]=new Array('Afghanistan and Iraq','Nope.  One of them was targeted, but not the other.',0,0,1);
I[12][3][2]=new Array('Afghanistan and Iran','Nope.  One of them was targeted, but not the other.',0,0,1);
I[12][3][3]=new Array('Iraq and Iran','Sorry.  Neither of these countries were targeted.',0,0,1);
I[12][3][4]=new Array('Somalia and Sudan','Nope.  One of them was targeted, but not the other.',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 USS Cole','Correct.  A small boat full of explosives was brought alongside and detonated, tearing a large hole in the USS Cole.',1,100,1);
I[13][3][1]=new Array('The USS Samuel Gompers','Nope.  This wasn\'t the ship.',0,0,1);
I[13][3][2]=new Array('The USS Enterprise','Nope.  This wasn\'t the ship.',0,0,1);
I[13][3][3]=new Array('The USS Bristol Bay','Nope.  This wasn\'t the ship.',0,0,1);
I[13][3][4]=new Array('The USS The Sullivans','Nope.  This wasn\'t the ship.',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 bombing of the Federal building in Oklahoma City.','Right.  Terrorists aren\'t always from other lands, as this incident proves.',1,100,1);
I[14][3][1]=new Array('The first bombing of the World Trade Center.','Nope.  This incident occurred earlier.',0,0,1);
I[14][3][2]=new Array('The destruction of the World Trade Center.','Nope.  This occurred on Sept. 11, 2001.',0,0,1);
I[14][3][3]=new Array('The bombing of the USS Cole in Yemen.','Nope.  This incident occurred in August of 2000.',0,0,1);
I[14][3][4]=new Array('The bombing of the American embassies in Kenya and Tanzania.','Sorry.  This occurred in 1998.',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('Operation Noble Eagle','Correct.  This operation was primarily carried out by Air National Guard units and Reservists.',1,100,1);
I[15][3][1]=new Array('Operation Vigilant Warrior','Nope.  This was a minor operation against Iraq in 1995.',0,0,1);
I[15][3][2]=new Array('Operation Careful Watch','Nope.  I just made this up.',0,0,1);
I[15][3][3]=new Array('Operation Anaconda','Sorry.  This was one of the many operations against the terrorist organizations in Afghanistan.',0,0,1);
I[15][3][4]=new Array('Operation Just Cause','Sorry.  This was the code name for the U.S. invasion of Panama.',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('Al Qaida ','Correct. While once based in Afghanistan, Al Qaida has cells in countries throughout the world.',1,100,1);
I[16][3][1]=new Array('The Taliban','Sorry.  The Taliban were the ruling party in Afghanistan before the U.S.-led forces drove them out of power.',0,0,1);
I[16][3][2]=new Array('The Red Brigade','Nope.  These is an Italian terrorist organization.',0,0,1);
I[16][3][3]=new Array('The Shining Path','Sorry.  This is a South American terrorist group.',0,0,1);
I[16][3][4]=new Array('The IRA','Nope.  This is an Irish terrorist group.',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('Afghanistan','Correct.  This was the operation launched in the wake of September 11 to drive the Taliban and Al Qaida from power.',1,100,1);
I[17][3][1]=new Array('Iraq','Nope.  This country wasn\'t the target of this operation.',0,0,1);
I[17][3][2]=new Array('Somalia','Nope.  This country wasn\'t the target of this operation.',0,0,1);
I[17][3][3]=new Array('Iran','Nope.  This country wasn\'t the target of this operation.',0,0,1);
I[17][3][4]=new Array('Serbia','Nope.  This country wasn\'t the target of this operation.',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 Northern Alliance','Correct.  This group of anti-Taliban fighters were already established on the ground and moved forward under the cover of U.S. air support.',1,100,1);
I[18][3][1]=new Array('The U.S. Army','Nope.  Army elements were not in place yet.',0,0,1);
I[18][3][2]=new Array('The U.S. Marine Corps','Sorry.  the Marines would see their share of fighting, but this would be after the Taliban were defeated.',0,0,1);
I[18][3][3]=new Array('The Afghanistan National Army','Sorry.  There was not such organization.',0,0,1);
I[18][3][4]=new Array('The Taliban','Nope.  The Taliban were the enemy in this fight.',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('300 and 370,000','Correct.  The Navy is much leaner than during the Vietnam days, but it is also far more capable and far-reaching.',1,100,1);
I[19][3][1]=new Array('1,000 and 600,000','Nope.  These were the figures for the Vietnam War period.',0,0,1);
I[19][3][2]=new Array('600 and 650,000','Sorry.  This was the target during the push at the end of the 1980\'s.',0,0,1);
I[19][3][3]=new Array('350 and 400,000','Nope.  but close.',0,0,1);
I[19][3][4]=new Array('450 and 325,000','Sorry.  Fewer ships and more people.',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('Land-based multiple-warhead missiles.','Excellent.  Sea-based multiple-warhead missiles are still allowed.',1,100,1);
I[20][3][1]=new Array('Sea-based multiple-warhead missiles.','Sorry.  These are still a main part of both the Russian and U.S. nuclear inventory.',0,0,1);
I[20][3][2]=new Array('Space-based nuclear weapons.','Nope.  Space-based nuclear were banned by earlier treaties between the USSR and the U.S.',0,0,1);
I[20][3][3]=new Array('Aircraft-launched nuclear weapons.','Sorry.  These are still a part of both countries\' inventory.',0,0,1);
I[20][3][4]=new Array('Terrorist-delivered nuclear weapons.','Nope.  No such weapons exist in the inventories of Russia and the U.S.',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('Kuwait quickly fell to the Iraqi Army.','Excellent!  The Kuwaiti Army fought  as well as they could, but they were no match for the much larger Iraqi Army.',1,100,1);
I[21][3][1]=new Array('Kuwaiti Armed Forces quickly threw back the invading Iraqi Armies.','Sorry.  Despite a determined attempt at defense, the Kuwati Armed Forces could not stand up to the Iraqi Army.',0,0,1);
I[21][3][2]=new Array('Kuwati and U.S. Armed Forces were able to slowly push the Iraqi Army back into Iraq.','Nope.  The U.S. did not have forces in Kuwait at this time.',0,0,1);
I[21][3][3]=new Array('United Nations Armed Forces first fell back and then slowly recaptured Kuwait.','Nope.  The UN did not have forces in Kuwait at this time.',0,0,1);
I[21][3][4]=new Array('Iraq quickly took Kuwait and then moved its troops back into Iraq.','Sorry.  While Kuwait was quickly taken, Iraqi troops did not move back into Iraq.',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('Operation Desert Storm','Right.  Launched on 16 January, 1991.',1,100,1);
I[22][3][1]=new Array('Operation Desert Shield','Sorry.  This was the code name for the build up of UN coalition forces to protect Saudi Arabia.',0,0,1);
I[22][3][2]=new Array('Operation Desert Attack','Nope.  There was no operation by this name.',0,0,1);
I[22][3][3]=new Array('Operation Desert Retreat','Nope.  There was no operation by this name.',0,0,1);
I[22][3][4]=new Array('Operation Southern Watch','Sorry.  This is the code name for the on-going operation to patrol the UN established no-fly zones over Southern Iraq.',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('Albania','Right.  Albania was never a part of Yugoslavia.  ',1,100,1);
I[23][3][1]=new Array('Slovenia','Nope.  Slovenia was one of the six republics.',0,0,1);
I[23][3][2]=new Array('Croatia','Sorry.  Croatia was one of the six republics and was actively involved in the fighting during the Civil War that followed.',0,0,1);
I[23][3][3]=new Array('Bosnia-Herzegovina','Sorry.  Bosnia-Herzegovina was one of the six republics and was actively involved in the fighting during the Civil War that followed.',0,0,1);
I[23][3][4]=new Array('Serbia','Nope.  Serbia was one of the primary republics of Yugoslavia.',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('Operation Deliberate Force','Right.  This came in response to the Serb military\'s violation of the UN-mandated "protected status" of Sarajevo and other Bosnian cities.',1,100,1);
I[24][3][1]=new Array('Operation Desert Storm','Sorry.  This was the UN operation to drive Iraqi forces out of Kuwait in 1991.',0,0,1);
I[24][3][2]=new Array('Operation Desert Shield','Nope.  This was the code name for the build up of UN forces in Saudi Arabia to protect that country from invasion from Iraq.',0,0,1);
I[24][3][3]=new Array('Operation Vigilant Warrior','Sorry.  This was a short-lived mobilization of U.S. forces to counter the threat of an Iraqi build up of forces along its border with Kuwait in 1995.',0,0,1);
I[24][3][4]=new Array('Operation Bosnian Shield','Nope.  There was never an operation by this name.',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('Liberia','Excellent.  Unrest and rebellion in this country threatened U.S. citizens and embassy personnel.',1,100,1);
I[25][3][1]=new Array('Congo','Nope.  U.S. Marines were not deployed to the Congo in 1996.',0,0,1);
I[25][3][2]=new Array('Algeria','Nope.  U.S. Marines were not deployed to the Algeria in 1996.',0,0,1);
I[25][3][3]=new Array('Egypt','Sorry.  Egypt was not the site of the unrest in 1996.',0,0,1);
I[25][3][4]=new Array('Somalia','Sorry.  U.S. forces were out of Somalia before 1996.',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('China','Correct.  The U.S. Navy P-3 was forced to land at Hainan Island, south of mainland China.',1,100,1);
I[26][3][1]=new Array('Russia','Sorry.  Although Navy reconnaissance aircraft do fly in international waters off of Russia, this wasn\'t where the incident occurred.',0,0,1);
I[26][3][2]=new Array('India','Nope.  The Navy doesn\'t fly reconnaissance missions routinely off of the Indian coast.',0,0,1);
I[26][3][3]=new Array('North Korea','Sorry.  While reconnaissance missions are flown off North Korea, this isn\'t where the incident occurred.',0,0,1);
I[26][3][4]=new Array('Iraq','Nope.  We were obviously watching Iraq closely at this time, but this incident didn\'t happen off of Iraq.',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('The destruction of the World Trade Center.','Right.  This incident began the U.S. War on Terror that continues through today.',1,100,1);
I[27][3][1]=new Array('The bombing of the Federal building in Oklahoma City.','Nope. This occurred in April, 1995.',0,0,1);
I[27][3][2]=new Array('The first bombing of the World Trade Center.','Sorry.  This occurred in the early 1990\'s.',0,0,1);
I[27][3][3]=new Array('The bombing of the USS Cole in Yemen.','Nope.  This occurred in August, 2000.',0,0,1);
I[27][3][4]=new Array('The bombing of the American embassies in Kenya and Tanzania.','Sorry.  This occurred in August 1998.',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('Anthrax','Right!  This and other mailings caused 22 cases of anthrax infection.',1,100,1);
I[28][3][1]=new Array('Small Pox','Sorry.  This is a deadly biological agent and a current worry, but this wasn\'t the type of virus spore used.',0,0,1);
I[28][3][2]=new Array('Malaria','Nope.  This is not a biological agent and is not transmitted via spores.',0,0,1);
I[28][3][3]=new Array('Black Plague','Nope.  This disease is not transmitted via spores.',0,0,1);
I[28][3][4]=new Array('Chicken Pox','Sorry.  This is not a dangerous disease to most people and is not transmitted via spores.',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('The Vietnam War','Correct.  Nearly 1,000 ships and 600,000 people in Navy uniforms.',1,100,1);
I[29][3][1]=new Array('The Korean War','Nope.  This was not the high point in Navy numbers in the last part of the 20th century.',0,0,1);
I[29][3][2]=new Array('Operation Desert Storm','Sorry.  While larger than today, the numbers of ships and personnel during this time were not the highest in the period after World War II.',0,0,1);
I[29][3][3]=new Array('Operation Enduring Freedom','Nope.  This wasn\'t the high point in terms of numbers of ships and personnel',0,0,1);
I[29][3][4]=new Array('The Invasion of Panama','Sorry.  This wasn\'t the high point for the Navy in terms of numbers of ships and personnel.',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('Mohammed Siad Barre','Excellent.  Mohammed Siad Barre died on January 2nd, 1995.',1,100,1);
I[30][3][1]=new Array('Mohammed Atta','Nope.  He was one of the leaders of the 911 Terrorists.',0,0,1);
I[30][3][2]=new Array('Saddam Hussein','Sorry.  Hussein is (was) the leader of Iraq.',0,0,1);
I[30][3][3]=new Array('Boris Yeltsin','Sorry.  Yeltsin was the first President of the Russian Republic following the fall of the Soviet Union.',0,0,1);
I[30][3][4]=new Array('Osama bin Laden','Nope.  bin Laden is the head of the terrorist al-Qaida organization.',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('Russia','Excellent.  Russia still desires to either enter NATO or form a closer alliance with it.',1,100,1);
I[31][3][1]=new Array('The Czech Republic','Nope.  The Czech Republic became a member of NATO in 1999.',0,0,1);
I[31][3][2]=new Array('Hungary','Nope.  Hungary became a member of NATO in 1999.',0,0,1);
I[31][3][3]=new Array('Poland','Sorry.  Poland became a member of NATO in 1999 and even bought F-16 fighters in December, 2002.',0,0,1);
I[31][3][4]=new Array('All of the listed countries were allowed to join NATO in 1999.','Sorry.  One of the four listed countries did not join in 1999.',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('Saudi Arabia','Excellent.  Iraq even made a small raid across the Saudi Arabian border in 1990, making the threat of an invasion more credible.',1,100,1);
I[32][3][1]=new Array('The United States','Nope.  The U.S. did not need UN protection from Iraq.',0,0,1);
I[32][3][2]=new Array('Iran','Sorry.  Iraq and Iran had fought a bitter war in the 1980\'s, but Iran was not the country that called for UN protection in 1990.',0,0,1);
I[32][3][3]=new Array('Turkey','Sorry.  Turkey was worried about Iraq, but did not expect Iraq to invade.',0,0,1);
I[32][3][4]=new Array('Bahrain','Nope.  Bahrain was worried about Iraq, but was not the country that called for protection.',0,0,1);
I[33]=new Array();I[33][0]=100;
I[33][1]='';
I[33][2]='0';
I[33][3]=new Array();
I[33][3][0]=new Array('Operation Desert Storm','Excellent!  The build-up alone required 6-months.',1,100,1);
I[33][3][1]=new Array('Operation Enduring Freedom','Nope.  This was a large operation, but not the largest.',0,0,1);
I[33][3][2]=new Array('Operation Noble Eagle','Sorry.  This mobilization of U.S. forces for Homeland Security was not a air and ground offensive.',0,0,1);
I[33][3][3]=new Array('Operation Deliberate Force','Sorry.  While a large and significant operation, this was not the largest.',0,0,1);
I[33][3][4]=new Array('Operation Vigilant Warrior','Nope.  This was not an air and ground offensive action.',0,0,1);
I[34]=new Array();I[34][0]=100;
I[34][1]='';
I[34][2]='0';
I[34][3]=new Array();
I[34][3][0]=new Array('An embargo on weapons and oil.','Correct.  This proved to be ineffective.',1,100,1);
I[34][3][1]=new Array('Bombing of the key cities of Srebrenica and Zepa.','Nope.  These two cities were actually UN protected cities later overrun by Serb forces.',0,0,1);
I[34][3][2]=new Array('Amphibious landings of UN forces in Croatia.','Nope.  This never happened.',0,0,1);
I[34][3][3]=new Array('U.S. Navy TLAM missile strikes into the capital of Yugoslavia.','Nope.  This never happened.',0,0,1);
I[34][3][4]=new Array('Naval gunfire bombardments into coastal towns and military facilities in Bosnia.','Sorry.  This never happened.',0,0,1);
I[35]=new Array();I[35][0]=100;
I[35][1]='';
I[35][2]='0';
I[35][3]=new Array();
I[35][3][0]=new Array('Dayton, Ohio','Excellent!  These were called the Dayton Peace Accords, after the city where they were signed',1,100,1);
I[35][3][1]=new Array('Paris, France','Nope.  Although many peace treaties have been signed in Paris over the years, this wasn\'t one of them.',0,0,1);
I[35][3][2]=new Array('Washington, D.C.','Sorry.  It wasn\'t signed in Washington D.C.',0,0,1);
I[35][3][3]=new Array('New York City, New York','Nope.  Not in New York City either!',0,0,1);
I[35][3][4]=new Array('Sarajevo, Bosnia-Herzegovina','Sorry.  While Sarajevo was at the very center of this conflict, the peace treaty was not signed here.',0,0,1);
I[36]=new Array();I[36][0]=100;
I[36][1]='';
I[36][2]='0';
I[36][3]=new Array();
I[36][3][0]=new Array('South America','Right!  In particular, the nation of Columbia.',1,100,1);
I[36][3][1]=new Array('Africa','Nope.  Significant amounts of drugs were not smuggled to the U.S. from Africa at this time.',0,0,1);
I[36][3][2]=new Array('Europe','Sorry.  Europe was not a major source of illegal drugs to the U.S. in the 1990\'s.',0,0,1);
I[36][3][3]=new Array('Canada','Sorry.  Canada was not the focal point for the main U.S. efforts against illegal drugs.',0,0,1);
I[36][3][4]=new Array('Asia','Nope.  While Asia is a significant producer of illegal drugs, it was not the main focal point for U.S. counterdrug efforts during the 1990\'s.',0,0,1);
I[37]=new Array();I[37][0]=100;
I[37][1]='';
I[37][2]='0';
I[37][3]=new Array();
I[37][3][0]=new Array('Las Vegas','Right.  This brought about a increased focus on sexual harassment training within the Navy.',1,100,1);
I[37][3][1]=new Array('New Orleans','Sorry.  This isn\'t the city.',0,0,1);
I[37][3][2]=new Array('New York','Nope.  It wasn\'t New York.',0,0,1);
I[37][3][3]=new Array('Seattle','Sorry.  It wasn\'t in Seattle.',0,0,1);
I[37][3][4]=new Array('Reno','Nope.  But you are close.',0,0,1);
I[38]=new Array();I[38][0]=100;
I[38][1]='';
I[38][2]='0';
I[38][3]=new Array();
I[38][3][0]=new Array('Four','Correct.  Two hit the twin towers, one hit the Pentagon and the other crashed in a field in western Pennsylvania.',1,100,1);
I[38][3][1]=new Array('Three','Nope.  There were more than three.',0,0,1);
I[38][3][2]=new Array('Five','Sorry.  Not that many.',0,0,1);
I[38][3][3]=new Array('Two','Nope.  There were more than the two that hit the World Trade Center.',0,0,1);
I[38][3][4]=new Array('Six','Sorry.  Not that many.',0,0,1);
I[39]=new Array();I[39][0]=100;
I[39][1]='';
I[39][2]='0';
I[39][3]=new Array();
I[39][3][0]=new Array('Afghanistan','Correct.  The Taliban government provided direct support for this organization.',1,100,1);
I[39][3][1]=new Array('Somalia','Sorry.  While there is evidence of al-Qaida presence in Somalia, this was not the main location of the terrorist group.',0,0,1);
I[39][3][2]=new Array('Sudan','Sorry.  While there is evidence of significant al-Qaida presence and training in the Sudan, this was not the main location of the terrorist group.',0,0,1);
I[39][3][3]=new Array('Egypt','Nope.  There were no State-sponsored al-Qaida organizations within Egypt.',0,0,1);
I[39][3][4]=new Array('Syria','Sorry.  While it has been speculated that Syria supported al-Qaida, this was not the prime location of the organization at the time of the attacks.',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);
	}
}










//-->

//]]>


