﻿function ASPxButtonVotar_Click(s, e) {
	var vValidou = true;
	if (ASPxRadioButtonListOpcaoEnquete.GetSelectedItem() != null) {
		if (ASPxCheckBoxComentario.GetChecked()) {
			if (!ValidarGrupo("Votar")) {
				vValidou = false;
			}
		}
	}
	else {
		vValidou = false;
		ExibirNotificacao("<p>Selecione uma das opções.</p>", "A");
	}
	if (vValidou) {
		LoadingPanel.Show();
		ASPxCallbackPanelEnquete.PerformCallback("Votar");
	}
}

function ASPxDataViewComentarios_Init(s, e) {
	if (s.cpItens > 0) {
		ASPxLabelNaoExistemComentarios.SetClientVisible(false);
		s.SetClientVisible(true);
	}
	else {
		ASPxLabelNaoExistemComentarios.SetClientVisible(true);
		s.SetClientVisible(false);
	}
}

function ASPxPanelComentario_Init(s, e) {
	s.SetClientVisible(ASPxCheckBoxComentario.GetChecked());
}

function ASPxCallbackPanelEnquete_EndCallback(s, e) {
	if (s.cpTipoMensagem != null) {
		LoadingPanel.Hide();
		ExibirNotificacao(s.cpMensagem, s.cpTipoMensagem);
		ASPxRadioButtonListOpcaoEnquete.SetSelectedItem(null);
		ASPxMemoComentario.SetText("");
	}
	else if (s.cpMostrarOpcoes) {
		ASPxPanelAvisosVoto.SetClientVisible(false);
		ASPxPanelComponentesVoto.SetClientVisible(true);
	}

}

function ASPxCheckBoxComentario_CheckedChanged(s, e) {
	ASPxPanelComentario.SetClientVisible(s.GetChecked());
}

function ASPxDataViewComentarios_Init(s, e) {
	if (s.cpItens > 0) {
		ASPxLabelNaoExistemComentarios.SetClientVisible(false);
		s.SetClientVisible(true);
	}
	else {
		ASPxLabelNaoExistemComentarios.SetClientVisible(true);
		s.SetClientVisible(false);
	}
}

function ASPxLabelResultado_Init(s, e) {
	ASPxImageNews.SetClientVisible(false);
	ASPxLabelResultado.SetClientVisible(true);

	if (ASPxLabelOpiniao.GetText() == "") {
		ASPxPanelAvisosVoto.SetClientVisible(false);
		ASPxPanelComponentesVoto.SetClientVisible(true);
	}
	else {
		ASPxPanelAvisosVoto.SetClientVisible(true);
		ASPxPanelComponentesVoto.SetClientVisible(false);
	}
}

function ExibirPopupLoginEnquete(pUrl) {
	ExibirPopUpControl(ASPxPopupControlPrincipal, "Identifique-se", null, "/LoginEnquete" + pUrl, false, 380, 255);
}

function ExibirPopupResultadosComentarios(pID) {
	ExibirPopUpControl(ASPxPopupControlPrincipal, "Resultados e comentários", null, "/ResultadoEnquete/" + pID, true, 170, 130);
}

function ExibirPopupResultados(pID) {
	ExibirPopUpControl(ASPxPopupControlPrincipal, "Resultados", null, "/ResultadoEnquete/" + pID, true, 170, 130);
}
