var conexion1;
var resultado;
function votar(cod,nombre,resul) 
{
  resultado=resul;
  conexion1=crearXMLHttpRequest();
  conexion1.onreadystatechange = procesarEventos;
  var aleatorio=Math.random();
  conexion1.open('GET','procesarvoto.php?nombre='+nombre+'&cod='+cod+"&aleatorio="+aleatorio, true);
  conexion1.send(null);
}

function procesarEventos()
{
  var resultados = document.getElementById(resultado);
  if(conexion1.readyState == 4)
  {
    resultados.innerHTML = conexion1.responseText;
  } 
  else 
  {
    resultados.innerHTML = '<img src="imagenes/cargando.gif">';	
  }
}

function crearXMLHttpRequest() 
{
  var xmlHttp=null;
  if (window.ActiveXObject) 
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  else 
    if (window.XMLHttpRequest) 
      xmlHttp = new XMLHttpRequest();
  return xmlHttp;
}

function rv(letra,palabra,inicio) 
{
  palabra=escape(palabra);
  conexion1=crearXMLHttpRequest();
  conexion1.onreadystatechange = procesarEventosVideo;
  var aleatorio=Math.random();
  conexion1.open('GET','recuperarvideos.php?letra='+letra+'&palabra='+palabra+'&inicio='+inicio+"&aleatorio="+aleatorio, true);
  conexion1.send(null);
}

function procesarEventosVideo()
{
  var resultados = document.getElementById('videos');
  if(conexion1.readyState == 4)
  {
    resultados.innerHTML = conexion1.responseText;
  } 
  else 
  {
  	window.scrollTo(0,0);
    resultados.innerHTML = '<center><img style=\'padding:50px\' width=\'50\' height=\'50\' src="imagenes/cargando.gif"><center>';	
  }
}
