//------------ Эта пара функций управляет звуком

function sound_start()
{
  document.getElementById('music_embed').innerHTML =
    '<embed src="' + base_url + 'images/main/music.mp3" ' +
    'autostart=true loop=true hidden=false style="width: 1px; height: 1px;">' +
    '</embed>';
  document.getElementById('music_embed').style.display = 'block';

  document.getElementById('button_on').src = base_url +
    'images/main/button_on_cur.jpg';
  document.getElementById('button_off').src = base_url +
    'images/main/button_off.jpg';
  set_sound('sound_on');
}

function sound_stop()
{
  document.getElementById('music_embed').style.display = 'none';
  document.getElementById('music_embed').innerHTML = '';

  document.getElementById('button_on').src = base_url +
    'images/main/button_on.jpg';
  document.getElementById('button_off').src = base_url +
    'images/main/button_off_cur.jpg';
  set_sound('sound_off');
}

function set_sound(cur_sound)
{
  var cur_sound_url = cur_sound + '/';
  var not_cur_sound_url = 'sound_on' == cur_sound ? 'sound_off/' : 'sound_on/';
  for (f = 0; f < document.links.length; f++)
  {
    if (document.links[f].href.match(base_url))
    {
      if ('/' !=
          document.links[f].href.charAt(document.links[f].href.length - 1))
      {
        document.links[f].href = document.links[f].href + '/';
      }
      document.links[f].href =
        (('sound_' + (sound ? 'on' : 'off')) != cur_sound) ?
          (document.links[f].href + cur_sound_url) :
          (document.links[f].href.replace(not_cur_sound_url, ''));
    }
  }
}





/*LGPL*/                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
