soundManager.url = 'swf/'; // directory where SM2 .SWFs live
// disable debug mode after development/testing..
soundManager.debugMode = false;
soundManager.defaultOptions.whileplaying = whilePlaying;

var currentIndex;

function playRingtone(index)
{
	soundManager.stop("sound"+index);
	if (currentIndex != null)
	{
		soundManager.stop("sound"+currentIndex);
		var barra = "barra"+currentIndex;
		barra = document.getElementById(barra);
		barra.src = 'images/fondos/barra_musica.gif';
		barra.style.width = "100px";
		var imagen = "img_escucha"+currentIndex;
		imagen = document.getElementById(imagen);
		imagen.src = imagen.src.replace('stop_','play_');
	}
		
	if (currentIndex != index)
	{
		currentIndex = index;
		soundManager.play("sound"+index);
		var imagen = "img_escucha"+currentIndex;
		imagen = document.getElementById(imagen);
		imagen.src = imagen.src.replace('play_','stop_');
		var barra = "barra"+currentIndex;
		barra = document.getElementById(barra);
		barra.src = 'images/fondos/barra_musica_rep.gif';
		barra.style.width = "0px";
	} else {
		currentIndex = null;
	}
}

function whilePlaying()
{		
	var width = Math.round(this.position * 100 / this.durationEstimate);
	var barra = "barra"+currentIndex;
	var barra = document.getElementById(barra);
	barra.style.width = width + "px";
}
