// JavaScript Document
//	try{
//	xmlhttp = new XMLHttpRequest();}catch(ee){try{
//	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{
//	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
//	catch(E){xmlhttp = false;}}}
function testaversao() {
  http_request = false;
  if (window.ActiveXObject) { // IE 
    try {    
      http_request = new ActiveXObject("Msxml2.XMLHTTP");} 
    catch (e) { 
      try {    
        http_request = new ActiveXObject("Microsoft.XMLHTTP");} 
      catch (e){ }}}
  else if (window.XMLHttpRequest) { // Mozilla, Safari,...      
    http_request = new XMLHttpRequest(); 
    if (http_request.overrideMimeType) { 
      http_request.overrideMimeType('text/xml');}} 
  return http_request;}



function ajaxTipoVeiculo(xtipo) {
		http_request = testaversao();
		var page = "tipoVeiculoSearch.asp?tipo="+xtipo;
		http_request.open("POST", page ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('mtipoveic').innerHTML = '<font size="1" face="tahoma"><img src="img/loading3.gif" width="15" height="15" /> Carregando...</font>'
		   if(http_request.readyState == 4){
					document.getElementById('mtipoveic').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}
function ajaxModelos() {
		http_request = testaversao();
		http_request.open("POST", "viewModel.asp?idmarca="+document.getElementById('idmarca').value+"&tipoveic="+document.getElementById('tpveic').value ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('model').innerHTML = '<font size="1" face="tahoma"><img src="img/loading.gif" width="15" height="15" /> Carregando...</font>'
		   if(http_request.readyState == 4){
					document.getElementById('model').innerHTML = http_request.responseText
					ajaxSearchAno();
					//ajaxSearchUf();
				}}
			http_request.send('') 
}
function ajaxSearchAno() {
		http_request = testaversao();
		http_request.open("POST", "viewAnoSearch.asp?idmarca="+document.getElementById('idmarca').value+"&tipoveic="+document.getElementById('tpveic').value+"&idmodelo="+document.getElementById('idmodelo').value ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('viewano').innerHTML = '<select disabled="disabled" class="form" style="width:150px;"><option value="">todos</option></select>'
//					document.getElementById('viewano').innerHTML = '<font size="1" face="tahoma"><img src="img/loading.gif" width="15" height="15" /> Carregando...</font>'
		   if(http_request.readyState == 4){
					document.getElementById('viewano').innerHTML = http_request.responseText
					ajaxSearchUf()
				}}
			http_request.send('') 
}

function ajaxSearchUf() {
		http_request = testaversao();
		http_request.open("POST", "viewUfSearch.asp?idmarca="+document.formveiculo.idmarca.value+"&tipoveic="+document.getElementById('tpveic').value+"&idmodelo="+document.formveiculo.idmodelo.value+"&anofabx="+document.formveiculo.anofabx.value ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('viewuf').innerHTML = '<select disabled="disabled" class="form" style="width:150px;"><option value="">todos</option></select>'
//					document.getElementById('viewuf').innerHTML = '<font size="1" face="tahoma"><img src="img/loading.gif" width="15" height="15" /> Carregando...</font>'
		   if(http_request.readyState == 4){
					document.getElementById('viewuf').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}

function ajaxValorMaximo() {
		http_request = testaversao();
		http_request.open("POST", "viewValorMaximo.asp?valorminimo="+document.getElementById('valorminimo').value ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('vlmaximo').innerHTML = '<select disabled="disabled" class="form" style="width:150px;"><option value="">indiferente</option></select>'
		   if(http_request.readyState == 4){
					document.getElementById('vlmaximo').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}
function ajaxValorMaximoMoto() {
		http_request = testaversao();
		http_request.open("POST", "viewValorMaximo.asp?valorminimo="+document.formmoto.valorminimo.value ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('vlmaximomoto').innerHTML = '<select disabled="disabled" class="form" style="width:150px;"><option value="">indiferente</option></select>'
		   if(http_request.readyState == 4){
					document.getElementById('vlmaximomoto').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}


function ajaxContato(filtro) {
		http_request = testaversao();
		var page = "contatoAnuncio.asp?"+filtro
		http_request.open("POST", page ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('contatoAnuncio').innerHTML = '<font size="1" face="tahoma"><img src="img/loading.gif" width="15" height="15" /> Carregando...</font>'
		   if(http_request.readyState == 4){
					document.getElementById('contatoAnuncio').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}
function ajaxFotoAnuncio(filtro) {
		http_request = testaversao();
		var page = "fotoFull.asp?codigo="+filtro
		http_request.open("POST", page ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('imgFull').innerHTML = '<font size="1" face="tahoma"><img src="img/loading.gif" width="15" height="15" /> Carregando...</font>'
		   if(http_request.readyState == 4){
					document.getElementById('imgFull').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}
function ajaxThumb(filtro) {
		http_request = testaversao();
		var page = "fotoThumb.asp?"+filtro
		http_request.open("POST", page ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('thumbnails').innerHTML = '<img src="img/loading.gif" width="15" height="15" />'
		   if(http_request.readyState == 4){
					document.getElementById('thumbnails').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}
function ajaxCompare(codigo) {
		http_request = testaversao();
		var urlCompare = "addCompare.asp?action=add&codigo="+codigo
		http_request.open("POST", urlCompare, true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('divcompare').innerHTML = '<img src="img/loading2.gif"/>'
		   if(http_request.readyState == 4){
					document.getElementById('divcompare').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}
function ajaxExcluirCompare(codigo) {
		http_request = testaversao();
		var urlDelCompare = "removeCompare.asp?"+codigo
		http_request.open("POST", urlDelCompare, true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('tdcompare').innerHTML = '<img src="img/loading2.gif"/>'
		   if(http_request.readyState == 4){
					document.getElementById('tdcompare').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}


/// BUSCA MOTOS

function ajaxTipoMoto(xtipoMoto) {
		http_request = testaversao();
		var page = "tipoMotoSearch.asp?tipomoto="+xtipoMoto;
		http_request.open("POST", page ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('mtipomoto').innerHTML = '<font size="1" face="tahoma"><img src="img/loading3.gif" width="15" height="15" /> Carregando...</font>'
		   if(http_request.readyState == 4){
					document.getElementById('mtipomoto').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}
function ajaxModelosMoto() {
		http_request = testaversao();
		http_request.open("POST", "viewModelMoto.asp?id_marca="+document.getElementById('id_marca').value+"&tipomoto="+document.getElementById('estado_moto').value ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('modelMoto').innerHTML = '<font size="1" face="tahoma"><img src="img/loading.gif" width="15" height="15" /> Carregando...</font>'
		   if(http_request.readyState == 4){
					document.getElementById('modelMoto').innerHTML = http_request.responseText
					ajaxSearchAnoMoto();
					//ajaxSearchUf();
				}}
			http_request.send('') 
}
function ajaxSearchAnoMoto() {
		http_request = testaversao();
		http_request.open("POST", "viewAnoSearchMoto.asp?id_marca="+document.getElementById('id_marca').value+"&tipomoto="+document.getElementById('estado_moto').value+"&id_modelo="+document.getElementById('id_modelo').value ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('viewanomoto').innerHTML = '<select disabled="disabled" class="form" style="width:150px;"><option value="">todos</option></select>'
//					document.getElementById('viewano').innerHTML = '<font size="1" face="tahoma"><img src="img/loading.gif" width="15" height="15" /> Carregando...</font>'
		   if(http_request.readyState == 4){
					document.getElementById('viewanomoto').innerHTML = http_request.responseText
					ajaxSearchUfMoto()
				}}
			http_request.send('') 
}

function ajaxSearchUfMoto() {
		http_request = testaversao();
		http_request.open("POST", "viewUfSearchMoto.asp?id_marca="+document.formmoto.id_marca.value+"&tipomoto="+document.getElementById('estado_moto').value+"&id_modelo="+document.getElementById('id_modelo').value+"&anofabmoto="+document.getElementById('anofabmoto').value ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('viewufmoto').innerHTML = '<select disabled="disabled" class="form" style="width:150px;"><option value="">todos</option></select>'
//					document.getElementById('viewuf').innerHTML = '<font size="1" face="tahoma"><img src="img/loading.gif" width="15" height="15" /> Carregando...</font>'
		   if(http_request.readyState == 4){
					document.getElementById('viewufmoto').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}
function ajaxFotoAnuncioMoto(filtro) {
		http_request = testaversao();
		var page = "fotoFullMoto.asp?codigo="+filtro
		http_request.open("POST", page ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('imgFull').innerHTML = '<font size="1" face="tahoma"><img src="img/loading.gif" width="15" height="15" /> Carregando...</font>'
		   if(http_request.readyState == 4){
					document.getElementById('imgFull').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}
function ajaxThumbMoto(filtro) {
		http_request = testaversao();
		var page = "fotoThumbMoto.asp?"+filtro
		http_request.open("POST", page ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('thumbnails').innerHTML = '<img src="img/loading.gif" width="15" height="15" />'
		   if(http_request.readyState == 4){
					document.getElementById('thumbnails').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}
function ajaxCompareMoto(codigo) {
		http_request = testaversao();
		var urlCompare = "addCompareMoto.asp?action=add&codigo="+codigo
		http_request.open("POST", urlCompare, true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('divcompare').innerHTML = '<img src="img/loading2.gif"/>'
		   if(http_request.readyState == 4){
					document.getElementById('divcompare').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}
function ajaxExcluirCompareMoto(codigo) {
		http_request = testaversao();
		var urlDelCompare = "removeCompareMoto.asp?"+codigo
		http_request.open("POST", urlDelCompare, true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('tdcompare').innerHTML = '<img src="img/loading2.gif"/>'
		   if(http_request.readyState == 4){
					document.getElementById('tdcompare').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}
function ajaxContatoMoto(filtro) {
		http_request = testaversao();
		var page = "contatoAnuncioMoto.asp?"+filtro
		http_request.open("POST", page ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('contatoAnuncio').innerHTML = '<font size="1" face="tahoma"><img src="img/loading.gif" width="15" height="15" /> Carregando...</font>'
		   if(http_request.readyState == 4){
					document.getElementById('contatoAnuncio').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}

function ajaxSearchCarro() {
		http_request = testaversao();
		http_request.open("POST", "searchVeiculo.asp" ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('buscaveiculos').innerHTML = '<div align="center"><font size="1" face="tahoma"><img src="img/loading.gif" width="15" height="15" /> Carregando...</font></div>'
		   if(http_request.readyState == 4){
					document.getElementById('buscaveiculos').innerHTML = http_request.responseText
					ajaxDestaquesHome('destaqueHorizonteAjax.asp')
				}}
			http_request.send('') 
}

function ajaxSearchMoto() {
		http_request = testaversao();
		http_request.open("POST", "searchMoto.asp" ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('buscaveiculos').innerHTML = '<div align="center"><font size="1" face="tahoma"><img src="img/loading.gif" width="15" height="15" /> Carregando...</font></div>'
		   if(http_request.readyState == 4){
					document.getElementById('buscaveiculos').innerHTML = http_request.responseText
					//ajaxDestaquesHome('destaqueHorizonteMotoAjax.asp')
				}}
			http_request.send('') 
}

function ajaxDestaquesHome(filtro) {
		http_request = testaversao();
		var page = filtro
		http_request.open("POST", page ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('destaqueHome').innerHTML = '<div align="center"><font size="1" face="tahoma"><img src="img/loading.gif" width="15" height="15" /> Carregando...</font></div>'
		   if(http_request.readyState == 4){
					document.getElementById('destaqueHome').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}


