
// framebuilder for consistent sound
try {
  void(parent.frames.audio.location.href.length);
} 
catch(e) {
  top.location.href='/';
}

// sound on/off toggle
function soundToggle(opt) {
  try {
    var metaNav = document.getElementById('metanav'), toggleHTML = '';
    if(!opt)
      opt = parent.frames[1].location.pathname;
    else
      parent.frames[1].location.href = opt;
    switch(opt) {
      case '/audio.html':
        toggleHTML = '<li class="sound"><a title="Sound Off" href="#" onClick="soundToggle(\'/audio-off.html\')"><span>Sound Off</span></a></li>';
        break;
      case '/audio-off.html':
        toggleHTML = '<li class="sound"><a title="Sound On" href="#" onClick="soundToggle(\'/audio.html\')"><span>Sound On</span></a></li>';
        break;
    }
    metaNav.innerHTML = metaNav.innerHTML.replace(/<li class="sound">.+<\/li>/,'');
    metaNav.innerHTML += toggleHTML;
  }
  catch(e) {
    console.log(e);
  }
}

window.onload = function(){
  soundToggle();
};


