//SCRIPT PARA AJAX
	function votar(enquete, alt0, alt1, alt2, alt3, alt4, alt5)
		{
		var correto = "nenhum";
		
		if (alt0 != 0)
			{
			var alternativa0 = document.getElementById("enquete0").checked;
			if (alternativa0 == true)
				{
				correto = alt0;
				}
			else
				{
				if (alt1 != 0)
					{
					var alternativa1 = document.getElementById("enquete1").checked;
					if (alternativa1 == true)
						{
						correto = alt1;
						}
					else
						{
						if (alt2 != 0)
							{
							var alternativa2 = document.getElementById("enquete2").checked;
							if (alternativa2 == true)
								{
								correto = alt2;
								}
							else
								{
								if (alt3 != 0)
									{
									var alternativa3 = document.getElementById("enquete3").checked;
									if (alternativa3 == true)
										{
										correto = alt3;
										}
									else
										{
										if (alt4 != 0)
											{
											var alternativa4 = document.getElementById("enquete4").checked;
											if (alternativa4 == true)
												{
												correto = alt4;
												}
											else
												{
												if (alt5 != 0)
													{
													var alternativa5 = document.getElementById("enquete5").checked;
													if (alternativa5 == true)
														{
														correto = alt5;
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		
		if (correto == "nenhum")
			{
			alert("Você precisa escolher uma das opções antes de votar.");
			}
		else
			{
			computarVoto(correto,enquete);
			}
		}

function computarVoto(voto,enquete)
	{
	var xmlHttp;
			
	try
		{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		}
	catch (e)
		{
		// Internet Explorer
		try
			{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
		catch (e)
			{
			try
				{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
			catch (e)
				{
				alert("ERRO: Seu navegador não suporta AJAX.");
				return false;
				}
			}
		}
	
	//REACAO CHAMADA ASSIM QUE O AJAX TERMINAR DE RODAR

	xmlHttp.onreadystatechange=function()
		{
		if(xmlHttp.readyState==4)
			{
			//DEPOIS QUE RODAR
			document.getElementById("alvoEnquete").innerHTML="<div id='alvoEnquete' name='alvoEnquete'><div id='tituloEnquete'><table border=0 class='txtTopoEnquete' cellpadding=\"0\" cellspacing=\"0\" hspace=\"0\" vspace=\"0\"><tr><td width=50%>Enquete</td><td width=50% align=right valign=top><a href='resultados.php?un=$codigoUnidade' target='_top'>Resultados[+]</a>&nbsp;&nbsp;</td></tr></table></div><div id='enquete'><img src='images/espaco15.gif' hspace=0 vspace=0><br><img src='images/espaco3.gif' hspace=0 vspace=0><br><strong><center>Voto registrado com sucesso. Obrigado!</center></strong><img src='images/espaco15.gif' hspace=0 vspace=0><br><img src='images/espaco3.gif' hspace=0 vspace=0><br></div></div>";
			}
		}

	var enviar = "voto=" + voto + "&enquete=" + enquete;
	xmlHttp.open("POST","votar.php",true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", enviar.length);
	xmlHttp.send(enviar);
	}