// UpdateMusicButton : update the music button image depending on its status or hide it if no frame is detected
function UpdateMusicButton() 
{
  if( document.MusicButton )
  {	
		if( parent && parent.musicFrame )
		{
			if( parent.MusicOn )
				document.MusicButton.src = '../_frame/music.png';
			else
				document.MusicButton.src = '../_frame/nomusic.png';
			}
		else
			document.MusicButton.style.display = 'none';
	}
}

// MusicPlay : play or stop a music depeinding on its topic name
// topic = "_stop_" is a dummy topic name meaning that there is no music and that any playing music has to be stopped
// topic = "" (an empty topic) means a topic witout any music but that should continue playing any previous music 
// for any other value the music page of the topic specified is used. This can be the reserved directory "_frame" in the case of a music played for the entire website
function MusicPlay( topic ) 
{
  if( parent && parent.musicFrame ) 
  {
		if( topic == "_stop_" ) // topic has no music so we redirect the silent index.html page located under the _frame directory
		{
      parent.MusicPageURL = '../_frame/blank.html';
      parent.musicFrame.location = parent.MusicPageURL;
		}
		else
		{
		  //  if any topic name is specified we use the url of its music page otherwise we do nothing meaning that we continue to use the previous music page
			if( topic != '' )
				parent.MusicPageURL = '../' + topic + '/music.html';
			if( parent.MusicOn ) 
			{
				parent.musicFrame.location = '../_frame/blank.html';
				parent.MusicOn = 0;
			}
			else if( parent.MusicPageURL != '' )
			{
				parent.musicFrame.location = parent.MusicPageURL;
				parent.MusicOn = 1;
			}
		}
		if( parent.MusicPageURL != '' )
      UpdateMusicButton();
  }
}

