//04/16/04
//alert("Utils.js");

var winMenu="";
var winBobbyIsBigMenu="";		
var winLtrRecog="";
var winWordRecog="";			;	
var winWordsToImages="";	
var winPhrasesToImages="";	
var winSummary="";	

var sNumbers=",ONE_1,TWO_2,THREE_3,FOUR_4,FIVE_5,SIX_6,SEVEN_7,EIGHT_8,NINE_9,TEN_10,";
var sColors=",BLACK_1,BLUE_2,BROWN_3,GREEN_4,ORANGE_5,PURPLE_6,RED_7,WHITE_8,YELLOW_9,";
var sLongVowels="AMY,EVA,IVY,OTTO,URSULA";

//Use to ratio images for varying screen resolutions:
var rh=0, rw=0, screenInfo="";
var yWindowTop=80;

function fnAdjAsc(val)
{
	//Required now that long vowels are included - needed?
	var sReturn=1;	//Handles the first A:
	if ((val>2) & (val<7)) {sReturn=(val-1);}
	if ((val>6) & (val<12)) {sReturn=(val-2);}
	if ((val>11) & (val<19)) {sReturn=(val-3);}
	if ((val>18) & (val<26)) {sReturn=(val-4);}
	if (val>26)  {sReturn=(val-5);}
	return sReturn;
}


function fnBuildHTMLLine(val)
{
	//Called from TrackingSheetA,B:
	//alert("val = " + val);
	var sHTMLLine="";
	for (var i=0;i<val;i++)
	{
		sHTMLLine +="<td width='2%'><font face='arial' size='2'>&nbsp;</font></td>";
	}
	//alert(sHTMLLine);
	return sHTMLLine;
}


function fnDisplayPage(val)
{
	//aryFrameDisplay.length
	//alert("50 fnDisplayPage val = " + val);
	//alert("51 aryFrameDisplay = " + aryFrameDisplay);
	//02/05/06
	if ((val>0) & (val<5))
	{
		if (document.getElementById("txtWhichLabel").value=="")
		{
			document.getElementById("divWhichLabel").innerHTML="<font face='verdana' size = '" + Math.round(2*rh) + "px' color='red'><b><i>&nbsp;&nbsp;&nbsp;Select a Book, Number or Color first ...</i></b></font>";
			alert("Select A Book, Number or Color first");
			return;
		}
	}
	for (var i=0;i<aryFrameDisplay.length;i++)
	{
		//Close all IFrames:
		//alert("53 IFrame  + i  = " + i);
		document.getElementById("IFrame" + i.toString()).style.display="none";
		//alert("55");
	}
	//Display IFrame (val):
	//alert("59 Utils After display=none, Before frame display");
	if (val==5)
	{
		window.frames["IFrame" + val].fnOnLoad();
	}
	document.getElementById("IFrame" + val).style.display="";		//.style.display="none";
	//alert("60 Utils After frame display");
	//alert("61 Utils " + document.getElementById("CurLetter" + val).value);
	
	fnSetWhichLabel2(val);
	//alert("64 Utils " + aryHTMLPages[val]);
	document.all.CurPage.value=val;
	//alert("67 val = " + val);
	var whichLabel=document.getElementById("txtWhichLabel").value;
	//alert("68 whichLabel = " + whichLabel);
	var curLabel=document.getElementById("CurLetter" + val).value;	//For HTML page index val;
	//alert("71 curLabel = " + curLabel);
	if (whichLabel!=curLabel) 
	{
		//alert("73 Before fnHTMLOnLoad()");
		if ((val>0) & (val<5)) {window.frames["IFrame" + val].fnHTMLOnLoad();}
	}
	//alert("74 Utils");
	document.getElementById("CurLetter" + val).value=whichLabel;
}


function fnOpenPageX(val)
{
	alert("44 Utils fnOpenPage val = " + val);

	/////////////////////////////////////////////////////////
	//Called from BobbyIsBig.htm and menu.htm
	//alert("Safari 222 Utils fnOpenPage val = " + val + ", rh = " + rh);
	//alert("fnOpenPage screenInfo.width = " + screenInfo.width + ", screenInfo.height = " + screenInfo.height);
	//sMsg+="\nOnLoad val = " + val;
	var attribs="left=0, top=" + (yWindowTop*rh) + "px, width=screen.availWidth, height=" + (screen.availHeight-(yWindowTop*rh)) + ", titlebar=no, resize=no, status=no, scrollbars=yes";
	//alert(attribs);
	//sMsg+="\nOnLoad attribs = " + attribs;

	//alert("58");
	//if (location.href.indexOf("BobbyIsBigMenu",0)==-1)
	{
		if (document.getElementById("txtWhichLabel").value=="")
		{
			document.getElementById("divWhichLabel").innerHTML="<font face='verdana' size = '" + Math.round(2*rh) + "px' color='red'><b><i>&nbsp;&nbsp;&nbsp;Select a Book, Number or Color first ...</i></b></font>";
			alert("66 Select A Book, Number or Color first");
			try
			{
				//////////parent.focus();		//Is BobbyIsBig.htm - OK
			}
			catch(e)
			{
				//alert("Safari 444: Error - parent.focus()");
			}
			return;
		}
	}
	
	//alert("Utils fnOpenPage val = " + val);
	//sMsg+="\nOnLoad switch val = " + val;
	switch (val)
	{
		
		case "Menu.htm":
		{
			//alert("Case Menu.htm");
			var attribs="left=0px, top=0px, height= 1px; width=screen.availWidth, scrollbars=no, resizable=no, menubar=no toobar=no, location=no";
			//sMsg+="\nOnLoad Menu.htm attribs = " + attribs;
			/////////////////////////////////////////////////////////////
			winMenu=window.open("Menu.htm","",attribs);
			/////////////////////////////////////////////////////////////
			//sMsg+="\nOnLoad Meu.htm open";
			//alert("Safari 555: Menu should be open yes/no");
			break;
		}
		
		case "LtrRecog.htm":
		{
			fnSetWhichLabel2(val);
			/*
			if ((winLtrRecog.closed==true) || (winLtrRecog.closed==null))
			{
				//alert("winLtrRecog closed");
				/////////////////////////////////////////////////////////
				//winLtrRecog=window.open("LtrRecog.htm","",attribs);
				
				/////////////////////////////////////////////////////////
			}
			else
			{
				//alert("LtrRecog focus");
				//winLtrRecog.focus();
			}
			*/
			document.getElementById("IFrame1").src="LtrRecog.htm";
			break;
		}
		
		case "WordRecog.htm":
		{
			fnSetWhichLabel2(val);
			/*
			if ((winWordRecog.closed==true) || (winWordRecog.closed==null))
			{
				//alert("winWordRecog closed");
				/////////////////////////////////////////////////////////
				winWordRecog=window.open("WordRecog.htm","",attribs);
				/////////////////////////////////////////////////////////
			}
			else
			{
				//alert("WordRecog focus");
				winWordRecog.focus();
			}
			*/
			document.getElementById("IFrame1").src="WordRecog.htm";
			break;
		}
		
		case "WordsToImages.htm":
		{
			fnSetWhichLabel2(val);
			/*
			if ((winWordsToImages.closed==true) || (winWordsToImages.closed==null))
			{
				//////////////////////////////////////////////////////////
				winWordsToImages=window.open("WordsToImages.htm","",attribs);
				/////////////////////////////////////////////////////////
			}
			else
			{
				//alert("winWordsToImages focus");
				winWordsToImages.focus();
			}
			*/
			document.getElementById("IFrame1").src="WordsToImages.htm";
			break;
		}
		
		case "PhrasesToImages.htm":
		{
			fnSetWhichLabel2(val);
			/*
			if ((winPhrasesToImages.closed==true) || (winPhrasesToImages.closed==null))
			{
				//////////////////////////////////////////////////////////
				winPhrasesToImages=window.open("PhrasesToImages.htm","",attribs);
				/////////////////////////////////////////////////////////
			}
			else
			{
				//alert("winPhrasesToImages focus");
				winPhrasesToImages.focus();
				
			}
			*/
			document.getElementById("IFrame1").src="PhrasesToImages.htm";
			break;
		}
		
		case "Summary.htm":
		{	
			fnSetWhichLabel2(val);
			/*
			if ((winSummary.closed!=true) & (winSummary.closed!=null))
			{
				//alert("Summary open, close it");
				winSummary.close();
			}
			/////////////////////////////////////////////////////////
			attribs="scrollbars=no, resizable=no, menubar=no, toobar=no, location=no";
			//alert("attribs = " + attribs);
			winSummary=window.open("Summary.htm","",attribs);
			/////////////////////////////////////////////////////////
			*/
			document.getElementById("IFrame1").src="Summary.htm";
			break;
		}
	
		default:
		{
			alert("Utils fnOpenPage Default - shouldn't be here");
			break;
		}
	}
	//Maintain window positions:
	//alert("Before setting moveBack");
	///////////////setInterval("moveBack(yWindowTop)",250);
	//sMsg+="\nEnd fnOnLoad()";
}


function 	fnMaximizeWindow(val, val2)
{
	//Called from DragNDrop.fnOnLoad():
	//alert("fnMaximizeWindow val = " + val + ", val2 = " + val2);
	//val: Currently 0 or yWindowTop
	//val2: true - display message in fnGetWidthHeight():
	screenInfo=fnGetWidthHeight(val2);
	//alert("fnMaximizeWindow screenInfo: " + screenInfo.width + ", " + screenInfo.height + ", " + screenInfo.ratio); 
	try
	{
		window.moveTo(0,val);
		window.resizeTo(screenInfo.width, screenInfo.height-val);
	}
	catch(e) {}
}


function moveBack(val)
{
	//alert("moveBack");
	try
	{
		if ((winMenu.closed!=true) && (winMenu.closed!=null)) {winMenu.moveTo(0,0);}
		if ((winBobbyIsBigMenu.closed!=true) && (winBobbyIsBigMenu.closed!=null)) {winBobbyIsBigMenu.moveTo(0,val);}
		if ((winLtrRecog.closed!=true) && (winLtrRecog.closed!=null)) {winLtrRecog.moveTo(0,val);}
		if ((winWordRecog.closed!=true) && (winWordRecog.closed!=null)) {winWordRecog.moveTo(0,val);}
		if ((winWordsToImages.closed!=true) && (winWordsToImages.closed!=null)) {winWordsToImages.moveTo(0,val);}
		if ((winPhrasesToImages.closed!=true) && (winPhrasesToImages.closed!=null)) {winPhrasesToImages.moveTo(0,val);}
		if ((winSummary.closed!=true) && (winSummary.closed!=null)) {winSummary.moveTo(0,val);}
	}
	catch(e) {}
}


function fnReplicate(val, val2)
{
	//val: char to replicate, val2: number of times to replicate:
	var sReturn="";
	for (var i=0;i<val2;i++)
	{
		sReturn+=val;
	}
	//alert("sReturn = " + sReturn);
	return sReturn;
}


function fnSetMouseUpDown(val)
{
	//12/29/05 disabled;

	//1: Activated, 0:Not activated
	if (val==0)
	{	
		document.onmousedown="";
		document.onmouseup="";
	}
	else
	{
		document.onmousedown=drags;
		document.onmouseup=drop;
	} 
}


function fnGetWidthHeight(val)
{
	//alert("fnGetWidthHeight val = " + val);
	//Returns usable screenWidth, screenHeight and ratio to 800x600 resolution:
	//val: Display message
	/* Screen resolutions and aspect ratios in W2000:
	640   x 480:  1.333333333
	720   x 480:  1.5
	720   x 576:  1.25
	800   x 600:  1.333333333
	848   x 480:  1.333333333
	1024 x 768:  1.333333333
	1152 x 864:  1.6
	1280 x 720:  1.777777777
	1280 x 1024: 1.25
	1900 x 1200: 1.583333333 - Thom's Dell WXP Home
	*/
	var res=screen.availWidth/screen.availHeight;
	var winWidth=screen.availWidth;
	var winHeight=screen.availHeight;
	var winRatio=0;
	var myRatio=800/600;
	if (res>=myRatio)
	{
		//Screen wider than 800x600 res:
		winWidth=(Math.round(100*winHeight*myRatio))/100;	//2 dp
	}
	else
	{
		//Screen higher than 800x600 res:
		winHeight=(Math.round(100*winWidth/myRatio))/100;		//2 dp
	}
	winRatio=winHeight/600;	//or winWidth/800;
	//Display message:
	if (val==true)
	{
		if ((winWidth<800) || (winHeight<600)) {alert("Attention System Administrator:\nThis application has been optimized for use with screen resolutions 800x600 or higher");}
	}
	//alert("fnGetWidthHeight return winwidth = " + winWidth + ", winHeight = " + winHeight + ", winRatio = " + winRatio);
	return {width:winWidth, height:winHeight, ratio:winRatio};
}


function fnClosePages()
{
	//Called from Menu.htm:
	var testHasStarted=false;
	workSheetsWereOpen=false;

	//alert("1. " + document.getElementById("txtTestHasStarted1").value + "\n2: "+ document.getElementById("txtTestHasStarted2").value + "\n3: " + document.getElementById("txtTestHasStarted3").value + "\n 4: " + document.getElementById("txtTestHasStarted4").value);

	if ((document.getElementById("txtTestHasStarted1").value=="1") || (document.getElementById("txtTestHasStarted2").value=="1") || (document.getElementById("txtTestHasStarted3").value=="1") || (document.getElementById("txtTestHasStarted4").value=="1")) {testHasStarted=true;}
	var resp="";
	if (testHasStarted==true)
	{
		resp=confirm("Before you close your tests, you need to print out the Score sheet.\nOtherwise you scores will be lost.\n\nClose?")
		//alert("resp 1 = " + resp);
		if (resp==null) {resp=true;}
		if (resp=="") {resp=false;}
		//alert("resp 2 = " + resp);
		if (resp!=true) {return;}
		//alert("after return");
	}
	if ((winLtrRecog.closed!=true) && (winLtrRecog.closed!=null)) 
	{
		workSheetsWereOpen=true;
		winLtrRecog.document.body.onbeforeunload=null;
		winLtrRecog.close();
	}
	if ((winWordRecog.closed!=true) && (winWordRecog.closed!=null)) 
	{
		workSheetsWereOpen=true;
		winWordRecog.document.body.onbeforeunload=null;
		winWordRecog.close();
	}
	if ((winWordsToImages.closed!=true) && (winWordsToImages.closed!=null)) 
	{	
		workSheetsWereOpen=true;
		winWordsToImages.document.body.onbeforeunload=null;
		winWordsToImages.close();
	}
	if ((winPhrasesToImages.closed!=true) && (winPhrasesToImages.closed!=null)) 
	{	
		workSheetsWereOpen=true;
		winPhrasesToImages.document.body.onbeforeunload=null;
		winPhrasesToImages.close();
	}
	if ((winSummary.closed!=true) && (winSummary.closed!=null)) 
	{
		workSheetsWereOpen=true;
		winSummary.close();
	}

	if (workSheetsWereOpen!=true)
	{
		/////////////////try {parent.close();} catch(e){}
		window.close();
	}
	else
	{
		document.getElementById("txtTestHasStarted1").value=0;
		document.getElementById("txtTestHasStarted2").value=0;
		document.getElementById("txtTestHasStarted3").value=0;
		document.getElementById("txtTestHasStarted4").value=0;
	}
}
		
		
function fnGetDate()
{
	var weekDays=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var months=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
	
	var today=new Date();
	//alert(today);
	var year=today.getYear();
	var month=months[today.getMonth()];
	//alert("month = " + month);
	var date=today.getDate();
	var day=today.getDay();
	//alert("day = " + day);
	var weekDay=weekDays[day];
	sDate=weekDay + ", " + month + " " + date + " " + year
	//alert(sDate);
	return sDate;
}


function fnName()
{
	//06/29/04 Needed in case Summary.htm is closed after entering name, then reopenend
	var sName=document.getElementById("txtName").value;
	try
	{
		parent.document.getElementById("txtName").value=sName;
	}
	catch(e){}
}


function fnTrimB(val,all)
{
	//Remove trailing, leading spaces.
	//all: 1 reduce inner spaces to 1. 0: remove ALL inner spaces
	//NOTE: When there is more then one space, they could be shown with &nbsp;!
	//	&nbsp; are removed with fnRemoveSpaceCode().
	//alert("fnTrimB val = " + val + ", all = " + all);
	var newVal="";
	var newVal2="";
	var cnt=0;

	if (val.length>0)
	{
		//Remove leading spaces:
		for (var i=0;i<val.length;i++)
		{
			var myChar=val.charAt(i);
			//alert("myChar = " + myChar);
			if (myChar!=" ")
			{
				//alert("i = " + i);
				newVal=val.substr(i);
				//alert("newVal 1 = " + newVal);
				break;
			}
		}
		//alert("fnTrimB newVal 1 = " + newVal);
		//Remove trailing spaces:
		for (var i=newVal.length-1;i>-1;i--)
		{
			var myChar=newVal.charAt(i);
			//alert("myChar = " + myChar);
			if (myChar!=" ")
			{
				newVal2=newVal.substr(0,i+1);
				//alert("newVal2 2 = " + newVal2);
				break;
			}
		}
		//alert("fnTrimB newVal 2 = " + newVal2);
		//Depending on value of all, remove inner spaces:
		newVal="";
		for (var i=0;i<newVal2.length;i++)
		{
			var myChar=newVal2.charAt(i);
			//alert("myChar = " + myChar);
			if (myChar==" ")
			{
				cnt+=1;
				//alert("myChar = " + myChar + ", all = " + all + ", cnt = " + cnt);
				if ((cnt==1) & (all==1))
				{
					newVal+=myChar;
					//alert("fnTrimB space addedfnTrimB  = " + newVal);
				}
			}
			else
			{
				cnt=0;
				newVal+=myChar;
			}
		}	
	}
	//alert("fnTrimB return = " + newVal);
	return newVal;
}


function fnUnLoad()
{
	//alert("unload");
	//Caled from Menu.htm
	var temp="";
	try		//In case menu.htm is closed manually
	{
		if (pageURL.indexOf("LtrRecog",0)>-1) {temp=parent.document.getElementById("txtTestHasStarted1").value;}
		if (pageURL.indexOf("WordRecog",0)>-1) {temp=parent.document.getElementById("txtTestHasStarted2").value;}
		if (pageURL.indexOf("PhrasesToImages",0)>-1) {temp=parent.document.getElementById("txtTestHasStarted3").value;}
		if (pageURL.indexOf("WordsToImages",0)>-1) {temp=parent.document.getElementById("txtTestHasStarted4").value;}
	} catch(e) {}
	if (temp=="1")
	{
		mess = "You will loose your test if your close the window by hitting the close button.\nClick Home to Close"
	}
	else
	{
		mess = "Do not close test by hitting the close button.\nClick Home to Close"
	}
	return mess;
}


function fnReplace(val, what, withwhat)
{
	//alert("fnReplace " + val + ", " + what + ", " + withwhat);
	var sReturn="";
	var temp=val;
	var pos=0;
	//alert("what.length = " + what.length);
	while (pos>-1)
	{
		pos=temp.indexOf(what);
		//alert("pos = " + pos);
		if (pos>-1)
		{
			//alert(temp.substr(0,pos) + "\n" + temp.substr(pos+1+what.length));
			//alert("pos+1+what.length = " + pos + ", 1 " + what.length + ", " + ((pos)+1+ (what.length)));
			var newpos=((pos) +  (what.length));
			//alert("newpos = " + newpos);
			//alert(temp.substr(0,pos) + "\n" + temp.substr(newpos));
			//temp=temp.substr(0,pos) + withwhat + temp.substr(newpos);
			temp=temp.substr(0,pos) + withwhat + temp.substr(newpos);
			//alert("new temp = " + temp);
		}
	}
	//alert("done\n" + temp); 
	return temp;
}


function fnGetNumberColor_Number(sNumberColor, word)
{
	//alert(sNumberColor + ", " + word);
	var pos=-1, pos2=-1, pos3=-1;
	var sReturn="";
	pos=sNumberColor.indexOf("," + word.toUpperCase() + "_",0);
	if (pos>-1)	//word found:
	{
		pos2=sNumberColor.indexOf("_",pos);
		pos3=sNumberColor.indexOf(",",pos2);
		//alert("pos = " + pos + ", pos2 = " + pos2 + ", pos3 = " + pos3);
		//alert("pos3-pos2-1 = " + (pos3-pos2-1));
		sReturn=sNumberColor.substr(pos2+1,pos3-pos2-1);
	}
	//alert("sReturn = " + sReturn);
	return sReturn;
}


function fnGetNumberColor_Word(sNumberColor, number)
{
	var pos2=-1, pos3=-1;
	var sReturn="";
	pos2=sNumberColor.indexOf(number.toString(),0);
	pos3=sNumberColor.lastIndexOf(",",pos2);
	//alert("pos2 = " + pos2 + ", pos3 = " + pos3);
	sReturn=sNumberColor.substr(pos3+1,pos2-pos3-2);
	//alert(sNumberColor + "\nsNumber = " + number + ", pos2 = " + pos2 + ", pos3 = " + pos3 + "\npos2-pos3-2 = " + (pos2-pos3-2) + ", sReturn = " + sReturn);	
	return sReturn;
}


function fnGetColorCode(val)
{
	var val1=val.toUpperCase();
	//alert("fnGetColorCode val1= " + val1);
	var sReturn="";
	if (val1=="ORANGE") {sReturn="#ffa500";}
	if (val1=="WHITE") {sReturn="#ffffff";}
	if (val1=="BROWN") {sReturn="#800000";}
	if (val1=="PURPLE") {sReturn="#800080";}
	if (val1=="RED") {sReturn="#ff0000";}
	if (val1=="BLUE") {sReturn="#0000ff";}
	if (val1=="GREEN") {sReturn="#00ff00";}
	if (val1=="BLACK") {sReturn="#000000";}
	if (val1=="YELLOW") {sReturn="#ffff00";}
	//alert("sReturn = " + sReturn);
	return sReturn;
}


function fnSetWhichLabel2(val)
{
	//Called from fnDisplayPage():
	//val: Index of parameter that was passed into fnOpenPage()
	var whichLabel=document.getElementById("txtWhichLabel").value.toUpperCase();
	var ltrNbrClr=document.getElementById("LtrNbrClr").value;
	var htmlPage=aryHTMLPages[val];
	//alert("628 fnSetWhichLabel2 val = " + val + ", whichLabel = " + whichLabel + ", ltrNbrClr  = " + ltrNbrClr + "\nrh = " + rh + ", htmlPage = " + htmlPage);
	var sTitle="";
	
	switch(htmlPage)
	{
		case "BobbyIsBig.htm":
		{
			sTitle="Select a Letter, Number or Color";
			break;
		}
		case "LtrRecog.htm":
		{
			var sWhat=whichLabel.substr(0,1) + "</i> letters";
			if (ltrNbrClr=="N") {sWhat=whichLabel + "s</i>";}
			if (ltrNbrClr=="C") {sWhat=whichLabel + "</i> shapes";}
			sTitle="Drag 5 <i>" +  sWhat + " into the boxes in the center.";
			break;
		}
		
		case "WordRecog.htm":
		{
			var whichLetter=whichLabel.substr(0,1);
			var whichLabelIsAVowel=false;
			var whichLabelIsALongVowel=false;
			var whichLabelIsAShortVowel=false;
			if (ltrNbrClr=="L")
			{
				if ("AEIOU".indexOf(whichLetter.toUpperCase(),0)>-1)
				{
					//Is a vowel
					whichLabelIsAVowel=true;
					///var sLongVowels="AMY,EVA,IVY,OTTO,URSULA";
					if (sLongVowels.indexOf(whichLabel.toUpperCase(),0)>-1)
					{
						whichLabelIsALongVowel=true;
					}
					else
					{
						whichLabelIsAShortVowel=true;
					}
					sTitle="Drag 5 words having the <i>" + ((whichLabelIsALongVowel==true)?" long":" short") + "<i> vowel " + whichLabel.substr(0,1) + "</i> into the boxes in the center";
				}
				else
				{
					sTitle="Drag 5 words beginning with <i>" + whichLabel.substr(0,1) + "</i> into the boxes in the center";
				}
			}
			if (ltrNbrClr=="N") {sTitle="Drag 5 words that mean the number " + fnGetNumberColor_Number(sNumbers,whichLabel) + " into boxes in the center";}
			if (ltrNbrClr=="C") {sTitle="<font color=" + fnGetColorCode(whichLabel) + ">Drag 5 words that mean the color of this text into boxes in the center</font>";}
			break;
		}
		
		case "WordsToImages.htm":
		{
			//Letters:
			sTitle="Match the 5 words to pictures.";
			if (ltrNbrClr!="L") {sTitle="Drag the 5 words to match pictures suggesting the" + ((ltrNbrClr=="N")?" number " + fnGetNumberColor_Number(sNumbers,whichLabel):" color of this text");} 
			if (ltrNbrClr!="L") 
			{	
				sTitle="";
				if (ltrNbrClr=="C") {sTitle="<font color=" + fnGetColorCode(whichLabel) + ">";}
				sTitle += "Drag the 5 words to match pictures suggesting the" + ((ltrNbrClr=="N")?" number " + fnGetNumberColor_Number(sNumbers,whichLabel):" color of this text");
				if (ltrNbrClr=="C") {sTitle += "</font>";}
			}
			break;
		}
		
		case "PhrasesToImages.htm":
		{
			sTitle="Match the 5 phrases to pictures.";
			if (ltrNbrClr!="L") 
			{	
				sTitle="";
				if (ltrNbrClr=="C") {sTitle="<font color=" + fnGetColorCode(whichLabel) + ">";}
				sTitle += "Drag the 5 phrases to match pictures suggesting the" + ((ltrNbrClr=="N")?" number " + fnGetNumberColor_Number(sNumbers,whichLabel):" color of this text");
				if (ltrNbrClr=="C") {sTitle += "</font>";}
			}
			break;
		}
			
		case "Summary.htm":
		{
			sTitle="Your Scores for <i>" + whichLabel + "</i>.";
			break;
		}
	}
	//alert("695 sTitle = " + sTitle);
	document.getElementById("divWhichLabel").innerHTML="<font face='verdana' color='black' size='" + Math.round(2*rh) + "px'><b>" + sTitle + "</b>";
}


function fnOpenPageSS(val)
{
	//Called from StateStandards.htm and EducStandards.htm:
	//alert("660 Utils: val = " + val);
	var whichPage="";
	var menuBar="";
	var scrollBars="";
	var winOpen="";
	if (val=="TT") {whichPage="TeachersTools.htm";menuBar="yes";scrollBars="yes";}
	if (val=="TS") {whichPage="TrackingSheet.htm";menuBar="no";scrollBars="no";}
	if (val=="BB") {whichPage="Menu.htm";menuBar="no";scrollBars="no";}
	if (val=="CO") {whichPage="Correlations.htm";menuBar="yes";scrollBars="yes";}
	if (val=="TH") {whichPage="TakeHome.htm";menuBar="no";scrollBars="no";}
	if (val=="SS") {whichPage="StateStandards.htm";menuBar="ye";scrollBars="yes";}
	if (val=="C1")
	{
		var index=document.getElementById("SelectCert").selectedIndex;
		if (index==0) {alert("Make a selection"); return;}
		alert("Certificate is intended to be printed landscape\nwith 0.75in borders all round.\n\nYou can set to landscape by clicking File/Page SetUp.\n\nYou may also print the pages without the default browser header and footer by removing the codes.");
		whichPage="Certificate1.htm";menuBar="yes";scrollBars="no";
	}
	mAttribs="scrollbars =" + scrollBars + ", resizable=yes, menubar=" + menuBar + ", toobar=no, location=no";
	//alert("mAttribs = " + mAttribs);
	var attribs="titlebar=no, resizable=yes, status=no, scrollbars=no";
	//var attribs="titlebar=no, resize=yes, status=no, scrollbars=no";

	//alert("mAttribs = " + mAttribs + "\nattribs = " + attribs);
	winOpen=window.open(whichPage,"",mAttribs);
	winOpen.focus();
}
		
		
function fnWindowPrint()
{
	//alert("fnWindowPrint");
	//Called from Summary.htm only
	document.Form1.Print.style.visibility="hidden";
	window.print();
	alert("Wait until the page has been sent to the printer\nbefore clicking this message off.");
	document.Form1.Print.style.visibility="visible";
	
	//Need this for Summary.htm.
	try
	{
		document.getElementById("txtName").focus();
	}
	catch(e){}
}