// Javascript functions for the presentation.  This file must only be loaded by the frames page (with_subtitles.htm or no_subtitles.htm)

// A sequence number used to give each flash movie a unique ID.
var flashMovieSequenceNum = 1;

// Information on the slides in the presentation:
var currentSlide = 0;
var numSlides = 11;

// The html pages to load for each slide:
var slidePages = new Array();
slidePages[0] = "slide-introduction.htm";
slidePages[1] = "slide-importance.htm";
slidePages[2] = "slide-training_strategies.htm";
slidePages[3] = "slide-coaches.htm"
slidePages[4] = "slide-web_based_benefits.htm";
slidePages[5] = "slide-all_ages.htm";
slidePages[6] = "slide-admin_features.htm";
slidePages[7] = "slide-tracking_progress.htm";
slidePages[8] = "slide-curriculum.htm";
slidePages[9] = "slide-fun.htm";
slidePages[10] = "slide-summary.htm";

// The title bar flash movies to load for each slide:
var slideTitles = new Array();
slideTitles[0] = "title_bar-introduction.swf";
slideTitles[1] = "title_bar-importance.swf";
slideTitles[2] = "title_bar-training_strategies.swf";
slideTitles[3] = "title_bar-coaches.swf";
slideTitles[4] = "title_bar-web_based_benefits.swf";
slideTitles[5] = "title_bar-all_ages.swf";
slideTitles[6] = "title_bar-admin_features.swf";
slideTitles[7] = "title_bar-tracking_progress.swf";
slideTitles[8] = "title_bar-curriculum.swf";
slideTitles[9] = "title_bar-fun.swf";
slideTitles[10] = "title_bar-summary.swf";


// Insert a flash movie into the document.  This is needed in order to work around Microsoft's "upgrade" which doesn't allow 
// flash movies to accept mouse or keyboard events unless clicked on.
function insert_flash(url,width,height,version)
{
	document.writeln(get_flash_html(url,width,height,version));
}

// Get the html for a flash movie:
function get_flash_html(url,width,height,version)
{
	var result = "";
	result = '<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj'+flashMovieSequenceNum+'" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version+'" border="0" width="'+width+'" height="'+height+'">';
	result += '<param name="movie" value="'+url+'">';
	result += '<param name="quality" value="High">';
	result += '<embed src="'+url+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj'+flashMovieSequenceNum+'" width="'+width+'" height="'+height+'" quality="High"></object>';
	flashMovieSequenceNum++;
	return(result);
}

// Determine if this is IE on a Mac:
function is_mac_ie()
{
    if (navigator.userAgent.indexOf("Mac_PowerPC")==-1 ||
        navigator.userAgent.indexOf("MSIE")==-1)
    {
        return false;
    }
    else
    {
        return true;
    }
}

// Change the subtitle text:
function set_subtitle(fontSize,text)
{
	if (document.getElementById("subtitle_cell") != null)
	{
		document.getElementById("subtitle_cell").style.fontSize = fontSize+"px";
		document.getElementById("subtitle_cell").innerHTML = text;
	}
}

// Change the status line at the bottom:
function set_status_text(text)
{
	if (document.getElementById("status") != null)
	{
		document.getElementById("status").innerHTML = text;
	}
}

// Set the status line initially:
function set_initial_status_text()
{
	set_status_text("Screen 1 of "+numSlides);
}

// Call this function from NOAH when the speech is finished.  If necessary, it will automatically go to the next slide:
function speech_complete()
{
	// Let the user know they should now press the next button:
	if (currentSlide<(numSlides-1))
	{
		set_status_text('Click on "Next" to continue');
	}
	
	// Clear the subtitle:
	setTimeout('set_subtitle(12,"&nbsp;");',1500);
	
	if (document.cookie.indexOf("presentation_auto_play")>=0)
	{
		// The presentation is being automatically played.  Sleep for a bit, then go to the next slide:
		if (currentSlide>=(numSlides-1))
		{
			// We're on the last slide.  Return to the first slide:
			currentSlide = 0;
			setTimeout("replay()",5000);
		}
		else
		{
			// Go to the next slide:
			setTimeout("go_forward()",5000);
		}
	}
}

// Navigation buttons...

function go_back()
{
	if (currentSlide==0)
	{
		to_start();
	}
	set_subtitle(22,"");
	currentSlide--;
	document.getElementById('title_bar_cell').innerHTML = get_flash_html(slideTitles[currentSlide],736,40,"6,0,40,0");
	window.open(slidePages[currentSlide],'slides');
	
	slideNum = currentSlide+1;
	set_status_text("Screen "+slideNum+" of "+numSlides);
}

function to_start()
{
	currentSlide = 0;
	window.open("http://www.customtyping.com/presentation","_top");
}

function replay()
{
	set_subtitle(22,"");
	document.getElementById('title_bar_cell').innerHTML = get_flash_html(slideTitles[currentSlide],736,40,"6,0,40,0");
	window.open(slidePages[currentSlide],'slides');
	
	slideNum = currentSlide+1;
	set_status_text("Screen "+slideNum+" of "+numSlides);
}

function go_forward()
{
	if (currentSlide>=(numSlides-1))
	{
		return;
	}
	set_subtitle(22,"");
	currentSlide++;
	document.getElementById('title_bar_cell').innerHTML = get_flash_html(slideTitles[currentSlide],736,40,"6,0,40,0");
	window.open(slidePages[currentSlide],'slides');
	
	slideNum = currentSlide+1;
	set_status_text("Screen "+slideNum+" of "+numSlides);
}


