function createRequest() //necesario para AJAX
{

try
  {
  // Firefox, Opera 8.0+, Safari
  return request=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    return request=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    return request=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return request;
}

function adjustIFrameSize(iframeWindow) { 
if(iframeWindow.name!='') { 
if (iframeWindow.document.height) { 
   var iframeElement = document.getElementById(iframeWindow.name); 
   iframeElement.style.height = iframeWindow.document.height + 'px'; 
} 
else if (document.all) { 
   var iframeElement = document.all[iframeWindow.name]; 
   if (iframeWindow.document.compatMode && 
       iframeWindow.document.compatMode != 'BackCompat') 
   { 
     iframeElement.style.height = iframeWindow.document.documentElement.scrollHeight + 'px'; 
   } 
   else { 
     iframeElement.style.height = iframeWindow.document.body.scrollHeight + 'px'; 
   } 
} 
if (parent.adjustIFrameSize) {parent.adjustIFrameSize(window);} 
} 
}
function createRequest()
{

try
  {
  // Firefox, Opera 8.0+, Safari
  return request=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    return request=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    return request=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return request;
}

function votar_enc(id_encuesta){
	var voto=999;
	for(i=0;i<30;i++){
		if(document.getElementById('imgrad_'+i)){
		if(document.getElementById('imgrad_'+i).value=='1'){
			voto=i;
			break;
		}
		}
	}
	if(voto!=999){
		var Mrequest=createRequest();
		var Murl="encuesta-enc-save.php";
		Mrequest.open("POST",Murl,true);
		Mrequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=utf-8');
		Mrequest.onreadystatechange=function(){
										if(Mrequest.readyState==4){
											var newtotal=Mrequest.responseText;
											document.getElementById('div_encuestas_enc').innerHTML=newtotal;

										}
									}
		Mrequest.send("id_encuesta="+escape(id_encuesta)+"&voto="+escape(voto)+"&huella="+escape(document.getElementById('huella').value));
	}else{
		alert("Debe Elegir Alguna Opcion!");	
	}
}

function clicar_enc(cont){
	for (i=0; i<30; i++){
		if(document.getElementById('imgrad_'+i)){ //para saber si existe ese imagen en la pagina
				document.getElementById('imgrad_'+i).src='images/encuesta/enc_radio_off.jpg'; //pone todos los radio en unchecked
				document.getElementById('imgrad_'+i).value='0';
		}
	}
	document.getElementById('imgrad_'+cont).src='images/encuesta/enc_radio_on.jpg'; //pone checked en el q se hizo clic
	document.getElementById('imgrad_'+cont).value='1';
}