function caracteresPermitidos(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode;
	if(charCode == 64){ alert("Não pode conter @"); }
	if(charCode == 32){ alert("Não pode conter ESPAÇO"); }
	if(charCode >= 65 && charCode <= 90){ alert("Somenente em Minúsculo"); }
	return (((charCode>=97) && (charCode<=122)) || (charCode<20) || (charCode == 46) || ((charCode>=48) && (charCode<=57))); /*LISTA DE PERMISSAO*/
}

function permitidos(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode;
	if(charCode == 32){ alert("Não pode conter ESPAÇO"); }
	if(charCode >= 65 && charCode <= 90){ alert("Somenente em Minúsculo"); }
	return (((charCode>=97) && (charCode<=122)) || (charCode<20) || (charCode == 64) || (charCode == 45) || (charCode == 46) || (charCode == 95) || ((charCode>=48) && (charCode<=57))); /*LISTA DE PERMISSAO*/
}

function validaForm() {
	x = document.formLivroVisita;
	emailRE = new RegExp("^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$");
	if (x.nome.value == ""){
		alert("Favor Preencher o campo << NOME >>");
		x.nome.focus();
		return false;
	}
	if  (!(emailRE.test(x.email.value))){
		alert("Campo EMAIL Vazio ou Inválido");
		x.email.value = "";
		x.email.focus();
		return false;
	}
	if (x.cidade.value == ""){
		alert("Favor Preencher o campo << CIDADE >>");
		x.cidade.focus();
		return false;
	}
	if (x.estado.value == ""){
		alert("Favor Selecionar o campo << ESTADO >>");
		x.estado.focus();
		return false;
	}
	if (x.igreja.value == ""){
		alert("Favor Preencher o campo << IGREJA >>");
		x.igreja.focus();
		return false;
	}
	if (x.mensagem.value == ""){
		alert("Favor Preencher o campo << MENSAGEM >>");
		x.mensagem.focus();
		return false;
	}
}
function formERMail() {
	y = document.erMail;
	emailRE = new RegExp("^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$");
	if (y.nome.value == ""){
		alert("Favor Preencher o campo << NOME >>");
		y.nome.focus();
		return false;
	}
	if (y.sobrenome.value == ""){
		alert("Favor Preencher o campo << SOBRENOME >>");
		y.sobrenome.focus();
		return false;
	}
	if (y.login.value == ""){
		alert("Favor Preencher o campo << EMAIL DESEJADO >>");
		y.login.focus();
		return false;
	}
	if (!(emailRE.test(y.email.value))){
		alert("Campo EMAIL de CONTATO Vazio ou Inválido");
		y.email.value = "";
		y.email.focus();
		return false;
	}
	if (y.cidade.value == ""){
		alert("Favor Preencher o campo << CIDADE >>");
		y.cidade.focus();
		return false;
	}
	if (y.estado.value == ""){
		alert("Favor Selecionar o campo << ESTADO >>");
		y.estado.focus();
		return false;
	}
	if (y.igreja.value == ""){
		alert("Favor Preencher o campo << IGREJA >>");
		y.igreja.focus();
		return false;
	}
	if (y.embaiy.da.value == ""){
		alert("Favor Preencher o campo << EMBAIXADA >>");
		y.embaixada.focus();
		return false;
	}
	if (y.conheceu.value == ""){
	    alert("Favor Selecionar uma das opções de << COMO CONHECEU? >>");
		y.conheceu.focus();
		return false;
	}
}

function validarER(){
	x = document.erMail.email;
	var emailER = x.value;
	var quebra = emailER.split("@");
	if(quebra[1] == "umavezembaixador.com.br"){
		alert("O Email de Contato não pode ser um email @umavezembaixador.com.br");
		x.value = "";
		x.focus();
	}
}

function verificaCheck(){
	document.erMail['submit'].disabled = (document.erMail['submit'].disabled)? false : true
}

function envia(url, metodo, modo, campo){
    var valCampo = document.getElementById(campo).value;
    remoto  = new ajax();
    xmlhttp = remoto.enviar(url + "&acao=" + valCampo, metodo, modo );
// Referente ao CAMPO de USUÁRIO
	if(xmlhttp == "userPequeno") {
        document.getElementById('login').className = 'erro';
        document.getElementById('alertaLogin').className = 'erroSpan';
        document.getElementById("alertaLogin").innerHTML = 'Mínimo de 6 Caracteres';
		document.getElementById("confirma").checked = false;
		document.getElementById("confirma").disabled = true;
		document.getElementById("submit").disabled = true;
	}
	if(xmlhttp == "userVazio") {
        document.getElementById('login').className = 'erro';
        document.getElementById('alertaLogin').className = 'erroSpan';
        document.getElementById("alertaLogin").innerHTML = 'Campo Email Desejado Vazio';
		document.getElementById("confirma").checked = false;
		document.getElementById("confirma").disabled = true;
		document.getElementById("submit").disabled = true;
    } 
	if(xmlhttp == "userExistente") {
        document.getElementById('login').className = 'erro';
        document.getElementById('alertaLogin').className = 'erroSpan';
        document.getElementById("alertaLogin").innerHTML = 'O Email digitado já existente...';
		document.getElementById("confirma").checked = false;
		document.getElementById("confirma").disabled = true;
		document.getElementById("submit").disabled = true;
    }   
	if(xmlhttp == "userDisponivel") {
        document.getElementById('login').className = 'ok';
        document.getElementById('alertaLogin').className = 'okSpan';
        document.getElementById("alertaLogin").innerHTML = 'OK! Email Disponível';
		document.getElementById("confirma").disabled = false;
    }    
}

function conta(){
	if (document.getElementById("login").value.length < 7){
		alert("Insira um Login Maior que 6 Caracteres");
		document.erMail.login.focus();
		document.erMail.login.value = "";		
	}
}

function validaFormNoticia() {
	var x = document.formNoticia;
	var i, conta = 0;
	for(i=0;i<x.manchete.length;i++){
		if (x.manchete[i].checked == false){
			conta = conta+1;
		}
	}
	if(conta == x.manchete.length){
		alert("Escolha um tipo de MANCHETE");
		return false;
	}
	if (x.titulo.value == ""){
		alert("Insira o TITULO");
		x.titulo.focus();
		return false;
	}
	if (x.lidi.value == ""){
		alert("Insira a LIDI");
		x.lidi.focus();
		return false;
	}
	/*if (x.descricao.value == ""){
		alert("Insira a DESCRIÇÃO");
		x.descricao.focus();
		return false;
	}*/
	return true;
}

function validaFormEvento() {
	var x = document.formEvento;
	if (x.titulo.value == ""){
		alert("Insira o TITULO");
		x.titulo.focus();
		return false;
	}
	if (x.lidi.value == ""){
		alert("Insira a LIDI");
		x.lidi.focus();
		return false;
	}
	/*if (x.descricao.value == ""){
		alert("Insira a DESCRIÇÃO");
		x.descricao.focus();
		return false;
	}*/
	if (x.banner.value == ""){
		alert("Selecione o Arquivo para o Banner");
		x.banner.focus();
		return false;
	}
	if(document.getElementById('00').checked == true){
		if (x.nomeDownload.value == ""){
			alert("Insira o Nome da Categoria para Download");
			x.nomeDownload.focus();
			return false;
		}	
		if (x.descricaoDownload.value == ""){
			alert("Insira a Descrição da Categoria para Download");
			x.descricaoDownload.focus();
			return false;
		}
	}
	return true;
}

function validaFormEditEvento() {
	var x = document.formEditEvento;
	if (x.titulo.value == ""){
		alert("Insira o TITULO");
		x.titulo.focus();
		return false;
	}
	if (x.lidi.value == ""){
		alert("Insira a LIDI");
		x.lidi.focus();
		return false;
	}
	/*if (x.descricao.value == ""){

		alert("Insira a DESCRIÇÃO");

		x.descricao.focus();

		return false;

	}*/
	if(document.getElementById('00').checked == true){
		if (x.banner.value == ""){
			alert("Selecione o Arquivo para Trocar o Banner ou Desmarque a opção de Troca de Banner!");
			x.banner.focus();
			return false;
		}	
	}
	return true;
}
function VerificaFormCategoria(){
	x = document.formCategoria;
	if (x.titulo.value == ""){
		alert("Insira o Título da Categoria para Download");
		x.titulo.focus();
		return false;
	}	
	if (x.descricao.value == ""){
		alert("Insira a Descrição da Categoria para Download");
		x.descricao.focus();
		return false;
	}
}

function verificaAlbum(){
	x = document.formPh;
	if(x.album.value == ""){
		alert("Selecione um Álbum!");
		x.album.focus();
		return false;
	}
	return true;
}
function verificaAlbumCriar(){
	x = document.album;
	if(x.titulo.value == ""){
		alert("Digite um Titulo para o Álbum!");
		x.titulo.focus();
		return false;
	}
	if(x.descricao.value == ""){
		alert("Digite uma Descrição para o Álbum!");
		x.descricao.focus();
		return false;
	}
	return true;
}
function verificaFormInserirArquivo(){
	x = document.formInserirArquivo;
	if(x.nome.value == ""){
		alert("Digite um Nome para o Arquivo!");
		x.nome.focus();
		return false;
	}
	/*if(x.descricao.value == ""){
		alert("Digite uma Descrição para o Arquivo!");
		x.descricao.focus();
		return false;
	}*/
	if(x.arquivo.value == ""){
		alert("Selecione um Arquivo!");
		x.arquivo.focus();
		return false;
	}
	if(x.tipo.value == ""){
		alert("Selecione um tipo de Arquivo!");
		x.tipo.focus();
		return false;
	}
	return true;
}
function verificaFormUpdateArquivo(){
	x = document.formAtualizarArquivo;
	if(x.nome.value == ""){
		alert("Digite um Nome para o Arquivo!");
		x.nome.focus();
		return false;
	}
	/*if(x.descricao.value == ""){
		alert("Digite uma Descrição para o Arquivo!");
		x.descricao.focus();
		return false;
	}*/
	if(document.getElementById('00').checked == true){	
		if(x.arquivo.value == ""){
			alert("Selecione um tipo de Arquivo ou desmarque a opção de upload!");
			x.arquivo.focus();
			return false;
		}
	}
	if(x.tipo.value == ""){
		alert("Selecione um Tipo!");
		x.tipo.focus();
		return false;
	}
	if(x.idCategoria.value == ""){
		alert("Selecione uma Categoria!");
		x.idCategoria.focus();
		return false;
	}
	return true;
}
function validaFormVideo() {
	var x = document.formVideo;
	if (x.titulo.value == ""){
		alert("Insira o TITULO");
		x.titulo.focus();
		return false;
	}
	if (x.video.value == ""){
		alert("Insira um ID VIDEO do youtube");
		x.video.focus();
		return false;
	}
	return true;
}
function validaFormLink() {
	var x = document.formLink;
	if (x.titulo.value == ""){
		alert("Insira o TITULO");
		x.titulo.focus();
		return false;
	}
	if (x.link.value == ""){
		alert("Insira o Link completo com http://");
		x.link.focus();
		return false;
	}
	return true;
}
function DesmarcaAtivo(id){
	if(document.getElementById(id).checked == false){
		document.getElementById(id).checked = true;
		//document.getElementById(id).disabled = false;
	} else {
		document.getElementById(id).checked = false;
		//document.getElementById(id).disabled = true;
	}
}
function ativaCadastroCategoriaDownload(){
	if(document.getElementById('00').checked == true){
		document.getElementById('01').disabled = false;
		document.getElementById('02').disabled = false;
	} else {
		document.getElementById('01').disabled = true;
		document.getElementById('02').disabled = true;
	}
}
function ativaUploadNew(){
	if(document.getElementById('00').checked == true){
		document.getElementById('01').disabled = false;
	} else {
		document.getElementById('01').disabled = true;
	}
}
function ativaTrocaBanner(){
	if(document.getElementById('00').checked == true){
		document.getElementById('01').disabled = false;
		document.getElementById("img01").style.display = "none";
	} else {
		document.getElementById('01').disabled = true;
		document.getElementById("img01").style.display = "block";
	}
}

