var contEstrutura = 0;

function cadastrarRemover(pFormulario)
{
	var vEmail = pFormulario.inpNewsletter.value;
	var vAcao = pFormulario.hidAcao.value;
	
	$.post(PATHR + 'newsletter/ajaxCadastrarRemover', {email: vEmail, acao: vAcao}, function(data){
		
		
		var texto = " <a href='JavaScript:ocultarMsgErro();'>(Ocultar)</a>";
		
		
		$('#divMsgErroNews').html(data + texto);
		$('#divMsgErroNews').show();
	});
	
}


function preencheEmails(pEmail)
{
	document.getElementById('formCadastrarNewsletter').inpNewsletter.value = pEmail;
	document.getElementById('formRemoverNewsletter').inpNewsletter.value = pEmail;
}

function ocultarMsgErro()
{
	$('#divMsgErroNews').hide();
}

function estruturaProxima(quantEstrutura)
{
	contEstrutura++;
	if (contEstrutura == quantEstrutura) {
    contEstrutura = 0;
	}
	exibeEstrutura(quantEstrutura);
}

function estruturaAnterior(quantEstrutura)
{
	contEstrutura--;
	if (contEstrutura == -1){
	  contEstrutura = quantEstrutura - 1 ;
	}
	exibeEstrutura(quantEstrutura);
}

function exibeEstrutura(quantEstrutura)
{
	$('span[id*="spanEstrutura_"]').hide();
	$('#spanEstrutura_' + contEstrutura).show();
  /*for (i=0; i < quantEstrutura; i++)
	{
		if (i == contEstrutura%quantEstrutura) {
			$('#spanEstrutura_' + i).show();
		}
		else
		{
			$('#spanEstrutura_' + i).hide();
		}
	}*/
	
}


function testaFormContato()
{
	var nome, email, assunto, mensagem, captcha;
	nome = document.formContato.inpNome.value;
	email = document.formContato.inpEmail.value;
	assunto = document.formContato.inpAssunto.value;
	mensagem = document.formContato.texMensagem.value;
	captcha = document.formContato.inpCaptcha.value;
	
	
	
	if (nome == '' || email == '' || assunto == '' || mensagem == '' || captcha == '')
	{
		var msgErro = "Preencha todos os campos <a href='javascript: void(0);' onclick=\"ocultar('spanMsgErro');\">(Ocultar)</a>";
		$('#spanMsgErro').html(msgErro);
		$('#spanMsgErro').show();
	}
	else
	{
		$('#spanMsgErro').html('Aguarde <img src="' + PATHR_INSTITUCIONAL_SER_IMAGE + 'loading.gif">');
		$('#spanMsgErro').show();
		$.post(PATHR + 'contato/ajaxEnviar', {nome: nome, email: email, assunto: assunto, mensagem: mensagem, captcha: captcha}, function(data){
			$('#spanMsgErro').html(data + " <a href='javascript: void(0);' onclick=\"ocultar('spanMsgErro');\">(Ocultar)</a>");
			$('#spanMsgErro').show();
		});
		
		
	}
}


function ocultar(idElemento)
{
	$('#' + idElemento).hide();
}

function mostrar(idElemento)
{
	$('#' + idElemento).show();
}
