function focusFieldBusca(id){
	document.getElementById(id).style.backgroundColor = '#DFFFFF';
	document.getElementById(id).style.border = '1px solid #CCC';	
}
function noFocusFieldBusca(id){
	document.getElementById(id).style.backgroundColor = '#FFFFFF';
	document.getElementById(id).style.border = '1px solid #D9D9D9';	
}


function validaFormBuscaVeiculo(){
	if (document.getElementById('modeloVeiculo').value == ''){
		document.getElementById('modeloVeiculo').value='Digite o modelo'; 
		document.getElementById('modeloVeiculo').focus(); 
	}
	return true;
}

function onchangeAnuncieConosco(selectedIndex, id, divIr){
	var url = document.getElementById(id)[selectedIndex].value;
	ajaxpage(url, divIr);	
}

var idDepoimentoDesativar = '';
var idLinkDesativar = '';
function detalhesDepoimento(id){
    document.getElementById('conteudo'+id).innerHTML = document.getElementById('campo'+id).value;
    document.getElementById('conteudo'+id).style.color = '0000ff';
    document.getElementById('link'+id).style.fontWeight = 'bold';
    if (idDepoimentoDesativar != ''){
        document.getElementById(idDepoimentoDesativar).innerHTML = '';
        document.getElementById(idLinkDesativar).style.fontWeight = 'normal';
    }
    idDepoimentoDesativar = 'conteudo' + id;
    idLinkDesativar = 'link' + id;
}
function trocaClasseDepoimento(id){
	if (document.getElementById(id).className == 'depoimentoExpandido depoimento'){
		document.getElementById(id).className = 'depoimentoEncolhido';
	}else{
		document.getElementById(id).className = 'depoimentoExpandido depoimento';
	}
}
var menuAtivo = new Array(3);
var menu = new Array(3);
// anuncie conosco;
menu[0]      = 6;
menuAtivo[0] = 0;
// revista
menu[1]      = 4;
menuAtivo[1] = 0;
function menuOn(id){
    if (menuAtivo[id] == 0){
       document.getElementById(id).style.display = '';
       document.getElementById(id+'tr').style.display = '';
       menuAtivo[id] = 1;
    }else{
        document.getElementById(id).style.display = 'none';
        document.getElementById(id+'tr').style.display = 'none';
        menuAtivo[id] = 0;
    }
}


function trocaValor(selecionado){
	if (selecionado == 1){
		document.getElementById('valoresA').style.display = '';
		document.getElementById('valoresB').style.display = 'none';
	}else{
		document.getElementById('valoresB').style.display = '';
		document.getElementById('valoresA').style.display = 'none';
	}
}

/****


**/
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 do método

function selecionaMarcaBt(url){
    if ($('#categoria').val() != ''){
        var urlBt = url+"veiculos/buscaTopoAjax.php?fc=selecionaMarcaBt&idCategoria="+$('#categoria').val();
        var htmlx = $.ajax({
            type: "GET",
            url: urlBt,
            async: false
        }).responseText;
        $("#idMarcaBusca").html( htmlx );
    }
}
function selecionaModeloBt(url){
    if ($('#idMarcaBusca').val() != ''){
        var urlBt = url+"veiculos/buscaTopoAjax.php?fc=selecionaModeloBt&idMarcaBusca="+$('#idMarcaBusca').val();
        var htmlx = $.ajax({
            type: "GET",
            url: urlBt,
            async: false
        }).responseText;
        $("#idModeloBusca").html( htmlx );
    }
}
function selecionaMarcaBp(url){
    if ($('#idCategoriaBp').val() != ''){
        var urlBt = url+"veiculos/buscaTopoAjax.php?fc=selecionaMarcaBt&idCategoria="+$('#idCategoriaBp').val();
        var htmlx = $.ajax({
            type: "GET",
            url: urlBt,
            async: false
        }).responseText;
        $("#idMarcaBp").html( htmlx );
    }
}
function selecionaModeloBp(url){
    if ($('#idMarcaBp').val() != ''){
        var urlBt = url+"veiculos/buscaTopoAjax.php?fc=selecionaModeloBt&idMarcaBusca="+$('#idMarcaBp').val();
        var htmlx = $.ajax({
            type: "GET",
            url: urlBt,
            async: false
        }).responseText;
        $("#idModeloBp").html( htmlx );
    }
}

