var _s=0; 
var Sounds = new Array();
    Sounds[_s++] = "mp3/popp_piano_schubert.mp3";
    Sounds[_s++] = "mp3/aria_graziosa.mp3";
    Sounds[_s++] = "mp3/schreker_sie_sind.mp3"; 

document.write('<BGSOUND ID="soundContainer_IE_DOM">');

var isIE4 = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? true:false;
var isNS4 = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? true:false;
var isDOM = document.getElementById?true:false;
var isOK = isIE4||isNS4||isDOM;

function PreLoadSounds()
{
  if (!isOK)
    return;

  if (isNS4)
    SoundDiv = new Layer(0,window);
  else
    document.body.insertAdjacentHTML("BeforeEnd","<DIV ID='SoundDiv' STYLE='position:absolute;visibility:hidden;'></DIV>");

  var Str = '';
  for (i=0;i<Sounds.length;i++)
    Str += "<EMBED SRC='"+Sounds[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"

  if(isDOM)
    document.getElementById("SoundDiv").innerHTML=Str;
  else if(isIE4)
    SoundDiv.innerHTML=Str;
  else
  {
    /* must be NS4 */
    SoundDiv.document.open();
    SoundDiv.document.write(Str);
    SoundDiv.document.close();
  }

  soundObject = null;
  if(isDOM)
    soundObject = document.getElementById('soundContainer_IE_DOM');
  else if(isIE4)
    soundObject = document.all.soundContainer_IE_DOM;
  else
    soundObject = SoundDiv;
  soundObject.control = auCtrl;
}

function auCtrl(SoundsArrayIndex,play)
{
  if (isIE4||isDOM)
    this.src = play? Sounds[SoundsArrayIndex]:'';
  else
    eval("this.document.embeds[SoundsArrayIndex]." + (play? "play()":"stop()"))
}

function playSound(SoundsArrayIndex) { if (window.soundObject) soundObject.control(SoundsArrayIndex,true); }
function stopSound(SoundsArrayIndex) { if (window.soundObject) soundObject.control(SoundsArrayIndex,false); }
