// validar a busca de e-mails
function valida_news(){
	if ((document.getElementById("news_nome").value == "") || (document.getElementById("news_nome").value == "Seu Nome")){
		alert("Por favor, informe o seu nome.");
		document.getElementById("news_nome").focus();
		return false;
	}
	if ((document.getElementById("news_email").value == "") || (document.getElementById("news_email").value == "Seu e-Mail")){
		alert("Por favor, informe o seu e-mail.");
		document.getElementById("news_email").focus();
		return false;
	}
	if ((document.getElementById("news_email").value.indexOf("@") < 0) || (document.getElementById("news_email").value.indexOf(".") < 0)){
		alert("Preencha o campo E-Mail no formato seu@email.com.br")
		document.getElementById("news_email").focus();
		return false;
	}
}


// validar nova categoria de e-mails
function valida_news_categoria(){
	if (document.getElementById("categoria").value == ""){
		alert("Por favor, informe o nome da categoria.");
		document.getElementById("categoria").focus();
		return false;
	}
}


// validar a exclusão de um e-mail
function excluirEmail(codigo,nome,codCategoria){
	confirma = confirm('Tem certeza que deseja excluir o email de '+nome+' ?');

	if(confirma){
		location.href='news_cadastros_visualizar.php?codEmail='+codigo+'&acao=remover&codCat='+codCategoria;
	}else{
		return false;
	}
}


// validar um novo e-mail
function valida_news_email(){
	if (document.getElementById("categoria_id").value == ""){
		alert("Por favor, informe o nome da categoria.");
		document.getElementById("categoria_id").focus();
		return false;
	}
	if (document.getElementById("nome").value == ""){
		alert("Por favor, informe o seu nome.");
		document.getElementById("nome").focus();
		return false;
	}
	if (document.getElementById("email").value == ""){
		alert("Por favor, informe o seu e-mail.");
		document.getElementById("email").focus();
		return false;
	}
	if ((document.getElementById("email").value.indexOf("@") < 0) || (document.getElementById("email").value.indexOf(".") < 0)){
		alert("Preencha o campo E-Mail no formato seu@email.com.br")
		document.getElementById("email").focus();
		return false;
	}
}


// selecionar todas as categorias para envio
function selecionar_tudo(){
	for (i=0;i<document.form_nova_news.elements.length;i++){
		if(document.form_nova_news.elements[i].type == "checkbox"){
			document.form_nova_news.elements[i].checked=1
		}
	}
}


// deselecionar todas as categorias para envio
function deselecionar_tudo(){
	for (i=0;i<document.form_nova_news.elements.length;i++){
		if(document.form_nova_news.elements[i].type == "checkbox"){
			document.form_nova_news.elements[i].checked=0
		}
	}
}


// validar cadastro de novo associado
function valida_associado(){
	if ((document.getElementById("enviar_email_n").checked == false) && (document.getElementById("enviar_email_s").checked == false)){
		alert("Deseja disparar um e-mail para o associado após o término do preenchimento deste formulário?");
		return false;
	}
	if (document.getElementById("matricula").value == ""){
		alert("O número da matrícula é obrigatório.");
		document.getElementById("matricula").focus();
		return false;
	}
	if (document.getElementById("nome").value == ""){
		alert("O nome completo é obrigatório.");
		document.getElementById("nome").focus();
		return false;
	}
	if (document.getElementById("email").value == ""){
		alert("O e-mail é obrigatório.");
		document.getElementById("email").focus();
		return false;
	}
	if ((document.getElementById("email").value.indexOf("@") < 0) || (document.getElementById("email").value.indexOf(".") < 0)){
		alert("Preencha o campo E-Mail no formato seu@email.com.br")
		document.getElementById("email").focus();
		return false;
	}
	if (document.getElementById("banco").value == ""){
		alert("O nome do banco é obrigatório.");
		document.getElementById("banco").focus();
		return false;
	}
	if (document.getElementById("agencia").value == ""){
		alert("O número da agência é obrigatório.");
		document.getElementById("agencia").focus();
		return false;
	}
	if (document.getElementById("conta").value == ""){
		alert("O número da conta é obrigatório.");
		document.getElementById("conta").focus();
		return false;
	}
}


