// alterado clique aqui em 30/09/2008 as 00:50

	var http_request = false;
	function busca(url) {
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
		   http_request = new XMLHttpRequest();
		} 
		else if (window.ActiveXObject) { // IE
		   http_request = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else {
			alert('Não foi possível instanciar o objeto HttpRequest');
		}
		http_request.onreadystatechange = mostraBusca;
		url = url+'&randomico='+Math.random();
		http_request.open('GET', url, true);
		http_request.send(null);
	}
	
	function mostraBusca() {
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				var div = document.getElementById("meio");
				document.getElementById('inicial').style.display = "none";
				document.getElementById('carregando').style.display = "none";
				var texto = http_request.responseText;
				div.innerHTML = texto;
			} 
			else {
				alert('Sua conexão esta lenta!');
			}
		}
		else{
			document.getElementById('carregando').style.display = "block";
		}
	}


//Lista Fabricas 2
function buscaFabrica(url) {
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
	   http_request = new XMLHttpRequest();
	} 
	else if (window.ActiveXObject) { // IE
	   http_request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else {
		alert('Não foi possível instanciar o objeto HttpRequest');
	}
	http_request.onreadystatechange = mostraFabrica;
	url = url+'&randomico='+Math.random();
	http_request.open('GET', url, true);
	http_request.send(null);
}

function mostraFabrica() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			var objDiv 		= document.getElementById('fabrica');
			var tamanho 	= objDiv.options.length;
			
			for(var i=tamanho; i >= 0; i--){
				objDiv.options[i] = null;
			}
			var texto 			= http_request.responseText;
			var val 			= texto.split(";;");
			var conta 			= val.length-1;
			
			for(var j=0; j < conta; j++){
				if (j > 0){
					var nome 			= val[j].replace(".","").replace("..","").replace("...","");
					var nomeFinal		= nome.substring(13);
					var nomeFinalM		= nomeFinal.toUpperCase();
					var valor_id		= nome.substr(0,11);
					objDiv.options[j] 	= new Option(nomeFinalM,valor_id);
				}else{
					objDiv.options[j] 	= new Option("Clique aqui","Clique aqui");
				}
			}
		} 
		else {
			alert('Sua conexão esta lenta!');
		}
	}
	else{
	objDiv = document.getElementById('fabrica');
	objDiv.options[0] = new Option("Carregando...", 0);
	}
}
//Final lista Fabricas 2

//Lista Veiculos
function buscaVeiculo(url) {
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
	   http_request = new XMLHttpRequest();
	} 
	else if (window.ActiveXObject) { // IE
	   http_request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else {
		alert('Não foi possível instanciar o objeto HttpRequest');
	}
	http_request.onreadystatechange = mostraVeiculo;
	url = url+'&randomico='+Math.random();
	http_request.open('GET', url, true);
	http_request.send(null);
}

function mostraVeiculo() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			var objDiv 	= document.getElementById('veiculo');
			var tamanho = objDiv.options.length;
			
			for(var i=tamanho; i >= 0; i--){
				objDiv.options[i] = null;
			}
			
			var texto 	= http_request.responseText;
			var val 	= texto.split(";;");
			var conta 	= val.length-1;
			
			for(var j=0; j < conta; j++){
				if (j > 0){
					var nome 			= val[j].replace(".","").replace("..","").replace("...","");
					var nomeFinal		= nome.substring(13);
					var nomeFinalM		= nomeFinal.toUpperCase();
					var valor_id		= nome.substr(0,11);
					objDiv.options[j] 	= new Option(nomeFinalM,valor_id);
				}else{
					objDiv.options[j] 	= new Option("Clique aqui","Clique aqui");
				}
			}
		} 
		else {
			alert('Sua conexão esta lenta!');
		}
	}
	else{
	objDiv = document.getElementById('veiculo');
	objDiv.options[0] = new Option("Carregando...", 0);
	}
}
//Final lista Veiculos

//Lista localidades
function buscaLocalidade(url) {
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
	   http_request = new XMLHttpRequest();
	} 
	else if (window.ActiveXObject) { // IE
	   http_request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else {
		alert('Não foi possível instanciar o objeto HttpRequest');
	}
	http_request.onreadystatechange = mostraLocalidade;
	url = url+'&randomico='+Math.random();
	http_request.open('GET', url, true);
	http_request.send(null);
}

function mostraLocalidade() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			var objDiv 	= document.getElementById('cidade');
			var tamanho = objDiv.options.length;
			
			for(var i=tamanho; i >= 0; i--){
				objDiv.options[i] = null;
			}
			
			var texto 	= http_request.responseText;
			var val 	= texto.split(";;");
			var conta 	= val.length-1;
			
			for(var j=0; j < conta; j++){
				if (j > 0){
					var nome 			= val[j].replace(".","").replace("..","").replace("...","");
					var nomeFinal		= nome.substring(13);
					var nomeFinalM		= nomeFinal.toUpperCase();
					var valor_id		= nome.substr(0,11);
					objDiv.options[j] 	= new Option(nomeFinalM,valor_id);
				}else{
					objDiv.options[j] 	= new Option("SELECIONE A CIDADE","PELOTAS");
				}
			}
		} 
		else {
			alert('Sua conexão esta lenta!');
		}
	}
	else{
	objDiv = document.getElementById('cidade');
	objDiv.options[0] = new Option("Carregando...", 0);
	}
}
//Final lista localidades

