/* These Functions are required for CTS Flash Interactivity Component */
function ctsGrabFlash(movieName) {	var isIE = navigator.appName.indexOf("Microsoft") != -1; return (isIE) ? window[movieName] : document[movieName]; }
function ctsFlashBack(command, arg) { eval("" + command + "(\"" + arg + "\");"); }
function findObj(n, d) { var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; }
function ctsLoadDiv(divname, divcontent) { nx = findObj(divname); nx.innerHTML = divcontent; }
function ctsPrependDiv(divname, divcontent) { nx = findObj(divname); nx.innerHTML = divcontent + nx.innerHTML; }
function ctsAssignClass(id, newClass) {identity=findObj(id);identity.className=newClass;}

var ctsFQueue = new Object();
var ctsJOnce = new Object();
var FAQopen = "faqans0";

function ctsFlashCommand(command, args) {
	ctsPrependDiv("debuglayer","System Event: FlashCommand Requested: " + command + " ( " + args + ")<BR>");
	switch (command)
	{
		case "playAnimation":
			gs = ctsGrabFlash("stage1");
			gs.playAnimation(args);
			break;
	}
}
function statusChange(pStatus) {
	ctsPrependDiv("debuglayer","Status Change:" + pStatus + "<BR>");
	if (pStatus in ctsFQueue)
	{
		ctsPrependDiv("debuglayer","System Event: FlashQueue Executing for Event [" + pStatus + "] <BR>");
		var tmpCmds;
		tmpCmds = ctsFQueue[pStatus].split("|",2);				
		delete ctsFQueue[pStatus];
		ctsFlashCommand(tmpCmds[0],tmpCmds[1]);
	}	
	else
	{
		ctsPrependDiv("debuglayer","System Event: FlashQueue No Commands for Event [" + pStatus + "] <BR>");
	}
}

function ctsJSOnce(idcode,jscommand)
{
	if (idcode in ctsJOnce)
	{
		// Dont repeat action
	}
	else
	{
		ctsJOnce[idcode] = "used";
		eval(jscommand);
	}
}

function showFAQ(faqid)
{
	ctsAssignClass(FAQopen,"faq_answer_off");
	ctsAssignClass(faqid,"faq_answer");
	FAQopen = faqid;	
}

function ctsFlashQueue(onstatus, command, args)
{
	ctsPrependDiv("debuglayer","System Event: FlashQueue Requested: " + command + " ( " + args + ") to happen on stage [ " + onstatus + " ]<BR>");
	ctsFQueue[onstatus] = command + "|" + args;
}
