var name;
function mostra(id){
	name = 'btn' + id;
	document.getElementById(name).style.display = "inline";
}
function esconde(id){
	name = 'btn' + id;
	document.getElementById(name).style.display = "none";
}
function lancamentos(id){
	document.getElementById("imglanc").src = "../fotos/" + id
}
function validaCadastro(){
	if(document.frmCadastro.cNome.value == ""){
	alert('O campo Nome é obrigatório');document.frmCadastro.cNome.focus();return false;
	}
	if(document.frmCadastro.cEmail.value == ""){
	alert('O campo Email é obrigatório');document.frmCadastro.cEmail.focus();return false;
	}
	if(document.frmCadastro.cTelefone.value == ""){
	alert('O campo Telefone é obrigatório');document.frmCadastro.cTelefone.focus();return false;
	}
	if(document.frmCadastro.cEmpresa.value == ""){
	alert('O campo  é obrigatório');document.frmCadastro.cEmpresa.focus();return false;
	}
	if(document.frmCadastro.cCnpj.value == ""){
	alert('O campo  é obrigatório');document.frmCadastro.cCnpj.focus();return false;
	}
	if(document.frmCadastro.cCargo.value == ""){
	alert('O campo Cargo é obrigatório');document.frmCadastro.cCargo.focus();return false;
	}
	if(document.frmCadastro.cCidade.value == ""){
	alert('O campo cCidade é obrigatório');document.frmCadastro.cCidade.focus();return false;
	}
	if(document.frmCadastro.cLogin.value == ""){
	alert('O campo Login é obrigatório');document.frmCadastro.cLogin.focus();return false;
	}
	if(document.frmCadastro.cSenha.value == ""){
	alert('O campo Senha é obrigatório');document.frmCadastro.cSenha.focus();return false;
	}
}
function validaContato(){
	if(document.frmContato.cNome.value == ""){
	alert('O campo Nome é obrigatório');document.frmContato.cNome.focus();return false;
	}
	if(document.frmContato.cEmail.value == ""){
	alert('O campo Email é obrigatório');document.frmContato.cEmail.focus();return false;
	}
	if(document.frmContato.cEndereco.value == ""){
	alert('O campo Endereço é obrigatório');document.frmContato.cEndereco.focus();return false;
	}
	if(document.frmContato.cBairro.value == ""){
	alert('O campo Bairro é obrigatório');document.frmContato.cBairro.focus();return false;
	}
	if(document.frmContato.cCep.value == ""){
	alert('O campo CEP é obrigatório');document.frmContato.cCep.focus();return false;
	}
	if(document.frmContato.cCidade.value == ""){
	alert('O campo Cidade é obrigatório');document.frmContato.cCidade.focus();return false;
	}
	if(document.frmContato.cCidade.value == ""){
	alert('O campo Cidade é obrigatório');document.frmContato.cCidade.focus();return false;
	}
	if(document.frmContato.cUf.value == ""){
	alert('O campo UF é obrigatório');document.frmContato.cUf.focus();return false;
	}
	if(document.frmContato.cTelefone.value == ""){
	alert('O campo Telefone é obrigatório');document.frmContato.cTelefone.focus();return false;
	}
	if(document.frmContato.cMensagem.value == ""){
	alert('O campo Mensagem é obrigatório');document.frmContato.cMensagem.focus();return false;
	}	
}

function validaEntrada(){
	if(document.frm.cLogin.value == ""){
		alert("O campo login não pode estar vazio");document.frm.cLogin.focus();return false;
	}
	if(document.frm.cSenha.value == ""){
		alert("O campo senha não pode estar vazio");document.frm.cSenha.focus();return false;
	}
}

function mostraResultado(codigo){
	window.open("includes/resultadoEnquete.asp?COD=" + codigo, "mywindow", "width=600, height=300");
}

function validaEnquete(){
	//validacao de radio buttons sem saber quantos sao
	marcado = -1
	for (i=0; i<document.frmEnquete.enquete.length; i++) {
		if (document.frmEnquete.enquete[i].checked) {
			marcado = i
			resposta = document.frmEnquete.enquete[i].value
		}
	}
	if (marcado == -1) {
		alert("Selecione uma resposta.");
		document.frmEnquete.enquete[0].focus();
		return false;
	} 
	else {
		return true;
	}
}

function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function telefone(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
}

function cnpj(v){
    v=v.replace(/\D/g,"")                //Remove tudo o que não é dígito
    v=v.replace(/(\d{3})(\d)/,"$1.$2") 
	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 SoLetra(v){
    v=v.toUpperCase()             //Maiúsculas
	v=v.replace(/[^asdfghjklçqwertyuiopzxcvbnmASDFGHJKLÇQWERTYUIOPZXCVBNM]/g,"") //Remove tudo o que não Letra
    return v
}

function soNumero(v){
    return v.replace(/\D/g,"")	
}

function cep(v){
    v=v.replace(/\D/g,"")                //Remove tudo o que não é dígito
    v=v.replace(/^(\d{5})(\d)/,"$1-$2") //Esse é tão fácil que não merece explicações
    return v
}

function cpf(v){
    v=v.replace(/\D/g,"")                //Remove tudo o que não é dígito
    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 nascimento(v){
	v=v.replace(/\D/g,"")
	v=v.replace(/(\d{2})(\d)/,"$1/$2")
	v=v.replace(/(\d{2})(\d)/,"$1/$2")
	return v
}

function outro(id){
	if(document.getElementById(id).value == "outro"){
		document.getElementById("cOutro").style.display = "";
		document.getElementById("cOutroTexto").style.display = "";
	}
	else{
		document.getElementById("cOutro").style.display = "none";
		document.getElementById("cOutroTexto").style.display = "none";
	}
}
