function getFlashMovieObject(movieName)
{
      if (window.document[movieName])
      {
                 return window.document[movieName];            
      }
      if (navigator.appName.indexOf("Microsoft Internet")==-1)
      {
            if (document.embeds && document.embeds[movieName])
                     return window.document.embeds[movieName];
      }
      else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
      {
              return document.getElementById(movieName);
      }
}

 function createXMLHttpRequest() {
   try { return new XMLHttpRequest(); } catch(e) {}
   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
   //alert("XMLHttpRequest not supported");
   return null;
}

function trackMaisOuvidos(id) {
	if(id != '-1'){
		var xhr = createXMLHttpRequest();
		xhr.open("GET","?/sc_building/maisTocadas/"+id,true);
		xhr.send(null);
	}
} 

function userPlay(tId, tTitulo,tPath){
	//document.getElementById("t"+tId).innerHTML = "<img src = 'img/layout/ico_som.gif'>";
	var flashPlayer = getFlashMovieObject("PlayerSpl");

	//flashPlayer.SetVariable("sndStop",true);
	flashPlayer.SetVariable("tit",tTitulo);
	flashPlayer.SetVariable("tPath",tPath);
	flashPlayer.SetVariable("tId",tId);
	flashPlayer.SetVariable("sndPlay",true);
	
	trackMaisOuvidos(tId);
	
}

function userPause(){
	var flash = getFlashMovieObject("hidePlayer");
	flash.SetVariable("sndPause",true);
}

function userUnPause(){
	var flash = getFlashMovieObject("hidePlayer");
	flash.SetVariable("sndUnPause",true);
}

function icoPause(tId){
	document.getElementById("t"+tId).innerHTML = "<a href = 'javascript:userPause();'><img src = 'img/layout/btnPause.gif'/></a>"
}

function icoPlay(tId,tPath,tTotal){
	
	tPath 	= '"'+tPath+'"'
	tTotal 	= '"'+tTotal+'"'
	if(document.getElementById("t"+tId))
		document.getElementById("t"+tId).innerHTML = "<a href = 'javascript:userPlay("+tId+","+tPath+","+tTotal+");'><img src ='img/layout/btn_Play.gif'/></a>"
	  
}

function icoUnPause(tId){
	document.getElementById("t"+tId).innerHTML = "<a href = 'javascript:userUnPause();'><img src = 'img/layout/btn_Play.gif'/></a>"
	  
}

function updateTime(tId, time){
	if(document.getElementById("time"+tId))
		document.getElementById("time"+tId).innerHTML = time
	  
}
