I am trying to swap embedded mp3s on a page. When a link is clicked I want to be able to swap out the name of the song, and the src of the mp3 file.
Right now I am able to get everything to swap except for the embedded mp3. The first mp3 that gets loaded remains loaded and I can not find a way to unload it and replace it.

Below is the javascript that I am using.

<script type="text/JavaScript" language="JavaScript">
function setMusic(music, name) {
var track = "tracks/" + music + ".mp3";
document.getElementById ("param1").value = track;
var embed = null;
if (document.embeds != null) {
embed = document.embeds[0];

else if (document.getElementById ("embed1") != null) {
embed = document.getElementById ("embed1");

embed.src = track;
document.getElementById ("ref1").href = track;
document.getElementById ("ref1").innerHTML = name;

and here is what's inside the html page

<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="270" height="16" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
<param id="param1" name="SRC" value="tracks/track_01.mp3">
<param name="AUTOPLAY" value="false">
<param name="CONTROLLER" value="true">
<embed id="embed1" src="tracks/track_01.mp3" width="270" height="16" autoplay="false" controller="true" pluginspage="http://www.apple.com/quicktime/download/"></embed></object><br>
<a id="ref1" href="tracks/track_01.mp3" target="_blank" class="mp3">??????????????????</a>
<a href="javascript:setMusic('track_02','First Song')">test 1</a>

Any help would be greatly appreciated.