/*
Music Player
By: Andrew Thrall

Add songs by increasing the total_song value and adding it to the 2 array lists.

Example:
	total_songs = 3;
	songs[2] = "SongFile.wav";
	song_names[2] = "Song Name";
	
Change the variables stop_button, play_button, previous_button and next_button to your images for these buttons. Also 
change song_directory to the directory of your songs.
*/
total_songs = 5; //Total number of songs
songs = new Array(total_songs); //Array containing Songs Files.
song_names = new Array(total_songs); //Array containing the Song Names.
songs[0] = "FromTheBeginning.mp3";
song_names[0] = "From the Beginning (clip)";
songs[1] = "Kryptonite.mp3";
song_names[1] = "Kryptonite (clip)";
songs[2] = "AManAndAWomen.mp3";
song_names[2] = "A Man and a Woman (clip)";
songs[3] = "RocketMan.mp3";
song_names[3] = "Rocket Man (clip)";
songs[4] = "DustintheWind.mp3";
song_names[4] = "Dust in the Wind (clip)";
current_song = 0;
song_directory = "Playlist";
stop_button="Images/stop_button.PNG";
play_button="Images/play_button.PNG";
previous_button="Images/previous_button.PNG";
next_button="Images/next_button.PNG";
ControlsID = "controls";
SongNameID = "song_name";

function InitMusicPlayer(controls_id, song_name_id)
{
	ControlsID = controls_id;
	SongNameID = song_name_id;
	document.getElementById(SongNameID).innerHTML = song_names[current_song];
	document.getElementById(ControlsID).innerHTML = '<img src="'+play_button+'" style="cursor:pointer;" onclick="Play()"><img src="'+previous_button+'" style="cursor:pointer;" onclick="Previous()"><img src="'+next_button+'" style="cursor:pointer;" onclick="Next()">';
}
function Play() 
{
	var path = '<embed src="'+song_directory+'/' + songs[current_song] + '" autostart="true" loop="true" hidden="true" height="0" width="0" id="song_playing">';
	document.getElementById(ControlsID).innerHTML = path + '<img src="'+stop_button+'" style="cursor:pointer;" onclick="Stop()"><img src="'+previous_button+'" style="cursor:pointer;" onclick="Previous()"><img src="'+next_button+'" style="cursor:pointer;" onclick="Next()">';
}
function Stop() 
{
	document.getElementById(ControlsID).innerHTML = '<img src="'+play_button+'" style="cursor:pointer;" onclick="Play()"><img src="'+previous_button+'" style="cursor:pointer;" onclick="Previous()"><img src="'+next_button+'" style="cursor:pointer;" onclick="Next()">';
}
function Next()
{
	current_song+=1;
	if (current_song == total_songs)
	{ current_song = 0; }
	document.getElementById(SongNameID).innerHTML = song_names[current_song];
	document.getElementById(ControlsID).innerHTML = '<img src="'+play_button+'" style="cursor:pointer;" onclick="Play()"><img src="'+previous_button+'" style="cursor:pointer;" onclick="Previous()"><img src="'+next_button+'" style="cursor:pointer;" onclick="Next()">';
}
function Previous()
{
	current_song-=1;
	if (current_song == -1)
	{ current_song = total_songs-1; }
	document.getElementById(SongNameID).innerHTML = song_names[current_song];
	document.getElementById(ControlsID).innerHTML = '<img src="'+play_button+'" style="cursor:pointer;" onclick="Play()"><img src="'+previous_button+'" style="cursor:pointer;" onclick="Previous()"><img src="'+next_button+'" style="cursor:pointer;" onclick="Next()">';
}
