function crearXMLHttpRequest() 
{
  var xmlHttp=null;
  if (window.ActiveXObject) 
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  else 
    if (window.XMLHttpRequest) 
      xmlHttp = new XMLHttpRequest();
  return xmlHttp;
}


function mostrarPregunta()
{
	divResultado = document.getElementById('encuesta');
	
	ajax=crearXMLHttpRequest();
	ajax.onreadystatechange= verIndex;
	ajax.open("GET", "encuesta/mostrarpregunta.php",true);
	//ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send(null)
	
	function verIndex()
	{
		if (ajax.readyState==4)
	   	{
		   if (ajax.status==200)
		      {
				  divResultado.innerHTML = ajax.responseText;
			  }
	    }
	    else
	   {
		  divResultado.innerHTML= '<img src="../images/loading.gif">'; 
		  //alert('ingrese un dato')
	   }
	}
}


function cargarResultados()
{
	divResultado = document.getElementById('encuesta');
	codencu=document.frmencuesta.CboId.value;
	nroopc=document.frmencuesta.nroopciones.value;
	
	i=1;
	while(i<=nroopc){
		opcion=document.getElementById(i).checked;
		if (opcion==true){
			codresp=i;
			i=nroopc+1;}	
		i++;
	}

	if (opcion==false){
	alert("¡..Seleccione Respuesta..!");
	return false;}
	
	ajax=crearXMLHttpRequest();
	ajax.onreadystatechange= Resultado;
	ajax.open("POST", "encuesta/resultados.php",true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("codresp="+codresp+"&codencu="+codencu)
	
	
	function Resultado()
	{
		if (ajax.readyState==4)
	   	{
		   if (ajax.status==200)
		      {
				  divResultado.innerHTML = ajax.responseText;
			  }
	    }
	    else
	   {
		  // alert("¡..Seleccione una Respuesta..!");
		  // return false;
		  divResultado.innerHTML= '<img src="../images/loading.gif">'; 
		  //alert('ingrese un dato')
	   }
	}
}



function MostrarResultado(idencu)
{
	divResultado = document.getElementById('encuesta');
	
	ajax=crearXMLHttpRequest();
	ajax.onreadystatechange= verResultado;
	ajax.open("POST", "encuesta/mostrarresultado.php",true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("codencu="+idencu)
	
	function verResultado()
	{
		if (ajax.readyState==4)
	   	{
		   if (ajax.status==200)
		      {
				  divResultado.innerHTML = ajax.responseText;
			  }
	    }
	    else
	   {
		  divResultado.innerHTML= '<img src="../images/loading.gif">'; 
		  //alert('ingrese un dato')
	   }
	}
}

window.onload=mostrarPregunta;