// $$$$$$$$$$$$$$$$$$$$$	GLOBALS:	$$$$$$$$$$$$$$$$
EMmode=0;
AWINopened = 0;
isNetscape = 1;
if (navigator.appName.indexOf('Netscape') == -1) {isNetscape=0};

leftx = 20;
 topy = 20;

var Qcount = 0;
var Acount = 0;
var probnum = 0;

var sumOfAllChecked = 0;

var QcountIsCorrect = 0;

//function setAWIN() {AWINopened = 0; alert("setAWIN() to 0")}

ALPHABETarray = new Array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'BB', 'CC', 'DD', 'EE', 'FF', 'GG', 'HH', 'II', 'JJ', 'KK', 'LL');


RightWrongArr = new Array();


var Fcol = " < Fcol > ";
var pTyp = "";
//#######################################################
var AnchorNumStored = 0;
var displaymode = "none";
var displayOneProbNum = 0;
//#######################################################
//________________________________________________________
function ifisOp() { 
  if (typeof(atxw)=="object")
	 { 
		if (isNetscape) 
		  { AWINopened = (atxw.closed)?0:1}
	 else { 
			AWINopened = ((typeof atxw.cgimaker != "undefined" || typeof atxw.creator == "object") && !atxw.closed)?1:0;
		  };
	 };
} // end of function


//________________________________________________________
//________________________________________________________
closeGenWinLoaded=1;

function CloseGeneratedWindow() { 
  if (typeof(atxw)=="object")
  { //alert('is defined');
	ifisOp();
	  if (AWINopened)
		 { if (typeof atxw.cgimaker!="undefined" ||(typeof atxw.creator=="object" && atxw.creator && atxw.creator==self)||(typeof atxw.opener=="object" && atxw.opener && atxw.opener==self) ) //  || (typeof atxw.cgimaker=="string" && !atxw.creator)||(isNetscape && (typeof atxw.creator!='object'||!atxw.creator) )
				{
					atxw.close();
				};
		 };
   };
} // end of function

//________________________________________________________



if  (typeof windowname != "string") {windowname = "AnalysisWindow"};

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
var atxw;
function printAnalysisTextHEAD() { 

   top.atxw.document.writeln(" <SCRIP" + "T TYPE=\"text/javascript\" LANGUAGE=\"JavaScript\">");

if (typeof(this.newWinSuppressor) != "number" || this.newWinSuppressor!=0)
 { //alert("suppressing");
   if(typeof notcapable == "number" && notcapable==1)
		 {
		  top.atxw.document.writeln("  window.onerror=null;");
		 }   /* error suppression*/
	else {
		  top.atxw.document.writeln("  window.onerror = new Function(\"return true;\");");
		 };
  }; // else {alert("not suppressing"); }
  
  top.atxw.document.writeln("self.name = '" +windowname+ "';");
  top.atxw.document.writeln(" <\/SCRIP" + "T>");
  
  top.atxw.document.writeln("<STYLE TYPE=\"text/css\">");
  top.atxw.document.writeln("A.redlink {text-decoration: none; Color: #CC0000}");
  top.atxw.document.writeln("A.greenlink {text-decoration: none; Color: #008800}");
  top.atxw.document.writeln("A.noundl {text-decoration: none; Color: black}");
//H3.red {font-family: Arial; font-size: 10pt; Color:red}A.greenlink {text-decoration: bold; Color:green; font-weight:bold}
// P  {font-size:12pt; line-height:20pt}
  top.atxw.document.writeln("<\/STYLE>");

 };
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //
 var isMac = 0;	  if (navigator.appVersion.indexOf('Mac') != -1)   {isMac = 1}; 
function FeedbackWindow(Url,winwidth,winheight)  { 


// if (typeof(this.outerWidth)=="number")  { winwidth = this.WindowWidth - 28   };
// if (typeof(this.outerHeight)=="number") { winheight = this.WindowHeight - 46 }; //138
//----------
  ifisOp();
//----------
winopenparams = "toolbar=0,location=0,directories=0,status=0,history=0,menubar=0,scrollbars=1,resizable=1"//dependent=1,

var resetparams=0;
if (typeof(atxw)=="object"  && typeof atxw.cgimaker == "unknown") {atxw.close();resetparams=1;};


if (resetparams || !atxw || !AWINopened)//
 {	//alert("is closed")
	winopenparams +=",width="+WindowWidth+",height="+WindowHeight;

 	if (typeof(this.outerWidth)=="number" && typeof(this.outerHeight)=="number")  
	 { winopenparams += ",outerWidth="+WindowWidth+",outerHeight="+WindowHeight }; //138

	if (typeof(this.screenX)=="number" && typeof(this.screenY)=="number")  
	 { winopenparams += ",screenX="+leftx+",screenY="+topy  };
 };
 

atxw = window.open('',windowname,winopenparams);



	atxw.document.close();
	atxw.document.open("text/html","replace");
	
top.atxw.document.writeln(" ");
top.atxw.document.write("<HTML><head><title>");
if (typeof pagename == "string"){top.atxw.document.writeln(pagename)};
top.atxw.document.writeln("<\/title>");

										//--------------------------------
										  printAnalysisTextHEAD();
										//--------------------------------


top.atxw.document.writeln("<\/head><body bgcolor=\"#F5F5FF\" text=\"#000011\" LINK=\"#1111CC\" ALINK=\"#FF00DD\" VLINK=\"#1111AA\" onMove=\"if (top.opener && top.opener.document){top.opener.SetXY()};\" onLoad=\"if (top.opener && typeof(top.opener.AWINopened)=='number'){top.opener.AWINopened=1}\"");
top.atxw.document.writeln(" onResize=\"if (top.opener&&top.opener.document){top.opener.setresizer();top.opener.SetXY()};\">");
top.atxw.document.writeln(" <FONT SIZE='+1' color=\"#000011\">" + AlertText + "<\/FONT>"); 

//--------------------------------------------------------

	 if (typeof isEmailFeature == "number") {		 //genWindowObject = new Object(); 
	 genWindowObject = atxw;
	 EmailerDirections = "E-mail a copy of your score report:";
	 top.atxw.document.writeln("<P><HR NOSHADE SIZE=1>");
	 if (EMmode){
	 writeEmailTable(top.atxw.document)}
	 else {
top.atxw.document.writeln("<center><B><a href=\"javascript:if(typeof(top.opener)=='object'&&top.opener!=null&&top.opener.document){top.opener.EMmode=1;top.opener.getScore('blank.htm',"+WindowWidth+","+WindowHeight+")};\"> E-mail a copy of your score report?<\/a><\/B><\/center>");	 
	 };
	 
	 };
//--------------------------------------------------------

						//--------------------------------
							if (typeof PFTloaded=="number") {PrintFeedbackTable(DEBUGMODE)};
						//--------------------------------

with (top.atxw.document) {
writeln(" <a name='LastAnchor'> <\/a> <BR> ");
writeln("<CENTER> <A HREF=\"javascript:if(top.opener&&top.opener.document)top.opener.focus();self.close()\">Close This Window<\/A> <\/CENTER> ");
writeln(" <\/BODY> <\/HTML> ");
};

//----------------------------------------- FINISHED WRITING TO atxw --------------------


	 } // END of fn()
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //** END of FeedbackWindow() **//

 var notcapable = 0;

 function captest() {
	if ( (parseInt(navigator.appVersion.charAt(0)) < 4) && navigator.appName.indexOf('Netscape') != -1 )
		{notcapable=1;}
					} //end of function

 captest();  //alert("notcapable: " + notcapable);

  if (notcapable) { 
		if (typeof newWinSuppressor != "number" || newWinSuppressor != 0)
		 { window.onerror=null; 
		 //alert("suppressing")
			};
				  };

// ---------------------------------------------------------------- getindex()
var thisAnswer =  "thisAnswer";
var AnswerN =  "AnswerN";
var bbb = 5;

function getindex(n) {

AnswerN = this.AnswerArray[n]
thisAnswer =  AnswerN.toUpperCase();

bbb = 5;

	 if (thisAnswer=="A" || thisAnswer=="T") {bbb = 0;}
else if (thisAnswer=="B" || thisAnswer=="F") {bbb = 1;}
else if (thisAnswer=="C") {bbb = 2;}
else if (thisAnswer=="D") {bbb = 3;}
else if (thisAnswer=="E") {bbb = 4;}

else {bbb = 4;}// alert("NON-VALID ANSWER in \"AnswerArray\"");};
return (bbb);
}
// ---------------------------------------------------------------- END of getindex()



// $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


var wrongAnsCountMsg = "STRING";
var wrongAnsCountMsgTEMP;
var AlertText = " ";

var IndexString = "00000";
var IndexChar = "0";

probnum = 0;

var numwrong = 0;
var score = 0;  
//var maximumScore = 999;
var lastcomma = 0;
var iii = 0;

//-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
if (typeof DEBUGMODE != "number") { DEBUGMODE=0 };	  //***DEBUG***


// $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ getScore()

function getScore(NewWinURL,winwidth,winheight) {
AlertText=" ";
emailWrongCount = "";//"\nThe following problems were answered incorrectly: ";
var EMAILessaySTRING="";

numwrong = 0;
score = 0; 

wrongAnsCountMsg = " ";
wrongAnsCountMsgTEMP = " ";

lastcomma = 0;
iii = 0;
counter = 0;

var maximumScore = (typeof AnswerArray != "undefined")?this.AnswerArray.length:0; 

if (typeof AnswerArray != "undefined") {
//####################################################################
//####################################################################
for (Qcount=0; Qcount<maximumScore; Qcount++)
  {
// ---------
QcountIsCorrect = 0;
probnum = Qcount+1;
iii = getindex(Qcount); 
radioObj=ALPHABETarray[Qcount];
if (document.inputForm[radioObj][iii].checked)         { QcountIsCorrect = 1; }
// ---------


	if (QcountIsCorrect==1)
		{ ++score;
		 RightWrongArr[Qcount] = 1;}
	else { ++numwrong; 
			RightWrongArr[Qcount] = 0;
			if (numwrong>1){wrongAnsCountMsg += ", "; emailWrongCount += ", ";}; //**** ADD COMMA
			wrongAnsCountMsg += "<FONT color='#CC0000'>";
			
	// if (!notcapable) { wrongAnsCountMsg += "<A HREF=\"javascript:top.opener.NewWinScroll(" + probnum + ");\" class=\"redlink\">"   };
	// if (!notcapable) { wrongAnsCountMsg += "<A HREF='#' onClick='top.opener.NewWinScroll(" + probnum + ");return false;' class=\"redlink\">"   };
	// wrongAnsCountMsg += "<FONT color='#CC0000'>" + probnum + "<\/FONT>";
	
			wrongAnsCountMsg += probnum;
	
	// if (!notcapable) { wrongAnsCountMsg += "<\/A>"};

			wrongAnsCountMsg += "<\/FONT>";
		emailWrongCount += probnum;
		  }; // end of ELSE
}; // end of FOR Qcount


if (numwrong>1) {lastcomma = wrongAnsCountMsg.lastIndexOf(","); 
				  wrongAnsCountMsgTEMP = wrongAnsCountMsg.substring(0,lastcomma);
				  //lastcomma++;  
				  wrongAnsCountMsgTEMP += " &" + wrongAnsCountMsg.substring(++lastcomma,wrongAnsCountMsg.length);
				  wrongAnsCountMsg = wrongAnsCountMsgTEMP;};

Fcol = "<font color='#008800'>";

if (score>=maximumScore) {
		wrongAnsCountMsgTEMP = " <BR>&nbsp;<BR> Nice Job!<\/FONT>";  }
/////////
else {
	  if (score==0)  { Fcol = "<font color='#F52445'>" };
	  wrongAnsCountMsg += ". ";
	  countMsg = (score==maximumScore-1)?"One response was incorrect: ":"The following problems had incorrect responses: ";
	  wrongAnsCountMsgTEMP = " <\/FONT> <BR>&nbsp;<BR>" + countMsg + "<BR>";

	 };
/////////

AlertText = "<BR><blockquote><CENTER><FONT SIZE='+2'>You answered <B>" + Fcol + score + "<\/font><\/B> out of " + maximumScore + " problems correctly." + wrongAnsCountMsgTEMP + wrongAnsCountMsg + "<\/CENTER><\/blockquote>";  //<\/font>
}; //end IF AnswerArray  ****

//####################################################################
//####################################################################
if (typeof countChecked != "undefined")
{ 
sumOfAllChecked = 0;
for (var ccc=0; ccc<document.inputForm.length; ccc++)
	{if ((document.inputForm[ccc].name.charAt(0) != "x"&&(document.inputForm[ccc].type == "radio" || document.inputForm[ccc].type == "checkbox")&&document.inputForm[ccc].checked) || document.inputForm[ccc].name.charAt(0) == "i")
		{  
		thisValue = parseInt(document.inputForm[ccc].value)
		if (!isNaN(thisValue)) {sumOfAllChecked+=thisValue};
		};
	}; // end FOR

}; // end IF countChecked
//####################################################################

if (typeof contentFuncLoaded != "undefined")
{ AlertText += contentFunction(); };

//####################################################################
//####################################################################

	//-----------------------------------------------
		FeedbackWindow(NewWinURL,winwidth,winheight);
	//----------------------------------------------

atxw.focus()
atxw.document.close();
						   //success1 = ScrollWindow();
//----------
atxw.creator = self;

	if (atxw.opener && atxw.opener.document && (typeof atxw.opener.AWINopened == "number"))
		{ if (atxw.opener != self)  {atxw.opener.AWINopened = 0;}
		};

atxw.opener = self;
//----------
 AWINopened = 1;
 
 if (isNetscape && !notcapable) top.atxw.window.stop();
 	//--------------
		setresizer();
		SetXY();
	//--------------
}  //*** end of fn() 
// $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ END of getScore()



/////////////////////////////////////////////////////
function setresizer() {
if (typeof(atxw)=="object" && typeof(atxw.creator)=="object") {

if ((isNetscape && !atxw.closed)||(!isNetscape &&atxw.creator==self)) // && AWINopened
   { SetResizeValues() };

	 };  // end of IF (atxw==object)
}
///////////////////

function SetResizeValues()
{   
 if (typeof(this.outerWidth)=="number")  { this.WindowWidth = top.atxw.window.outerWidth   };
 if (typeof(this.outerHeight)=="number") { this.WindowHeight = top.atxw.window.outerHeight }; 

   ///alert("WindowHeight: " + WindowHeight);
}
///////////////////

function SetXY()
{
 if (typeof top.atxw.window.screenX == "number")
	{ leftx = top.atxw.window.screenX; topy = top.atxw.window.screenY;  }
} // end of function


self.name = "mainWindow";
self.focus();



///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////

function ExtractFromPathname()

{
var pagenumber=" "; var pthStr = this.location.pathname;
var lastslash=pthStr.lastIndexOf("/");
var lastbacksl=pthStr.lastIndexOf("\\");
var lastdir=(lastslash>lastbacksl)?lastslash:lastbacksl;
var namestring = pthStr.substring(lastdir,pthStr.length);//  alert(namestring);

pagename = (namestring.indexOf("ptp")==-1)?"Activity page":"Practice Test page";
if (namestring.indexOf("exp") != -1&&namestring.indexOf("EXP") != -1){pagename="Exercise page"};

for (i=1; i<namestring.length; i++)
	{ ThisChar = namestring.charAt(i); //if (typeof parseInt(ThisChar) == "number" && !isNaN(ThisChar))
	  if (pagenumber.length == 4 || ThisChar=="0" || ThisChar=="1" || ThisChar=="2" || ThisChar=="3" || ThisChar=="4" || ThisChar=="5" || ThisChar=="6" || ThisChar=="7" || ThisChar=="8" ||ThisChar=="9")
		 { pagenumber += namestring.charAt(i) }; 
	 }; // end FOR
pagename += pagenumber;
return pagename;
}  // end of function ExtractFromPathname()

if (typeof pagename != "string") {
pagename = (typeof(this.titlebarname) == "string")?this.titlebarname:ExtractFromPathname();
}
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////

function onLoadFuncs() { 
 document.inputForm.onsubmit = new Function("return false;"); 
 return true;
}
this.onload = onLoadFuncs;

// **********************************************************************
        
function clickall(ppp) {
var xx = 0, yy = '0';
for (var n=0; n<AnswerArray.length; n++) {
	//document.inputForm[xx].click();    
	xx = (ppp==99)?getindex(n):ppp;
	if (document.inputForm.elements[ALPHABETarray[n]].length > xx)
	 { document.inputForm.elements[ALPHABETarray[n]][xx].checked = true}
	 else {
		 if (ppp==1){yy=document.anchors[n].name} 
		 else {yy=(ppp==99)?AnswerArray[n]:ALPHABETarray[n]};
		document.inputForm[ALPHABETarray[n]].value = yy;
	}; 
}; //end FOR
}
// **********************************************************************

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~  All javascript written by:  Erwin O. Fox Tree, 1999  ~~
//~~  foxtree@tiac.net                   okwa@hotmail.com  ~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





