function validaCadastro(){

	if(document.getElementById('txtnomecompleto').value == ""){
		alert('Campo NOME COMPLETO obrigatório!');
		document.getElementById('txtnomecompleto').focus();
		return false;
	}else if(document.getElementById('txtendereco').value == ""){
		alert('Campo ENDEREÇO obrigatório!');
		document.getElementById('txtendereco').focus();
		return false;
	}else if(document.getElementById('txtcidade').value == ""){
		alert('Campo CIDADE obrigatório!');
		document.getElementById('txtcidade').focus();
		return false;
	}else if(document.getElementById('txttelefone').value == ""){
		alert('Campo TELEFONE obrigatório!');
		document.getElementById('txttelefone').focus();
		return false;
	}else if(document.getElementById('txtemail').value == ""){
		alert('Campo E-MAIL obrigatório!');
		document.getElementById('txtemail').focus();
		return false;
	}else if(document.getElementById('txtprofissao').value == ""){
		alert('Campo PROFISSÃO obrigatório!');
		document.getElementById('txtprofissao').focus();
		return false;
	}else{
		return true;
	}

}

function validaCadastroNoticia(){
	if(document.getElementById('txttitulo').value == ""){
		alert('Campo TÍTULO obrigatório.');
		document.getElementById('txttitulo').focus();
		return false;
	}else{
		return true;
	}
}

function validaEditarAnuncio(){

	if(document.getElementById('txttelefone').value == ""){
		alert('Campo TELEFONE obrigatório.');
		document.getElementById('txttelefone').focus();
		return false;
	}else if(document.getElementById('txtendereco').value == ""){
		alert('Campo ENDEREÇO obrigatório.');
		document.getElementById('txtendereco').focus();
		return false;
	}else if(document.getElementById('txtcidade').value == ""){
		alert('Campo CIDADE obrigatório.');
		document.getElementById('txtcidade').focus();
		return false;
	}else if(document.getElementById('txtpropriedade').value == ""){
		alert('Nome da PROPRIEDADE obrigatório.');
		document.getElementById('txtpropriedade').focus();
		return false;
	}else if(document.getElementById('hidden_opcao').value == "Vender" && document.getElementById('txtvalor').value == ""){
		alert('Campo VALOR obrigatório.');
		document.getElementById('txtvalor').focus();
		return false;
	}else{
		return true;
	}

}

function validaCadastroAnuncio(){
	if(document.getElementById('chk_cadastro').checked == false && document.getElementById('txtresponsavel').value == ""){
		alert('Nome do RESPONSÁVEL obrigatório.');
		document.getElementById('txtresponsavel').focus();
		return false;
	}else if(document.getElementById('chk_cadastro').checked == false && document.getElementById('txttelefone').value == ""){
		alert('Campo TELEFONE obrigatório.');
		document.getElementById('txttelefone').focus();
		return false;
	}else if(document.getElementById('chk_cadastro').checked == false && document.getElementById('txtendereco').value == ""){
		alert('Campo ENDEREÇO obrigatório.');
		document.getElementById('txtendereco').focus();
		return false;
	}else if(document.getElementById('chk_cadastro').checked == false && document.getElementById('txtcidade').value == ""){
		alert('Campo CIDADE obrigatório.');
		document.getElementById('txtcidade').focus();
		return false;
	}else if(document.getElementById('txtpropriedade').value == ""){
		alert('Nome da PROPRIEDADE obrigatório.');
		document.getElementById('txtpropriedade').focus();
		return false;
	}else if(document.getElementById('radio_vender').checked == true && document.getElementById('txtvalor').value == ""){
		alert('Campo VALOR obrigatório.');
		document.getElementById('txtvalor').focus();
		return false;
	}else{
		return true;
	}
}

function validaCadastroEvento(){
	if(document.getElementById('txt_tipo_evento').value == ""){
		alert('Campo TIPO DO EVENTO obrigatório.');
		document.getElementById('txt_tipo_evento').focus();
		return false;
	}else if(document.getElementById('txttitulo').value == ""){
		alert('Campo NOME DO EVENTO obrigatório.');
		document.getElementById('txttitulo').focus();
		return false;
	}else if(document.getElementById('txtdtinicio').value == ""){
		alert('Campo DATA INICIO obrigatório.');
		document.getElementById('txtdtinicio').focus();
		return false;
	}else if(document.getElementById('txthrinicio').value == ""){
		alert('Campo HORA INICIAL obrigatório.');
		document.getElementById('txthrinicio').focus();
		return false;
	}else if(document.getElementById('txthrfinal').value == ""){
		alert('Campo HORA FINAL obrigatório.');
		document.getElementById('txthrfinal').focus();
		return false;
	}else if(document.getElementById('txtlocal').value == ""){
		alert('Campo LOCAL obrigatório.');
		document.getElementById('txtlocal').focus();
		return false;
	}else if(document.getElementById('txtendereco').value == ""){
		alert('Campo ENDEREÇO obrigatório.');
		document.getElementById('txtendereco').focus();
		return false;
	}else if(document.getElementById('txtcidade').value == ""){
		alert('Campo CIDADE obrigatório.');
		document.getElementById('txtcidade').focus();
		return false;
	}else if(document.getElementById('txttelefone').value == ""){
		alert('Campo TELEFONE obrigatório.');
		document.getElementById('txttelefone').focus();
		return false;
	}else if(document.getElementById('txtemail').value == ""){
		alert('Campo E-MAIL obrigatório.');
		document.getElementById('txtemail').focus();
		return false;
	}else{
		return true;
	}

}

function Limpar(valor, validos) {
	// retira caracteres invalidos da string
	var result = "";
	var aux;
	for (var i=0; i < valor.length; i++) {
	aux = validos.indexOf(valor.substring(i, i+1));
	if (aux>=0) {
	result += aux;
	}
	}
	return result;
}


//Formata número tipo moeda usando o evento onKeyDown

function Formata(campo,tammax,teclapres,decimal) {
	var tecla = teclapres.keyCode;
	vr = Limpar(campo.value,"0123456789");
	tam = vr.length;
	dec=decimal
	
	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }
	
	if (tecla == 8 )
	{ tam = tam - 1 ; }
	
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
	{
	
	if ( tam <= dec )
	{ campo.value = vr ; }
	
	if ( (tam > dec) && (tam <= 5) ){
	campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; }
	if ( (tam >= 6) && (tam <= 8) ){
	campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; 
	}
	if ( (tam >= 9) && (tam <= 11) ){
	campo.value = vr.substr( 0, tam - 8 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
	if ( (tam >= 12) && (tam <= 14) ){
	campo.value = vr.substr( 0, tam - 11 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
	if ( (tam >= 15) && (tam <= 17) ){
	campo.value = vr.substr( 0, tam - 14 ) + "." + vr.substr( tam - 14, 3 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - 2, tam ) ;}
	} 

}

function validaCadastroUsuario(){
	if(document.getElementById('txtlogin').value == ""){
		alert('Campo LOGIN obrigatório.');
		document.getElementById('txtlogin').focus();
		return false;
	}else if(document.getElementById('txtsenha').value == ""){
		alert('Campo SENHA obrigatório.');
		document.getElementById('txtsenha').focus();
		return false;
	}else if(document.getElementById('txtnome').value == ""){
		alert('Campo NOME obrigatório.');
		document.getElementById('txtnome').focus();
		return false;
	}else if(document.getElementById('opt_cnpj').checked == true && document.getElementById('txtcpf').value == ""){
			alert('Campo CNPJ obrigatório.');
			document.getElementById('txtcpf').focus();
			return false;
	}else if(document.getElementById('opt_cpf').checked == true && document.getElementById('txtcpf').value == ""){
			alert('Campo CPF obrigatório.');
			document.getElementById('txtcpf').focus();
			return false;
	}else if (!Validar()){
			document.getElementById("txtcpf").focus();
			return false;
	}else if(document.getElementById('txtendereco').value == ""){
		alert('Campo ENDEREÇO obrigatório.');
		document.getElementById('txtendereco').focus();
		return false;
	}else if(document.getElementById('txtbairro').value == ""){
		alert('Campo BAIRRO obrigatório.');
		document.getElementById('txtbairro').focus();
		return false;
	}else if(document.getElementById('txtcidade').value == ""){
		alert('Campo CIDADE obrigatório.');
		document.getElementById('txtcidade').focus();
		return false;
	}else if(document.getElementById('txttelefone').value == ""){
		alert('Campo TELEFONE obrigatório.');
		document.getElementById('txttelefone').focus();
		return false;
	}else if(document.getElementById('txtemail').value == ""){
		alert('Campo E-MAIL obrigatório.');
		document.getElementById('txtemail').focus();
		return false;
	}else if (document.getElementById('opt_cnpj').checked == true && document.getElementById('txtresponsavel').value == ""){
		alert('Campo RESPONSÁVEL obrigatório.');
		document.getElementById('txtresponsavel').focus();
		return false;
	}else{
		return true;
	}

}

function validaMeusDados(){
	if(document.getElementById('txtnome').value == ""){
		alert("Campo NOME obrigatório");
		document.getElementById('txtnome').focus();
		return false;
	}else if(document.getElementById('txtendereco').value == ""){
		alert("Campo ENDEREÇO obrigatório");
		document.getElementById('txtendereco').focus();
		return false;
	}else if(document.getElementById('txtcidade').value == ""){
		alert("Campo CIDADE obrigatório");
		document.getElementById('txtcidade').focus();
		return false;
	}else if(document.getElementById('txttelefone').value == ""){
		alert("Campo TELEFONE obrigatório");
		document.getElementById('txttelefone').focus();
		return false;
	}else if(document.getElementById('txtemail').value == ""){
		alert("Campo E-MAIL obrigatório");
		document.getElementById('txtemail').focus();
		return false;
	}else{
		return true;
	}
}


function soNumeros(e) {
    if(window.event) { _TXT = e.keyCode; }
    else if(e.which) { _TXT = e.which; }
	
    if((_TXT > 47 && _TXT < 58) || (_TXT == 8)) {
       return true;
    } else {
       return false;
    }
}

function soLetras(e) {
    if(window.event) { _TXT = e.keyCode; }
    else if(e.which) { _TXT = e.which; }
	
    if(!(_TXT > 47 && _TXT < 58) || (_TXT == 8)) {
       return true;
    } else {
       return false;
    }
}
	
function FormataTelefone(e,src,mask) {
	    if(window.event) { _TXT = e.keyCode; } 
	    else if(e.which) { _TXT = e.which; }
	    if(_TXT > 47 && _TXT < 58) { 
	 var i = src.value.length; var saida = mask.substring(0,1); var texto = mask.substring(i)
	 if (texto.substring(0,1) != saida) { src.value += texto.substring(0,1); } 
	    return true; } else { if (_TXT != 8) { return false; } 
	 else { return true; }
	    }
}

<!--
function Validar() 
{ 
  
  if (document.getElementById('txtcpf').value == "") 
  { 
    alert("Campo inválido. É necessário informar o CPF ou CNPJ"); 
    document.getElementById('txtcpf').focus(); 
    return (false); 
  } 
  if (((document.getElementById('txtcpf').value.length == 11) && (document.getElementById('txtcpf').value == 11111111111) || (document.getElementById('txtcpf').value == 22222222222) || (document.getElementById('txtcpf').value == 33333333333) || (document.getElementById('txtcpf').value == 44444444444) || (document.getElementById('txtcpf').value == 55555555555) || (document.getElementById('txtcpf').value == 66666666666) || (document.getElementById('txtcpf').value == 77777777777) || (document.getElementById('txtcpf').value == 88888888888) || (document.getElementById('txtcpf').value == 99999999999) || (document.getElementById('txtcpf').value == 00000000000))) 
  { 
    alert("CPF/CNPJ inválido."); 
    document.getElementById('txtcpf').focus(); 
    return (false); 
  } 


  if (!((document.getElementById('txtcpf').value.length == 11) || (document.getElementById('txtcpf').value.length == 14))) 
  { 
    alert("CPF/CNPJ inválido."); 
    document.getElementById('txtcpf').focus(); 
    return (false); 
  } 

  var checkOK = "0123456789"; 
  var checkStr = document.getElementById('txtcpf').value; 
  var allValid = true; 
  var allNum = ""; 
  for (i = 0;  i < checkStr.length;  i++) 
  { 
    ch = checkStr.charAt(i); 
    for (j = 0;  j < checkOK.length;  j++) 
      if (ch == checkOK.charAt(j)) 
        break; 
    if (j == checkOK.length) 
    { 
      allValid = false; 
      break; 
    } 
    allNum += ch; 
  } 
  if (!allValid) 
  { 
    alert("Favor preencher somente com dígitos o campo CPF/CNPJ."); 
    document.getElementById('txtcpf').focus(); 
    return (false); 
  } 

  var chkVal = allNum; 
  var prsVal = parseFloat(allNum); 
  if (chkVal != "" && !(prsVal > "0")) 
  { 
    alert("CPF zerado !"); 
    document.getElementById('txtcpf').focus(); 
    return (false); 
  } 

if (document.getElementById('txtcpf').value.length == 11) 
{ 
  var tot = 0; 

  for (i = 2;  i <= 10;  i++) 
    tot += i * parseInt(checkStr.charAt(10 - i)); 

  if ((tot * 10 % 11 % 10) != parseInt(checkStr.charAt(9))) 
  { 
    alert("CPF/CNPJ inválido."); 
    document.getElementById('txtcpf').focus(); 
    return (false); 
  } 
  
  tot = 0; 
  
  for (i = 2;  i <= 11;  i++) 
    tot += i * parseInt(checkStr.charAt(11 - i)); 

  if ((tot * 10 % 11 % 10) != parseInt(checkStr.charAt(10))) 
  { 
    alert("CPF/CNPJ inválido."); 
    document.getElementById('txtcpf').focus(); 
    return (false); 
  } 
} 
else 
{ 
  var tot  = 0; 
  var peso = 2; 
  
  for (i = 0;  i <= 11;  i++) 
  { 
    tot += peso * parseInt(checkStr.charAt(11 - i)); 
    peso++; 
    if (peso == 10) 
    { 
        peso = 2; 
    } 
  } 

  if ((tot * 10 % 11 % 10) != parseInt(checkStr.charAt(12))) 
  { 
    alert("CPF/CNPJ inválido."); 
    document.getElementById('txtcpf').focus(); 
    return (false); 
  } 
  
  tot  = 0; 
  peso = 2; 
  
  for (i = 0;  i <= 12;  i++) 
  { 
    tot += peso * parseInt(checkStr.charAt(12 - i)); 
    peso++; 
    if (peso == 10) 
    { 
        peso = 2; 
    } 
  } 

  if ((tot * 10 % 11 % 10) != parseInt(checkStr.charAt(13))) 
  { 
  	if(document.getElementById("cadastro2").checked == false){
  	
  	}
    alert("CPF/CNPJ inválido."); 
    document.getElementById('txtcpf').focus(); 
    return (false); 
  } 
} 
  return(true); 
} 

//-->

