var footerDate="082008";

function initFooter()
{
	//load js with special functions for wpos
	if (pgTpl=="wpos" && typeof(wdivposIncluded) == "undefined") includeJs(sharedDirectory +"js/wdivpos.js"); //must be at bottom of page
	if (pgTpl.indexOf("full") > -1 && pgTpl.indexOf("cliq") == -1) initializePage();
	if (pgTpl=="summary_co1") customButton="scores";
	resetNextButton()
	
	if (useNewDesign)
	{
		if (pgTpl.indexOf("mc") > -1 && typeof(pgType) != "undefined" && pgType.indexOf("question") > -1)
		{
			if (typeof(document.form1.radio) != "undefined")
			{
				for (i=0; i<8; i++)
				{
					if (document.form1.radio[i] != null)
					{
						ThisPage.addEvent(document.form1.radio[i], "click", highlightQuestionButtons);
						document.form1.radio[i].style.display="none";
					}
				}
			}
			if (typeof(document.form1.checkbox1) != "undefined")
			{
				for (i=1; i<9; i++)
				{
					if (document.form1["checkbox"+i] != null)
					{
						ThisPage.addEvent(document.form1["checkbox"+i], "click", highlightQuestionButtons);
						document.form1["checkbox"+i].style.display="none";
					}
				}
			}
			if (hasBeenAnswered()) highlightQuestionButtons();
		}
		if (pgType.indexOf("question, text") > -1 && pgTpl !="fullq") // set textbox style
		{
			for (i=1;i < 10;i++)
			{
				tBox=document.form1["text"+i];
				if (tBox != null && tBox.type=="text")
				{
					if (typeof(useDos) != "undefined" && useDos) tBox.className="codeTextBoxDos";
					else if (pgTpl=="fullcodeq" || pgTpl=="textentnp") tBox.className="codeTextBox";
					else if (pgTpl=="textentcode") tBox.className="codeTextBoxGray";
						else tBox.className="textBox";
				}
			}
		}
		if (pgType.indexOf("question") > -1) formatAnsweredQuestion();
		// if (pgTpl=="full_text") document.simForm.simTextbox.value=document.form1.text1.value;
		if (pgTpl=="fullq" && pgAction=="8") document.fieldForm.textBox.focus();
	}

	//Preload the images specified by pgPreload
	preloadPage();

	if (typeof(keyDescription) != "undefined") addButton("keyboard,showkeys," + keyboardButtonW + ",29," + resStr.keyboardAlt);
	if (typeof(showmeName) != "undefined" && showmeName != "") addButton("showme,showme," + showmeButtonW + ",29," + resStr.showmeAlt);
	if (typeof(quickrefFile) != "undefined" && quickrefFile != "")
	{
		if (typeof(useMindnotes) != "undefined" && useMindnotes) addButton("mindnotes,quickref,72,29,Open the MindNotes file");
			else addButton("reference,quickref," + refButtonW + ",29," + resStr.quickrefAlt);
	}
	if (pgTpl=="doitpg" && hasFlash() && (typeof(simContent) == "undefined" || simContent=="") )
	{
		if (ThisPage.getPassedParm("autorun") == "1") addButton("doitpg,doitpg," + doitpgButtonW + ",29," + resStr.doitAlt);
			else 	addButton("showme,showmepg," + showmeButtonW + ",29," + resStr.showmeAlt);

	}
	if (pgTpl=="full_exploreit" && hasFlash("8") && typeof(showFlashExplore) != "undefined" && typeof(excludeExploreShowme) == "undefined")
	{
			if (showFlashExplore)
			{
				if (typeof(showmeOnly) == "undefined" || !showmeOnly) addButton("expbut,showexploreit," + exploreitButtonW + ",29," + resStr.exploreitAlt);
				pageHasAudio=false;
			}
			else
			{
				addButton("showme,showexploreflash," + showmeButtonW + ",29," + resStr.showmeAlt);
			}
			if (ThisPage.getPassedParm("noinstr")=="1") instructionsShown=true;
	}

	//Accessibility SA popups -- add back link
	if (isAccessibilityWindow && pgType=="pop")
	{
		var backText="<BR><A HREF=\"javascript:history.back()\" onMouseover=\"self.status='" + resStr.returnQuestionStatus + "'; return true\">" + resStr.returnQuestionLink;
		document.write (backText);
	}

	// Set the form action
	if (pgType.indexOf("question") > -1) setFormAction();
	
	if (pgTpl=="htldoit") FillTextArea();
	if (pgType.indexOf("dropdown") != -1)
	{
		seqSetValues();
		if (typeof(choiceColumnWidth) != "undefined")
		{
			obj=document.getElementById("matchcolumn");
			if (obj != null) obj.width=choiceColumnWidth;
		}
	}
	if (pgType.indexOf("droptext") != -1) dropwordSetValues();

	// set running head to sco title if it is "Lesson"
	var thisScoTitle =getScoTitle();
	if ( (runningHead==resStr.prLesson || runningHead=="Instructor Presentation") && thisScoTitle && thisScoTitle !="") runningHead=thisScoTitle;
	
	if (isDummies)
	{
		if (runningHead==resStr.SummaryOts) runningHead=resStr.SummaryDummies;
		setPagePath();
	} else if (typeof(pgSequence) != "undefined") setPagePath();
				else showWindowStatus();
	
	// testing --- full page html sims
	if (prevPage != "" && typeof(courseFullpageSims) != "undefined" && courseFullpageSims.indexOf(prevPage.substring(0, prevPage.length-4)) > -1) prevPage=prevPage + "?step=last";
	if (typeof(useDragAndDrop) != "undefined") initDrag();
	
	isLoaded=true; // used to prevent error using repeat keys to paginate;
	if (coursewareHandler != null)
		coursewareHandler.onCoursePageLoad(self);
	
	// Audio. Never in Sa
	if (!isSa())
	{
		setUnitCompletion()
	
		// play right answer sound (nothing for wrong answer)
		if (pgType.indexOf("question") > -1)
		{
			if (typeof(c_fdbkAudio) == "undefined" && hasFlash("5") && ThisPage.getPreference(PR_SoundEffects) != "0" && isRight())
			{
				var rightSound=baseStyleDir + "sounds/right";
				insertFlash(rightSound,"2","2","#FFFFFF",false);
			}
		}
		else
		{
			//Flash single page Audio
			if (playPageAudio)
			{
				requiredVersion=5;
				audioPlayer=sharedDirectory + "templates/audioplayer.swf?pageaudio=" + pgAudio;
				if (audioVersion=="6")
				{
					requiredVersion=6;
					if (pgAudio.indexOf("quartersecond") > -1 || pgAudio=="") audioPlayer=sharedDirectory + "templates/audioplayer_" + requiredVersion+ ".swf";
						else audioPlayer=sharedDirectory + "templates/audioplayer_" + requiredVersion+ ".swf?pageaudio=" + pgAudio;
				}
				insertFlash(audioPlayer,"2","2","#FFFFFF",false,false);
			}
		}
		//Flash "streaming" Course Audio
		if (pageHasAudio && ThisPage.getPreference(PR_PageAudio) != "0" && pgTpl.indexOf("flash") == -1)
		{
				if (typeof(document.form1) != "undefined" && typeof(c_fdbkAudio) != "undefined" && typeof(isCorrect) == "undefined" && typeof(document.form1.startques) != "undefined") pgAudio=courseSoundDirectory + "a_" + currPage.substring(0, currPage.length-4) + "_h";
				requiredVersion=6;
				if (nextPage.indexOf(".htm") >-1) nextParm="nextpageaudio=" + courseSoundDirectory + "a_" + nextPage.substring(0, nextPage.length-4) + ".mp3" + "&";
					else nextParm="";
				if (pgAudio=="") audioPlayer=sharedDirectory + "templates/audioplayer_" + requiredVersion + ".swf";
					else audioPlayer=sharedDirectory + "templates/audioplayer_" + requiredVersion + ".swf?" + nextParm + "pageaudio=" + pgAudio;
				if (coursewareHandler.useFsStyle && ThisPage.isIE && ThisPage.browserVersion < 7)
				{
					if (pgAudio=="") audioPlayer=sharedDirectory + "templates/audioplayer_fs.swf";
						else audioPlayer=sharedDirectory + "templates/audioplayer_fs.swf?" + nextParm + "pageaudio=" + pgAudio;
					vbAudioScript="<SCRIPT LANGUAGE=\"VBScript\">Sub audioplayer_FSCommand(ByVal command, ByVal args) call audioplayer_DoFSCommand(command, args) end sub</SCR" + "IPT>"
					document.write(vbAudioScript);
				}
				if (pgTpl == "flsize" && typeof(audioPause) != "undefined" && audioPause!=0)
				{
					document.write("<span id=audioSpan><img src=\"" + sharedImageDir + "spacer.gif\" height=2 width=2></span>");
					audioTmr=setTimeout("delayAudio(\"" + audioPlayer + "\")",audioPause * 1000);
				} else
				{
					if (!coursewareHandler.fromJsBack || !coursewareHandler.useFsStyle )
						insertFlash(audioPlayer,"2","2","#FFFFFF",false,false);
					else
					{
						fsShowAllText()
						coursewareHandler.fromJsBack=false;
					}
				}
		}
	}
	
	if (isAccessibilityWindow )
	{
		if (!isSa()) document.title=resStr.accQuestion;
		closeCode="<center><br><br><a href=\"javascript:self.close()\">" + resStr.closeWin + "</a></center>";
		document.write(closeCode);
	}
	
	// Write a div used to display floating messages
	if(useNewDesign)
	{
		msgDiv="<DIV ID=\"msgDiv\" STYLE=\"position:absolute; top:0; left:0; visibility:hidden; z-index:12;display:inline\" onmouseover=\"showFloatingMessage(self,'',0,0,0,false,'')\">" +
			"<TABLE class=\"popBox\" WIDTH=\"100%\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0><TR><TD><span id=\"msgLabelDiv\" class=\"popLabel\"></span><span id=\"msgTextDiv\" class=\"popText\"></span></TD></TR></TABLE></TD></TR></TABLE>" +
			"</DIV>";
		msgDiv += "<DIV ID=\"progressDiv\" STYLE=\"position:absolute; top:0; left:0; visibility:hidden; z-index:2;display:inline\">" + "</DIV>";
		if (typeof(keyDescription) != "undefined") msgDiv += getShortcutKeyDiv();
		if (coursewareHandler.useFsStyle) msgDiv += fsGetPromptDiv();
		document.write(msgDiv);
	}
	
	if (pgTpl.indexOf("flash") > -1)
	{
		if (!hasFlash("6") || ThisPage.getPreference(PR_PageAudio) == "0") document.getElementById("flashText").style.display="block";
	}

	if (typeof(autoNumberCode) != "undefined" && autoNumberCode) autoNumberCodeLines();

	if (!isAccessibilityWindow && typeof(useDos) != "undefined" && useDos)
	{
		codeDiv=document.getElementById("winCode");
		codeDiv.className="dos";
		document.getElementById("winTable").style.backgroundColor="#000000";
		codeText=codeDiv.innerHTML;
		if (codeText.indexOf("codeHighlightNP") > -1)
		{
			codeText=ThisPage.replaceText(codeText, "codeHighlightNP","codeHighlightDos");
			codeDiv.innerHTML=codeText;
		}
	}

	if (typeof(c2cCoords) != "undefined" || typeof(clickCoords) != "undefined" || typeof(mouseoverCoords) != "undefined") writeImageMap();

	// Embed Exit Warning Div if the page has an exit button.
	hasExitButton=(coursewareHandler.foobar && coursewareHandler.foobar.wndFoobar && (coursewareHandler.foobar.wndFoobar.document.getElementById("bsv_exitbutoff") !=null || parent.coursewareHandler.foobar.wndFoobar.document.getElementById("exitbutoff") != null) )
	if (!isAccessibilityWindow && !coursewareHandler.is3rdLMS && hasExitButton) writeExitWarningDiv();

	document.write("</span>") //end pgText span
	if (typeof(c_verticalCenter) != "undefined" && currPage != "video.htm") document.write("</td></tr></table>") //end pg  table

	if (document.getElementById("introText") != null) hideIntroText("introText")

	if (typeof(textNoBox) != "undefined" && textNoBox && document.getElementById("wTable") != null)
	{
		document.getElementById("wTable").className="";
		document.getElementById("wGripper").className="";
		document.getElementById("gripperPic").src="";
		document.getElementById("textDiv").className="cWords";
		document.getElementById("textDiv").innerHTML=ThisPage.replaceText(document.getElementById("textDiv").innerHTML,"overlayLabel","cLabel")
	}
	if (typeof(winTextStyle) != "undefined") document.getElementById("winCode").className=winTextStyle;

	if (pgTpl=="videopg") loadVideoPage();
	if (pgTpl=="clickpic" || pgTpl=="clickpic_long") clickpicAudioOnly();
	if (pgTpl.indexOf("_progress") > -1 && typeof(useTranscript) != "undefined" && typeof(pgTranscript) != "undefined") progressUseTranscript();

	if (coursewareHandler.launchEnvironment=="CB" && document.getElementById("mlonly") != null) document.getElementById("mlonly").style.display="none";

	if (coursewareHandler.scoOnly)
	{
		if (pgTpl=="tryit" && document.getElementById("exerciseLink") != null) document.getElementById("exerciseLink").style.display="none";
	}
	// Set focus
	if (self.location.search.indexOf("nofocus") < 0) //keeps search and topics windows on top.
	{
		if (pgType.indexOf("question, text") > -1 && pgType.indexOf("sim") == -1 && pgType.indexOf("drop") == -1 && pgTpl.indexOf("sim") == -1) LoadText();
			else if (pgTpl != "doitpg" && pgTpl.indexOf("questiontime") == -1) self.focus(); // ensures keystrokes are trapped
		if (isTfCourse && pgTpl=="doitpg") focustheMovie();
		if (pgTpl.indexOf("full") > -1 && pgAction == 3 && typeof(grayTextboxValue) == "undefined") document.simForm.simTextbox.focus();
		if (pgTpl=="acthtml") document.form1.text1.focus();
	}
	if (typeof(c_fdbkWidth) != "undefined")
	{
		if (document.getElementById("answerFeedback") != null) document.getElementById("answerFeedback").style.width=c_fdbkWidth;
	}

	if (pgTpl=="pretest" || pgTpl=="posttest")
	{
		if (coursewareHandler.pt_numQuestions == coursewareHandler.pt_currentQuestionNum && coursewareHandler.pt_currentQuestionNum != 0) ptShowTestResults();
			else document.getElementById("pt_beginTest").style.display="block";
		// ECDL notice
		document.getElementById("pt_beginTest").innerHTML= document.getElementById("pt_beginTest").innerHTML + resStr.ecdlNotice;
		document.getElementById("pt_endTest").innerHTML= document.getElementById("pt_endTest").innerHTML + resStr.ecdlNotice;
	}

	document.close();

	// if (typeof(courseImages) != "undefined" && !isSa() && parent.parent.worker != null) parent.parent.worker.preloadImages();
}

function formatAnsweredQuestion()
{
	if (hasBeenAnswered())
	{
		if (pgTpl=="cliqnp") document.getElementById("cliqLine").className="codeHighlightNP";
		if (pgTpl=="cliqcode") document.getElementById("cliqLine").className="codeHighlightGrey";
		if (pgTpl=="actcliq")
		{
			for (i=1;i<choice.length;i++)
			{
				chDiv=document.getElementById("choiceBox" + i);
				if (chDiv!=null) chDiv.style.left = -(answerBoxWidth + answerLeft);
			}
			activityQuestionWriteCorrectTries();
			isReady=false;
		}
		repaintDivs();
		//if (coursewareHandler.scoOnly) scoOnlySetScores();// set scores in coursewareHandler.scoresRec
	}
}

function getNextQButton()
{
	if (coursewareHandler.pt_currentQuestionNum==coursewareHandler.pt_numQuestions) // last Question
		return "<img id=npButton src=\"" + sharedImageDir + "sascrbut.gif\" onmouseover=\"buttonRollover('npButton','sascrbut',true)\" onmouseout=\"buttonRollover('npButton','sascrbut',false)\"onclick=\"pt_nextQuestion()\" alt=\"" + resStr.sa_scoresMouseover +"\">";
	else
		return "<img id=npButton src=\"" +  sharedImageDir + "sanextq.gif\" onmouseover=\"buttonRollover('npButton','sanextq',true)\" onmouseout=\"buttonRollover('npButton','sanextq',false)\"onclick=\"pt_nextQuestion()\" alt=\"" + resStr.sa_nextQuestionMouseover +"\">";
}

if (!textNoFrame) initFooter();
