var currentSongIndex = null;

function triggerFlashAction(theAction,theArg) {
    thisMovie(theArg).triggerAction(theAction,theArg);
}

function thisMovie(movieName) {	
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName];
    }
    else {
        return document[movieName];
    }
}
function playing(theId) {
	if(currentSongIndex != null)
		triggerFlashAction("stop", "flash" + currentSongIndex);
		
    currentSongIndex = theId;       
}

function nextTrack(){
	currentSongIndex++;
	var movieName = "flash" + currentSongIndex;	
	
	//checking to see if we are at the end of the page, if we are start again at the top
	if ((navigator.appName.indexOf("Microsoft") != -1 && !window[movieName]) || 
			(navigator.appName.indexOf("Microsoft") == -1 && !document[movieName])) {			
        currentSongIndex = 0;  
        movieName = "flash" + currentSongIndex;     
    }
    
	//add some other functionality to highlight the next song
	triggerFlashAction("play", movieName);
}

var newState = "Pause Song";
		
function playPause(){		
	if(currentSongIndex != null){
		var elements = null;
		
		if(newState == "Pause Song"){
			newState = "Play Song";		
			triggerFlashAction("stop", "flash0");		
		}else if(newState == "Play Song"){
			newState = "Pause Song";		
			triggerFlashAction("play", "flash0");
		}
		
		if(newState != null){
			elements = document.getElementsByName("playPause");
			var length = elements.length;
			
			for(var i = 0;i < length;i++){
				elements[i].value = newState;		
			}
		}
	}
}