var altura = 160;
var Tloop = 0;

function abrirEnquete(resposta){
	var alturaAtual = window.parent.document.getElementById("enquete").style.height;

	if (!alturaAtual) {
		alturaAtual = 0;
	} else if (alturaAtual.indexOf("px") != -1) {
		alturaAtual = alturaAtual.replace("px", "");
	}
	alturaAtual = parseInt(alturaAtual);

	if (alturaAtual != this.altura) {
		this.rolarAbertura(0);
	}

	if (resposta == 1) {
		window.parent.document.getElementById("enqueteBotaoVotar").style.display = "none";
	}
}

function rolarAbertura(posicao){
	if (posicao < this.altura) {
		posicao = posicao + 20;
		window.parent.document.getElementById("enquete").style.height = posicao + "px";
		Tloop = setTimeout("rolarAbertura("+posicao+")", 1);
	} else{
		clearTimeout(Tloop);
	}
}

// ------------------------------------------------- //

function validarVotacao(){
	var len;
	var checked = 0;

	try{
		if (typeof document.form.resposta.value != "undefined") {
			len = 1;
		} else {
			len = document.form.resposta.length;
		}
	} catch(e) {}

	if (typeof len == "undefined") {
		len = 0;
	}

	if (len == 1) {
		if (document.form.resposta.checked == true) {
			checked = 1;
		}
	} else {
		for (i = 0; i < len; i++) {
			if (document.form.resposta[i].checked == true) {
				checked = 1;
				break;
			}
		}
	}

	if (checked == 1) {
		window.open("about:blank", "enquete", "width=330, height=300, scrollbars=1");	
		document.form.submit();
	} else{
		alert("Nenhuma opção de resposta foi selecionada!");
	}
}


function result(id) {
	window.open("/site/modulos/enquete/resposta.php?pergunta="+id, "enquete", "width=330, height=300, scrollbars=1");	
}
