////////////////////////////////////////
/////////// Funções Players ////////////
////////////////////////////////////////

// Função para exibir a música atual tocando no streaming
function musica_atual_players( servidor, porta, local, caracteres ) {
	
  if(porta == "") {
  document.getElementById(local).innerHTML = "Error!";
  } else {
  
  document.getElementById(local).innerHTML = "<img src='data:image/gif;base64,R0lGODlhEAAQALMIAGp74nSF7H6P9rrL/6a3/5Kj/1ZnzmBx2P///wAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFCgAIACwAAAAAEAAQAAAESBDJiYyhmFqb5xjVhhwH9n3hSJbeSa1sm5EUQXQTACC2jeu63q0D3PlwCB2lUMgEAhgmk/J8LqUIgQBRhV6z2q0VF94iJ9pOBAAh+QQFCgAIACwAAAAAEAAQAAAESBDJicagmFqbJyHVhhgG9n3hSJbeSa1sm5FUUXTTcSC2jeu63q0D3PlwCB1FIMgAABgmk/J8LqWIQABRhV6z2q0VF94iJ9pOBAAh+QQFCgAIACwAAAAAEAAQAAAESBDJiQihmFqbZynVhgwD9n3hSJbeSa1sm5GUIHSTYSC2jeu63q0D3PlwCB0lEMgcDhgmk/J8LqUIAABRhV6z2q0VF94iJ9pOBAAh+QQFCgAIACwAAAAAEAAQAAAESBDJiUqhmFqbpxDVhhAE9n3hSJbeSa1sm5FUEHTTMCC2jeu63q0D3PlwCB0FAMgYDBgmk/J8LqWIwwFRhV6z2q0VF94iJ9pOBAAh+QQFCgAIACwAAAAAEAAQAAAESBDJiYSgmFqbZwjVhhQF9n3hSJbeSa1sm5EUAHQTQSC2jeu63q0D3PlwCB3lcMgMBhgmk/J8LqUIgwFRhV6z2q0VF94iJ9pOBAAh+QQFCgAIACwAAAAAEAAQAAAESBDJiUKgmFqbJwDVhggC9n3hSJbeSa1sm5HUcXRTUSC2jeu63q0D3PlwCB3FYMgQCBgmk/J8LqWIwQBRhV6z2q0VF94iJ9pOBAAh+QQFCgAIACwAAAAAEAAQAAAESBDJiQCgmFqb5znVhgQB9n3hSJbeSa1sm5GUYXSTICC2jeu63q0D3PlwCB1lMMgUChgmk/J8LqUIAgFRhV6z2q0VF94iJ9pOBAAh+QQFCgAIACwAAAAAEAAQAAAESBDJic6hmFqbpzHVhgAA9n3hSJbeSa1sm5HUMHRTECC2jeu63q0D3PlwCB2FQMgIBBgmk/J8LqWIQgFRhV6z2q0VF94iJ9pOBAA7' />";
  
  var http = new Ajax();
  http.open("GET", "/funcoes-ajax-players/musica_atual/"+servidor+"/"+porta+"/200" , true);
  http.onreadystatechange = function() {
	
  if(http.readyState == 4) {
  
	resultado = http.responseText;
	
	resultado_partes = resultado.split("-");
	
	var artista = resultado_partes[0];
	var musica = resultado_partes[1];
	
	if(artista && musica) {
	document.getElementById(local).innerHTML = "<font size='4'>"+add3Dots(artista,caracteres)+"</font><br>"+add3Dots(musica,caracteres)+"";
	} else {
	document.getElementById(local).innerHTML = "<img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACLklEQVR42mNkoBAw4pJg0rBjZRZXUhWUVdXklFTR4hBT0OTg5NGU+Hhrzs7qwKl4DYjY/HTmva9MiayMjKw/fv5h+P/nLwMDEH//8Zvh9fl9HW/mZ1biNcBt9ZP9D74wOvz+9Yfh3++/DD9+/GL49OUXw/dvvxgYbh/qYFhfhN8Ah6UP9h948seB4fcfBoaf3xkYPr15zfDx1VURXh72Nw9uHmTYXIbfAJsFd/Yf2bjiJMOtw7sYXt+/wvDq1iuQuHNOX+6+ez+l/m+rJGDA7Jv7j/RmlTPc2HsKWdw5qyd33+3vUv931xIwYPrV/Uf6cyoYbu0/iWJARlfuvpvfpP7vbyBgwKSL+49MyqtguHMQ1YDUDqABX6T+H2rBb4B139n9R6cWlTHcPXgaJqZk4i4jYxYUe/jCA77/x9qxG6Bj7sDxm19Bh88hc8rpOWWZDPcOngeJ183etfTaB96oq/ffM1w/c6CD4VQXpgHq7vEKARk1h888/Cpz48knhqdrqvUYHhy+omfuKM3pUPPo2oP3jJ8//2BgeLC3heHa/FoMA8Kbl5ef/6PUcffZJ4a/P34yMGzM0GH49OQ+KxuHgJR/z5mHn3klGT49/cRwttud4ef7ExgGiGtZ+X0yLVrz/RcjK8O1TfsYLi6MAQr/AqlhZGaR/s/Gb8rw48Mphv9/rwDF/mELAxZGFjbd/wxMkgx/fpwD8j8DMTATMPyHaoDh/8jhhi0WkMX+MxAAANiK9xHqut4pAAAAAElFTkSuQmCC' width='16' height='16' border='0' align='absmiddle' />&nbsp;"+resultado;
	}
	
  }
  
  }
  http.send(null);
  delete http;
  }
}

// Função para exibir a música atual tocando no streaming
function capa_musica_atual( servidor, porta, local, altura ) {
	
  if(porta == "") {
  document.getElementById(local).innerHTML = "Error!";
  } else {
  
  var http = new Ajax();
  http.open("GET", "/funcoes-ajax-players/capa_musica_atual/"+servidor+"/"+porta , true);
  http.onreadystatechange = function() {
	
  if(http.readyState == 4) {
  
	resultado = http.responseText;
	
	document.getElementById(local).src = resultado;
	document.getElementById(local).height = altura;
	
  }
  
  }
  http.send(null);
  delete http;
  }
}

function get_host() {

var url = location.href;
url = url.split("/");

return url[2];

}

function abrir_janela( url,largura,altura ) {
window.open( url, "","width="+largura+",height="+altura+",toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=NO" );
}

function add3Dots(string, limit)
{
  var dots = "...";
  if(string.length > limit)
  {
    // you can also use substr instead of substring
    string = string.substring(0,limit) + dots;
  }

    return string;
}

// Rotina AJAX
function Ajax() {
var req;

try {
 req = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
 try {
	req = new ActiveXObject("Msxml2.XMLHTTP");
 } catch(ex) {
	try {
	 req = new XMLHttpRequest();
	} catch(exc) {
	 alert("Esse browser não tem recursos para uso do Ajax");
	 req = null;
	}
 }
}

return req;
}