/* All character comments are stored here in an associative array 
 * Comments are indexed by a key: 
 *    intro refers to introductory remarks
 *    faq1, faq2 are common questions on the lefthand side
 *    help1, help2 refers to help icons inserted in the questions
 *    qq1, qq2 are form elements
 */

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

function Load(file){
	AgentObj = InternetExplorer ? Agent : window.document.Agent;
	AgentObj.LoadMovie(1, file);
}

function Say(id) {
	var swf = "../media/"+id+".swf";
	Load(swf);
	/*
	phrase = phrase.replace(/TwinACT\'s/g, "##1##");
	phrase = phrase.replace(/TwinACT/g, "<PRON SYM = \"t w ih n & ae 1 k t\">TwinACT</PRON>");
	phrase = phrase.replace(/WorldDoc/g, "<PRON SYM = \"w er 1 l d & & d aa k 1\">WorldDoc</PRON>");
	phrase = phrase.replace(/##1##/g, "<PRON SYM = \"t w ih n & ae 1 k t s\">TwinACT's</PRON>");
	AgentObj = InternetExplorer ? Agent : window.document.Agent;
	AgentObj.SetVariable("newInput", phrase); */
}

var Timer = null;	//Pointer to the timer 
var TimerCycle = 1;	//Counter 
var TimerMax = 3;
var TimeLimit = 60;	//Countdown time in seconds 

function TimeOut(){ 
	Say('timeout'+TimerCycle);
    TimerCycle++;
	if (TimerCycle < TimerMax) Timer = setTimeout("TimeOut()", TimeLimit*1000);
}

function SetTimer(secs, ncycles){
	TimeLimit = secs;
	TimerMax = ncycles+1;
	TimerCycle = 1;
	if (TimeLimit) Timer = setTimeout("TimeOut()", TimeLimit*1000);
}
//SetTimer(120, 2);

function ResetTimer(){
	if ((Timer) && (TimerCycle < TimerMax)){ 
		clearTimeout(Timer);
		TimerCycle = 1;
		if (TimeLimit) Timer = setTimeout("TimeOut()", TimeLimit*1000);
	}
}

document.onkeypress = ResetTimer;
document.onmousedown = ResetTimer;
	
function StopTimer(){
	try {
		clearTimeout(Timer); 
		Timer = null; 
	} catch(e) {
	}
}
function Agent_DoFSCommand (command, args){
	 //just ignore
	 //alert("Unrecognized Flash Command: " + command);
}
/*
function Say(id){
	if (id.substring(0, 4) == 'txt:') {
		var phrase = id.substring(4);
	} else {
		var phrase = comments[id];
	}
	if (typeof(phrase) == 'undefined')  return;
	//HintMsg = phrase;
	if (Speak) {
		if (phrase.substring(0, 4) == 'swf:') {
			Load("./media/"+phrase.substring(4));
		} else {
			phrase = encodeURI(phrase);
			Load("speech2swf.php"+"?input=BOT_SAY "+phrase); 
		}
	} else {
		Display (phrase); //won't work for swf
	}
}
*/