var player = null;
var currentItem = -1; 
var previousItem = -1; 
function playerReady(thePlayer) {
	player = window.document[thePlayer.id];
	addListeners();
}
function addListeners() {
	if (player) { 
		player.addControllerListener("ITEM", "itemListener");
	} else {
		setTimeout("addListeners()",100);
	}
}
function itemListener(obj) {
	if (obj.index != currentItem) {
 		previousItem = currentItem;
		currentItem = obj.index;
		plst = player.getPlaylist();
		var id = plst[currentItem].description;
		$("#pos"+previousItem).removeClass('over');
		$("#pos"+currentItem).addClass('over');		
		$("#tabI").val(id);
		$("#mU").val(music[id].url);
		$("#mC").html(music[id].cancion);
		$("#mA").html(music[id].artista);
		$("#playlistA").attr('href', '/backend/ajax.php?id='+id);
		var enlace = escape("Escuchando en @fullritmo: "+ music[id].artista +" - "+ music[id].cancion + " - "+ music[id].url);
		$("#aTwitter").attr('href', 'http://twitter.com/home?status='+enlace);
		$("#aFacebook").attr('href', 'http://www.facebook.com/share.php?u='+escape(music[id].url));
		$("#mLA").attr('href', music[id].linkArtista);
		$.post("/backend/musica.php", { id_mp3: plst[currentItem].description } );
		votito();
	}
	
	if(idcan){
		idcan = false;
		player.sendEvent('ITEM',vPlay);
	}
}
function getItemData(idx) {
	if(idcan){
		player.sendEvent('ITEM',vPlay)
		idcan = false;
	}
	var obj = thisMovie("thePlayerId").itemData(idx);
	$("#listmp3 li").removeClass('over');
	$("#mp3"+obj["id"]).addClass('over');
	$("#tabI").val(obj["id"]);
	$("#mU").val(music[obj["id"]].url);
	$("#mC").html(music[obj["id"]].cancion);
	$("#mA").html(music[obj["id"]].artista);
	$("#playlistA").attr('href', '/backend/ajax.php?id='+obj["id"]);
	var enlace = escape("RT @fullritmo Escuchando");
	$("#aTwitter").attr('href', 'http://twitter.com/home?status='+enlace);
	$("#mLA").attr('href', music[obj["id"]].linkArtista);
	if(obj["id"] != actual){
		$.post("/backend/musica.php", { id_mp3: obj["id"] } );
		actual = obj["id"];

	}	

}
function sendEvent(typ,prm) {
	
  	document.getElementById("thePlayerId").sendEvent(typ,prm);
}
function thisMovie(movieName) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}
function get_musica(program,container,id,idt){
	$("#listmp3 li").removeClass('over');
	$("#mp3"+id).addClass('over');
	sendEvent('playitem',idt);
}
function processJson(data){
	$("#ajaxForm").html(data.message);
}
function procesado(data){
	$("#ajaxCompartir").html(data.message);
}
$(document).ready(function(){
$("#leermas").click(function () {
  $("#biografia p").toggle();
});
$("#ajaxForm").ajaxForm({dataType:  'json', success:   processJson}); 
$("#ajaxCompartir").ajaxForm({dataType:  'json', success:   procesado});
var y = $("#listmp3").height();
if(y < 480){
	$("#contentMp3").height(y + 12);
}
});
$(document).ready(function(){
	$('.Oartista').hide();				
	$('#Aartista').click(function() {
      $('.Oartista').toggle();
      
	  return false;
   });

 $(".contimage").hover(function() {
		$(this).animate({
			opacity:1
		},200);
	}, function() {
		$(this).animate({
			opacity:0.8
		},200);
	});
	$('#submitform').ajaxForm({
		target: '#error',
		success: function() {
		$('#error').fadeIn('slow');
		}
});
$('a[rel*=facebox]').facebox();
});function mano(manito) { 
obje = document.getElementById(manito);
if(obje.style.display != "none"){obje.style.display = "none";} else {obje.style.display = "";}
}
function votitoni(d) { 
mano('votito');
}
function votito(cantidad) { 
 divContenido = document.getElementById('votito1');
Ajax=objetoAjax();
var url = 't.php?f='+cantidad+' - '+$("#mC").html();+'';

 Ajax.open("GET", url, true);

 Ajax.onreadystatechange=function() {
  if (Ajax.readyState==4) {
   divContenido.innerHTML = Ajax.responseText
  }
 }
 Ajax.send(null)
}
function lyr(obtcp) { 
obje = document.getElementById(obtcp);
if(obje.style.display != "none"){obje.style.display = "none";} else {obje.style.display = "";}
}

function lr_c(tipo) {
lyr('lyc');
objet = document.getElementById('lyc');
var tipo;
objet.innerHTML= '<br /><br /><br /><br /><br /><br /><center><img height=15 src="http://fullritmo.net/img/Carg1.gif"></center><br /><br />';
  Ajax=objetoAjax();
var url = './Proc/'+tipo+'.php?f='+$("#mA").html()+' - '+$("#mC").html();+'';
Ajax.open("GET", url, true);
Ajax.onreadystatechange = function() {
  if (Ajax.readyState == 4) {
	  if (Ajax.status == 200) {
		var Respuesta = Ajax.responseText;
		objet.innerHTML = Respuesta;
	  }
  }
}
Ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
Ajax.send("f=Don Omar - Se Fue El Amor");
}