/*

  (c) 2006 TUFaT.com. All Rights Reserved

*/

function muteResore (node) {
	if( node == "All" )
	{
		config["sound"]["muteAll"] = TempArraySound[node];
		return;
	}
	if( node == "volume" )
	{
		config["sound"]["volume"] = TempArraySound[node];
		return;
	}
  if ( TempArraySound[node] == true )
    config["sound"]["ev"][node]["muted"] = true;
  else
    config["sound"]["ev"][node]["muted"] = false;
}

function muteUnmute (node) {
  if (node["mutes"] == "all") 
  {
    if (node.checked == true)
      config["sound"]["muteAll"] = true;
    else
      config["sound"]["muteAll"] = false;

    return;
  }

  if (node.checked == true)
  {
	config["sound"]["ev"][node["mutes"]]["muted"] = false;
}
  else
    config["sound"]["ev"][node["mutes"]]["muted"] = true;
}

function changeVolume (selNode) {
  var newValue = selNode.value;

  config["sound"]["volume"] = newValue;
}

function testSound (name, mainvolume) 
{
  var play = name;
  playSound (play, true, mainvolume);  
}

function playSound (whatToPlay,testsound, mainvolume) {	
  /* TODO: implement this. For now, just show in the status */
  if ((config["sound"]["muteAll"] != "1" && config["sound"]["ev"][whatToPlay]["muted"] != true) || (testsound==true))
  {
  	var playFlag = false;	
	if ( (config['sound']['ev'][whatToPlay]['volume'] == undefined) || (mainvolume) || (config['sound']['ev'][whatToPlay]['main'] == true) )
	{
		if (config["sound"]["volume"] != 0)
		{
			playFlag = true;
			mysound.gotoAndStop("/",config["sound"]["volume"]);
		}
	}
	else
	{	
		if (config['sound']['ev'][whatToPlay]['volume'] != 0)
		{
			playFlag = true;
			mysound.gotoAndStop("/",config['sound']['ev'][whatToPlay]['volume']);
		}
	}
	if (playFlag == true)
	{
		mysound.gotoAndPlay("/PLAY" + config["sound"]["ev"][whatToPlay]["file"].replace("sounds/","").replace(".mp3",""),'start');
	}

  }
}
