// audioPlayer.js
// interface between song titles in menu listing
// and the audio player

function switchSong() {
  var songMenu = document.getElementById("songTitles");
  var songList = songMenu.getElementsByTagName("li");
  for (var i=0; i<songList.length; i++) {
    setTextColor = songList[i].firstChild;				  // initialize colors
    setTextColor.style.color = "#c9c9bb";
    songList[i].onclick = function() {
      songToPlay = this.id;
      for (var j=0; j<songList.length; j++) {             // reset colors
        changeTextColor = songList[j].firstChild;
        changeTextColor.style.color = "#c9c9bb";
      }    
      changeTextColor = this.firstChild;
      changeTextColor.style.color = "#e60e0e";
      container = document.getElementById("player");
      /*playbar = document.getElementById("playbar");
      container.removeChild(playbar);*/
      newEmbed = document.createElement("EMBED");
      newEmbed.id = "playbar";
      newEmbed.src = "../audio/" + songToPlay + ".mp3";
      newEmbed.width = "140";
      newEmbed.height = "40";  
      newEmbed.autostart = "false";
      newEmbed.loop = "FALSE";
      container.appendChild(newEmbed);
    }
    songList[i].onmouseover = function() {
      mouseOverColor = this.firstChild;
      if (mouseOverColor.style.color == "rgb(201, 201, 187)") {
        
        mouseOverColor.style.color = "#cc8b08";
      }
    }
    songList[i].onmouseout = function() {
      mouseOutColor = this.firstChild;
      if (mouseOutColor.style.color == "rgb(204, 139, 8)") {
        mouseOutColor.style.color = "#c9c9bb";
      }
    }   
  }
}

addLoadEvent(switchSong);


