function objetoAjax(){
	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 Votar(id_encuesta){
	var id_encuesta;
	var radio;
	var i;
	var flag;
	var test;
	test=1;
	id_encuesta=id_encuesta;
    for (i=0;i < document.form1.radio.length;i++){ 
	     flag=0
         if (document.form1.radio[i].checked){
			 flag=1		 
             break;
		 }
	}
	if (flag==1){
        radio=document.form1.radio[i].value;
	    divResultado = document.getElementById('encuesta');
	    ajax=objetoAjax();
	    ajax.open("POST", "encuesta_resultado.php", true);
	}else{
          radio=0;
	      divResultado = document.getElementById('encuesta');
	      ajax=objetoAjax();
          ajax.open("POST", "encuesta.php", true);
	     }
	ajax.onreadystatechange=function(){
     if(ajax.readyState==4){
        divResultado.innerHTML = unescape(ajax.responseText);
     }
    }
    ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    ajax.send("id_encuesta="+id_encuesta+"&radio="+radio+"&test="+test);
}


function Ver(id_encuesta){
	var id_encuesta;
	id_encuesta=id_encuesta;
	divResultado = document.getElementById('encuesta');
	ajax=objetoAjax();
    ajax.open("POST", "encuesta_resultado.php", true);
	ajax.onreadystatechange=function(){
     if(ajax.readyState==4){
        divResultado.innerHTML = unescape(ajax.responseText);
     }
    }
    ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    ajax.send("id_encuesta="+id_encuesta);
}

function Votarb(id_encuesta){
	var id_encuesta;
	var radio;
	var i;
	var flag;
	var test;
	test=1;
	id_encuesta=id_encuesta;
    for (i=0;i < document.form1.radio.length;i++){ 
	     flag=0
         if (document.form1.radio[i].checked){
			 flag=1		 
             break;
		 }
	}
	if (flag==1){
        radio=document.form1.radio[i].value;
	    divResultado = document.getElementById('encuestab');
	    ajax=objetoAjax();
	    ajax.open("POST", "encuesta_resultadob.php", true);
	}else{
          radio=0;
	      divResultado = document.getElementById('encuestab');
	      ajax=objetoAjax();
          ajax.open("POST", "encuestab.php", true);
	     }
	ajax.onreadystatechange=function(){
     if(ajax.readyState==4){
        divResultado.innerHTML = unescape(ajax.responseText);
     }
    }
    ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    ajax.send("id_encuesta="+id_encuesta+"&radio="+radio+"&test="+test);
}


function Bver(id_encuesta){
	var id_encuesta;
	id_encuesta=id_encuesta;
	divResultado = document.getElementById('encuestab');
	ajax=objetoAjax();
    ajax.open("POST", "encuesta_resultadob.php", true);
	ajax.onreadystatechange=function(){
     if(ajax.readyState==4){
        divResultado.innerHTML = unescape(ajax.responseText);
     }
    }
    ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    ajax.send("id_encuesta="+id_encuesta);
}

