// JavaScript Document

//index.php
function validaEmail(){
	var campo_email = document.email.email.value;
	//Checando se o endereço e-mail não esta vazio
	if(campo_email=="") {
		alert("e-mail nao pode ser nulo.");
		document.email.email.focus();
		return false;

	//Checando se o endereço de e-mail é válido
	}else if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.email.email.value))) {
		alert("e-mail invalido!");
		document.email.email.focus();
		return false;

	//Se tudo estiver ok submit:
	}else{
		document.forms['email'].submit();	
	}

}

// Titulo caixa texto 'Cadastro de email'
function onEmail(){
	if(document.email.email.value == 'e-mail'){
		document.email.email.value = '';
	}
}

function outEmail(){
	if(document.email.email.value == ''){
		document.email.email.value = 'e-mail';
	}
}

// Titulo BUSCA
function onBusca(){
	if(document.form1.busca.value == 'Associado'){
		document.form1.busca.value = '';
	}
}

function outBusca(){
	if(document.form1.busca.value == ''){
		document.form1.busca.value = 'Associado';
	}
}

// contato.php
function validaContato(){
	if((document.contato.nome.value == '') || (document.contato.email.value == '') || (document.contato.mensagem.value == '')){
		alert("Por favor, preencha todos os campos.");

	//Checando se o endereço de e-mail é válido
	}else if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.contato.email.value))) {
		alert("e-mail invalido!");
		document.contato.email.focus();
		return false;

	//Se tudo estiver ok submit:
	}else{
		document.forms['contato'].submit();	
	}
}

// associe.php
function mascara(src, mascara) {
	var campo = src.value.length;
	var saida = mascara.substring(0,1);
	var texto = mascara.substring(campo);
	if(texto.substring(0,1) != saida) {
		src.value += texto.substring(0,1);
	}
}

function validaAssocie(){
	if((document.associe.nome.value == '') || (document.associe.email.value == '') || (document.associe.cpf.value == '') || (document.associe.celular.value == '')){
		alert("Por favor, preencha todos os campos.");

	//Checando se o endereço de e-mail é válido
	}else if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.associe.email.value))) {
		alert("e-mail invalido!");
		document.associe.email.focus();
		return false;

	//Se tudo estiver ok submit:
	}else{
		document.forms['associe'].submit();	
	}
}

//organizacao.php
function abreMapa(ref){
	if(ref=='M'){
		document.getElementById('mapaM').style.display = 'block';	
		document.getElementById('mapaF').style.display = 'none';	
	}else if(ref=='F'){
		document.getElementById('mapaF').style.display = 'block';	
		document.getElementById('mapaM').style.display = 'none';	
	}
}

function fechaMapa(){
		document.getElementById('mapaM').style.display = 'none';	
		document.getElementById('mapaF').style.display = 'none';	
}



//top.php
//function mostraSubmenu(){
//	document.getElementById('submenu').style.display = 'block';	
//}

//function escondeSubmenu(){
//	document.getElementById('submenu').style.display = 'none';	
//}

//catalogos.php
//function mudaFoto(imagem,foto,desc){
//	var nome = "desc_"+imagem;
//	document[imagem].src = foto;
//	document.getElementById(nome).value = desc;
//}


//Uniformes:
//function validaUniformes(){
//	var nulo = '';
//
//	if(document.contact.empresa.value == ''){
//		nulo = " Empresa";
//	}
//	if(document.contact.contato.value == ''){
//		nulo = nulo + " - Contato";
//	}
//	if(document.contact.endereco.value == ''){
//		nulo = nulo + " - Endereco";
//	}
//	if(document.contact.cidade.value == ''){
//		nulo = nulo + " - Cidade";
//	}
//	if(document.contact.telefone.value == ''){
//		nulo = nulo + " - Telefone";
//	}
//	if(document.contact.email.value == ''){
//		nulo = nulo + " - email";
//	}
//	if(document.contact.texto.value == ''){
//		nulo = nulo + " - Texto";
//	}
//
//	if(nulo == ''){
//		document.forms['contact'].submit();
//	}else{
//		alert("Campos nao podem ser nulos:"+nulo);
//		return;
//	}
//}

