// JavaScript Document
function initPlaya() {
		Playa.songList[0]['src']="music/chasingshadows.mp3"; //This first song should have no spaces.  It also must be set in audioPlayer.html.
		Playa.songList[0]['title']="ChasingShadows";
		Playa.songList[1]['src']="music/wdoesitend.mp3";
		Playa.songList[1]['title']="Where Does It End";
		Playa.songList[2]['src']="music/awaken.mp3";
		Playa.songList[2]['title']="Awaken";
		Playa.songList[3]['src']="music/02DilChahataHai.mp3";
		Playa.songList[3]['title']="Dil Chahata Hai";
		Playa.songList[4]['src']="music/06Suryasta.mp3";
		Playa.songList[4]['title']="Suryasta";
		setSongTitle();
		
		//set on off switch correctly.
		if(parent.frames["bottomFrame"].globalHalt == true) {
			document.getElementById("OnOff").innerHTML = 'On';
		}
	}
	
	Playa.onPlayStop = function() {
		
		if(parent.frames["bottomFrame"].globalHalt == false) {
			if(parent.frames["bottomFrame"].globalSongCount == 4) {
				parent.frames["bottomFrame"].globalSongCount = 0;
			}
			else {
				parent.frames["bottomFrame"].globalSongCount++;
			}
			Playa.doPlayUrl(Playa.songList[parent.frames["bottomFrame"].globalSongCount]['src']);
			setSongTitle();
		}	
	}
	
	function OnOff() {
		if(parent.frames["bottomFrame"].globalHalt == true) { 
			parent.frames["bottomFrame"].globalHalt = false;
			document.getElementById("OnOff").innerHTML = 'Off';
		}
		else { 
			parent.frames["bottomFrame"].globalHalt = true;
			document.getElementById("OnOff").innerHTML = 'On';
		}
		
		Playa.doPlayStop();
	}
	
	function Off() {
		if(parent.frames["bottomFrame"].globalHalt == false) {
			parent.frames["bottomFrame"].globalHalt = true;
			document.getElementById("OnOff").innerHTML = 'On';
			Playa.doPlayStop();
			
		}
	}
	
	function Previous() {
		//first check if music is on or off.  If on play previous song.  If off do nothing.
		if(parent.frames["bottomFrame"].globalHalt == false) {
			//Decrease by 2 because doPlayStop will increase by 1.
			parent.frames["bottomFrame"].globalSongCount-=4;
			
			//Catch if it's on first song.  Adjust to 1 because doPlayStop will advance by 1.
			if(parent.frames["bottomFrame"].globalSongCount == -4) {
				
				//Set to 1 because 2 is the third and last song (0,1,2) This number should be set to one 
				//less than the last index value in the songlist array.
				parent.frames["bottomFrame"].globalSongCount = 3;
			}
			
			Playa.doPlayStop();
		}
		
	}
	
	function Next() {
		//first check is music is on or off. If on play next song.  If off do nothing.
		if(parent.frames["bottomFrame"].globalHalt == false) {
			Playa.doPlayStop();
		}
	}
	
	function setSongTitle(title) {
		if(title) document.getElementById("songTitle").innerHTML = title;
		else {
			sTitle = Playa.songList[parent.frames["bottomFrame"].globalSongCount]['title'];
			document.getElementById("songTitle").innerHTML = sTitle;
		}
	}
	
	function goToSong(src, title) {
		if(parent.frames["bottomFrame"].globalHalt == true) {
			parent.frames["bottomFrame"].globalHalt = false;
			document.getElementById("OnOff").innerHTML = 'Off';
		}
		Playa.doPlayUrl(src);
		setSongTitle(title);
	}
