
var arrCPFMask=['XXXXXXXXXXX','XXXXXXXXX/XX','XXX.XXX.XXX-XX'], intCPFLimNum=arrCPFMask[0].length, intCPFMaskType=0, strCPFMaskValue=arrCPFMask[intCPFMaskType], intCPFMaskMaxLen=strCPFMaskValue.length;
function mkCPF(e) {
	var elm=getSrc(e), sV=elm.value, sL=elm.selectionStart/*sV.length*/, key_code=getKeyCode(e);
	if (sL==intCPFMaskMaxLen) return (keyHab(key_code))? true:actNo(e);
	if (keyHab(key_code)) return true;
	if (intCPFMaskType==1) {
		if (sL==9 && key_code==223) return true;
		if (sL==9 && numHab(key_code)) return elm.value = sV + '/';
	}
	else if (intCPFMaskType==2) {
		if (((sL==3 || sL==7) && key_code==46) || (sL==11 && key_code==45)) return true;
		if ((sL==3 || sL==7) && numHab(key_code)) return elm.value = sV + '.';
		if (sL==11 && numHab(key_code)) return elm.value = sV + '-';
	}
	return numHab(key_code)? true:actNo(e);
}
function isCPF(strCPF) {
	var strErro='', intResto=0, x=0;	
	if (strCPF.length!=intCPFMaskMaxLen) strErro = 'CPF com comprimento inválido. São permitidos: ' + intCPFMaskMaxLen + ' caracteres.\n';
	if ((intCPFMaskType==1 && strCPF.charAt(9)!='/') || (intCPFMaskType==2 && (strCPF.charAt(3)!='.' || strCPF.charAt(7)!='.' || strCPF.charAt(11)!='-'))) strErro += 'Formato: '+strCPFMaskValue+'\n';
	if (intCPFMaskType!=0) { var arrChars=['/','.','.','-']; for(x=0,n=arrChars.length; x<n; x++) strCPF=strCPF.replace(arrChars[x],''); }
	if (isNaN(strCPF)) strErro += 'Estranho?\n';
	if (strCPF.length!=intCPFLimNum) strErro += 'CPF com comprimento numérico inválido. Deve ter exatamente ' + intCPFLimNum + ' caracteres numéricos.\n';
	for(x=0; x<10; x++) if (String(strCPF) == rptStr(x,intCPFLimNum)) { strErro += 'Número de CPF inválido!\n'; break; }
	var a=[], b=0, c=11;	
	for(x=0; x<11; x++) { a[x]=strCPF.charAt(x); if (x<9) b+=a[x]*--c; }
	((intResto=b%11)<2)? a[9]=0 : a[9]=11-intResto;
	b=0; c=11;	
	for(x=0; x<10; x++) b+=a[x]*c--;
	((intResto=b%11)<2)? a[10]=0 : a[10]=11-intResto;
	if (strCPF.charAt(9)!=a[9] || strCPF.charAt(10)!=a[10]) strErro += 'O dígito verificador do CPF inconfere!\n';
	if (strErro.length>0) { alert(strErro+'O CPF informado é inválido.'); return false; } return true;
}


//----------------------------------------------------------------------------------------------------//

//Desativa teclas invalidas
function checa_referencia(e){
var unicode=e.charCode? e.charCode : e.keyCode
if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
		if ((unicode<48||unicode>57) && (unicode<65||unicode>90) && (unicode<97||unicode>122)) //if not a number
		return false //disable key press
		}
}

//----------------------------------------------------------------------------------------------------//


//Desativa teclas invalidas APENAS NUMERO
function so_numero(e){
var unicode=e.charCode? e.charCode : e.keyCode
if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
		if (unicode<48||unicode>57)  //if not a number
		return false //disable key press
		}
}

//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//



 //--------------------------------------------------------------------------------------------------------------------------------------
// FORMATAÇÃO DE CAMPOS TEXT PRÉ-ESTABELECIDOS
// Função para formatação de campos pré-estabelecidos, como CPF, GR, CEP,CGC, CNPJ, etc.
// O uso desta função deve ser feito diretamente no campo texto com o atributo OnKeyPress, como se segue:
// - Formatação de CPF:  <OnKeyPress="formatar(this, '###.###.###-##')">
// - Formatação de CNPJ: <OnKeyPress="formatar(this, '##.###.###/####-##')">
// - Formatação de CEP:  <OnKeyPress="formatar(this, '#####-##')">
// ou seja, aplica-se a função formatar preenchendo os número com '#' e os símbolos de separações dos mesmos*

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);
   }

} 

//----------------------------------------------------------------------------------------------------//


function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

//----------------------------------------------------------------------------------------------------//


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;
      }

 }//fim de for

return result;

}//fim de function


//----------------------------------------------------------------------------------------------------//

function limpa_form(formu) {
	formu.value = '';
}


//----------------------------------------------------------------------------------------------------//



function formataValorv(campo,tammax,event) {
 
 var rcode = (window.Event) ? event.which : event.keyCode;
 
 // Enter - 13, Tab - 9, backspace, delete - 46 e setas direcionais (37,38,39,40)
 if ((rcode == 13) ||(rcode == 9) ||(rcode == 0) || (rcode == 46) || (rcode == 8) || (rcode >= 37 && rcode <= 40)) {
  return true;
 }
 
 var vl = String.fromCharCode(rcode);
 
 vr = campo.value;
 
 vr = Limpar(vr,"0123456789");
 
 tam = vr.length;

 if (tam < tammax && rcode != 8){ tam = vr.length + 1 ; }

 if (rcode == 8 ){ tam = tam - 1 ; }

 if ((rcode == 8) || ( rcode >= 48 && rcode <= 57 ) || (rcode >= 96 && rcode <= 105)){
  if ( tam <= 2 ){
    campo.value = vr ; }
   if ( (tam > 2) && (tam <= 5) ){
    campo.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
   if ( (tam >= 6) && (tam <= 8) ){
    campo.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, 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 - 2, 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 - 2, 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 ) ;}
 } else
 {
   return false; 
 }
}


//----------------------------------------------------------------------------------------------------//
//  FORMATACAO DO CPF DO SITE DO BANCO DO BRASIL

function formataCPF(campo){
	//campo.value = filtraCampo(campo);
	vr = Limpar(campo.value, "0123456789");
	tam = vr.length ;
	if ( tam <= 2 ){
 		campo.value = vr ;}
	if ( tam > 2 && tam <= 5 ){
		campo.value = vr.substr( 0, tam - 2 ) + '-' + vr.substr( tam - 2, tam );}
	if ( tam >= 6 && tam <= 8 ){
		campo.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr(tam - 5, 3 ) + '-' + vr.substr( tam - 2, 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 - 2, tam );}

}

function formataRG(campo){
	//campo.value = filtraCampo(campo);
	vr = Limpar(campo.value, "0123456789");
	tam = vr.length ;
	if ( tam <= 2 ){
 		campo.value = vr ;}
	if ( tam > 2 && tam <= 5 ){
		campo.value = vr.substr( 0, tam - 2 ) + '-' + vr.substr( tam - 2, tam );}
	if ( tam >= 6 && tam <= 8 ){
		campo.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr(tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam );}
	if ( tam >= 9 && tam <= 12 ){
		campo.value = vr.substr( 0, tam - 7 ) + '.' + vr.substr( tam - 7, 3 ) + '.' + vr.substr(tam - 4, 3 ) + '-' + vr.substr( tam - 1, tam );}

}

function formataCGC(campo) {
	//campo.value = filtraCampo(campo);
	vr = campo.value;
	tam = vr.length;

	if ( tam <= 2 ){ 
 		campo.value = vr ; }
 	if ( (tam > 2) && (tam <= 6) ){
 		campo.value = vr.substr( 0, tam - 2 ) + '-' + vr.substr( tam - 2, tam ) ; }
 	if ( (tam >= 7) && (tam <= 9) ){
 		campo.value = vr.substr( 0, tam - 6 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
 	if ( (tam >= 10) && (tam <= 12) ){
 		campo.value = vr.substr( 0, tam - 9 ) + '.' + vr.substr( tam - 9, 3 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
 	if ( (tam >= 13) && (tam <= 14) ){
 		campo.value = vr.substr( 0, tam - 12 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, 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 validaCPF() {
		cpf = document.login.stringCPF.value;
		valor = true;
		erro = new String;
		if (cpf.length < 11) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n"; 
		var nonNumbers = /\D/;
		if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros! \n\n";	
		if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
			  erro += "Numero de CPF invalido!"
		}
		var a = [];
		var b = new Number;
		var c = 11;
		for (i=0; i<11; i++){
			a[i] = cpf.charAt(i);
			if (i < 9) b += (a[i] *  --c);
		}
		if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
		b = 0;
		c = 11;
		for (y=0; y<10; y++) b += (a[y] *  c--); 
		if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
		if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
			erro +="Digito verificador com problema!";
		}
		if (erro.length > 0){
			alert(erro);
			return false;
		} 
		return true;
	}
//----------------------------------------------------------------------------------------------------//
function validaCNPJ() {
CNPJ = document.cadastro_revenda.cnpj.value;
erro = new String;
if (CNPJ.length < 18) erro += "Deve preencher corretamente o numero do CNPJ! \n\n";
if ((CNPJ.charAt(2) != ".") || (CNPJ.charAt(6) != ".") || (CNPJ.charAt(10) != "/") || (CNPJ.charAt(15) != "-")){
if (erro.length == 0) erro += "Deve preencher corretamente o numero do CNPJ! \n\n";
}
//substituir os caracteres que nao sao numeros
if(document.layers && parseInt(navigator.appVersion) == 4){
x = CNPJ.substring(0,2);
x += CNPJ.substring(3,6);
x += CNPJ.substring(7,10);
x += CNPJ.substring(11,15);
x += CNPJ.substring(16,18);
CNPJ = x;
} else {
CNPJ = CNPJ.replace(".","");
CNPJ = CNPJ.replace(".","");
CNPJ = CNPJ.replace("-","");
CNPJ = CNPJ.replace("/","");
}
var nonNumbers = /\D/;
if (nonNumbers.test(CNPJ)) erro += "A verificacao de CNPJ suporta apenas numeros! \n\n";
var a = [];
var b = new Number;
var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
for (i=0; i<12; i++){
a[i] = CNPJ.charAt(i);
b += a[i] * c[i+1];
}
if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x }
b = 0;
for (y=0; y<13; y++) {
b += (a[y] * c[y]);
}
if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11-x; }
if ((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13])){
erro +="Digito verificador com problema!";
}
if (erro.length > 0){
alert(erro);
return false;
} else {
	alert("CNPJ valido!");
	return false;
}
return true;
}
//----------------------------------------------------------------------------------------------------//
//-----------------------------------------------------------------------------
// Retornar uma data ajustada no formato dd/mm/aaaa
// Entrada: d1 = d/m/aaaa ou dd/m/aaaa ou d/mm/aaaa ou dd/mm/aaaa
//				 d-m-aaaa ou dd-m-aaaa ou d-mm-aaaa ou dd-mm-aaaa
//			inv = true --> aaaa/m/d , aaaa/d/m etc..
//-----------------------------------------------------------------------------
function AjustaData(d1,inv) {
	d2 = d1;
	if (d2.length >= 8 && d2.length <= 10) {
	
		if (inv) d2 = d2.substring(5,d2.length) + '/' + d2.substring(0,4) 

		d2 = d2.replace(/[\-]/gi,'/');

		if (d2.length != 10 && d2.indexOf('/') != -1){
			if (d2.substring(1,2) == '/') {
				d2 = '0' + d2;
			}
			if (d2.substring(4,5) == '/') {
				d2 = d2.substring(0,3) + '0' + d2.substring(3,d2.length);
			}
		}

		if (inv) d2 = d2.substring(6,d2.length) + '/' + d2.substring(0,5)

	}
	return d2;
}
//------------------------------------------------------------25/05/2005--------

//  FORMATACAO MONETARIA DO SITE DO BANCO DO BRASIL
//Esta funcao sera chamada no evento onKeyUp do objeto.
	function formataValor5(campo,tammax){
// 		window.alert('teste');
		var valorAuxiliar = "";
		digitosValidos = "0123456789" ;
		
		valor = document.banco_de_pedidos[campo].value;
			
		//retira digitos n?o numericos
 		for (i=0;i<valor.length;i++){
 			if(digitosValidos.indexOf(valor.charAt(i))>=0) {
 				valorAuxiliar += valor.charAt(i);
 			}
 		}

		

		//verifica tamanho (tamanho m?ximo vindo do m?todo)
		if(tammax > 0 && tammax < valorAuxiliar.length)
			valorAuxiliar = valorAuxiliar.substring(0,tammax);

		//retira zeros desnecess?rios ao in?cio do n?mero
		while (valorAuxiliar.length > 3 && valorAuxiliar.charAt(0) == "0")
			valorAuxiliar = valorAuxiliar.substring(1);

		valor = valorAuxiliar;
		digitosNumericos = valor.length;

		//insere pontos decimais
		for(i = 1;i<=(digitosNumericos/3);i++)
			valor = valor.substring(0,digitosNumericos + 1 - 3*i) +
				(i==1?',':'.') +
				valor.substring(digitosNumericos + 1 - 3*i);
					
		document.banco_de_pedidos[campo].value = valor;
		//document.new_product[campo].select();

	}
//------------------------------------------------------------25/05/2005--------

//  FORMATACAO MONETARIA DO SITE DO BANCO DO BRASIL
//Esta funcao sera chamada no evento onKeyUp do objeto.
	function formataValor6(campo,tammax){
// 		window.alert('teste');
		var valorAuxiliar = "";
		digitosValidos = "0123456789" ;
		
		valor = document.buscar_veiculos[campo].value;
			
		//retira digitos n?o numericos
 		for (i=0;i<valor.length;i++){
 			if(digitosValidos.indexOf(valor.charAt(i))>=0) {
 				valorAuxiliar += valor.charAt(i);
 			}
 		}

		

		//verifica tamanho (tamanho m?ximo vindo do m?todo)
		if(tammax > 0 && tammax < valorAuxiliar.length)
			valorAuxiliar = valorAuxiliar.substring(0,tammax);

		//retira zeros desnecess?rios ao in?cio do n?mero
		while (valorAuxiliar.length > 3 && valorAuxiliar.charAt(0) == "0")
			valorAuxiliar = valorAuxiliar.substring(1);

		valor = valorAuxiliar;
		digitosNumericos = valor.length;

		//insere pontos decimais
		for(i = 1;i<=(digitosNumericos/3);i++)
			valor = valor.substring(0,digitosNumericos + 1 - 3*i) +
				(i==1?',':'.') +
				valor.substring(digitosNumericos + 1 - 3*i);
					
		document.buscar_veiculos[campo].value = valor;
		//document.new_product[campo].select();

	}

//----------------------------------------------------------------------------------------------------//

//  FORMATACAO MONETARIA DO SITE DO BANCO DO BRASIL
//Esta funcao sera chamada no evento onKeyUp do objeto.
	function formataValor7(campo,tammax){
// 		window.alert('teste');
		var valorAuxiliar = "";
		digitosValidos = "0123456789" ;
		
		valor = document.adicionar_acessorios[campo].value;
			
		//retira digitos n?o numericos
 		for (i=0;i<valor.length;i++){
 			if(digitosValidos.indexOf(valor.charAt(i))>=0) {
 				valorAuxiliar += valor.charAt(i);
 			}
 		}

		

		//verifica tamanho (tamanho m?ximo vindo do m?todo)
		if(tammax > 0 && tammax < valorAuxiliar.length)
			valorAuxiliar = valorAuxiliar.substring(0,tammax);

		//retira zeros desnecess?rios ao in?cio do n?mero
		while (valorAuxiliar.length > 3 && valorAuxiliar.charAt(0) == "0")
			valorAuxiliar = valorAuxiliar.substring(1);

		valor = valorAuxiliar;
		digitosNumericos = valor.length;

		//insere pontos decimais
		for(i = 1;i<=(digitosNumericos/3);i++)
			valor = valor.substring(0,digitosNumericos + 1 - 3*i) +
				(i==1?',':'.') +
				valor.substring(digitosNumericos + 1 - 3*i);
					
		document.adicionar_acessorios[campo].value = valor;
		//document.new_product[campo].select();

	}

//----------------------------------------------------------------------------------------------------//

//  FORMATACAO MONETARIA DO SITE DO BANCO DO BRASIL
//Esta funcao sera chamada no evento onKeyUp do objeto.
	function formataValor8(campo,tammax){
// 		window.alert('teste');
		var valorAuxiliar = "";
		digitosValidos = "0123456789" ;
		
		valor = document.adicionar_veiculos[campo].value;
			
		//retira digitos n?o numericos
 		for (i=0;i<valor.length;i++){
 			if(digitosValidos.indexOf(valor.charAt(i))>=0) {
 				valorAuxiliar += valor.charAt(i);
 			}
 		}

		

		//verifica tamanho (tamanho m?ximo vindo do m?todo)
		if(tammax > 0 && tammax < valorAuxiliar.length)
			valorAuxiliar = valorAuxiliar.substring(0,tammax);

		//retira zeros desnecess?rios ao in?cio do n?mero
		while (valorAuxiliar.length > 3 && valorAuxiliar.charAt(0) == "0")
			valorAuxiliar = valorAuxiliar.substring(1);

		valor = valorAuxiliar;
		digitosNumericos = valor.length;

		//insere pontos decimais
		for(i = 1;i<=(digitosNumericos/3);i++)
			valor = valor.substring(0,digitosNumericos + 1 - 3*i) +
				(i==1?',':'.') +
				valor.substring(digitosNumericos + 1 - 3*i);
					
		document.adicionar_veiculos[campo].value = valor;
		//document.new_product[campo].select();

	}
//----------------------------------------------------------------------------------------------------//

//  FORMATACAO MONETARIA DO SITE DO BANCO DO BRASIL
//Esta funcao sera chamada no evento onKeyUp do objeto.
	function formataValor9(campo,tammax){
// 		window.alert('teste');
		var valorAuxiliar = "";
		digitosValidos = "0123456789" ;
		
		valor = document.inserir_credito[campo].value;
			
		//retira digitos n?o numericos
 		for (i=0;i<valor.length;i++){
 			if(digitosValidos.indexOf(valor.charAt(i))>=0) {
 				valorAuxiliar += valor.charAt(i);
 			}
 		}

		

		//verifica tamanho (tamanho m?ximo vindo do m?todo)
		if(tammax > 0 && tammax < valorAuxiliar.length)
			valorAuxiliar = valorAuxiliar.substring(0,tammax);

		//retira zeros desnecess?rios ao in?cio do n?mero
		while (valorAuxiliar.length > 3 && valorAuxiliar.charAt(0) == "0")
			valorAuxiliar = valorAuxiliar.substring(1);

		valor = valorAuxiliar;
		digitosNumericos = valor.length;

		//insere pontos decimais
		for(i = 1;i<=(digitosNumericos/3);i++)
			valor = valor.substring(0,digitosNumericos + 1 - 3*i) +
				(i==1?',':'.') +
				valor.substring(digitosNumericos + 1 - 3*i);
					
		document.inserir_credito[campo].value = valor;
		//document.new_product[campo].select();

	}

//----------------------------------------------------------------------------------------------------//
//Rodrigo Pistille
// retira caracteres invalidos da string de valor
function LimparValor(valor, validos) {
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;
}

//----------------------------------------------------------------------------------------------------//

function confirma(){

var answer = confirm ("Tem certeza que deseja deletar este imovel?")
if (answer)
return true;
else
return false;

}

//----------------------------------------------------------------------------------------------------//


function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


//----------------------------------------------------------------------------------------------------//

//Desativa teclas invalidas
function checa_referencia(e){
var unicode=e.charCode? e.charCode : e.keyCode
if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
		if ((unicode<48||unicode>57) && (unicode<65||unicode>90) && (unicode<97||unicode>122)) //if not a number
		return false //disable key press
		}
}


//----------------------------------------------------------------------------------------------------//


function CheckSearch() {

			if(document.f1.what.value=="")
			{
				window.alert('Digite o critério de busca, por favor!');
				document.f1.what.focus();
				return false;
			}

		}

		function CheckFriend() {

			if(document.sfriend.f1.value=="")
			{
				window.alert('Digite seu e-mail, por favor');
				document.sfriend.f1.focus();
				return false;
			}

			if(document.sfriend.f2.value=="")
			{
				window.alert('Digite o endereço de e-mail de seu amigo');
				document.sfriend.f2.focus();
				return false;
			}

		}

//----------------------------------------------------------------------------------------------------//

		function CheckLogin() {

			if(document.lform.us.value=="")
			{
				window.alert('Digite seu nome de usuário, por favor.');
				document.lform.us.focus();
				return false;
			}

			if(document.lform.ps.value=="")
			{
				window.alert('Digite sua senha, por favor.');
				document.lform.ps.focus();
				return false;
			}

		}

//----------------------------------------------------------------------------------------------------//

		function CheckForgot() {

			if(document.ForgotForm.u2.value=="")
			{
				window.alert('Digite seu nome de usuário, por favor.');
				document.ForgotForm.u2.focus();
				return false;
			}
		}

//----------------------------------------------------------------------------------------------------//

		function BoxLogin() {
			if(document.box_login.usuario.value=="")
			{
				window.alert('Digite o nome de usuário, por favor.');
				document.box_login.usuario.focus();
				return false;
			}

			if(document.box_login.password.value=="")
			{
				window.alert('Digite a senha, por favor.');
				document.box_login.password.focus();
				return false;
			}
		}

//----------------------------------------------------------------------------------------------------//
//----------------------------------------------------------------------------------------------------//

		function ContatoAnuncio() {
			if(document.contato_cliente.nome.value=="")
			{
				window.alert('Digite o seu Nome, por favor.');
				document.contato_cliente.nome.focus();
				return false;
			}
			if(document.contato_cliente.email.value=="")
			{
				window.alert('Digite o seu Email, por favor.');
				document.contato_cliente.email.focus();
				return false;
			}
			if(document.contato_cliente.telefone.value=="")
			{
				window.alert('Digite o seu Telefone, por favor.');
				document.contato_cliente.telefone.focus();
				return false;
			}
			if(document.contato_cliente.cidade.value=="")
			{
				window.alert('Digite o sua Cidade, por favor.');
				document.contato_cliente.cidade.focus();
				return false;
			}
			if(document.contato_cliente.proposta.value=="")
			{
				window.alert('Digite o sua Proposta, por favor.');
				document.contato_cliente.proposta.focus();
				return false;
			}
			document.contato_cliente.submit();
		}

//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//

		function BoxLogin2() {
			if(document.box_login2.usuario.value=="")
			{
				window.alert('Digite o nome de usuário, por favor.');
				document.box_login2.usuario.focus();
				return false;
			}

			if(document.box_login2.password.value=="")
			{
				window.alert('Digite a senha, por favor.');
				document.box_login2.password.focus();
				return false;
			}
		}

//----------------------------------------------------------------------------------------------------//

		function BoxPesquisar() {
			if((document.pesquisar.tipo_veiculo.value=="") && (document.pesquisar.marca.value=="") && (document.pesquisar.palavra_chave.value==""))
			{
				window.alert('Selecione uma opção de busca, por favor.');
				document.pesquisar.tipo_veiculo.focus();
				return false;
			}else{
				document.pesquisar.submit();
			}

		}
//----------------------------------------------------------------------------------------------------//

		function BoxLoginNew() {
			if((document.new_login.usuario.value=="") && (document.new_login.password.value==""))
			{
				window.alert('Preencha os campos de login, por favor.');
				document.new_login.usuario.focus();
				return false;
			}else{
				document.new_login.submit();
			}

		}
//----------------------------------------------------------------------------------------------------//

		function BoxLojas() {
			if((document.pesq_lojas.revenda.value==""))
			{
				window.alert('Selecione uma loja para buscar, por favor.');
				document.pesq_lojas.revenda.focus();
				return false;
			}else{
				document.pesq_lojas.submit();
			}
		}

//----------------------------------------------------------------------------------------------------//

		function BoxAcessorios() {
			if((document.pesq_acessorio.tipo_acessorio.value=="") && (document.pesq_acessorio.palavra_chave.value=="") )
			{
				window.alert('Selecione uma opção de busca, por favor.');
				document.pesq_acessorio.tipo_acessorio.focus();
				return false;
			}else{
				document.pesq_acessorio.submit();
			}
		}
//----------------------------------------------------------------------------------------------------//


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


//----------------------------------------------------------------------------------------------------//