function PesquisaVeiculo(){
	Parametros = "confirma=1";
	Parametros += "&codmarca=" + document.frmPesquisa.codMarca[document.frmPesquisa.codMarca.selectedIndex].value;
	Parametros += "&codmodelo=" + document.frmPesquisa.codModelo[document.frmPesquisa.codModelo.selectedIndex].value;
	Parametros += "&txtanode=" + document.frmPesquisa.txtAnoDe.value;
	Parametros += "&txtanoate=" + document.frmPesquisa.txtAnoAte.value;
	Parametros += "&txtvalorde=" + document.frmPesquisa.txtValorDe.value;
	Parametros += "&txtvalorate=" + document.frmPesquisa.txtValorAte.value;
	AbreConteudo(document.frmPesquisa.codmenu.value,"Veiculos", Parametros);
	return false;
}



xmlDocVeiculo = XmlDocument.create();
xmlDocVeiculo.onreadystatechange = function () {
	if (xmlDocVeiculo.readyState == 4){
		PopulaSelect();
		DesativaSubmit(false);
		oSelModelo.options[0].text = ">>> SELECIONE A MARCA <<<";
	}
};




function CarregaValores(atual){
	oSelMarca = document.getElementById("codMarca")
	oSelModelo = document.getElementById("codModelo");

	oSelModelo.options.length = 1;

	//if(atual != ""){
	//	xmlValorAtual = atual;
	//}

	if(oSelMarca.value == ""){
		return false;
	}

	oSelModelo.options[0].text = "Carregando Lista...";
	DesativaSubmit(true);
	xmlDocVeiculo.load('admin/xmlveiculos.asp?marca=' + oSelMarca[oSelMarca.selectedIndex].value + '&especie=1');
}

function PopulaSelect(){
	try {
		var Teste = xmlDocVeiculo.getElementsByTagName('itens');
		if(Teste.length == 0){
			throw "Erro";
		}
		Teste = null;
	}
	catch(er) {
		//alert("Erro ao carregar os dados. Tente novamente.");
		oSelModelo.options[0].text = ">>> SELECIONE A MARCA <<<"
		return false;
	}

	var Objetos = xmlDocVeiculo.getElementsByTagName("modelo");
	for (x = 0; x < Objetos.length; x++){
		var Texto = document.createTextNode(Objetos[x].getAttribute('nome'));
		var Option = document.createElement('option');
			Option.setAttribute('value', Objetos[x].getAttribute('cod'));
			Option.appendChild(Texto);

		//if(xmlSelecionado == Objetos[x].getAttribute('cod')){
		//	Option.setAttribute('selected', true);
		//}
		
		oSelModelo.appendChild(Option);
	}
}

