
//---------------- Getting a reference to the player -----------------

//store a reference to the flash video player
var player = null;

/*
* This function is called by the video player swf file when the player has been initiated 
* id is the id that will contain the flash movie - this is set in the FlashVars of the embed of the swf movie
*/
function onPlayerInitiated(id)
{
	player = document.getElementById(id);
}


//---------------- Controlling the player ---------------------------

/**
* Example function that will change all the assets for the video player
* If some of the assets do not exist or the file path is incorrect the player will ignore that asset and the respective button (if any) will be removed form the player toolbar.
* 
* 
*/
function changeMedia(value)
{
	switch(value)
	{
		case "FLV" :
			player.send("mediaURL", "assets/videos/regalex_512x384.flv");
			player.send("captionsURL", "assets/captions/regalex.xml");
			player.send("audioDescriptionURL", "assets/audio/sally_vo_cut2.mp3");
			player.send("imageURL", "assets/images/regalex_512x384.jpg");
		break;
		//
		case "YOUTUBE":
			player.send("mediaURL", "Oe3St1GgoHQ");
			player.send("captionsURL", "assets/captions/yt_captions.xml");
			//player.send("captionsURL", "a/url/to/a/captions.xml");
			player.send("audioDescriptionURL", "a/url/to/an/audiodescription.mp3");
			player.send("imageURL", "a/url/to/an/image.jpg");
		break;
	}
}


/**
* the following functions control the state of the video player - all possible functions are listed below
*/

//start playback
function play()
{
	player.send("control", "play");
}

//pause playback
function pause()
{
	player.send("control", "pause");
}

//skips 2 seconds forward
function fastforward()
{
	player.send("control", "fastforward");
}

//skips 2 seconds back
function rewind()
{
	player.send("control", "rewind");
}

//resart the video
function restart()
{
	player.send("control", "restart");
}

//toggle mute on/off
function togglemute()
{
	player.send("control", "togglemute");
}

//increase volume by 1
function volumeup()
{
	player.send("control", "volumeup");
}

//decrease volume by 1
function volumedown()
{
	player.send("control", "volumedown");
}

//toggle captions on/off
function togglecaptions()
{
	player.send("control", "togglecaptions");
}

//toggle shortcut screen on/off
function togglehelp()
{
	player.send("control", "togglehelp");
}

//toggle audiodescription on/off
function toggleaudiodescription()
{
	player.send("control", "toggleaudiodescription");
}

//change the text size
function changetextsize()
{
	player.send("control", "changetextsize");
}

//change the text colour
function changetextcolour()
{
	player.send("control", "changetextcolour");
}

//----------------------- Transcript control --------------------


/**
* example function to toggle the transcript on/off
*/
function toggleTranscript()
{
	var viewtranscriptObj = document.getElementById('viewTranscript')
	var transcriptObj = document.getElementById('transcript')
	var transcriptText = document.getElementById('transcriptText')
		
	if (transcriptObj.style.display == 'block') 
	{
		transcriptObj.style.display = 'none'
		transcriptText.innerHTML = "Show transcript"
	} 
	else
	{
		transcriptObj.style.display = 'block'
		transcriptText.innerHTML = "Hide transcript"
	}
}

