<!-- Begin /////////Focus nos formulario com cor

var highlightcolor="#EAEAEA"

var ns6=document.getElementById&&!document.all
var previous=''
var eventobj

//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION/

//Function to check whether element clicked is form element
function checkel(which){
if (which.style&&intended.test(which.tagName)){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}

//Function to highlight form element
function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
previous=eventobj
}
}
//  End -->


<!-- Begin ////////////
//MÁSCARA DE VALORES

function txtBoxFormat(objeto, sMask, evtKeyPress) {
    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;


if(document.all) { // Internet Explorer
    nTecla = evtKeyPress.keyCode;
} else if(document.layers) { // Nestcape
    nTecla = evtKeyPress.which;
} else {
    nTecla = evtKeyPress.which;
    if (nTecla == 8) {
        return true;
    }
}

    sValue = objeto.value;

    // Limpa todos os caracteres de formatação que
    // já estiverem no campo.
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( " ", "" );
    sValue = sValue.toString().replace( " ", "" );
    fldLen = sValue.length;
    mskLen = sMask.length;

    i = 0;
    nCount = 0;
    sCod = "";
    mskLen = fldLen;

    while (i <= mskLen) {
      bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))
      bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

      if (bolMask) {
        sCod += sMask.charAt(i);
        mskLen++; }
      else {
        sCod += sValue.charAt(nCount);
        nCount++;
      }

      i++;
    }

    objeto.value = sCod;

    if (nTecla != 8) { // backspace
      if (sMask.charAt(i-1) == "9") { // apenas números...
        return ((nTecla > 47) && (nTecla < 58)); }
      else { // qualquer caracter...
        return true;
      }
    }
    else {
      return true;
    }
  }
  
  /*tipos
Data:<input type="text" size="20" onkeypress="return txtBoxFormat(this, '99/99/9999', event);">
RG:<input type="text" size="20" onkeypress="return txtBoxFormat(this, '99.999.999-9', event);">
Telefone:<input type="text" size="20" onkeypress="return txtBoxFormat(this, '(99)9999-9999', event);">
Código:<input type="text" size="20" onkeypress="return txtBoxFormat(this, '99-999', event);">
*/
//  End -->

<!-- Início da Função FormataReais --> 

function FormataReais(fld, milSep, decSep, e) { 

var sep = 0; 

var key = ''; 

var i = j = 0; 

var len = len2 = 0; 

var strCheck = '0123456789'; 

var aux = aux2 = ''; 

var whichCode = (window.Event) ? e.which : e.keyCode; 

if (whichCode == 13) return true; 

key = String.fromCharCode(whichCode);// Valor para o código da Chave 

if (strCheck.indexOf(key) == -1) return false; // Chave inválida 

len = fld.value.length; 

for(i = 0; i < len; i++) 

if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break; 

aux = ''; 

for(; i < len; i++) 

if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i); 

aux += key; 

len = aux.length; 

if (len == 0) fld.value = ''; 

if (len == 1) fld.value = '0'+ decSep + '0' + aux; 

if (len == 2) fld.value = '0'+ decSep + aux; 

if (len > 2) { 

aux2 = ''; 

for (j = 0, i = len - 3; i >= 0; i--) { 

if (j == 3) { 

aux2 += milSep; 

j = 0; 

} 

aux2 += aux.charAt(i); 

j++; 

} 

fld.value = ''; 

len2 = aux2.length; 

for (i = len2 - 1; i >= 0; i--) 

fld.value += aux2.charAt(i); 

fld.value += decSep + aux.substr(len - 2, len); 

} 

return false; 

} 

//Fim da Função FormataReais --> 
//validações

function validacpf(){ 
  
var i; 
  
s = document.forms[0].txtCPF.value; 
  
var c = s.substr(0,9); 
  
var dv = s.substr(9,2); 
  
var d1 = 0; 
  
for (i = 0; i < 9; i++) 
  
{ 
  
d1 += c.charAt(i)*(10-i); 
  
} 
  
if (d1 == 0){ 
  
alert("CPF Invalido") 
  
return false; 
  
} 
  
d1 = 11 - (d1 % 11); 
  
if (d1 > 9) d1 = 0; 
  
if (dv.charAt(0) != d1) 
  
{ 
  
alert("CPF Invalido") 
  
return false; 
  
} 
  
  
d1 *= 2; 
  
for (i = 0; i < 9; i++) 
  
{ 
  
d1 += c.charAt(i)*(11-i); 
  
} 
  
d1 = 11 - (d1 % 11); 
  
if (d1 > 9) d1 = 0; 
  
if (dv.charAt(1) != d1) 
  
{ 
  
alert("CPF Invalido") 
  
return false; 
  
} 
  
return true; 
  
} 
function valida_form(op){

	if(document.forms[0].txtNome.value <= 0) {alert('Campo Nome obrigatorio'); return;}
	if(document.forms[0].cmbDia.value <= 0) {alert('Campo Dia obrigatorio'); return;}
	if(document.forms[0].cmbMes.value <= 0) {alert('Campo Mês obrigatorio'); return;}
	if(document.forms[0].cmbAno.value <= 0) {alert('Campo Ano obrigatorio'); return;}
	if(document.forms[0].cmbEstado.value <= 0) {alert('Campo Estado obrigatorio'); return;}
	if(document.forms[0].txtEndereco.value <= 0) {alert('Campo Endereco obrigatorio'); return;}
	
	if(document.forms[0].txtBairro.value <= 0) {alert('Campo Bairro obrigatorio'); return;}
	if(document.forms[0].txtCidade.value <= 0) {alert('Campo Cidade obrigatorio'); return;}
	if(document.forms[0].cmbEstado.value <= 0) {alert('Campo Estado obrigatorio'); return;}
	if(document.forms[0].txtTelefoneFixo.value <= 0) {alert('Campo TelefoneFixo obrigatorio'); return;}
	if(document.forms[0].txtCelular.value <= 0) {alert('Campo Celular obrigatorio'); return;}
	if(op=='consorcio'){
		if(document.forms[0].txtCPF.value <= 0) {alert('Campo CPF obrigatorio'); return;}
		if(document.forms[0].txtRG.value <= 0) {alert('Campo RG obrigatorio'); return;}
	    if(document.forms[0].cmbEstadoCivil.value <= 0) {alert('Campo Estado Civil obrigatorio'); return;}
	    if(document.forms[0].cmbDependentes.value <= 0) {alert('Campo Dependentes obrigatorio'); return;}
		if(document.forms[0].txtNascionalidade.value <= 0) {alert('Campo Nascionalidade obrigatorio'); return;}
		if(document.forms[0].txtNatural.value <= 0) {alert('Campo Natural de obrigatorio'); return;}
		if(document.forms[0].cmbTempoResidencia.value <= 0) {alert('Campo Tempo de Residencia obrigatorio'); return;}
	    if(document.forms[0].cmbTipoResidencia.value <= 0) {alert('Campo Tipo de Residencia obrigatorio'); return;}
		if(document.forms[0].cmbProfissao.value  <= 0) {alert('Campo Profissao obrigatorio'); return;}
	}

	if(confirm('Deseja confirmar?')){document.forms[0].submit();}else{ return;}
}


function Favoritos(URLSite,TituloSite){

if(confirm('Deseja adicionar aos favoritos?')){
	if (document.all) 
	window.external.AddFavorite(URLSite,TituloSite);
	else
	window.sidebar.addPanel(URLSite,TituloSite);
}

}

