var mp3PlayerLoadFile = false;
var curcontainer = null
var container;
var soundPlayer;
var playerwidth;
var buttonColorVar;
var progressColorVar;
var loadProgressColorVar;
var soundLengthVar;
var soundFileVar;
function soundDuration(t) {if (window.soundDurationDo) soundDurationDo(t)}
var soundContainers = [];
var soundContainersId = [];
//mp3PlayerLoad('3hv727c3','/_root/_lib2/players/mp3PlayerBackEnd.swf',240,'0x95a1ae','0xb5bdc6','0x617080',false,'/torben/wil4/_files/music/freewill.mp3',false);

function mp3PlayerLoad(xcontainer,xsoundPlayer,xplayerwidth,xbuttonColorVar,xprogressColorVar,xloadProgressColorVar,xsoundLengthVar,xsoundFileVar,cSoundAutoPlay) {
	if (mp3PlayerLoadFile!=xsoundFileVar) loadSound = 1;
	else loadSound = 0;

	if (xsoundPlayer.indexOf('mp3PlayerBackEnd')>-1) { 
		buttonwidth=40;
		buttonheight=20;
		}
	else {
		buttonwidth=75;
		buttonheight=38;
		}
	c = []
	c['container'] = xcontainer;
	c['soundPlayer'] = xsoundPlayer;
	c['buttonheight'] = buttonheight;
	c['buttonwidth'] = buttonwidth;
	c['playerwidth'] = xplayerwidth;
	c['buttonColorVar'] = xbuttonColorVar;//"0xff0000";//xbuttonColorVar
	c['progressColorVar'] = xprogressColorVar;//"0xffcc00";//
	c['loadProgressColorVar'] = xloadProgressColorVar;
	c['soundLengthVar'] = xsoundLengthVar;
	c['soundFileVar'] = xsoundFileVar;
// 	this.container = xcontainer;
// 	this.soundPlayer = xsoundPlayer;
// 	this.buttonheight = buttonheight;
// 	this.buttonwidth = buttonwidth;
// 	this.playerwidth = xplayerwidth;
// 	this.buttonColorVar = xbuttonColorVar;
// 	this.progressColorVar = xprogressColorVar;
// 	this.loadProgressColorVar = xloadProgressColorVar;
// 	this.soundLengthVar = xsoundLengthVar;
// 	this.soundFileVar = xsoundFileVar;
// 	alert(this.soundFileVar)
// 	//var cSoundAutoPlay = cSoundAutoPlay;
	//this.
	id = soundContainers.length;
	soundContainers[id] = c;
	soundContainersId.push(xcontainer);
	if (cSoundAutoPlay) loadSoundPlayer(xcontainer);
	}
	
function loadSoundPlayer(id) {
	curcontainer = id
	for (i in soundContainersId) { 
		//alert(soundContainersId[i])
		if ((typeof(soundContainersId[i])=='string') && (soundContainersId[i]==id)) curMpeg = soundContainers[i];
		}
	if (mp3PlayerLoadFile!=curMpeg['soundFileVar']) {
		unLoadSoundPlayer();
		/*if (!playerwidth) {
			toolObj = document.getElementById('tools');
			rightBarObj = document.getElementById('docmenubar');
			playerwidth = parseInt(objectXpos(rightBarObj)-objectXpos(toolObj)-25);
			}
		*/
		soundDur = curMpeg['soundLengthVar'];
		var so = new SWFObject(curMpeg['soundPlayer'], "FullScreen", curMpeg['playerwidth'], 20, "8", "#FFFFFF");
		so.addVariable("buttonColor", curMpeg['buttonColorVar']);
		so.addVariable("progressBackColor", curMpeg['buttonColorVar']);
		so.addVariable("progressColor", curMpeg['progressColorVar']);
		so.addVariable("loadProgressColor", curMpeg['loadProgressColorVar']);

		so.addVariable("progressWidth", curMpeg['playerwidth']-curMpeg['buttonwidth']);
		so.addVariable("soundFile", curMpeg['soundFileVar']);
		if (soundDur) so.addVariable("songDuration", soundDur);
		so.write(curMpeg['container']);
		mp3PlayerLoadFile = curMpeg['soundFileVar'];
		loader = document.getElementById(id+'_loader')
		if (loader) loader.style.display = 'none';
		}
	else {
		unLoadSoundPlayer();
 		}
	}
function unLoadSoundPlayer() {
	for (i in soundContainersId) {
		if (typeof(soundContainersId[i])=='string') {
			id = soundContainersId[i]
			loader = document.getElementById(id+'_loader')
			if (loader) loader.style.display = 'block';
			document.getElementById(soundContainersId[i]).innerHTML='';
			mp3PlayerLoadFile = false;
			}
		}
	}

