

//<![CDATA[

<!--


function Client(){
//if not a DOM browser, hopeless
	this.min = false; if (document.getElementById){this.min = true;};

	this.ua = navigator.userAgent;
	this.name = navigator.appName;
	this.ver = navigator.appVersion;  

//Get data about the browser
	this.mac = (this.ver.indexOf('Mac') != -1);
	this.win = (this.ver.indexOf('Windows') != -1);

//Look for Gecko
	this.gecko = (this.ua.indexOf('Gecko') > 1);
	if (this.gecko){
		this.geckoVer = parseInt(this.ua.substring(this.ua.indexOf('Gecko')+6, this.ua.length));
		if (this.geckoVer < 20020000){this.min = false;}
	}
	
//Look for Firebird
	this.firebird = (this.ua.indexOf('Firebird') > 1);
	
//Look for Safari
	this.safari = (this.ua.indexOf('Safari') > 1);
	if (this.safari){
		this.gecko = false;
	}
	
//Look for IE
	this.ie = (this.ua.indexOf('MSIE') > 0);
	if (this.ie){
		this.ieVer = parseFloat(this.ua.substring(this.ua.indexOf('MSIE')+5, this.ua.length));
		if (this.ieVer < 5.5){this.min = false;}
	}
	
//Look for Opera
	this.opera = (this.ua.indexOf('Opera') > 0);
	if (this.opera){
		this.operaVer = parseFloat(this.ua.substring(this.ua.indexOf('Opera')+6, this.ua.length));
		if (this.operaVer < 7.04){this.min = false;}
	}
	if (this.min == false){
		alert('Your browser may not be able to handle this page.');
	}
	
//Special case for the horrible ie5mac
	this.ie5mac = (this.ie&&this.mac&&(this.ieVer<6));
}

var C = new Client();

//for (prop in C){
//	alert(prop + ': ' + C[prop]);
//}



//CODE FOR HANDLING NAV BUTTONS AND FUNCTION BUTTONS

//[strNavBarJS]
function NavBtnOver(Btn){
	if (Btn.className != 'NavButtonDown'){Btn.className = 'NavButtonUp';}
}

function NavBtnOut(Btn){
	Btn.className = 'NavButton';
}

function NavBtnDown(Btn){
	Btn.className = 'NavButtonDown';
}
//[/strNavBarJS]

function FuncBtnOver(Btn){
	if (Btn.className != 'FuncButtonDown'){Btn.className = 'FuncButtonUp';}
}

function FuncBtnOut(Btn){
	Btn.className = 'FuncButton';
}

function FuncBtnDown(Btn){
	Btn.className = 'FuncButtonDown';
}

function FocusAButton(){
	if (document.getElementById('CheckButton1') != null){
		document.getElementById('CheckButton1').focus();
	}
	else{
		if (document.getElementById('CheckButton2') != null){
			document.getElementById('CheckButton2').focus();
		}
		else{
			document.getElementsByTagName('button')[0].focus();
		}
	}
}




//CODE FOR HANDLING DISPLAY OF POPUP FEEDBACK BOX

var topZ = 1000;

function ShowMessage(Feedback){
	var Output = Feedback + '<br /><br />';
	document.getElementById('FeedbackContent').innerHTML = Output;
	var FDiv = document.getElementById('FeedbackDiv');
	topZ++;
	FDiv.style.zIndex = topZ;
	FDiv.style.top = TopSettingWithScrollOffset(30) + 'px';
//IE can't focus a hidden div; Moz needs to focus before display to avoid jumping
	if (C.gecko){
		document.getElementById('FeedbackOKButton').focus();
	}
	FDiv.style.display = 'block';

	ShowElements(false, 'input');
	ShowElements(false, 'select');

	if (C.ie){
		document.getElementById('FeedbackOKButton').focus();
	}
	
//
}

function ShowElements(Show, TagName){
//Special for IE bug -- hide all the form elements that will show through the popup
	if (C.ie){
		var Els = document.getElementsByTagName(TagName);
		for (var i=0; i<Els.length; i++){
			if (Show == true){
				Els[i].style.display = 'inline';
			}
			else{
				Els[i].style.display = 'none';
			}
		}
	} 
}

function HideFeedback(){
	document.getElementById('FeedbackDiv').style.display = 'none';
	ShowElements(true, 'input');
	ShowElements(true, 'select');
	if (Finished == true){
		Finish();
	}
}


//GENERAL UTILITY FUNCTIONS AND VARIABLES

//PAGE DIMENSION FUNCTIONS
function PageDim(){
//Get the page width and height
	this.W = 600;
	this.H = 400;
	this.W = document.getElementsByTagName('body')[0].clientWidth;
	this.H = document.getElementsByTagName('body')[0].clientHeight;
}

var pg = null;

function GetPageXY(El) {
	var XY = {x: 0, y: 0};
	while(El){
		XY.x += El.offsetLeft;
		XY.y += El.offsetTop;
		El = El.offsetParent;
	}
	return XY;
}

function GetScrollTop(){
	if (document.documentElement && document.documentElement.scrollTop){
		return document.documentElement.scrollTop;
	}
	else{
		if (document.body){
 			return document.body.scrollTop;
		}
		else{
			return window.pageYOffset;
		}
	}
}

function GetViewportHeight(){
	if (window.innerWidth){
		return window.innerWidth;
	}
	else{
		return document.getElementsByTagName('body')[0].clientHeight;
	}
}

function TopSettingWithScrollOffset(TopPercent){
	var T = Math.floor(GetViewportHeight() * (TopPercent/100));
	return GetScrollTop() + T; 
}

//CODE FOR AVOIDING LOSS OF DATA WHEN BACKSPACE KEY INVOKES history.back()
var InTextBox = false;

function SuppressBackspace(e){ 
	if (InTextBox == true){return;}
	if (C.ie) {
		thisKey = window.event.keyCode;
	}
	else {
		thisKey = e.keyCode;
	}

	var Suppress = false;

	if (thisKey == 8) {
		Suppress = true;
	}

	if (Suppress == true){
		if (C.ie){
			window.event.returnValue = false;	
			window.event.cancelBubble = true;
		}
		else{
			e.preventDefault();
		}
	}
}

if (C.ie){
	document.attachEvent('onkeydown',SuppressBackspace);
	window.attachEvent('onkeydown',SuppressBackspace);
}
else{
	window.addEventListener('keypress',SuppressBackspace,false);
}

function ReduceItems(InArray, ReduceToSize){
	var ItemToDump=0;
	var j=0;
	while (InArray.length > ReduceToSize){
		ItemToDump = Math.floor(InArray.length*Math.random());
		InArray.splice(ItemToDump, 1);
	}
}

function Shuffle(InArray){
	Temp = new Array();
	var Len = InArray.length;

	var j = Len;

	for (var i=0; i<Len; i++){
		Temp[i] = InArray[i];
	}

	for (i=0; i<Len; i++){
		Num = Math.floor(j  *  Math.random());
		InArray[i] = Temp[Num];

		for (var k=Num; k < j; k++) {
			Temp[k] = Temp[k+1];
		}
		j--;
	}
	return InArray;
}

function WriteToInstructions(Feedback) {
	Feedback = '<span class="FeedbackText">' + Feedback + '</span>';
	document.getElementById('InstructionsDiv').innerHTML = Feedback;

}




function EscapeDoubleQuotes(InString){
	return InString.replace(/"/g, '&quot;')
}

function FocusAButton(){
	if (document.getElementById('CheckButton1') != null){
		document.getElementById('CheckButton1').focus();
	}
	else{
		document.getElementsByTagName('button')[0].focus();
	}
}

function TrimString(InString){
        var x = 0;

        if (InString.length != 0) {
                while ((InString.charAt(InString.length - 1) == '\u0020') || (InString.charAt(InString.length - 1) == '\u000A') || (InString.charAt(InString.length - 1) == '\u000D')){
                        InString = InString.substring(0, InString.length - 1)
                }

                while ((InString.charAt(0) == '\u0020') || (InString.charAt(0) == '\u000A') || (InString.charAt(0) == '\u000D')){
                        InString = InString.substring(1, InString.length)
                }

                while (InString.indexOf('  ') != -1) {
                        x = InString.indexOf('  ')
                        InString = InString.substring(0, x) + InString.substring(x+1, InString.length)
                 }

                return InString;
        }

        else {
                return '';
        }
}

function FindLongest(InArray){
	if (InArray.length < 1){return -1;}

	var Longest = 0;
	for (var i=1; i<InArray.length; i++){
		if (InArray[i].length > InArray[Longest].length){
			Longest = i;
		}
	}
	return Longest;
}

//UNICODE CHARACTER FUNCTIONS
function IsCombiningDiacritic(CharNum){
	var Result = (((CharNum >= 0x0300)&&(CharNum <= 0x370))||((CharNum >= 0x20d0)&&(CharNum <= 0x20ff)));
	Result = Result || (((CharNum >= 0x3099)&&(CharNum <= 0x309a))||((CharNum >= 0xfe20)&&(CharNum <= 0xfe23)));
	return Result;
}

function IsCJK(CharNum){
	return ((CharNum >= 0x3000)&&(CharNum < 0xd800));
}

//SETUP FUNCTIONS
//BROWSER WILL REFILL TEXT BOXES FROM CACHE IF NOT PREVENTED
function ClearTextBoxes(){
	var NList = document.getElementsByTagName('input');
	for (var i=0; i<NList.length; i++){
		if (NList[i].id.indexOf('Guess') > -1){
			NList[i].value = '';
		}
		if (NList[i].id.indexOf('Chk') > -1){
			NList[i].checked = '';
		}
	}
}

//EXTENSION TO ARRAY OBJECT
function Array_IndexOf(Input){
	var Result = -1;
	for (var i=0; i<this.length; i++){
		if (this[i] == Input){
			Result = i;
		}
	}
	return Result;
}
Array.prototype.indexOf = Array_IndexOf;

//IE HAS RENDERING BUG WITH BOTTOM NAVBAR
function RemoveBottomNavBarForIE(){
	if (C.ie){
		if (document.getElementById('BottomNavBar') != null){
			document.getElementById('TheBody').removeChild(document.getElementById('BottomNavBar'));
		}
	}
}




//HOTPOTNET-RELATED CODE

var HPNStartTime = (new Date()).getTime();
var SubmissionTimeout = 30000;
var Detail = ''; //Global that is used to submit tracking data

function Finish(){
//If there's a form, fill it out and submit it
	if (document.store != null){
		Frm = document.store;
		Frm.starttime.value = HPNStartTime;
		Frm.endtime.value = (new Date()).getTime();
		Frm.mark.value = Score;
		Frm.detail.value = Detail;
		Frm.submit();
	}
}



//JQUIZ CORE JAVASCRIPT CODE

var CurrQNum = 0;
var CorrectIndicator = ':-)';
var IncorrectIndicator = 'X';
var YourScoreIs = 'Your score is ';
var ContinuousScoring = true;
var CorrectFirstTime = 'Questions answered correctly first time: ';
var ShowCorrectFirstTime = false;
var ShuffleQs = true;
var ShuffleAs = true;
var DefaultRight = 'Correct!';
var DefaultWrong = 'Sorry! Try again.';
var QsToShow = 10;
var Score = 0;
var Finished = false;
var Qs = null;
var QArray = new Array();
var ShowingAllQuestions = false;
var ShowAllQuestionsCaption = 'Show all questions';
var ShowOneByOneCaption = 'Show questions one by one';
var State = new Array();
var Feedback = '';

function CompleteEmptyFeedback(){
	var QNum, ANum;
	for (QNum=0; QNum<I.length; QNum++){
		for (ANum = 0; ANum<I[QNum][3].length; ANum++){
			if (I[QNum][3][ANum][1].length < 1){
				if (I[QNum][3][ANum][2] > 0){
					I[QNum][3][ANum][1] = DefaultRight;
				}
				else{
					I[QNum][3][ANum][1] = DefaultWrong;
				}
			}
		}
	}
}

function SetUpQuestions(){
	var AList = new Array(); 
	var QList = new Array();
	var i, j;
	Qs = document.getElementById('Questions');
	while (Qs.getElementsByTagName('li').length > 0){
		QList.push(Qs.removeChild(Qs.getElementsByTagName('li')[0]));
	}
	var DumpItem = 0;
	while (QsToShow < QList.length){
		DumpItem = Math.floor(QList.length*Math.random());
		for (j=DumpItem; j<(QList.length-1); j++){
			QList[j] = QList[j+1];
		}
		QList.length = QList.length-1;
	}
	if (ShuffleQs == true){
		QList = Shuffle(QList);
	}
	if (ShuffleAs == true){
		var As;
		for (var i=0; i<QList.length; i++){
			As = QList[i].getElementsByTagName('ol')[0];
			if (As != null){
  			AList.length = 0;
				while (As.getElementsByTagName('li').length > 0){
					AList.push(As.removeChild(As.getElementsByTagName('li')[0]));
				}
				AList = Shuffle(AList);
				for (j=0; j<AList.length; j++){
					As.appendChild(AList[j]);
				}
			}
		}
	}
	
	for (i=0; i<QList.length; i++){
		Qs.appendChild(QList[i]);
		QArray[QArray.length] = QList[i];
	}

//Show the first item
	QArray[0].style.display = '';
	
//Now hide all except the first item
	for (i=1; i<QArray.length; i++){
		QArray[i].style.display = 'none';
	}		
	SetQNumReadout();
}

function ChangeQ(ChangeBy){
	if (((CurrQNum + ChangeBy) < 0)||((CurrQNum + ChangeBy) >= QArray.length)){return;}
	QArray[CurrQNum].style.display = 'none';
	CurrQNum += ChangeBy;
	QArray[CurrQNum].style.display = '';
	SetQNumReadout();
//if there's a textbox, set the focus in it
	if (QArray[CurrQNum].getElementsByTagName('input')[0] != null){
		QArray[CurrQNum].getElementsByTagName('input')[0].focus();
	}
}

function SetQNumReadout(){
	document.getElementById('QNumReadout').innerHTML = (CurrQNum+1) + ' / ' + QArray.length;
}

I=new Array();
I[0]=new Array();I[0][0]=100;
I[0][1]='';
I[0][2]='0';
I[0][3]=new Array();
I[0][3][0]=new Array('Political','Correct.  It is through politics, both at home and abroad, that the minds and actions of people can be influenced.',1,100,1);
I[0][3][1]=new Array('Military','Nope.  The military is an important part of national power, but it is not the primary policy type of the United States.',0,0,1);
I[0][3][2]=new Array('Economic','Sorry.  While the economic health and well-being of the nation are driving factors for our national strategy, there is a more important policy type to consider.',0,0,1);
I[0][3][3]=new Array('Security','Nope.  While security considerations are important to national strategy, there is one policy type which is considered even more important.',0,0,1);
I[0][3][4]=new Array('Social','Sorry.  While this can be an important aspect of national strategy, it isn\'t considered the most important.',0,0,1);
I[1]=new Array();I[1][0]=100;
I[1][1]='';
I[1][2]='3';
I[1][3]=new Array();
I[1][3][0]=new Array('Capabilities','Partially correct.  Capabilities is one of the three basic considerations.  What are the other two?  You must have all three checked to get the answer correct.',1,100,1);
I[1][3][1]=new Array('Intentions','Partially correct.  Intentions is one of the three basic considerations.  What are the other two?  You must have all three checked to get the answer correct.',1,100,1);
I[1][3][2]=new Array('Vulnerabilities','Partially correct.  Vulnerabilities is one of the three basic considerations.  What are the other two?  You must have all three checked to get the answer correct.',1,100,1);
I[1][3][3]=new Array('Limitations','Sorry.  Limitations are considered as a part of each of the three basic considerations and not a basic consideration in and of itself.',0,0,1);
I[1][3][4]=new Array('Time Factors','Sorry.  While time factors may play into the three key considerations, it isn\'t one of these basic considerations.',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('Capabilities','Correct.  Put another way, "What can the enemy do?"',1,100,1);
I[2][3][1]=new Array('Intentions','Sorry.  The goal of this basic consideration is knowing "What will the enemy do?"',0,0,1);
I[2][3][2]=new Array('Vulnerabilities','Sorry.  The goal of this basic consideration is knowing "What are the enemy\'s weaknesses?"',0,0,1);
I[2][3][3]=new Array('Limitations','Nope.  Limitations is not one of the three basic considerations when evaluating an external threat.',0,0,1);
I[2][3][4]=new Array('Time Factors','Nope.  Time factors is not one of the three basic considerations when evaluating an external threat.',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('Mass forces','Right!  A force, even one smaller than its enemy, can achieve decisive results when it concentrates its assets on defeating an enemy\'s critical vulnerability.',1,100,1);
I[3][3][1]=new Array('Take the offensive','Sorry.  This Principal of War advises us seize, retain, and exploit the initiative.',0,0,1);
I[3][3][2]=new Array('Maneuver','Nope.  This Principal of War advises us to place an enemy in a position of disadvantage through the use of speed and agility.',0,0,1);
I[3][3][3]=new Array('Maintain security','Sorry.  This Principal of War advises to never permit an enemy to acquire an unexpected advantage.',0,0,1);
I[3][3][4]=new Array('Achieve surprise','Nope.  This Principal of War advises us to strike an enemy at a time or place or in a manner for which the enemy is unprepared.',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('Maintain security','Correct!  Alert watchstanders, scouting forces, and the use of electronic emission control all promote freedom of action by reducing vulnerability to hostile acts, influence, or surprise.',1,100,1);
I[4][3][1]=new Array('Achieve surprise','Nope.  This Principal of War advises us to strike an enemy at a time or place or in a manner for which the enemy is unprepared.',0,0,1);
I[4][3][2]=new Array('Maintain simplicity','Sorry.  This Principal of War advises us that we need to avoid unnecessary complexity in preparing, planning, and conducting military operations.',0,0,1);
I[4][3][3]=new Array('Define the objective','Nope.  This Principal of War advises us that every military operation should be directed toward a clearly defined, decisive, and attainable objective.',0,0,1);
I[4][3][4]=new Array('Economize force','Nope.  This Principal of War advises us to employ all combat power available in the most effective way possible.',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('Take the offensive','Right!  It is critical that the commander seize, retain, and exploit the initiative.',1,100,1);
I[5][3][1]=new Array('Mass forces','Sorry.  This Principal of War reminds us that a force, even one smaller than its enemy, can achieve decisive results when it concentrates its assets on defeating an enemy\'s critical vulnerability.',0,0,1);
I[5][3][2]=new Array('Define the objective','Nope.  This Principal of War advises us that every military operation should be directed toward a clearly defined, decisive, and attainable objective.',0,0,1);
I[5][3][3]=new Array('Achieve surprise','Nope.  This Principal of War advises us to strike an enemy at a time or place or in a manner for which the enemy is unprepared.',0,0,1);
I[5][3][4]=new Array('Maintain security.','Sorry.  This Principal of War advises to never permit an enemy to acquire an unexpected advantage.',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('Achieve surprise','Correct!  It is important to try and strike an enemy at a time or place or in a manner for which the enemy is unprepared.',1,100,1);
I[6][3][1]=new Array('Maintain security','Sorry.  This Principal of War advises to never permit an enemy to acquire an unexpected advantage.',0,0,1);
I[6][3][2]=new Array('Maneuver','Nope.  This Principal of War advises us to place an enemy in a position of disadvantage through the use of speed and agility.',0,0,1);
I[6][3][3]=new Array('Maintain simplicity','Sorry.  This Principal of War advises us that we need to avoid unnecessary complexity in preparing, planning, and conducting military operations.',0,0,1);
I[6][3][4]=new Array('Economize force','Nope.  This Principal of War advises us to employ all combat power available in the most effective way possible.',0,0,1);
I[7]=new Array();I[7][0]=100;
I[7][1]='';
I[7][2]='3';
I[7][3]=new Array();
I[7][3][0]=new Array('General War','Partially correct.  General War is one of the three main forms.  What are the other two?  Be sure and check each one of the three boxes.',1,100,1);
I[7][3][1]=new Array('Revolutionary War','Partially correct.  Revolutionary War is one of the three main forms.  What are the other two?  Be sure and check each one of the three boxes.',1,100,1);
I[7][3][2]=new Array('Limited War','Partially correct.  Limited Warfare is one of the three main forms.  What are the other two?  Be sure and check each one of the three boxes.',1,100,1);
I[7][3][3]=new Array('Nuclear War','Nope.  Any one of the three forms of large scale conflict may use nuclear weapons, so nuclear war is not considered a separate form of large scale conflict.',0,0,1);
I[7][3][4]=new Array('Terrorist War','Sorry.  While we are currently in a war against terrorism world-wide, this is not one of the three recognized forms of large scale armed conflicts.',0,0,1);
I[7][3][5]=new Array('Jungle War','Nope.  Although wars are fought in jungle areas, this is not one of the three main forms of modern conflict.',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('General War','Correct!  This is part of the definition of General War by the U.S Joint Chiefs of Staff.',1,100,1);
I[8][3][1]=new Array('Revolutionary War','Sorry.  Revolutionary warfare is not a conflict fought by two major powers, but rather an internal effort to seize political power through force of arms.',0,0,1);
I[8][3][2]=new Array('Limited War','Sorry.  Limited War does not require the total resources of the belligerents.',0,0,1);
I[8][3][3]=new Array('Global War','Nope.  Global War is not considered a separate form of modern, large-scale armed conflict.',0,0,1);
I[8][3][4]=new Array('Nuclear War','Nope.  Any of the types of modern large-scale armed conflicts may use nuclear weapons, so nuclear war is not considered a separate form of large scale conflict.',0,0,1);
I[9]=new Array();I[9][0]=100;
I[9][1]='';
I[9][2]='3';
I[9][3]=new Array();
I[9][3][0]=new Array('Accidental initiation','Partially Correct.  The prospect of an accidental initiation of a nuclear war with another nuclear power is certainly less likely since the break-up of the Soviet Union.  What are the other two?  You must select all three to get the question correct.',1,100,1);
I[9][3][1]=new Array('Miscalculation','Partially Correct.  The prospect of a miscalculation with another nuclear power is certainly less likely since the break-up of the Soviet Union.  What are the other two?  You must select all three to get the question correct.',1,100,1);
I[9][3][2]=new Array('Misunderstanding','Partially Correct.  The prospect of a misunderstanding with another nuclear power is certainly less likely since the break-up of the Soviet Union.  What are the other two?  You must select all three to get the question correct.',1,100,1);
I[9][3][3]=new Array('Deliberate initiation','Sorry.  Although the deliberate start of a General War is a remote possibility, since no sane leader would ever deliberately start one, it is just as possible today as it was during the Cold War.',0,0,1);
I[9][3][4]=new Array('Entanglement','Sorry.  Entanglements are always a danger, since wars can be touched off intentionally by a third country or coalition for a variety of motives.',0,0,1);
I[9][3][5]=new Array('Irrational acts','Sorry.  Irrational acts can never be discounted and are just as possible now as during the Cold War against the Soviet Union.',0,0,1);
I[10]=new Array();I[10][0]=100;
I[10][1]='';
I[10][2]='0';
I[10][3]=new Array();
I[10][3][0]=new Array('A Proxy War','Correct.  There were several such proxy wars during the Cold War.  The conflicts in Korea and Vietnam are examples of proxy wars.',1,100,1);
I[10][3][1]=new Array('A Revolutionary War','Sorry.  A Revolutionary War is an internal attempt within a major power for some group to gain political power, usually through force of arms.',0,0,1);
I[10][3][2]=new Array('A General War','Sorry.  A general war is an all-out effort between two or more major world powers.',0,0,1);
I[10][3][3]=new Array('A Pax Ballistica','Nope.  This term means "missile peace" and refers to the nuclear missile standoff that we experienced during the Cold War.',0,0,1);
I[10][3][4]=new Array('A Cold War','Nope.  The term "Cold War" refers to the post-World War II conflict conducted by the U.S. and the Soviet Union.  There were several limited wars that were a part of the overall Cold War.',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('A charismatic leader','Correct.  Although this has helped to make many revolutions more successful, as in the case of Fidel Castro in Cuba, it is not a requirement.  Numerous revolutions have occurred without a single, charismatic leader in charge.',1,100,1);
I[11][3][1]=new Array('Dissatisfaction with the status quo','Sorry.  In order to convince people to change their government, they must first be dissatisfied with that government.',0,0,1);
I[11][3][2]=new Array('A cause to rally behind','Sorry.  Without a popular cause to rally the people behind, the chances of a successful revolution are remote.',0,0,1);
I[11][3][3]=new Array('A carefully directed organization','Nope.  In order to achieve its goals, the revolutionary parties need to be organized and carefully directed.',0,0,1);
I[11][3][4]=new Array('All of these are prerequisites for a successful revolution.','Nope.  There is one on the list that is not required.',0,0,1);
I[12]=new Array();I[12][0]=100;
I[12][1]='';
I[12][2]='3';
I[12][3]=new Array();
I[12][3][0]=new Array('The U.S.-led operation Iraqi Freedom','Partially correct.  Operation Iraqi Freedom was not a revolutionary war, but there is another conflict in this list that was also not a revolutionary war.  You need to select both of these answers to get this question right.',1,100,1);
I[12][3][1]=new Array('The Taliban rise to power in Afghanistan','Nope.  The Taliban took advantage of the post-war disarray in Afghanistan to take power and establish their regime.  This was a revolutionary war.',0,0,1);
I[12][3][2]=new Array('The Chinese Communist takeover in China','Sorry.  This was a classic revolutionary war, supported and supplied by the Soviet Union to aid in the spread of Communism.',0,0,1);
I[12][3][3]=new Array('Fidel Castro\'s rise to power in Cuba','Sorry.  This was a popular revolutionary war against the corrupt government that had previously controlled Cuba.',0,0,1);
I[12][3][4]=new Array('The American Civil War','',0,0,1);
I[12][3][5]=new Array('The Spanish-American War','Partially correct.  The Spanish-American war was not a revolutionary war, but there is another conflict in this list that was also not a revolutionary war.  You need to select both of these answers to get this question right.',1,100,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('Revolutionary Warfare','Correct.  A small group of individuals outside the established government attempt to being about political change through fear.',1,100,1);
I[13][3][1]=new Array('Limited Warfare','Sorry.  Limited Warfare is warfare fought on a limited scale between major and/or minor world powers.  Terrorists are not major or minor world powers.',0,0,1);
I[13][3][2]=new Array('General Warfare','Sorry.  General warfare is warfare between two or more major powers.  Terrorists are not major powers.',0,0,1);
I[13][3][3]=new Array('Global Warfare','Nope.  Although terrorism is fought against around the world, this is not the definition of Global Warfare',0,0,1);
I[13][3][4]=new Array('Hit-And-Run Warfare','Nope.  There is no classification of "Hit-And-Run" Warfare.',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('Intentions','Right!  To truly know an enemy\'s intentions, you\'d have to be able to read their minds.  Actions speak louder than words in this area, but nothing can be known with complete accuracy.  Intentions are constantly changing as well.',1,100,1);
I[14][3][1]=new Array('Capabilities','Sorry.  While this can sometimes be difficult to fully assess, it is far easier than another item on this list.',0,0,1);
I[14][3][2]=new Array('Vulnerabilities','Sorry.  Intensive studies of an enemy\'s economy and military will reveal vulnerabilities.',0,0,1);
I[14][3][3]=new Array('Limitations','Nope.  This isn\'t one of the three basic considerations.',0,0,1);
I[14][3][4]=new Array('Time Factors','Nope.  This isn\'t one of the three basic considerations.',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('Sun Tzu','Right!  This was one of the maxims found in his book "The Art of War".',1,100,1);
I[15][3][1]=new Array('Douglas MacArthur','Sorry.  MacArthur\'s warfighting skills show that he believed in this principal, but this quotation is not his.',0,0,1);
I[15][3][2]=new Array('Winston Churchill','Sorry.  While Churchill had a great many quotations along the same line, this wasn\'t one of his.',0,0,1);
I[15][3][3]=new Array('Harry Truman','Nope.  This quote goes back a lot longer than the Truman administration.',0,0,1);
I[15][3][4]=new Array('Alexander the Great','Nope.  This quotation was not Alexander\'s.',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('Douglas MacArthur','Correct.  MacArthur was referring in this statement to his desire to press ahead and attack Communist Chinese staging areas within Manchuria during the Korean War.',1,100,1);
I[16][3][1]=new Array('Winston Churchill','Sorry.  Churchill spoke often about victory during World War II, but this was not among his many quotes.',0,0,1);
I[16][3][2]=new Array('Dwight D. Eisenhower','Sorry.  Eisenhower, no doubt, believed this, but he didn\'t make this statement.',0,0,1);
I[16][3][3]=new Array('Alexander the Great','Nope.  There are not a lot of existing quotations from Alexander.  By the history of his conquests we know, however, that he believed in this maxim.',0,0,1);
I[16][3][4]=new Array('Sun Tzu','Nope.  While Sun Tzu\'s philosophy emphasized this same point, he did not make this statement.',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('Entanglement','Correct.  Protection treaties signed by the major powers promising to protect one or more of the nations in the Middle East has the potential of dragging one or more of the major powers into a conflict.  If this happens, it might possibly escalate to a General War.',1,100,1);
I[17][3][1]=new Array('Irrational acts','Sorry.  Although irrational acts can never be discounted and are certainly going on to a limited degree by terrorist groups in the Middle East, it is unlikely they could bring about a General War between the major powers.',0,0,1);
I[17][3][2]=new Array('Deliberate initiation','Nope.  Deliberate initiation relies on a major power believing they have the assurance of victory or an expectation of destruction if they don\'t act first.  Neither precondition is the case in the Middle East conflict between the world\'s major powers.',0,0,1);
I[17][3][3]=new Array('Miscalculation','Sorry.  While this sounds like it might be correct, miscalculation deals more with one major power miscalculating the ability of another one to wage war on a global scale.  ',0,0,1);
I[17][3][4]=new Array('Misunderstanding','Nope.  Misunderstanding implies a misunderstanding between the two or more major powers who would go to war.  This is not the case in the Middle East.',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('Because the major powers would use nuclear weapons and the scale of the destruction would mean there were no winners.','Right.  It would be a hollow victory, since even the nation that came out on top would be severely affected by the conflict.',1,100,1);
I[18][3][1]=new Array('Because no one major power could ever defeat another in the modern world.','Sorry.  While one side or another would always come out on top in such a conflict, what would be left would probably not be worth the price paid in the conflict.',0,0,1);
I[18][3][2]=new Array('Because General Wars could never take place in modern times.','Sorry.  There is always the possibility that one of the many smaller conflicts or limited wars could develop into a General War.',0,0,1);
I[18][3][3]=new Array('Because it wouldn\'t be allowed under the rules of the United Nations.','Nope.  The rules of the UN would have little meaning if two or more major powers decided to engage in a global, General War.',0,0,1);
I[18][3][4]=new Array('Because no major power has the resources to fight a General War.','Nope.  The United States, Russia and China are all countries that could engage in a General War.',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('Revolutionary War','Correct!  This was the same form of Revolutionary Warfare as the American Revolution.  The modern version of Revolutionary Warfare is an entirely different model.',1,100,1);
I[19][3][1]=new Array('General War','Sorry.  General Wars are fought between two or more major powers.  This was not the case in these colonial wars for independence.',0,0,1);
I[19][3][2]=new Array('Limited War','Sorry.  Limited warfare is fought between two or more major or minor powers.  This was not the case in these colonial wars for independence.',0,0,1);
I[19][3][3]=new Array('Terrorism','Nope.  While terrorism falls within the same broad category, it is not the type of war that was fought in South America in the early 1800\'s.',0,0,1);
I[19][3][4]=new Array('Global War','Nope.  Global War is not considered one of the three types of wars, and these wars were not fought on a global scale.',0,0,1);


function StartUp(){
	RemoveBottomNavBarForIE();
	

	

	
	CompleteEmptyFeedback();

	SetUpQuestions();
	ClearTextBoxes();
	CreateStatusArray();
	

	
}

function ShowHideQuestions(){
	FuncBtnOut(document.getElementById('ShowMethodButton'));
	document.getElementById('ShowMethodButton').style.display = 'none';
	if (ShowingAllQuestions == false){
		for (var i=0; i<QArray.length; i++){
				QArray[i].style.display = '';
			}
		document.getElementById('Questions').style.listStyleType = 'decimal';
		document.getElementById('OneByOneReadout').style.display = 'none';
		document.getElementById('ShowMethodButton').innerHTML = ShowOneByOneCaption;
		ShowingAllQuestions = true;
	}
	else{
		for (var i=0; i<QArray.length; i++){
				if (i != CurrQNum){
					QArray[i].style.display = 'none';
				}
			}
		document.getElementById('Questions').style.listStyleType = 'none';
		document.getElementById('OneByOneReadout').style.display = '';
		document.getElementById('ShowMethodButton').innerHTML = ShowAllQuestionsCaption;
		ShowingAllQuestions = false;	
	}
	document.getElementById('ShowMethodButton').style.display = 'inline';
}

function CreateStatusArray(){
	var QNum, ANum;
//For each item in the item array
	for (QNum=0; QNum<I.length; QNum++){
//Check if the question still exists (hasn't been nuked by showing a random selection)
		if (document.getElementById('Q_' + QNum) != null){
			State[QNum] = new Array();
			State[QNum][0] = -1; //Score for this q; -1 shows question not done yet
			State[QNum][1] = new Array(); //answers
			for (ANum = 0; ANum<I[QNum][3].length; ANum++){
				State[QNum][1][ANum] = 0; //answer not chosen yet; when chosen, will store its position in the series of choices
			}
			State[QNum][2] = 0; //tries at this q so far
			State[QNum][3] = 0; //incrementing percent-correct values of selected answers
			State[QNum][4] = 0; //penalties incurred for hints
			State[QNum][5] = ''; //Sequence of answers chosen by number
		}
	}
}



function CheckMCAnswer(QNum, ANum, Btn){
//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){
		ShowMessage(Feedback);
		return;
	}
	
//Hide the button while processing
	Btn.style.display = 'none';

//Increment the number of tries
	State[QNum][2]++;
	
//Add the percent-correct value of this answer
	State[QNum][3] += I[QNum][3][ANum][3];
	
//Store the try number in the answer part of the State array, for tracking purposes
	State[QNum][1][ANum] = State[QNum][2];
	State[QNum][5] += String.fromCharCode(65+ANum) + ',';
	
//Should this answer be accepted as correct?
	if (I[QNum][3][ANum][2] < 1){
//It's wrong

//Mark the answer
		Btn.innerHTML = IncorrectIndicator;
		
//Check whether this leaves just one MC answer unselected, in which case the Q is terminated
		var RemainingAnswer = FinalAnswer(QNum);
		if (RemainingAnswer > -1){
//Behave as if the last answer had been selected, but give no credit for it
//Increment the number of tries
			State[QNum][2]++;		
		
//Calculate the score for this question
			CalculateMCQuestionScore(QNum);

//Get the overall score and add it to the feedback
			CalculateOverallScore();
			if ((ContinuousScoring == true)||(Finished == true)){
				Feedback += '<br />' + YourScoreIs + ' ' + Score + '%.';
				WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
			}
		}
	}
	else{
//It's right
//Mark the answer
		Btn.innerHTML = CorrectIndicator;
				
//Calculate the score for this question
		CalculateMCQuestionScore(QNum);

//Get the overall score and add it to the feedback
		if (ContinuousScoring == true){
			CalculateOverallScore();
			if ((ContinuousScoring == true)||(Finished == true)){
				Feedback += '<br />' + YourScoreIs + ' ' + Score + '%.';
				WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
			}
		}
	}
	
//Show the button again
	Btn.style.display = 'inline';
	
//Finally, show the feedback	
	ShowMessage(Feedback);
	
//Check whether all questions are now done
	CheckFinished();
}

function CalculateMCQuestionScore(QNum){
	var Tries = State[QNum][2] + State[QNum][4]; //include tries and hint penalties
	var PercentCorrect = State[QNum][3];
	var TotAns = GetTotalMCAnswers(QNum);
	var HintPenalties = State[QNum][4];
	
//Make sure it's not already complete

	if (State[QNum][0] < 0){
//Allow for Hybrids
		if (HintPenalties >= 1){
			State[QNum][0] = 0;
		}
		else{
			State[QNum][0] = ((TotAns-(Tries-1))/TotAns)*(PercentCorrect/(100*Tries));
		}
		if (State[QNum][0] < 0){
			State[QNum][0] = 0;
		}
	}
}

function GetTotalMCAnswers(QNum){
	var Result = 0;
	for (var ANum=0; ANum<I[QNum][3].length; ANum++){
		if (I[QNum][3][ANum][4] == 1){ //This is an MC answer
			Result++;
		}
	}
	return Result;
}

function FinalAnswer(QNum){
	var UnchosenAnswers = 0;
	var FinalAnswer = -1;
	for (var ANum=0; ANum<I[QNum][3].length; ANum++){
		if (I[QNum][3][ANum][4] == 1){ //This is an MC answer
			if (State[QNum][1][ANum] < 1){ //This answer hasn't been chosen yet
				UnchosenAnswers++;
				FinalAnswer = ANum;
			}
		}
	}
	if (UnchosenAnswers == 1){
		return FinalAnswer;
	}
	else{
		return -1;
	}
}





function CheckMultiSelAnswer(QNum){
//bail if question doesn't exist or exercise finished
	if ((State[QNum].length < 1)||(Finished == true)){return;}

//Increment the tries for this question
	State[QNum][2]++;
	
	var ShouldBeChecked;
	var Matches = 0;
	State[QNum][5] += '|';
	
//Check if there are any mismatches
	Feedback = '';
	var CheckBox = null;
	for (var ANum=0; ANum<I[QNum][3].length; ANum++){
		CheckBox = document.getElementById('Q_' + QNum + '_' + ANum + '_Chk');
		if (CheckBox.checked == true){
			State[QNum][5] += 'Y';
		}
		else{
			State[QNum][5] += 'N';
		}
		ShouldBeChecked = (I[QNum][3][ANum][2] == 1);
		if (ShouldBeChecked == CheckBox.checked){
			Matches++;
		}
		else{
			Feedback = I[QNum][3][ANum][1];
		}
	}
//Add the hit readout
	Feedback = Matches + ' / ' + I[QNum][3].length + '<br />' + Feedback;
	if (Matches == I[QNum][3].length){
//It's right
		CalculateMultiSelQuestionScore(QNum);
		if (ContinuousScoring == true){
			CalculateOverallScore();
			if ((ContinuousScoring == true)||(Finished == true)){
				Feedback += '<br />' + YourScoreIs + ' ' + Score + '%.';
				WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
			}
		}
	}
//If it's wrong, no need to do anything but show the feedback
	ShowMessage(Feedback);
}

function CalculateMultiSelQuestionScore(QNum){
	var Tries = State[QNum][2];
	var TotAns = State[QNum][1].length;
	
//Make sure it's not already complete
	if (State[QNum][0] < 0){
		State[QNum][0] = (TotAns - (Tries-1)) / TotAns;
		if (State[QNum][0] < 0){
			State[QNum][0] = 0;
		}
	}
}



function CalculateOverallScore(){
	var TotalWeighting = 0;
	var TotalScore = 0;
	
	for (var QNum=0; QNum<State.length; QNum++){
		if (State[QNum] != null){
			if (State[QNum][0] > -1){
				TotalWeighting += I[QNum][0];
				TotalScore += (I[QNum][0] * State[QNum][0]);
			}
		}
	}
	Score = Math.floor((TotalScore/TotalWeighting)*100);
}

function CheckFinished(){
	var FB = '';

	var AllDone = true;
	for (var QNum=0; QNum<State.length; QNum++){
		if (State[QNum][0] < 0){
			AllDone = false;
		}
	}
	if (AllDone == true){
	
//Report final score and submit if necessary
		CalculateOverallScore();
		FB = YourScoreIs + ' ' + Score + '%.';
		if (ShowCorrectFirstTime == true){
			var CFT = 0;
			for (QNum=0; QNum<State.length; QNum++){
				if (State[QNum][0] >= 1){
					CFT++;
				}
			}
			FB += '<br />' + CorrectFirstTime + ' ' + CFT + '/' + State.length;
		}
		WriteToInstructions(FB);
		
		Finished == true;

		TimeOver = true;
		Locked = true;
		


		Finished = true;
		Detail = '<?xml version="1.0"?><hpnetresult><fields>';
		for (QNum=0; QNum<State.length; QNum++){
			if (State[QNum][5].length > 0){
				Detail += '<field><fieldname>Question #' + (QNum+1) + '</fieldname><fieldtype>question-tracking</fieldtype><fieldlabel>Q ' + (QNum+1) + '</fieldlabel><fieldlabelid>QuestionTrackingField</fieldlabelid><fielddata>' + State[QNum][5] + '</fielddata></field>';
			}
		}
		Detail += '</fields></hpnetresult>';
		setTimeout('Finish()', SubmissionTimeout);
	}
}










//-->

//]]>


