That's another way to do it. If you setTimeout(handlerfunction, songlength*1000), you'll know when to set the next one.
Assuming document.bgsound is valid, you would use:
Code:
<script>
var songs = Array("sound1.mid","sound2.mid","sound3.mid"); //Filenames
var slength = Array(67,23,43); //Duration in seconds
var song_id = 0; //Start ID
nextSong();
function nextSong() {
document.bgsound = songs[song_id];
setTimeout ("nextSong();",slength[song_id]*1000);
song_id++;
if (song_id > songs.length) song_id = 0;
}
</script>