var xmlHttp;
function selCidade(uf){

Vvalor = uf;
var url = 'gera_cidades.asp?uf='+uf;

	if (window.ActiveXObject){
		xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
	}
  	else if (window.XMLHttpRequest)
  	{
		xmlHttp = new XMLHttpRequest();
  	}
  
  	xmlHttp.open('GET', url, true);
  	xmlHttp.onreadystatechange = callback1;
  	xmlHttp.send(null);
}

function callback1(){
	if (xmlHttp.readyState == 4){
    	if (xmlHttp.status == 200){
			var cidades = xmlHttp.responseXML.getElementsByTagName('cidade');
			var obj = document.getElementById('campo1126');
			obj.options.length = 0;
			
			var o = document.createElement("option");
	    		o.text = '- Selecione a cidade -';
	    		o.value = '';
	    		obj.options.add(o);
	    		
	  		for(i=0; i<cidades.length; i++){
				var o = document.createElement("option");
/*	    		o.text =  cidades.item(i).firstChild.data;
	    		o.value = cidades.item(i).firstChild.data;*/
				o.text =  cidades[i].firstChild.data;
	    		o.value = cidades[i].firstChild.data;
				obj.options.add(o);
			    //if ( cidades[i].text == Vvalor ){
				//    document.getElementById('campo1126').value = Vvalor;
			    //}
      		}
    	}
  	}
}

function mostraImg(imagem){
    if (imagem != '')
        document.getElementById('img').src = '../imagens/'+imagem;
    else
        document.getElementById('img').src = '../imagens/white.jpg';
}

var xmlHttp1;
function selMarca(cidade,valor){

V_valor = valor;
var url = 'gera_marcas.asp?cidade='+cidade;

	if (window.ActiveXObject){
		xmlHttp1 = new ActiveXObject('Microsoft.XMLHTTP');
	}
  	else if (window.XMLHttpRequest)
  	{
		xmlHttp1 = new XMLHttpRequest();
  	}
  
  	xmlHttp1.open('GET', url, true);
  	xmlHttp1.onreadystatechange = callback2;
  	xmlHttp1.send(null);
}

function callback2(){
	if (xmlHttp1.readyState == 4){
    	if (xmlHttp1.status == 200){
			var cidades = xmlHttp1.responseXML.getElementsByTagName("cidade")
	 		var obj = document.getElementById('campo1127');
			obj.options.length = 0;

			var o = document.createElement("option");
	    		o.text = '- Selecione a marca -';
	    		o.value = '';
	    		obj.options.add(o);
				
	  		for(i=0; i<cidades.length; i++){
				var o = document.createElement("option");
	    		o.text = cidades[i].firstChild.data;
	    		o.value = cidades[i].firstChild.data;
	    		obj.options.add(o);
				
				//if ( cidades[i].text == V_valor ){
				//	document.getElementById('campo1127').value = V_valor;
				//}
      		}
    	}
  	}
}