

// $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
function CloseGeneratedWindow() { closeWin(printWIN,0) };
// $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

//---------------------------------------------------------------------------------------
var genWINopened = 0;

function closeWin(winObj,prntclosemode) {

	if (typeof winObj =="object")
	{

	if (isOpen(winObj))
		 {
			var openerIsSelf = 0; var emailConfirmMode = 0; var openerNotFound = 0;

			if (	(typeof winObj.creator == "object" && winObj.creator && winObj.creator == self) ||	(typeof winObj.opener  == "object" && winObj.opener  && winObj.opener  == self)	)
				{openerIsSelf = 1}
			else 
			if (typeof winObj.havesubmitted == 'number' && typeof winObj.cgimaker!="undefined" )
				{emailConfirmMode = 1};
			
			if (openerIsSelf || emailConfirmMode) 
			{
				if (prntclosemode && typeof winObj.parentclosing=="number") winObj.parentclosing=1;
				winObj.close();
			}
		 };
	}
}
//-------------------------------------
function isOpen(winObj) {
	if (typeof winObj != 'object') {return 0};
	var thisWinOpen = 0;
	if (isNetscape)
		{ thisWinOpen = (winObj.closed)?0:1}
	else {
		thisWinOpen = ((typeof winObj.creator == "object" || typeof winObj.cgimaker!="undefined") &&!winObj.closed)?1:0;
	};
	return thisWinOpen
}
//-------------------------------------
CloseGenWinLoaded = 1;
//---------------------------------------------------------------------------------------



CloseGenWinLoaded = 1;


var innernum=0;
var i = 0;
var probnum=0;

var buttonclickcount=0;
var reductionNum = 2;
var outerNumString = "";
var subLetterString = "";

var endl = "\n";


var inNumString = new String(" ");
var formattedAnswer = new String(" ");
var QuestionfromHidform = new String(" ");
var HTMLSTRING = new String(" ");

var QNAME = new String(" ");
var HeadName = new String(" ");
var beginHead = new String(" ");
var HEADING = new String(" ");
var beginText = new String(" ");

subLetterArray = 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');

_beginHTML_ = new String("<HTML>\n<HEAD>\n<TITLE>");

pagename = new String("Activity ");

_endTITLE_ = new String("</TITLE>");





_endHEADbeginBODY_ = new String("</HEAD>\n<BODY bgcolor=\"#EEEEFF\" text=\"#000011\" LINK=\"#0000FF\" ALINK=\"#FF00DD\" VLINK=\"#0000EE\">");



_beginTABLEbeginROW_ = new String("\n<center><TABLE  WIDTH=\"92%\" CELLSPACING=2 CELLPADDING=1 BORDER=0><TR><TD COLSPAN=4><BR>")

_endROW_HRtableROW_ = new String("</TD></TR><TR><TD COLSPAN=4><HR NOSHADE SIZE=1 WIDTH=\"100%\"></TD></TR>\n");



_HR_ROW_ = "<TR><TD COLSPAN=4><HR></TD></TR>";

_beginTRbeginTD_H3_ = "\n<TR><TD VALIGN=TOP WIDTH=\"3%\"><H3>";



_endH3_TDbeginTD_ = new String("</H3> </TD><TD VALIGN=TOP COLSPAN=2>");

_lineBR_ = new String(" <BR>");


_HRtableROW_ = new String("\n<TR><TD COLSPAN=4><HR NOSHADE SIZE=1 WIDTH=\"100%\"></TD></TR>\n<TR><TD COLSPAN=4>");

_endTABLE_ = new String("</TD></TR></TABLE></center>");

_windowCloser_ = new String(" <BR> &nbsp; <CENTER><A HREF=\"javascript:if(typeof(top.opener)=='object'&&top.opener!=null){if(top.opener.document){top.opener.focus();}};self.close()\"><b>Close Window</b></A> </CENTER> \n");

_endBODYendHTML_ = new String(" <BR> &nbsp; \n </BODY> \n </HTML> ");




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

 var isNetscape =(navigator.appName.indexOf('Netscape') == -1)?0:1;
 var isMac		= (navigator.appVersion.indexOf('Mac') == -1)?0:1;
 var notcapable = 0;

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


emptyspacer=(notcapable&&isMac)?" ":" &nbsp; ";

AnsGivenEndText = new String("<BR></TD><TD>" + emptyspacer + "</TD></TR> \n");
if (typeof(this.hrdraw)=="number" && this.hrdraw==1)  {  AnsGivenEndText = "</TD><TD>" + emptyspacer + "</TD></TR> \n";   }


answerTextForEmail = new String();

mainHeadingH2 = "";
subHeadingH3 = "";

function PrintWindow()
{
HTMLSTRING =  _beginTABLEbeginROW_;
probnum=0;
innernum=0;



getFormHeadingValues();

if (typeof isEmailFeature == "number") {

EMAILSTRING = (typeof  bookTitle== "string")?(bookTitle+"\n"):"";

EMAILSTRING += pagename;

EMAILSTRING += (mainHeadingH2 == "")?"":"\n";
EMAILSTRING += mainHeadingH2;
EMAILSTRING += (subHeadingH3 == "")?"":"\n";
EMAILSTRING += subHeadingH3;
};
subHeadingH3html = (subHeadingH3=="")?"":"<H3>" + subHeadingH3 + "</H3>"

cr = new String("\r");	     cr = (isMac)?"\r":"\n";


buttonclickcount++

if (buttonclickcount<3)
	{ HTMLSTRING += "[From the <B>FILE</B> menu, select either <B>Print</B> or <B>Save as.</B>]<BR>" };
HTMLSTRING += "<H2>" + mainHeadingH2 + "</H2>" +  subHeadingH3html + document.hidForm.customHeader.value + _endROW_HRtableROW_;


if (typeof(this.numberOfButtons)=="number")  {reductionNum = this.numberOfButtons};
if (typeof(this.reduceFormNumber)=="number") {reductionNum = this.reduceFormNumber};


for (i=0; i<(document.inputForm.length-reductionNum); i++)
  {
	if (i>0 && typeof(this.hrdraw)=="number" && this.hrdraw==1) { HTMLSTRING += _HR_ROW_  };



	responseGiven = document.inputForm[i].value.toString();


	textarCOLS=72;





	if (responseGiven=="" || responseGiven==" " || responseGiven=="\r" || responseGiven=="\n" || responseGiven==document.inputForm[i].defaultValue)
		{ responseGiven = responseGiven + "         (no response was given)          "
		 formattedAnswer = emptyspacer + "<PRE><tt><font color=\"#003333\">" + wrapText(document.inputForm[i].defaultValue,textarCOLS,cr) + "</font></tt></PRE><center><font color=\"#333333\"><i>no response was given</i></font></center><BR>";
	} else
		{
		 formattedAnswer = " <PRE><tt><font color=\"#003333\">" + wrapText(responseGiven,textarCOLS,cr) + "</font></tt></PRE>" };


	QuestionfromHidform = document.hidForm[i].value;


		beginText = (i==0)?_beginTRbeginTD_H3_:(_HR_ROW_ + _beginTRbeginTD_H3_)


	QNAME = document.hidForm[i].name;


if (typeof(this.innerNumMode)!="number"){this.innerNumMode=1};

	if (QNAME.charAt(0)=="h")
	  { ++probnum;

		if (this.innerNumMode == 2 || this.innerNumMode == -1)   {innernum = 0};
		HEADING = document.headingForm[probnum-1].value + "</TD></TR><TR><TD></TD><TD VALIGN=TOP> ";
		HeadName = document.headingForm[probnum-1].name;

		beginHead = (HeadName.charAt(0)=="n")?(beginText + probnum +"."+ _endH3_TDbeginTD_):"<TR><TD VALIGN=TOP COLSPAN=4>";

		innernum++;
			inNumString = (this.innerNumMode >0)?("<B>" + innernum + ".</B>"):emptyspacer;
		HTMLSTRING +=   beginHead + HEADING + inNumString + "</TD><TD>  " +QuestionfromHidform + _lineBR_ +formattedAnswer  +AnsGivenEndText;

	if (typeof this.outerNumMode!='number' || outerNumMode==1){outerNumString=probnum}else{outerNumString="";}



	 }
	else
	 {
		innernum++;

	  if (this.innerNumMode == -2)
		 {inNumString=subLetterArray[innernum].toUpperCase() + "."}
	  else
		 { inNumString = (this.innerNumMode > 0)?(innernum + "."):emptyspacer };
		HTMLSTRING += "<TR><TD WIDTH=\"2%\"></TD><TD VALIGN=TOP WIDTH=\"3%\"><B>"+ inNumString + "</B></TD><TD>" +QuestionfromHidform+_lineBR_+formattedAnswer+AnsGivenEndText;


	 };




if (typeof(this.innerNumMode)!="number" || this.innerNumMode > 0)
	{subLetterString = (innerNumMode==2)?"-":"";
	 subLetterString +=innernum + ".) "
	}
 else if (this.innerNumMode == -1)
	{subLetterString="-"+subLetterArray[innernum] + ".) "}
 else if (this.innerNumMode == -2)
	{subLetterString=subLetterArray[innernum].toUpperCase() + ".) "}
 else {subLetterString="";outerNumString="";};

wholeProbName = outerNumString + subLetterString;


  if (typeof isEmailFeature == "number")
	 {
	  EMAILSTRING += (i>0)?brokenSeparator:solidSeparator
	  EMAILSTRING += "\n" + wholeProbName + QuestionfromHidform + "\n \n";
	  EMAILSTRING += responseGiven;
	 };







	};




 HTMLSTRING += _HRtableROW_ + document.hidForm.customFooter.value;


		NewWin(HTMLSTRING);

}

var winopenparams = "";
var defaultparams = "toolbar=no,location=no,directories=no,status=no,history=no,menubar=yes,scrollbars=yes,resizable=yes,screenX=3,screenY=3,width=600,height=400";


var printWIN;
function NewWin(inputstring)
{
winopenparams = defaultparams;

if (typeof(printWIN)=="object" && typeof printWIN.cgimaker == "unknown")
	{printWIN.close()};


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

	top.printWIN.document.close();
	top.printWIN.document.open("text/html","replace");

  printWIN.document.writeln(_beginHTML_ + pagename + _endTITLE_);


	 printScript();


  printWIN.document.writeln(_endHEADbeginBODY_);
  printWIN.document.writeln(inputstring);


	 if (typeof isEmailFeature == "number") {

	 genWindowObject = printWIN;

	 if (typeof preWrap=="undefined") preWrap=1;
	 if (typeof preWrap=="number" && preWrap) {



					deleteHTMLarray=new Array('\r','&quot;','<P>','<BR>','<i>','</i>','<b>','</b>','<B>','<I>','<u>','</u>','</P>')
				  replaceWtextArray=new Array('\n','\"','\n \n','\n','','','','','','','','','','','','')

					for (var a=0; a<deleteHTMLarray.length; a++)
					 {
					  EMAILSTRING_split = EMAILSTRING.split(deleteHTMLarray[a]);
					  EMAILSTRING =  EMAILSTRING_split.join(replaceWtextArray[a])
					 };

		EMAILSTRING = wrapText(EMAILSTRING,72,"\n")

	  }

		 EMAILSTRING += "\n \n" + solidSeparator + "\n \n \n ";
	 EmailerDirections = " E-mail your responses: ";
	 writeEmailTable(printWIN.document)
  printWIN.document.writeln("<center><HR NOSHADE SIZE=1 WIDTH=\"100%\"></center>");
 };


  printWIN.document.writeln(_endTABLE_);
  printWIN.document.writeln(_windowCloser_);
  printWIN.document.writeln(_endBODYendHTML_);

	top.printWIN.document.close();
	if (isNetscape && !notcapable) { top.printWIN.window.stop(); };
	
	top.printWIN.focus();


 if (!isNetscape)
	{
	 if (typeof printWIN.creator == "object" && printWIN.opener && printWIN.opener.document && (typeof printWIN.opener.genWINopened == "number"))
		{
		  if (printWIN.opener != self) { printWIN.opener.genWINopened = 0 };
		};
	};
 printWIN.creator = self;
 printWIN.opener = self;
 genWINopened = 1


}




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





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

function printScript() {
	printWIN.document.writeln(" <SCRIP" + "T TYPE=\"text/javascript\" LANGUAGE=\"JavaScript\">");


if (typeof(this.newWinSuppressor) != "number" || this.newWinSuppressor!=0)
 {

	if(notcapable==1)
		 {
		  printWIN.document.writeln("  window.onerror=null;");
		 }   /* error suppression*/
	else {
		  printWIN.document.writeln("  window.onerror = new Function(\"return true;\");");
		 };
  };

	printWIN.document.writeln("self.name = '" +windowname+ "';");
	printWIN.document.writeln(" </SCRIP" + "T>");

}





wrapTextSuccess = 0;

 function wrapText(inputString,colwidth,r) {
 if (wrapTextSuccess==-1) {return inputString};
 wrapTextSuccess = -1;
 splitarr = inputString.split("\t");
 inputString = splitarr.join("   ");

	 space=new String(" ");
	 startspan = 0;
	 endat = inputString.length;
	 insertR = 0;

	 for (var rrr=0; rrr<2*endat/colwidth; rrr++) {

	  lastreturn = inputString.indexOf(r, startspan)

		if ((startspan+colwidth<endat) && (lastreturn > startspan+colwidth || lastreturn==-1))
		 {



				  insertR = (inputString.lastIndexOf(space, startspan+colwidth)) + 1;


			if (insertR == -1 || insertR<startspan) {insertR = startspan+colwidth;};
			inputStringTemp = inputString.substring(0,insertR) + r + inputString.substring(insertR,endat)

			inputString = inputStringTemp;
		 }
		else {insertR=lastreturn};

		if (startspan+colwidth>endat) { wrapTextSuccess = 1; return inputString;}

		startspan = insertR+1;

		keeplooking=1;
		while (keeplooking && keeplooking<endat/colwidth)
		{
		  if (inputString.lastIndexOf(r, startspan+colwidth)>startspan && startspan+colwidth<endat)
			 {startspan = inputString.lastIndexOf(r, startspan+colwidth);keeplooking++}
		  else {keeplooking=0;break;}
		}

		endat = inputString.length;
		}
		wrapTextSuccess = 1;
		return inputString;
	 }


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);


for (i=1; i<namestring.length; i++)
	{ ThisChar = namestring.charAt(i);

	if (ThisChar=="0" || ThisChar=="1" || ThisChar=="2" || ThisChar=="3" || ThisChar=="4" || ThisChar=="5" || ThisChar=="6" || ThisChar=="7" || ThisChar=="8" ||ThisChar=="9")
		{  pagenumber += namestring.charAt(i) }
	else if (pagenumber.length == 4)
	  {
		if (ThisChar=="a" || ThisChar=="b" || ThisChar=="c" || ThisChar=="d" || ThisChar=="e")
		  { pagenumber += namestring.charAt(i) };
		};
  };

pagename = "Activity page" + pagenumber;
}


if (typeof(this.titlebarname) == "string")
		{ pagename = this.titlebarname }
 else  { ExtractFromPathname() };






function getFormHeadingValues()
{
if (typeof(document.hidForm) != "undefined")
{
 with (document.hidForm)
  {
  if(typeof(headingH2) != "undefined" && typeof(headingH2.value) != "undefined")
	{ mainHeadingH2 = document.hidForm.headingH2.value };

  if(typeof(headingH3) != "undefined")
	{ subHeadingH3 = document.hidForm.headingH3.value };
  };
};

if (typeof mainHeadingH2 == 'undefined' || mainHeadingH2==" "||mainHeadingH2=="  ") mainHeadingH2="";
if (typeof subHeadingH3 == 'undefined' || subHeadingH3==" "||subHeadingH3=="  ") subHeadingH3="";

}



function onLoadFuncs() {
  document.inputForm.onsubmit = new Function("return false;");
  if (typeof document.tableForm != 'undefined')
	 {document.tableForm.onsubmit = new Function("return false;")};
	setMouseDownEvents();
  return true;
}

dirstr='';
function changeStatusSubmitter() { window.status=('Print all of the questions with the answers you gave.' + dirstr);return true; }

function changeStatusResetter() {window.status='Erase all responses permanently.'; return true;}

function clearStatus() {window.status=' '; return true;}

function setMouseDownEvents(){
if (typeof document.inputForm!='undefined' && typeof document.inputForm.submitter!='undefined' && typeof document.inputForm.resetter!='undefined')
	 {  document.inputForm.submitter.onmousedown=changeStatusSubmitter;
	    dirstr=(typeof isEmailFeature == "number")? '   E-mail the results if you are satisfied.':' ';
		document.inputForm.submitter.onmouseup=clearStatus;		document.inputForm.resetter.onmouseup=clearStatus;
		document.inputForm.resetter.onmousedown=changeStatusResetter;
	 }  }


this.onload = onLoadFuncs;






function zw()
{
if (typeof obj == "undefined") var obj=top.printWIN;
w=window.open('',"testwindow2");
w.document.writeln("<XMP>");
for(var props in obj)
  {w.document.writeln("property:" + props + "\nvalue: " + obj[props] +"\n")};
w.document.writeln("</XMP>");
w.document.close();

}





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






