// mp3 player
var currentPosition;
var currentVolume;
var currentItem;

var theID; 
var p1playing;
var p2playing;

// these functions are caught by the JavascriptView object of the player.
function sendEvent(thePlayer, typ, prm) { thisMovie(thePlayer).sendEvent(typ,prm); };

function getUpdate(typ,pr1,pr2,pid) { 
	if ((pid != "null")&&(typ=="state")&&(pr1==2)) {
		if (pid=="player1") { 
			p1playing=true;
			if (p1playing) { 
				sendEvent("player2", 'stop');  p1playing=false;
				sendEvent("player3", 'stop');  p1playing=false;
				sendEvent("player4", 'stop');  p1playing=false;
				sendEvent("player5", 'stop');  p1playing=false;
			}
		}
		
		if (pid=="player2") { 
			p2playing=true;
			if (p2playing) { 
				sendEvent("player1", 'stop');  p1playing=false;
				sendEvent("player3", 'stop');  p1playing=false;
				sendEvent("player4", 'stop');  p1playing=false;
				sendEvent("player5", 'stop');  p1playing=false;
			}
		} 
		
		if (pid=="player3") { 
			p3playing=true;
			if (p3playing) { 
				sendEvent("player1", 'stop');  p1playing=false;
				sendEvent("player2", 'stop');  p1playing=false;
				sendEvent("player4", 'stop');  p1playing=false;
				sendEvent("player5", 'stop');  p1playing=false;
			}
		} 
		
		if (pid=="player4") { 
			p4playing=true;
			if (p4playing) { 
				sendEvent("player1", 'stop');  p1playing=false;
				sendEvent("player2", 'stop');  p1playing=false;
				sendEvent("player3", 'stop');  p1playing=false;
				sendEvent("player5", 'stop');  p1playing=false;
			}
		} 
		
		if (pid=="player5") { 
			p5playing=true;
			if (p5playing) { 
				sendEvent("player1", 'stop');  p1playing=false;
				sendEvent("player2", 'stop');  p1playing=false;
				sendEvent("player3", 'stop');  p1playing=false;
				sendEvent("player4", 'stop');  p1playing=false;
			}
		} 		
		
	}

};

function getItemData(pid, idx) {

};

// This is a javascript handler for the player and is always needed.
function thisMovie(movieName) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
};

function initialize() {
	createPlayer("placeholder1", "player1", "mp3/edits/Freedom.mp3", "gfx/covers/freedom.jpg", false, true);
	createPlayer("placeholder2", "player2", "mp3/edits/RunningBack.mp3", "gfx/covers/runningbacktoyou.jpg", false, true);
	createPlayer("placeholder3", "player3", "mp3/edits/StrengthToCarryOn.mp3", "gfx/covers/strengthtocarryon.jpg", false, true);
	createPlayer("placeholder4", "player4", "mp3/edits/DeeperLove.mp3", "gfx/covers/deeperlove.jpg", false, true);
	createPlayer("placeholder5", "player5", "mp3/edits/MyHeartSpeaks.mp3", "gfx/covers/myheartspeaks.jpg", false, true);
}

function createPlayer(thePlace, thePlayer, theFile, theImg, start, icons) {
	var s1 = new SWFObject("swf/mp3player.swf", thePlayer, "122","91","7");
	s1.addParam("allowfullscreen", "false");
	s1.addVariable("enablejs","true");
	s1.addVariable("repeat","false");
	s1.addVariable("shuffle","false");
	s1.addVariable("file", theFile);
	s1.addVariable("javascriptid",thePlayer);
	s1.addVariable("width", "122");
	s1.addVariable("height", "91");
	//s1.addVariable("displaywidth", "280");
	//s1.addVariable("displayheight", "176");
	if (start) s1.addVariable("autostart", "false");
	if (! icons) s1.addVariable("showicons", "false");
	if (theImg != "") s1.addVariable("image", theImg);
	s1.write(thePlace);
}
