function mostraForm(valor) {
	
	if(valor == 1) {
	
		document.getElementById('divInformativo').style.display = 'block';
	}
	else {
	
		document.getElementById('divInformativo').style.display = 'none';
	}
}

function cadastraInformativo() {

	nome  = document.informativo.informativoNome.value;
	email = document.informativo.informativoEmail.value;
	
	if(validaEmail(email)) {
	
		if(nome && email) {
		
			var url = "_include/cadastraInformativo.php";
		
			var pars = "acao=cadastra&nome=" + nome + "&email=" + email;
			
			var objetoAjax = new Ajax.Request( url, { method: "post", parameters: pars, onComplete: retorna });
		}
		else {
			
			alert('É necessário inserir o nome e o email para cadastro!');
		}
	}
	else {
	
		alert('Email inválido!');
	}
}

// FUNÇÃO PARA VALIDAR E-MAILS
function validaEmail(email){
	
	var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
	
	if(typeof(email) == "string") {
		
		if(er.test(email)){ 
			return true; 
		}
	}
	else if(typeof(email) == "object") {
	  
		if(er.test(email.value)) {
			return true;
		}
	}
	else {
		return false;
	}
}

function retorna(javascript) {
	
	var javascript = javascript.responseText;
	javascript = javascript.replace(/\+/g," ");
	javascript = unescape(javascript);
	if(javascript) {
		alert(javascript);
	}
	else {
	
		alert('E-mail cadastro com sucesso!');
		document.getElementById('divInformativo').style.display = 'none';
	}
	//alert(javascript);
	eval(javascript);
}