function obtener_votacion(id_noticia, dominio){
	var lectorXML = new LectorXML('/votacion/pixel_votos.php?codigo='+id_noticia+'&dominio='+dominio);
	var xml = lectorXML.xml;
	pintarResultados(xml, id_noticia);
}

function votar(id_noticia, dominio, voto){
	//modificado 16/04/08 puede haber 2 noticias en una pagina, se añade id, para paginas antiguas se deja sin id
	if (document.getElementById('votacion'+id_noticia)!=null){
		document.getElementById('votacion'+id_noticia).className="no";
	}else{
		document.getElementById('votacion').className="no";
	}
	if (document.getElementById('enviandoVotacion'+id_noticia)!=null){
		document.getElementById('enviandoVotacion'+id_noticia).className="votnot";
	}else{
		document.getElementById('enviandoVotacion').className="votnot";
	}
	//hacemos la petición
	var lectorXML = new LectorXML('/votacion/pixel_vota.php?codigo='+id_noticia+'&dominio='+dominio+'&voto='+voto);
	//recogemos datos y pintamos
	var xml = lectorXML.xml;
	pintarResultados(xml,id_noticia);
	
	if (document.getElementById('enviandoVotacion'+id_noticia)!=null){
		document.getElementById('enviandoVotacion'+id_noticia).className="no";
	}else{
		document.getElementById('enviandoVotacion').className="no";
	}
	if (document.getElementById('votacion'+id_noticia)!=null){
		document.getElementById('votacion'+id_noticia).className="votnot";
	}else{
		document.getElementById('votacion').className="votnot";
	}
	if (document.getElementById('votacionEnviada'+id_noticia)!=null){
		document.getElementById('votacionEnviada'+id_noticia).className="votnot";
	}else{
		document.getElementById('votacionEnviada').className="votnot";
	}
	//Deshabilitamos el envio de votos
	for (i=0;i<5;i++){
		if (document.getElementById('star'+id_noticia+i)!=null){
			document.getElementById('star'+id_noticia+i).onclick=nada;
		}else{
			document.getElementById('star'+i).onclick=nada;
		}
	}
}

//función para que una vez se haya realizado la votación, no se pueda votar
function nada(){
return false;
//nada
}

//Recoge los datos y pinta las estrellas y el número de votos
function pintarResultados(xml, id_noticia){
	if (xml!=null){
		xmldoc = xmlParse(xml);
		if (xmldoc!=null && xmldoc.getElementsByTagName("RESULTADO")[0]!=null){
			// Obtiene los datos del XML
			var valoracionEnviada=xmldoc.getElementsByTagName("ENVIADA")[0].firstChild.nodeValue;;
			var valoracionMedia=xmldoc.getElementsByTagName("MEDIA")[0].firstChild.nodeValue;
			var numeroVotos=xmldoc.getElementsByTagName("NUMEROVOTOS")[0].firstChild.nodeValue;
			if (document.getElementById('star'+id_noticia+'99')!=null){
				document.getElementById('star'+id_noticia+'99').src="http://media.lavozdegalicia.es/img/stars_" + valoracionMedia + ".gif";
			}else{
				for (i=0;i<5;i++){
					if (valoracionMedia>i){
						if (document.getElementById('star'+id_noticia+i)!=null){
							document.getElementById('star'+id_noticia+i).className="star on";
						}else{
							document.getElementById('star'+i).className="star on";
						}
					}else{
						if (document.getElementById('star'+id_noticia+i)!=null){
							document.getElementById('star'+id_noticia+i).className="star";
						}else{
							document.getElementById('star'+i).className="star";
						}
					}
				}
			}
			if (document.getElementById('numeroVotos'+id_noticia)!=null){
				document.getElementById('numeroVotos'+id_noticia).innerHTML="("+numeroVotos+" votos)";
			}else{
				document.getElementById('numeroVotos').innerHTML="("+numeroVotos+" votos)";
			}
		}
	}
}