  xmlhttp = function ()
  {
	  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;
  }
  
  voto = xmlhttp();
  function vota(id, nro)
  {
    	  voto.open("POST", "/utils/votar.php?IdItem="+id+"&votos="+nro, true);
	  voto.send("");
	  voto.onreadystatechange = function()
	  {
		  if (voto.readyState == 4) 
		  {
			  if (voto.status == 200)
			  {
        			var span = document.getElementById('nrodevotos');
				var selectvotar = document.getElementById('alternativas');
				selectvotar.disabled = true;
		        	span.innerText = voto.responseText;
		        	alert('Gracias por tu voto.');
			  }
			  else{
			  alert('No se puede realizar el Voto');}
		  }
	  }
  }  
  
  function vistapre()
  {
  	  aa = xmlhttp();
  	  aa.open("", "", true);
	  aa.send("");
	  aa.onreadystatechange = function()
	  {
		  if (aa.readyState == 4) 
		  {
			  if (aa.status == 200)
			  {
			  	alert('entro');
        			var span = document.getElementById('elpoema');
        			var salida = document.getElementById('vistaprevia');
		        	salida.innerText = span.responseText;
			  }
			  else{
			   alert('no salio')
			  }
		  }
	  }
  }    