function updatePlayerControl(typ,s1,s2){
	if((s1==null)||(s1==undefined)){return;}
	s1=Math.round(s1);s2=Math.round(s2);
	if(typ=="time"){
		var cpos = Math.round((s1*140)/(s2+s1));
		document.getElementById("imgAvance1").width=cpos;
		document.getElementById("playerTime").innerHTML=converTime(s1);
		document.getElementById("playerTimeRemainder").innerHTML=converTime(s2);
		currentPosition=s1;
		return;
	}
	if(typ=="state"){currentState=s1;return;}
	if(typ=="volume"){setVolumen(parseInt(s1/10));currentVolume=s1;return;}
}
function reposObjs(){
	var psize = getPageSize();
	if(psize[0]<880){
		document.getElementById("barraTope").style.width="880px";document.getElementById("barraBaja").style.width="880px";
	}else{
		document.getElementById("barraTope").style.width="100%";document.getElementById("barraBaja").style.width="100%";
	}
	var posX = findPosX(document.getElementById("logo"));
	posX=(814+33+posX)-220;
	document.getElementById("wmlPlayerControl").style.top="21px";
	document.getElementById("wmlPlayerControl").style.left=posX+"px";
	if(document.getElementById("wmlPlayerList").style.display=="block"){
		var posX = findPosX(document.getElementById("wmlPlayerControl"));
		document.getElementById("wmlPlayerList").style.top="75px";
		if(window.is_ie){document.getElementById("wmlPlayerList").style.left=posX+"px";}else{document.getElementById("wmlPlayerList").style.left=(posX+69)+"px";}
	}
}
var trys = 0;
function updateOnload(){
	var posX = findPosX(document.getElementById("logo"));
	posX=(814+33+posX)-220;
	document.getElementById("wmlPlayerControl").style.top="21px";
	document.getElementById("wmlPlayerControl").style.left=posX+"px";
	if(parent.cabecera){
		if(parent.cabecera.mp3s.length!=0){
			mp3s = parent.cabecera.mp3s;
			populateList();
			document.getElementById("wmlPlayerControl").style.display="block";
			if(parent.cabecera.currentIndex){
				currentIndex=parent.cabecera.currentIndex;
				if(window.is_ie){
					document.getElementById("playTitle").innerHTML="<nobr><marquee width=220 height=15 scrollamount=1 scrolldelay=10>Canción:&nbsp;"+mp3s[currentIndex][3]+"</marquee></nobr>";
				}else{
					document.getElementById("playTitle").innerHTML="<nobr>Canción:&nbsp;"+mp3s[currentIndex][3]+"</nobr>";
				}
			}
			if(parent.cabecera.newVolumen){currentVolume=parent.cabecera.newVolumen;setVolumen(parseInt(currentVolume/10));}
		}
	}else{
		trys++
		if(trys<3){setTimeout("updateOnload()",3000);}
	}
}
function playerPlayPause(obj){
	if(obj.src.indexOf("b_play.gif")>0){obj.src="/images/layout/playercontrol/b_pause.gif";}else{obj.src="/images/layout/playercontrol/b_play.gif";}
	parent.cabecera.sendEvent('playpause');
}
function playerStop(obj){
	parent.cabecera.sendEvent('stop');
}
function playerTrack(offset){
	var tempIndex = currentIndex+offset;
	if((tempIndex<0)||(tempIndex>=mp3s.length)){return;}
	playerPlayItem(document.getElementById("items"+tempIndex),tempIndex);
	currentIndex=tempIndex;playerShowLista();
}		
function playerPlayItem(obj,index){
	parent.cabecera.getPlayer(index);
	for(var i=0;i<mp3s.length;i++){if(document.getElementById("items"+i)){document.getElementById("items"+i).className="items";}}
	obj.className="itemsC"
	if(window.is_ie){
		document.getElementById("playTitle").innerHTML="<nobr><marquee width=220 height=15 scrollamount=1 scrolldelay=10>Canción:&nbsp;"+mp3s[index][3]+"</marquee></nobr>";
	}else{
		document.getElementById("playTitle").innerHTML="<nobr>Canción:&nbsp;"+mp3s[index][3]+"</nobr>";
	}
	playerShowLista();
}
function playerShowLista(){
	if(document.getElementById("wmlPlayerList").style.display=="block"){
		document.getElementById("wmlPlayerList").style.display="none";
	}else{
		var posX = findPosX(document.getElementById("wmlPlayerControl"));
		document.getElementById("wmlPlayerList").style.top="75px";
		if(window.is_ie){document.getElementById("wmlPlayerList").style.left=posX+"px";}else{document.getElementById("wmlPlayerList").style.left=(posX+69)+"px";}
		document.getElementById("wmlPlayerList").style.display="block";
	}
	
}
function converTime(stime){
	if(stime==null){return;}
	var segundos=stime%60;var minutos=((stime-segundos)/60)
	return ("00"+minutos.toString()).substr(minutos.toString().length)+":"+("00"+segundos.toString()).substr(segundos.toString().length);
}
function populateList(){
	var html = "";
	for(var i=0;i<mp3s.length;i++){
		html+="<div id=items"+i+" class=items onmouseover=\"togleButtons(this);\" onmouseout=\"togleButtons(this);\" onclick=\"playerPlayItem(this,"+i+");\"><nobr>-&nbsp;";
		if(mp3s[i][3].toString().length>28){var title=mp3s[i][3].toString().substring(0,25)+"..."}else{var title=mp3s[i][3].toString();}
		html+=title;
		html+="&nbsp;</nobr></div>"
	}
	if(document.getElementById("wmlPlayerListItems")){document.getElementById("wmlPlayerListItems").innerHTML=html;html=null;}
}
function setVolumen(index){
	for(var i=0;i<11;i++){if(i<=index){document.getElementById("volumen"+i).style.borderLeftColor="#ffffff";}else{document.getElementById("volumen"+i).style.borderLeftColor="#606060";}}
	var newVolumen=index*10;
	//parent.cabecera.sendEvent('volume',newVolumen);parent.cabecera.currentVolume=newVolumen;
	//parent.cabecera.newVolumen=newVolumen;
}
function makeVolumen(){
	var html="<nobr>";
	for (var i=0;i<11;i++){
		html+="<img id=volumen"+i+" src=\"/images/layout/clearpixel.gif\" width=3 height="+(i+2)+" ";
		html+="onclick=\"setVolumen("+i+");\" "
		html+="style=\"margin-top:"+(14-i)+"px;border-left:1px solid #ffffff;cursor:pointer\">";
	}
	html+="</nobr>"
	document.write(html);
}