// Handle mute functionality. Logic by AP.

// The main problems that will occur with the scripting on this page
// is if the header frame containing the hidden variables
// doesn't load in time for this script to get hold of

// If an error occurs...
function handleError() {
	//alert("handleError() called");
	// ... just load the video with audio by default
	UFO.create(	FO, "player");
	document.getElementById("input1").style.background = "transparent url(images/sound.gif) no-repeat center top";
	return true;
}

window.onerror = handleError;

// Check the value of the hidden variable in the header frame
if (!readCookie("volume"))
{
	createCookie("volume", "sound", 21);

	UFO.create(	FO, "player");
	document.getElementById("input1").style.background = "transparent url(images/sound.gif) no-repeat center top";
// If the audio is enabled...
} else if(readCookie("volume") == "sound"){

	/// ...load the FO video object which has 100% sound volume								
	UFO.create(	FO, "player");
	document.getElementById("input1").style.background = "transparent url(images/sound.gif) no-repeat center top";
	document.getElementById("input1").title = "Click to disable audio";

}else if(readCookie("volume") == "mute"){
	
	// Otherwise load the FOmute object which has 0% volume
	UFO.create(	FOmute, "player");
	document.getElementById("input1").style.background = "transparent url(images/nosound.gif) no-repeat center top";
	document.getElementById("input1").title = "Click to enable audio";
	
}


// If the user clicks the button, change the hidden variable in the header frame as appropriate
// This video frame will reload and load the changed value from the header frame
function toggleMute(){
	if(readCookie("volume") == "sound"){

		UFO.create(	FOmute, "player");
		
		eraseCookie("volume");		
		createCookie("volume", "mute", 21);
		
		document.getElementById("input1").style.background = "transparent url(images/nosound.gif) no-repeat center top";
		document.getElementById("input1").title = "Click to enable audio";
								
	}else if(readCookie("volume") == "mute"){
		UFO.create(	FO, "player");
		
		eraseCookie("volume");					
		createCookie("volume", "sound", 21);
		
		document.getElementById("input1").style.background = "transparent url(images/sound.gif) no-repeat center top";
		document.getElementById("input1").title = "Click to disable audio";					
											
	}
}