var button_id, button_id_old;

// This code catches events from the EP MP3 
function EP_eventHandler(evt) {
switch(evt) {
   case 'MP3_PLAYING':
      // When a new MP3 is loaded, one might still be playing, so
      // Change the button back for any playing MP3. Unless it's the
      // same MP3 that is already playing.
      if (button_id_old != button_id) {
         button_stop(button_id_old);
      }
      break;
   case 'MP3_COMPLETE':
      // When an MP3 is stopped or completed, change the button back.
      button_stop(button_id);
      break;
   default:
      break;
}

}

// This code overlays the buttons
function overlayHTML (target, source) {
var element;
if (document.getElementById) {
t = document.getElementById(target);
s = document.getElementById(source);
}
else if (document.all) {
t = document.all[target];
s = document.all[source];
}
t.innerHTML = s.innerHTML;
}

function button_play(id) {
overlayHTML(id,'play_button');
// Save the id of the button
button_id_old=button_id;
button_id=id;
}
 
function button_stop(id) {
overlayHTML(id,'stop_button');
} 
