function nuevoAjax()
{ 
	var xmlhttp=false; 
	try 
	{ 
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{ 
		try
		{ 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!="undefined") { xmlhttp=new XMLHttpRequest(); } 
	return xmlhttp; 
}


function eliminaEspacios(cadena)
{
	var x=0, y=cadena.length-1;
	while(cadena.charAt(x)==" ") x++;	
	while(cadena.charAt(y)==" ") y--;	
	return cadena.substr(x, y-x+1);
}


function nuevoEvento(evento, rating)
{
	//Recepcion
	if(evento=="ingreso")
	{	
		var div_titulo    = document.getElementById("texto_votos");
		var div_votos     = document.getElementById("texto_votos2");
		var div_estrellas = document.getElementById("votos");
		var r_idcliente   = document.getElementById("v_idcliente").value;
		
		var textoAccion   = "Enviando...";	
		r_rating	      = eliminaEspacios(rating);
				
		//Enviando valores
		div_titulo.innerHTML   = textoAccion;
		div_titulo.innerHTML   = "¡Gracias por votar!";
		div_estrellas.innerHTML = "<img src='imagenes/bg_stars.gif'>" ;
		
		var ajax=nuevoAjax();
		ajax.open("POST", "rating_proceso.php5", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send("v_rating="+r_rating+"&v_idcliente="+r_idcliente);
		ajax.onreadystatechange=function()
		{
			if (ajax.readyState==4)
			{
				div_votos.innerHTML   = ajax.responseText;		
			}
		}	
	}
}
