
// LEIA COM ATENÇÃO
// Para localizar os scripts de determinada página, basta fazer um busca pelo nome do arquivo
// que você deseja localizar os scripts. [Ctrl + F] em grande parte dos editores ativa a busca,
// basta digitar o nome do arquivo de pressionar [Enter]


// FUNÇÕES GLOBAIS





// FORMATAÇÃO DE NÚMEROS
function FloattoStr(valor)
{
	var inteiro,decimal;
 	var aNum;
 
 	aNum = eval('"' + valor + '"');
 	aNum = aNum.split('.',2);
 
 	inteiro = aNum[0];
 	decimal = aNum[1];
 
	if (aNum.length == 2)
 	{
 		if (decimal.length==1)
  		{
   			decimal=decimal+"0";
  		}
  		else
  		{
   			if (decimal.length > 2)
   			{
	    		decimal = decimal.substring(0,2);
   			}
  		}
 	}
 	else
 	{
  	decimal = "00";
}
 
return inteiro+','+decimal;

}
 
function Decimal(formulario, valor, campo)
{	
	valor = StrtoFloat(valor);
   	eval("document."+ formulario +"."+ campo +".value=FloattoStr("+ valor +")");
}

function StrtoFloat(valor)
{
	var campo;
	campo=valor.replace(',','.');
	campo=parseFloat(campo);
	if (isNaN(parseFloat(campo)))
	{ 
		campo=0;
	}
return campo;
}





// CRÍTICA DE E-MAIL
function CriticaEmail(formulario, campo) 
{
	var email = eval("document."+ formulario +"."+ campo +".value");
	var arroba = email.indexOf("@");
 	var ponto_last = email.lastIndexOf("."); // posição do último ponto
 	var ponto_first = email.indexOf(".")
    var space = email.indexOf(" ");
 
	if (email.length > 0)
	{
  		if (email.length < 6)
		{
	  		alert("Por favor,verifique o seu email");
	 		eval("window.document."+ formulario +"."+ campo +".focus();");
	  		return false;
		}
	 	if (email.indexOf("@",0)==-1)
		{    
	  		alert("Por favor, verifique seu e-mail.");
			eval("window.document."+ formulario +"."+ campo +".focus();");
	  		return false;
		}
	
	 	if (email.indexOf(".",0)==-1)
		{
			alert("Por favor, verifique seu e-mail.");
			eval("window.document."+ formulario +"."+ campo +".focus();");
	  		return false;}
	 
	 	if (email.indexOf("@",0)==0)
		{
	  		alert("Email começado por @. Por favor, verifique seu e-mail.");
	  		eval("window.document."+ formulario +"."+ campo +".focus();");
			return false;}
	 
	 	if (ponto_last > (email.length - 3))
		{
	  		alert("Por favor, verifique seu email.")
	  		eval("window.document."+ formulario +"."+ campo +".focus();");
			return false;}
	 
	 	if (space != -1)
		{
	  		alert("Email não pode conter espaços em branco. Por favor, verifique.");
	  		eval("window.document."+ formulario +"."+ campo +".focus();");
			return false;}
	 
		if (ponto_first == arroba + 1)
		{  
	  		alert("'@' seguido de 'ponto'. Por favor verifique.")
	  		eval("window.document."+ formulario +"."+ campo +".focus();");
			return false;
		}
	}
return true;

}









// TRIM DAS PALAVRAS
function lTrim(str)
{
	while (str.substr(0,1)==' ') 
    	str = str.substr(1);
  	return str;
}

function rTrim(str)
{
  	while (str.substr(str.length-1,1)==' ') 
    	str = str.substr(0,str.length-1);
  	return str;
}

function Trim(str)
{
  	str = rTrim(lTrim(str));
  	return str;
}



// CARACTERES VÁLIDOS
function CaracteresValidos(CharsValidos,objeto,msg)
{
	var fc_i;
	var fc_char1;
	var flag;
	var fc_a=objeto.value.length - 1;
	for (fc_i=0; fc_i<=fc_a; fc_i++) 
	{
  		fc_char1	= objeto.value.substring(fc_i, fc_i+1)
		flag		= CharsValidos.indexOf(fc_char1)
		if (flag == -1)
		{
			objeto.value = objeto.value.substring(0,objeto.value.length - 1);
			//alert(objeto.value.substring(0,objeto.value.length - 1));
			alert(msg);
			objeto.focus();
			return(false);
		}
	}
return(true);
}


// VALIDAR E-MAIL
function valida_mail(email){
   var i;
   var tot = 0;
   for (i=0;i < email.length - 1;i++){
      if (email.charAt(i) == '@'){
         tot = tot + 1;
 }}
   if (tot != 1){
	  alert('Erro!\r\nE-Mail inválido.');
	  email.focus();
	  return false;
   }
   return true;
}








// DEFAULT.ASP
function ValidarLogin()
{
	var txtlogin;
	var txtsenha;
	
	txtlogin 	= document.frm_login.txt_login.value;
	txtsenha 	= document.frm_login.txt_senha.value;
	
	if (txtlogin == '')
	{	alert('Você deve digitar o seu login!');
		document.frm_login.txt_login.focus();
		return false;	}
		
	if (txtsenha == '')
	{	alert('Você deve digitar a sua senha!');
		document.frm_login.txt_senha.focus();
		return false;	}
	
	return true;
}




// TIPO.ASP
function ValidarTipoInc()
{
	var txt_tipo;
	
	txt_tipo 	= Trim(document.frm_tipo.txt_tipo.value);
	
	if (txt_tipo == '')
	{
		alert('Digite o tipo de imóvel!');
		document.frm_tipo.txt_tipo.select();
		return false;
	}

	return true;
}



function ValidarTipoSel()
{
	var id_tipo;
	
	id_tipo 	= document.frm_tipo.id_tipo.value;
	
	if (id_tipo == '')
	{
		alert('Selecione o tipo de imóvel!');
		document.frm_tipo.id_tipo.focus();
		return false;
	}
	
	document.frm_tipo.txt_tipo.value = document.frm_tipo.id_tipo[document.frm_tipo.id_tipo.selectedIndex].text;	
	
	return true;
}

function ValidarTipoEdi()
{
	var txt_tipo;
	
	txt_tipo 	= Trim(document.frm_tipo.txt_tipo.value);
	
	if (txt_tipo == '')
	{
		alert('Digite o tipo de imóvel!');
		document.frm_tipo.txt_tipo.select();
		return false;
	}
	
	return true;
}

function ValidarTipoExc()
{
	var id_tipo;
	var resposta;
	
	id_tipo 	= document.frm_tipo.id_tipo.value;
	
	if (id_tipo == '')
	{
		alert('Selecione o tipo de imóvel!');
		document.frm_tipo.id_tipo.focus();
		return false;
	}
	else
	{
		resposta = confirm('Deseja mesmo excluir o tipo selcionado?');
	}
	
	if (resposta == true)
	{
		return true;
	}
	return false;
}



// CIDADE.ASP
function ValidarCidadeInc()
{
	var txt_cidade;
	
	txt_cidade 	= Trim(document.frm_cidade.txt_cidade.value);
	
	if (txt_cidade == '')
	{
		alert('Digite o nome da cidade!');
		document.frm_cidade.txt_cidade.select();
		return false;
	}

	return true;
}

function ValidarCidadeSel()
{
	var id_cidade;
	
	id_cidade 	= document.frm_cidade.id_cidade.value;
	
	if (id_cidade == '')
	{
		alert('Selecione a cidade!');
		document.frm_cidade.id_cidade.focus();
		return false;
	}

	document.frm_cidade.txt_cidade.value = document.frm_cidade.id_cidade[document.frm_cidade.id_cidade.selectedIndex].text;
	
	return true;
}

function ValidarCidadeEdi()
{
	var txt_cidade;
	
	txt_cidade 	= Trim(document.frm_cidade.txt_cidade.value);
	
	if (txt_cidade == '')
	{
		alert('Digite o nome da cidade!');
		document.frm_cidade.txt_cidade.select();
		return false;
	}
	
	return true;
}

function ValidarCidadeExc()
{
	var id_cidade;
	var resposta;
	
	id_cidade 	= document.frm_cidade.id_cidade.value;
	
	if (id_cidade == '')
	{
		alert('Selecione a cidade!');
		document.frm_cidade.id_cidade.focus();
		return false;
	}
	else
	{
		resposta = confirm('Deseja mesmo excluir a cidade selecionada?');
	}
	
	if (resposta == true)
	{
		return true;
	}
	return false;
}




// LOGIN.ASP
function ValidarLoginInc()
{
	var txt_nome;
	var txt_sobrenome;
	var txt_email;
	var txt_telefone;
	var txt_login;
	var txt_senha;
	var txt_senha_conf;	
	
	txt_nome		= Trim(document.frm_login.txt_nome.value);
	txt_sobrenome 	= Trim(document.frm_login.txt_sobrenome.value);
	txt_email		= Trim(document.frm_login.txt_email.value);
	txt_telefone	= Trim(document.frm_login.txt_telefone.value);
	txt_login 		= Trim(document.frm_login.txt_login.value);
	txt_senha		= Trim(document.frm_login.txt_senha.value);
	txt_senha_conf	= Trim(document.frm_login.txt_senha_conf.value);
	
	if (txt_nome == '')
	{
		alert('Digite o nome!');
		document.frm_login.txt_nome.select();
		return false;
	}
	
	if (txt_sobrenome == '')
	{
		alert('Digite o sobrenome!');
		document.frm_login.txt_sobrenome.select();
		return false;
	}
	
	if (txt_email == '')
	{
		alert('Digite o email!');
		document.frm_login.txt_email.select();
		return false;
	}
	
	if (txt_telefone == '')
	{
		alert('Digite o telefone!');
		document.frm_login.txt_telefone.select();
		return false;
	}
	
	if (txt_login == '')
	{
		alert('Digite o login!');
		document.frm_login.txt_login.select();
		return false;
	}
	
	if (txt_senha == '')
	{
		alert('Digite a senha!');
		document.frm_login.txt_senha.select();
		return false;
	}
	
	if (txt_senha_conf == '')
	{
		alert('Digite a confirmação da senha!');
		document.frm_login.txt_senha_conf.select();
		return false;
	}
	
	if (txt_senha != txt_senha_conf)
	{
		alert('A senha e a confirmação da senha\rdevem coincidir!');
		document.frm_login.txt_senha_conf.select();
		return false;
	}


	return true;
}

function ValidarLoginSel()
{
	var id_login;
	
	id_cidade 	= document.frm_login.id_login.value;
	
	if (id_cidade == '')
	{
		alert('Selecione o login!');
		document.frm_login.id_login.focus();
		return false;
	}
	
	return true;
}

function ValidarLoginEdi()
{
	var txt_login;
	
	txt_login 	= Trim(document.frm_login.txt_login.value);
	
	if (txt_login == '')
	{
		alert('Digite o login!');
		document.frm_login.txt_login.select();
		return false;
	}
	
	return true;
}

function ValidarLoginExc()
{
	var id_login;
	var resposta;
	
	id_login 	= document.frm_login.id_login.value;
	
	if (id_login == '')
	{
		alert('Selecione o login!');
		document.frm_login.id_login.focus();
		return false;
	}
	else
	{
		resposta = confirm('Deseja mesmo excluir o login selecionado?');
	}
	
	if (resposta == true)
	{
		return true;
	}
	return false;
}



// BAIRRO.ASP
function ValidarBairroInc()
{
	var id_cidade;
	var txt_bairro;
	
	id_cidade	= document.frm_bairro.id_cidade.value
	txt_bairro 	= Trim(document.frm_bairro.txt_bairro.value);
	
	if (id_cidade == '')
	{
		alert('Selecione a cidade!');
		document.frm_bairro.id_cidade.focus();
		return false;
	}
	
	if (txt_bairro == '')
	{
		alert('Digite o nome do bairro!');
		document.frm_bairro.txt_bairro.select();
		return false;
	}

	return true;
}

function ValidarBairroSel()
{
	var id_cidade;
	var id_bairro;
	
	id_cidade 	= document.frm_bairro.id_cidade.value;
	id_bairro	= document.frm_bairro.id_bairro.value;

	if (id_cidade == '')
	{
		alert('Selecione a cidade!');
		document.frm_bairro.id_cidade.focus();
		return false;
	}
	
	if (document.frm_bairro.id_bairro.disabled == true)
	{
		alert('Selecione uma cidade \rque possua bairros cadastrados!');
		document.frm_bairro.id_cidade.focus();
		return false;
	}
	else
	{
		if (id_bairro == '')
		{
			alert('Selecione o bairro!');
			document.frm_bairro.id_bairro.focus();
			return false;
		}
	}
	
	document.frm_bairro.txt_bairro.value = document.frm_bairro.id_bairro[document.frm_bairro.id_bairro.selectedIndex].text;
	
	return true;
}

function ValidarBairroEdi()
{
	var txt_bairro;
	
	txt_bairro 	= Trim(document.frm_bairro.txt_bairro.value);
	
	if (txt_bairro == '')
	{
		alert('Digite o nome do bairro!');
		document.frm_bairro.txt_bairro.select();
		return false;
	}
	
	return true;
}

function ValidarBairroExc()
{
	var id_cidade;
	var id_bairro;
	
	id_cidade 	= document.frm_bairro.id_cidade.value;
	id_bairro	= document.frm_bairro.id_bairro.value;

	if (id_cidade == '')
	{
		alert('Selecione a cidade!');
		document.frm_bairro.id_cidade.focus();
		return false;
	}
	
	if (document.frm_bairro.id_bairro.disabled == true)
	{
		alert('Selecione uma cidade \rque possua bairros cadastrados!');
		document.frm_bairro.id_cidade.focus();
		return false;
	}
	else
	{
		if (id_bairro == '')
		{
			alert('Selecione o bairro!');
			document.frm_bairro.id_bairro.focus();
			return false;
		}
	}
	
	resposta = confirm('Deseja mesmo excluir o bairro selecionado?');
		
	if (resposta == true)
	{
		return true;
	}
	return false;
}




// USUARIO.ASP

function ValidarUsuarioInc()
{
	var txt_nome;
	var txt_sobrenome;
	var txt_email;
	var txt_endereco;
	var txt_bairro;
	var txt_cidade;
	var txt_estado;	
	var txt_cep;
	var txt_telefone;
	
	txt_nome		= Trim(document.frm_usuario.txt_nome.value);
	txt_sobrenome 	= Trim(document.frm_usuario.txt_sobrenome.value);
	txt_email		= Trim(document.frm_usuario.txt_email.value);
	txt_endereco	= Trim(document.frm_usuario.txt_endereco.value);
	txt_bairro		= Trim(document.frm_usuario.txt_bairro.value);
	txt_cidade		= Trim(document.frm_usuario.txt_cidade.value);
	txt_estado		= Trim(document.frm_usuario.txt_estado.value);
	txt_cep			= Trim(document.frm_usuario.txt_cep.value);
	txt_telefone	= Trim(document.frm_usuario.txt_telefone.value);
	
	
	if (txt_nome == '')
	{
		alert('Digite o nome!');
		document.frm_usuario.txt_nome.select();
		return false;
	}
	
	if (txt_sobrenome == '')
	{
		alert('Digite o sobrenome!');
		document.frm_usuario.txt_sobrenome.select();
		return false;
	}
	
	if (txt_email == '')
	{
		alert('Digite o email!');
		document.frm_usuario.txt_email.select();
		return false;
	}
	
	if (txt_endereco == '')
	{
		alert('Digite o endereco!');
		document.frm_usuario.txt_endereco.select();
		return false;
	}
	
	if (txt_bairro == '')
	{
		alert('Digite o bairro!');
		document.frm_usuario.txt_bairro.select();
		return false;
	}
	
	if (txt_cidade == '')
	{
		alert('Digite a cidade!');
		document.frm_usuario.txt_cidade.select();
		return false;
	}
	
	if (txt_estado == '')
	{
		alert('Selecione o estado!');
		document.frm_usuario.txt_estado.focus();
		return false;
	}
		
	if (txt_cep == '')
	{
		alert('Digite o CEP!');
		document.frm_usuario.txt_cep.select();
		return false;
	}
	
	if (txt_telefone == '')
	{
		alert('Digite o telefone!');
		document.frm_usuario.txt_telefone.select();
		return false;
	}
	
	return true;
}



function ValidarUsuarioSel()
{
	var id_usuario;
	
	id_usuario 	= document.frm_usuario.id_usuario.value;
	
	if (id_usuario == '')
	{
		alert('Selecione o usuário!');
		document.frm_usuario.id_usuario.focus();
		return false;
	}
	
	return true;
}



function ValidarUsuarioExc()
{
	var id_usuario;
	var resposta;
	
	id_usuario 	= document.frm_usuario.id_usuario.value;
	
	if (id_usuario == '')
	{
		alert('Selecione o usuário!');
		document.frm_usuario.id_usuario.focus();
		return false;
	}
	else
	{
		resposta = confirm('Deseja mesmo excluir o usuário selecionado?');
	}
	
	if (resposta == true)
	{
		return true;
	}
	return false;
}




// ANUNCIE.ASP
function ValidarAnuncioInc()
{
	var id_tipo;
	var id_status;
	var txt_bairro;
	var txt_cidade;
	var vl_valor;
	var txt_descricao;
	var txt_nome;
	var txt_email;
	var txt_telefone;
	
	var email_ok;
	
	txt_nome		= Trim(document.frm_anuncio.txt_nome.value);
	txt_telefone	= Trim(document.frm_anuncio.txt_telefone.value);
	txt_email		= Trim(document.frm_anuncio.txt_email.value);
	id_tipo			= Trim(document.frm_anuncio.id_tipo.value);
	txt_descricao	= Trim(document.frm_anuncio.txt_descricao.value);
	
/*
	id_status		= Trim(document.frm_anuncio.id_status.value);
	txt_bairro		= Trim(document.frm_anuncio.txt_bairro.value);
	txt_cidade		= Trim(document.frm_anuncio.txt_cidade.value);
	vl_valor		= Trim(document.frm_anuncio.vl_valor.value);
*/	
	
	
	
	
	if (txt_nome == '')
	{
		alert('Digite o nome!');
		document.frm_anuncio.txt_nome.select();
		return false;
	}
	
	
	
	if (txt_telefone == '')
	{
		alert('Digite o telefone!');
		document.frm_anuncio.txt_telefone.select();
		return false;
	}

	
	
	if (txt_email == '')
	{
		alert('Digite o e-mail!');
		document.frm_anuncio.txt_email.select();
		return false;
	}
	
	
	email_ok = CriticaEmail('frm_anuncio', 'txt_email') 
	
	
	if (email_ok == true)
	{
		if (id_tipo == '')
		{
			alert('Selecione o tipo!');
			document.frm_anuncio.id_tipo.focus();
			return false;
		}
		
		
		
		if (txt_descricao == '')
		{
			alert('Faça uma breve descrição do imóvel!');
			document.frm_anuncio.txt_descricao.select();
			return false;
		}
	}
	else
	{
		return false;
	}
	
	/*
	if (id_status == '')
	{
		alert('Selecione o status!');
		document.frm_anuncio.id_status.focus();
		return false;
	}
	
	if (txt_bairro == '')
	{
		alert('Digite o bairro!');
		document.frm_anuncio.txt_bairro.select();
		return false;
	}
	
	if (txt_cidade == '')
	{
		alert('Digite a cidade!');
		document.frm_anuncio.txt_cidade.focus();
		return false;
	}
	
	if ((vl_valor == '') || (vl_valor == '0,00'))
	{
		alert('Digite o valor!');
		document.frm_anuncio.vl_valor.select();
		return false;
	}
	
	
	
	*/
	
	
	
	
//	return true;
}


function ValidarAnuncioExc()
{
	var id_anuncio;
	var resposta;
	
	id_anuncio 	= document.frm_anuncio.id_anuncio.value;
	
	resposta = confirm('Deseja mesmo excluir este anúncio?');
	
	if (resposta == true)
	{
		document.frm_anuncio.action = 'anuncio_exec.asp?act=exc&id_anuncio=' + id_anuncio;
		document.frm_anuncio.submit();
	}
	return false;
}



function ValidarAnuncioEnv()
{
	var txt_mensagem;
	var resposta;
	
	txt_mensagem	= document.frm_anuncio.txt_mensagem.value;
	
	if (txt_mensagem != '')
	{
		resposta = confirm('Confirma o envio da mensagem?');
	}
	else
	{
		alert('Você deve digitar algo no corpo da mensagem');
		document.frm_anuncio.txt_mensagem.focus();
		return false;
	}
	
	if (resposta == true)
	{
//		document.frm_anuncio.action = 'anuncio_exec.asp?act=exc&id_anuncio=' + id_anuncio;
//		document.frm_anuncio.submit();
		return true;
	}
	return false;
}




// IMOVEL.ASP

function ValidarImovelInc()
{
	var id_tipo;
	var id_status;
	var id_cidade;
	var id_bairro;
	var txt_endereco;
	var txt_referencia;
	var txt_descricao;
	var txt_chamada;
	var vl_valor;
	var txt_taxa;
	var id_code_pro;
	var id_code_imo;
	var id_code_ven;
	

	id_tipo				= Trim(document.frm_imovel.id_tipo.value);
	id_status			= Trim(document.frm_imovel.id_status.value);
	id_cidade			= Trim(document.frm_imovel.id_cidade.value);
	id_bairro			= Trim(document.frm_imovel.id_bairro.value);
	txt_endereco		= Trim(document.frm_imovel.txt_endereco.value);
	txt_referencia		= Trim(document.frm_imovel.txt_referencia.value);
	txt_descricao		= Trim(document.frm_imovel.txt_descricao.value);
	txt_chamada			= Trim(document.frm_imovel.txt_chamada.value);
	vl_valor			= Trim(document.frm_imovel.vl_valor.value);
	txt_taxa			= Trim(document.frm_imovel.txt_taxa.value);
	id_code_pro			= Trim(document.frm_imovel.id_code_pro.value);
	id_code_imo			= Trim(document.frm_imovel.id_code_imo.value);
	id_code_ven			= Trim(document.frm_imovel.id_code_ven.value);

	
	
	if (id_status == '')
	{
		alert('Selecione o status!');
		document.frm_imovel.id_status.focus();
		return false;
	}
	
	if (id_tipo == '')
	{
		alert('Selecione o tipo!');
		document.frm_imovel.id_tipo.focus();
		return false;
	}
	
	if (id_cidade == '')
	{
		alert('Selecione a cidade!');
		document.frm_imovel.id_cidade.focus();
		return false;
	}
	
	if (id_bairro == '')
	{
		alert('Selecione o bairro!');
		document.frm_imovel.id_bairro.focus();
		return false;
	}

/*	
	if (txt_endereco == '')
	{
		alert('Digite o endereço!');
		document.frm_imovel.txt_endereco.focus();
		return false;
	}
*/

	
//	if (txt_referencia == '')
//	{
//		alert('Digite a referência!');
//		document.frm_imovel.txt_referencia.focus();
//		return false;
//	}
	
	
	if (txt_descricao == '')
	{
		alert('Digite a descrição!');
		document.frm_imovel.txt_descricao.focus();
		return false;
	}
	
	
	if (txt_chamada == '')
	{
		alert('Digite o texto da chamada!');
		document.frm_imovel.txt_chamada.focus();
		return false;
	}
	
/*	
	if (vl_valor == '')
	{
		alert('Digite o valor!');
		document.frm_imovel.vl_valor.focus();
		return false;
	}
*/
	
	if (id_status == 3 )
	{
		if (id_code_pro == '')
		{
			alert('Digite o código do proprietário!');
			document.frm_imovel.id_code_pro.focus();
			return false;
		}
	
		if (id_code_imo == '')
		{
			alert('Digite o código do imobiliário!');	
			document.frm_imovel.id_code_imo.focus();
			return false;
		}
	}

	if (id_status == 4 )
	{
		if (id_code_ven == '')
		{
			alert('Digite o código da venda!');	
			document.frm_imovel.id_code_ven.focus();
			return false;
		}
	}
	

	//Armazenando os valores da Cidade e do Bairro
	document.frm_imovel.id_cidade_hidden.value = id_cidade;
	document.frm_imovel.id_bairro_hidden.value = id_bairro;
	
	
	
	return true;
}



function ValidarImovelSel()
{
	var id_status;
	var id_code_pro;
	var id_code_imo;
	var id_code_ven;
	
	id_status		= Trim(document.frm_imovel.id_status.value);
	id_code_pro		= Trim(document.frm_imovel.id_code_pro.value);
	id_code_imo		= Trim(document.frm_imovel.id_code_imo.value);
	id_code_ven		= Trim(document.frm_imovel.id_code_ven.value);
	
	if (id_status == '')
	{
		alert('Selecione o status do imóvel!');
		document.frm_imovel.id_status.focus();
		return false;
	}
	
	if (id_status == 3)
	{
		if (id_code_pro == '')
		{
			alert('Digite o código do proprietário!');
			document.frm_imovel.id_code_pro.focus();
			return false;
		}
		
		if (id_code_imo == '')
		{
			alert('Digite o código do imobiliário!');
			document.frm_imovel.id_code_imo.focus();
			return false;
		}
	}
	else
	{
		if (id_code_ven == '')
		{
			alert('Digite o código da venda!');
			document.frm_imovel.id_code_ven.focus();
			return false;
		}
	}
return true;
}



function ValidarImovelExc()
{
	var id_status;
	var id_code_pro;
	var id_code_imo;
	var id_code_ven;
	
	id_status		= Trim(document.frm_imovel.id_status.value);
	id_code_pro		= Trim(document.frm_imovel.id_code_pro.value);
	id_code_imo		= Trim(document.frm_imovel.id_code_imo.value);
	id_code_ven		= Trim(document.frm_imovel.id_code_ven.value);
	
	if (id_status == '')
	{
		alert('Selecione o status do imóvel!');
		document.frm_imovel.id_status.focus();
		return false;
	}
	
	if (id_status == 3)
	{
		if (id_code_pro == '')
		{
			alert('Digite o código do proprietário!');
			document.frm_imovel.id_code_pro.focus();
			return false;
		}
		
		if (id_code_imo == '')
		{
			alert('Digite o código do imobiliário!');
			document.frm_imovel.id_code_imo.focus();
			return false;
		}
	}
	else
	{
		if (id_code_ven == '')
		{
			alert('Digite o código da venda!');
			document.frm_imovel.id_code_ven.focus();
			return false;
		}
	}

	resposta = confirm('Deseja realmente excluir o imóvel?');
	
	if (resposta == true)
	{
		return true;
	}
	return false;
}



function TxtMaximo()
{
	var digitos;
	digitos = document.frm_imovel.txt_chamada.value.length;

	if ((digitos > 51) || (digitos == 51))
	{
		alert('O máximo são 50 caracteres!');
		document.frm_imovel.txt_digitos.value = 50;
		document.frm_imovel.txt_chamada.value = document.frm_imovel.txt_chamada.value.substring(0,50);
	}
	else
	{
	document.frm_imovel.txt_digitos.value = digitos;
	} 	
}