// Funções Javascript

/* Funções numericas */

function numero(v){
		return v.replace(/\D/g,"");
	}

	function telefone(v){
		v=v.replace(/\D/g,"");
		v=v.replace(/^(\d\d)(\d)/g,"($1) $2");
		v=v.replace(/(\d{4})(\d)/,"$1-$2");
		return v
	}

	function cep(v){
		v=v.replace(/\D/g,"");
		v=v.replace(/^(\d{5})(\d)/,"$1-$2");
		return v
	}


	function cpf(v){
		v=v.replace(/\D/g,"");
		v=v.replace(/(\d{3})(\d)/,"$1.$2");
		v=v.replace(/(\d{3})(\d)/,"$1.$2");
		v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2");
		return v
	}

	function cnpj(v){
		v=v.replace(/\D/g,"");
		v=v.replace(/^(\d{2})(\d)/,"$1.$2");
		v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3");
		v=v.replace(/\.(\d{3})(\d)/,".$1/$2");
		v=v.replace(/(\d{4})(\d)/,"$1-$2");
		return v
	}

	function rg(v){
		v=v.replace(/\D/g,"");
		v=v.replace(/(\d{2})(\d)/,"$1.$2");
		v=v.replace(/(\d{3})(\d)/,"$1.$2");
		v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2");
		return v
	}
	
	function data(v){
		v=v.replace(/\D/g,"");
		v=v.replace(/(\d{2})(\d)/,"$1/$2");
		v=v.replace(/(\d{2})(\d)/,"$1/$2");
		return v
	}


/*
Função Sub-Menu
*/

function abrirmenu(nome) {
	
		// Abre menu
		document.getElementById("menu_" + nome).style.visibility='';


	}
	
	function fecharmenu() {
		
		// Fecha Menu
		document.getElementById("menu_serracima").style.visibility='hidden';

	}

/*
Validando Formulário Fale Conosco
*/

function enviaContato()
{
	 if (document.form1.nome.value.length == 0) {
		alert("Informe seu Nome!");
     	document.form1.nome.focus();
        return ;
     }
	 if (document.form1.cidade.value.length == 0) {
		alert("Informe seu CPF ou CNPJ corretamente!");
     	document.form1.cidade.focus();
        return ;
     }
	 if (document.form1.estado.value.length == 0) {
		alert("Informe o CEP de sua região!");
     	document.form1.estado.focus();
        return ;
     }
	 if (document.form1.email.value.length == 0) {
		alert("Informe seu Endereço!");
     	document.form1.email.focus();
        return ;
     }
	 if (document.form1.telefone.value.length == 0) {
		alert("Informe sua Cidade!");
     	document.form1.telefone.focus();
        return ;
     }
	 if (document.form1.msg.value.length == 0) {
		alert("Informe seu Estado!");
     	document.form1.msg.focus();
        return ;
     }

	else
	{ 	
	document.forms['form1'].action= "fale-conosco-enviado.php"
	document.forms['form1'].target= ""
	document.forms['form1'].submit();
	}
}

/*
Validando doações
*/

function enviaDoacao()
{
	 if (document.form1.nome.value.length == 0) {
		alert("Informe seu Nome!");
     	document.form1.nome.focus();
        return ;
     }
	 if (document.form1.cpf_cnpj.value.length == 0) {
		alert("Informe seu CPF ou CNPJ corretamente!");
     	document.form1.cpf_cnpj.focus();
        return ;
     }
	 if (document.form1.cep.value.length == 0) {
		alert("Informe o CEP de sua região!");
     	document.form1.cep.focus();
        return ;
     }
	 if (document.form1.endereco.value.length == 0) {
		alert("Informe seu Endereço!");
     	document.form1.endereco.focus();
        return ;
     }
	 if (document.form1.cidade.value.length == 0) {
		alert("Informe sua Cidade!");
     	document.form1.cidade.focus();
        return ;
     }
	 if (document.form1.uf.value.length == 0) {
		alert("Informe seu Estado!");
     	document.form1.uf.focus();
        return ;
     }
	 if (document.form1.endereco.value.length == 0) {
		alert("Informe seu Endereço!");
     	document.form1.endereco.focus();
        return ;
     }
	 if (document.form1.tel.value.length == 0) {
		alert("Informe seu Telefone!");
     	document.form1.tel.focus();
        return ;
     }
	  if (document.form1.email.value.length == 0) {
		alert("Informe seu E-mail!");
     	document.form1.email.focus();
        return ;
     }

	else
	{ 	
	document.forms['form1'].action= "faca-sua-doacao-enviado.php"
	document.forms['form1'].target= ""
	document.forms['form1'].submit();
	}
}