/*define scope for vo tags */
var content;
var voe;

/**/

var currentVoice = 1;

var colorFaded = "#999";
var colorHLight = "#000";
var wpm = "350";	// words per minute

/*  
    If we have voice, fade all the text out onload
	(called through Flash) except the first para.

	Without voice we setup the same way.
*/
function voiceOverInit(){
	_initVar();
	if(!voe) return;
	for(var i=1;i<voe.length;i=i+1)
		{
			// only <span> in #page-body with id mvo_..
			if (voe[i].id.substring(0,4) == "mvo_")
			{
				voe[i].style.color = colorFaded;
			}
		}
};
/*
	Call the standard init script and start the
	timer off on the first section of text
*/
function muteInit()
{
	_initVar();
	if(!voe) return;
	voiceOverInit();
	//document.getElementById('mvo_'+currentVoice).className='classHlight';
	//InitializeTimer(document.getElementById('mvo_1').innerHTML.split(" ").length);
}

/*
	Hit this every time we need to move to the next
	voiceover.

	Moves the highlighted text to the next section.
*/
function voiceOverTrigger()
{
	return;	// delete me!!!
	_initVar();
	if(!voe) return;
	document.getElementById('mvo_'+currentVoice).style.color = colorFaded;	//fade current text
	currentVoice++;
	document.getElementById('mvo_'+currentVoice).style.color = colorHLight; //highlight new text
}

/*
	Highlights each paragraph in order and
	triggers the timer for the next
*/
function muteTrigger()
{
	_initVar();
	if(!voe) return;
	currentVoice++;

	//document.getElementById('mvo_'+currentVoice).className='classHlight';
	document.getElementById('mvo_'+currentVoice).style.color = colorHLight; //highlight next para
	
	//var strlength = document.getElementById('mvo_'+currentVoice).innerHTML.split(" ").length;
	
	/*if (voe[currentVoice])
	{
		InitializeTimer(strlength);
	}*/
}

/*
	Timer stuff..

*/
var timerID = null
var timerRunning = false
var delay = 1000

/*function InitializeTimer(strlength)
{
	_initVar();
	if(!voe) return;
    // Sets the length of the timer to our WPM
    secs = Math.round(strlength / (wpm / 60));
   /* StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
	_initVar();
	if(!voe) return;
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
	_initVar();
	if(!voe) return;
    if (secs==0)
    {
        StopTheClock()
        muteTrigger();	// the function call
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}*/

function _initVar(){

	content = document.getElementById("page-body");
	if(content)
	{
		voe = content.getElementsByTagName("span");
	}
}

function flashGetAllDurations()
{	
	_initVar();
	var _varToFlash = "";
	if(voe)
	{
		for(var i=0;i<voe.length;i++)
		{
			// only <span> in #page-body with id mvo_..
			if (voe[i].id.substring(0,4) == "mvo_")
			{				
				var _txtL = voe[i].innerHTML.split(" ").length;
				var secs = Math.round(_txtL / (wpm / 60));
				if( (i+1) == voe.length )
				_varToFlash = _varToFlash + secs;
				else
				_varToFlash = _varToFlash + secs + ",";				
			}
		}
		
		var _m = document.getElementById("objMentor");
		if(_m)
		{
			_m.SetVariable("times", _varToFlash);
		}
	}
	else
	{
		//do nothing for now
	}
}
/**/

