function verificar() {
with(document.proposta)
{	
if (NOME.value == "")
{
alert("Informe o nome do proponente!");
NOME.focus();
return false;}
if (RG.value == "")
{
alert("Informe o número do RG!");
RG.focus();
return false;}
if (CORRETOR.value == "")
{
alert("Informe o nome do Corretor!");
CORRETOR.focus();
return false;}
if (Email.value == "")
{
alert("Informe o email!");
Email.focus();
return false;}
if (Residencial.value == "")
{
alert("Informe o número de telefone para contato!");
Residencial.focus();
return false;}
if (IMOVEL.value == "")
{
alert("Informe o endereço do imóvel!");
IMOVEL.focus();
return false;}
if (NUMERO.value == "")
{
alert("Informe o número do imóvel!");
NUMERO.focus();
return false;}
if (VALOR.value == "")
{
alert("Informe o valor da proposta para o imóvel!");
VALOR.focus();
return false;}

submit();
}
}	

/* LIMPAR CAMPO */

function limpa_RES() {
if (document.proposta.Residencial.value == "Residencial") 
{
document.proposta.Residencial.value = "";
}
}

function limpa_COM() {
if (document.proposta.Comercial.value == "Comercial") 
{
document.proposta.Comercial.value = "";
}
}

function limpa_CEL() {
if (document.proposta.Celular.value == "Celular") 
{
document.proposta.Celular.value = "";
}
}

function limpa_PRE1() {
if (document.proposta.Prefixo.value == "11") 
{
document.proposta.Prefixo.value = "";
}
}

function limpa_PRE2() {
if (document.proposta.Prefixo2.value == "11") 
{
document.proposta.Prefixo2.value = "";
}
}

function limpa_PRE3() {
if (document.proposta.Prefixo3.value == "11") 
{
document.proposta.Prefixo3.value = "";
}
}

/* MUDANÇA DE CAMPO */

function troca_campo1()
{
if (document.proposta.Prefixo.value.length == 2)
{
document.proposta.Residencial.focus();
}
}

function troca_campo2()
{
if (document.proposta.Residencial.value.length == 9)
{
document.proposta.Prefixo2.focus();
}
}

function troca_campo3()
{
if (document.proposta.Prefixo2.value.length == 2)
{
document.proposta.Comercial.focus();
}
}

function troca_campo4()
{
if (document.proposta.Comercial.value.length == 9)
{
document.proposta.Prefixo3.focus();
}
}

function troca_campo5()
{
if (document.proposta.Prefixo3.value.length == 2)
{
document.proposta.Celular.focus();
}
}

/* LIMPAR CAMPO SUGESTÕES */

function limpa_COM_sugestoes() {
if (document.sugestoes.Comercial.value == "Comercial") 
{
document.sugestoes.Comercial.value = "";
}
}

function limpa_CEL_sugestoes() {
if (document.sugestoes.Celular.value == "Celular") 
{
document.sugestoes.Celular.value = "";
}
}

function limpa_PRE1_sugestoes() {
if (document.sugestoes.Prefixo.value == "11") 
{
document.sugestoes.Prefixo.value = "";
}
}

function limpa_PRE2_sugestoes() {
if (document.sugestoes.Prefixo2.value == "11") 
{
document.sugestoes.Prefixo2.value = "";
}
}

function limpa_PRE3_sugestoes() {
if (document.sugestoes.Prefixo3.value == "11") 
{
document.sugestoes.Prefixo3.value = "";
}
}

/* MUDANÇA DE CAMPO SUGESTÕES*/

function troca_campo1_sugestoes()
{
if (document.sugestoes.Prefixo.value.length == 2)
{
document.sugestoes.Residencial.focus();
}
}

function troca_campo2_sugestoes()
{
if (document.sugestoes.Residencial.value.length == 8)
{
document.sugestoes.Prefixo2.focus();
}
}

function troca_campo3_sugestoes()
{
if (document.sugestoes.Prefixo2.value.length == 2)
{
document.sugestoes.Comercial.focus();
}
}

function troca_campo4_sugestoes()
{
if (document.sugestoes.Comercial.value.length == 8)
{
document.sugestoes.Prefixo3.focus();
}
}

function troca_campo5_sugestoes()
{
if (document.sugestoes.Prefixo3.value.length == 2)
{
document.sugestoes.Celular.focus();
}
}

/* divisor de valor */

function FormataValor(obj,tammax,teclapres) {
 var tecla = teclapres.keyCode;
 var  vr = obj.value;
 vr = vr.replace( "/", "" );
 vr = vr.replace( "/", "" );
 vr = vr.replace( ",", "" );
 vr = vr.replace( ",", "" );
 vr = vr.replace( ".", "" );
 vr = vr.replace( ".", "" );
 vr = vr.replace( ".", "" );
 vr = vr.replace( ".", "" );
 //Replaces adicionais
 //vr = vr.replace( "-", "" );
 //vr = vr.replace( "+", "" );
 //vr = vr.replace( "*", "" );
 tam = vr.length;
 
 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 <= 2 )
  { 
   obj.value = vr ;
  }
  if ( (tam > 2) && (tam <= 5) )
  {
   obj.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ;
  }
  if ( (tam >= 6) && (tam <= 8) )
  {
   obj.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;
  }
  if ( (tam >= 9) && (tam <= 11) )
  {
   obj.value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;
  }
  if ( (tam >= 12) && (tam <= 14) )
  {
   obj.value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;
  }
  if ( (tam >= 15) && (tam <= 17) )
  {
   obj.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 numeros()
{   
    if (document.all) // Internet Explorer   
            var tecla = event.keyCode;   
    else if(document.layers) // Nestcape   
            var tecla = e.which;   
  
    if ((tecla > 47 && tecla < 58)) // numeros de 0 a 9   
        return true;   
    else {   
        if (tecla != 8) // backspace   
            //event.keyCode = 0;   
            return false;   
        else   
            return true;   
    }   
}

/* DIVISOR DE NÚMEROS */

function Formatar(src, mask)
{
 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);
 }
}

/* SOMENTE NÚMEROS */
function numeros(x)
{   
if(navigator.appName=='Microsoft Internet Explorer'){
      var y=x.keyCode;
      if(y>=48 && y<=57 || y==8){
         return true;
      } else {
         return false;
      }
   }

   if(navigator.appName=='Netscape'){
      var y=x.which;
      if(y>=48 && y<=57 || y==8){
         return true;
      } else {
         return false;
      }
   }
}

/* CHECAGEM DE EMAIL */

function ValidaEmail()
{
  var obj = eval("document.forms[0].Email");
  var txt = obj.value;
  if ((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 7)))
  {
    alert('Email incorreto!');
	obj.focus();
  }
}