
var sndElm;

function CreateAndPlaySound(sndFile) {
  if (sndElm && sndElm.parentNode) return;  // don't play sound twice
  if (typeof window.pageXOffset == 'undefined') {  // for IE and Opera
    sndElm = document.createElement("bgsound");
    document.getElementsByTagName("body")[0].appendChild(sndElm);
    sndElm.src = sndFile;
  }
  else { // for Firefox and Netscape
    sndElm = document.createElement("object");
    sndElm.width="0px";
    sndElm.height="0px";
    sndElm.type = "audio/x-wav";
    sndElm.data = sndFile;
    var body = document.getElementsByTagName("body")[0];
    body.appendChild(sndElm);
  }
}

function StopSound() {
  if (sndElm && sndElm.parentNode) {
    sndElm.parentNode.removeChild(sndElm);
    sndElm = null;
  }
}

// this method is old and not used anymore
function InsertBackSound(soundFile) {
 document.write('<EMBED src="' + soundFile + '" width=0  height=0 AUTOSTART=TRUE>');
}

