//AJAX********************************************************************************************
//-----------------------------------------------------------------------------------------------
function nuevoAjax()
{ 
	/* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
	lo que se puede copiar tal como esta aqui */
	var xmlhttp=false; 
	try 
	{ 
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{ 
		try
		{ 
			// Creacion del objet AJAX para IE 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!="undefined") { xmlhttp=new XMLHttpRequest(); } 

	return xmlhttp; 
}
//----------------------------------------------------------------------------------------------------
//****************************************************************************************************
//*******************************************************************************************
function VotarEncuesta(id)
{
	
	
	var radio_opcion = "";
	var formulario = document.getElementById('form1');
	var radio = document.form1.opcion_radio;
	
	for(i=0;i<radio.length;i++)
	{
        if(radio[i].checked) 
		{
			radio_opcion = radio[i].value;
		}
	}
	
	var id_encuesta = document.getElementById('id_encuesta');
	
	var ajax=nuevoAjax();
		ajax.open("POST", "procesar_votar_encuesta.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send("opcion_radio="+escape(radio_opcion)+
				  "&id_encuesta="+escape(id_encuesta.value));
	
	ajax.onreadystatechange=function()
		{
			if (ajax.readyState==4)
			{
				var patron = /ERROR : /;
				if(ajax.responseText.search(patron)!=-1)
				{
						alert(ajax.responseText);
				}
				else
				{
						alert(ajax.responseText);
						VerResultados(id);
				}
			}
		}
}

//***********************************************************************************************************************
function VerResultados(id)
{
	window.open('encuesta_resultados.php?ide='+id,'Encuesta');	
}

//***********************************************************************************************************************

//*******************************************************************************************
function VotarEncuesta90s(id)
{
	
	
	var radio_opcion = "";
	var formulario = document.getElementById('form1');
	var radio = document.form1.opcion_radio;
	
	for(i=0;i<radio.length;i++)
	{
        if(radio[i].checked) 
		{
			radio_opcion = radio[i].value;
		}
	}
	
	var id_encuesta = document.getElementById('id_encuesta');
	
	var ajax=nuevoAjax();
		ajax.open("POST", "procesar_votar_encuesta.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send("opcion_radio="+escape(radio_opcion)+
				  "&id_encuesta="+escape(id_encuesta.value));
	
	ajax.onreadystatechange=function()
		{
			if (ajax.readyState==4)
			{
				var patron = /ERROR : /;
				if(ajax.responseText.search(patron)!=-1)
				{
						alert(ajax.responseText);
				}
				else
				{
						alert(ajax.responseText);
						VerResultados90s(id);
				}
			}
		}
}

//***********************************************************************************************************************
function VerResultados90s(id)
{
	window.open('encuesta_resultados_90s.php?ide='+id,'Encuesta');	
}

//***********************************************************************************************************************



function refreshImg()
{
    document.form1.vistaprevia.src = 'file:///'+document.form1.foto.value;
}


function Ventana_PopUp(pagina,ancho,alto)
{
	var opciones = 'width='+ancho+',height='+alto;
    window.open(pagina,'FLVPlayer',opciones);
}


