// JavaScript Document

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;}

// BUSCA DE CARRO

function ajaxSearchCarro() {
		http_request = testaversao();
		http_request.open("POST", "search/searchVeiculo.asp" ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('buscaveiculos').innerHTML = '<img src="img/loadingbar.gif" />'//'<select name="select" id="select" disabled="disabled" class="fontTrebuchet11Preto" style="width:130px;"><option value="">Carregando...</option></select>'
		   if(http_request.readyState == 4){
					document.getElementById('buscaveiculos').innerHTML = http_request.responseText
					ajaxDestaquesHome('destaqueHorizonteAjax.asp')
				}}
			http_request.send('') 
}

function ajaxTipoVeiculo(xtipo) {
		http_request = testaversao();
		var page = "search/marcaSearch.asp?tipoVeiculo="+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('marcaView').innerHTML = '<select name="select" id="select" disabled="disabled" class="fontTrebuchet11Preto" style="width:130px;"><option value="">Carregando...</option></select>'//'<img src="img/loadingbar.gif" />'
		   if(http_request.readyState == 4){
					document.getElementById('marcaView').innerHTML = http_request.responseText
					ajaxModeloVeiculo()
				}}
			http_request.send('') 
}

function ajaxModeloVeiculo() {
		http_request = testaversao();
		var page = "search/modeloSearch.asp?tipoVeiculo="+document.getElementById('tpveic').value+"&marca="+document.getElementById('idmarca').value;
		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('modeloView').innerHTML = '<select name="select" id="select" disabled="disabled" class="fontTrebuchet11Preto" style="width:130px;"><option value="">Carregando...</option></select>'//'<img src="img/loadingbar.gif" />'
		   if(http_request.readyState == 4){
					document.getElementById('modeloView').innerHTML = http_request.responseText
					ajaxMotorModelo()
				}}
			http_request.send('') 
}

function ajaxMotorModelo() {
		http_request = testaversao();
		var page = "search/ajaxMotor.asp?tipoVeiculo="+document.getElementById('tpveic').value+"&marca="+document.getElementById('idmarca').value+"&codmodelo="+document.getElementById('codmodelo').value;
		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('motorView').innerHTML = '<select name="select" id="select" disabled="disabled" class="fontTrebuchet11Preto" style="width:130px;"><option value="">Carregando...</option></select>'//'<img src="img/loadingbar.gif" />'
		   if(http_request.readyState == 4){
					document.getElementById('motorView').innerHTML = http_request.responseText
					ajaxAnoModelo()
				}}
			http_request.send('') 
}

function ajaxAnoModelo() {
		http_request = testaversao();
		var page = "search/ajaxAnoModelo.asp?tipoVeiculo="+document.getElementById('tpveic').value+"&marca="+document.getElementById('idmarca').value+"&codmodelo="+document.getElementById('codmodelo').value+"&motor="+document.getElementById('motor').value;
		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('anoView').innerHTML = '<select name="select" id="select" disabled="disabled" class="fontTrebuchet11Preto" style="width:130px;"><option value="">Carregando...</option></select>'//'<img src="img/loadingbar.gif" />'
		   if(http_request.readyState == 4){
					document.getElementById('anoView').innerHTML = http_request.responseText
					ajaxCidadeVeiculo()
				}}
			http_request.send('') 
}

function ajaxCidadeVeiculo() {
		http_request = testaversao();
		var page = "search/ajaxCidade.asp?tipoVeiculo="+document.getElementById('tpveic').value+"&marca="+document.getElementById('idmarca').value+"&codmodelo="+document.getElementById('codmodelo').value+"&motor="+document.getElementById('motor').value+"&anomodel="+document.getElementById('anomodel').value;
		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('cidadeView').innerHTML = '<select name="select" id="select" disabled="disabled" class="fontTrebuchet11Preto" style="width:130px;"><option value="">Carregando...</option></select>'//'<img src="img/loadingbar.gif" />'
		   if(http_request.readyState == 4){
					document.getElementById('cidadeView').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}

// BUSCA DE MOTO

function ajaxSearchMoto() {
		http_request = testaversao();
		http_request.open("POST", "search/searchMoto.asp" ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('buscaveiculos').innerHTML = '<img src="img/loadingbar.gif" />'//'<select name="select" id="select" disabled="disabled" class="fontTrebuchet11Preto" style="width:130px;"><option value="">Carregando...</option></select>'
		   if(http_request.readyState == 4){
					document.getElementById('buscaveiculos').innerHTML = http_request.responseText
					//ajaxDestaquesHome('destaqueHorizonteMotoAjax.asp')
				}}
			http_request.send('') 
}
function ajaxTipoMoto(xtipoMoto) {
		http_request = testaversao();
		var page = "search/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", "search/modeloMotoSearch.asp?id_marca="+document.getElementById('id_marca').value+"&estado_moto="+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
					ajaxCilindradas()
				}}
			http_request.send('') 
}
function ajaxCilindradas() {
		http_request = testaversao();
		var page = "search/ajaxCilindradas.asp?id_marca="+document.getElementById('id_marca').value+"&estado_moto="+document.getElementById('estado_moto').value+"&id_modelo="+document.getElementById('id_modelo').value;
		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('cilindradaView').innerHTML = '<select name="select" id="select" disabled="disabled" class="fontTrebuchet11Preto" style="width:130px;"><option value="">Carregando...</option></select>'//'<img src="img/loadingbar.gif" />'
		   if(http_request.readyState == 4){
					document.getElementById('cilindradaView').innerHTML = http_request.responseText
					ajaxSearchAnoMoto()
				}}
			http_request.send('') 
}
function ajaxSearchAnoMoto() {
		http_request = testaversao();
		http_request.open("POST", "search/ajaxAnoModeloMoto.asp?id_marca="+document.getElementById('id_marca').value+"&estado_moto="+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('anoView').innerHTML = '<select disabled="disabled" class="fontTrebuchet11Preto" style="width:130px;"><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('anoView').innerHTML = http_request.responseText
					ajaxCidadeModeloMoto()
				}}
			http_request.send('') 
}

function ajaxCidadeModeloMoto() {
		http_request = testaversao();
		http_request.open("POST", "search/ajaxCidadeModeloMoto.asp?id_marca="+document.getElementById('id_marca').value+"&estado_moto="+document.getElementById('estado_moto').value+"&id_modelo="+document.getElementById('id_modelo').value+"&anomodel="+document.getElementById('anomodel').value ,true);
		http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		http_request.onreadystatechange=function() { 
					document.getElementById('cidadeView').innerHTML = '<select disabled="disabled" class="fontTrebuchet11Preto" style="width:130px;"><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('cidadeView').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="fontTrebuchet11Preto" style="width:130px;"><option value="">indiferente</option></select>'
		   if(http_request.readyState == 4){
					document.getElementById('vlmaximomoto').innerHTML = http_request.responseText
				}}
			http_request.send('') 
}

// detalhes do anuncio

function ajaxFotoAnuncioMoto(filtro) {
		var page = "fotoFullMoto.asp?codigo="+filtro
		xmlhttp.open("POST", page ,true);
		xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		xmlhttp.onreadystatechange=function() { 
					document.getElementById('imgFull').innerHTML = '<font size="1" face="tahoma"><img src="img/loading.gif" width="15" height="15" /> Carregando...</font>'
		   if(xmlhttp.readyState == 4){
					document.getElementById('imgFull').innerHTML = xmlhttp.responseText
				}}
			xmlhttp.send('') 
}
function ajaxThumbMoto(filtro) {
		var page = "fotoThumbMoto.asp?"+filtro
		xmlhttp.open("POST", page ,true);
		xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		xmlhttp.onreadystatechange=function() { 
					document.getElementById('thumbnails').innerHTML = '<img src="img/loading.gif" width="15" height="15" />'
		   if(xmlhttp.readyState == 4){
					document.getElementById('thumbnails').innerHTML = xmlhttp.responseText
				}}
			xmlhttp.send('') 
}
function ajaxCompareMoto(codigo) {
		var urlCompare = "addCompareMoto.asp?action=add&codigo="+codigo
		xmlhttp.open("POST", urlCompare, true);
		xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		xmlhttp.onreadystatechange=function() { 
					document.getElementById('divcompare').innerHTML = '<img src="img/loading2.gif"/>'
		   if(xmlhttp.readyState == 4){
					document.getElementById('divcompare').innerHTML = xmlhttp.responseText
				}}
			xmlhttp.send('') 
}
function ajaxExcluirCompareMoto(codigo) {
		var urlDelCompare = "removeCompareMoto.asp?"+codigo
		xmlhttp.open("POST", urlDelCompare, true);
		xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		xmlhttp.onreadystatechange=function() { 
					document.getElementById('tdcompare').innerHTML = '<img src="img/loading2.gif"/>'
		   if(xmlhttp.readyState == 4){
					document.getElementById('tdcompare').innerHTML = xmlhttp.responseText
				}}
			xmlhttp.send('') 
}
function ajaxContatoMoto(filtro) {
		var page = "contatoAnuncioMoto.asp?"+filtro
		xmlhttp.open("POST", page ,true);
		xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		xmlhttp.onreadystatechange=function() { 
					document.getElementById('contatoAnuncio').innerHTML = '<font size="1" face="tahoma"><img src="img/loading.gif" width="15" height="15" /> Carregando...</font>'
		   if(xmlhttp.readyState == 4){
					document.getElementById('contatoAnuncio').innerHTML = xmlhttp.responseText
				}}
			xmlhttp.send('') 
}


// GERAL

function ajaxContato(filtro) {
		var page = "contatoAnuncio.asp?"+filtro
		xmlhttp.open("POST", page ,true);
		xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		xmlhttp.onreadystatechange=function() { 
					document.getElementById('contatoAnuncio').innerHTML = '<font size="1" face="tahoma"><img src="img/loading.gif" width="15" height="15" /> Carregando...</font>'
		   if(xmlhttp.readyState == 4){
					document.getElementById('contatoAnuncio').innerHTML = xmlhttp.responseText
				}}
			xmlhttp.send('') 
}
function ajaxFotoAnuncio(filtro) {
		var page = "fotoFull.asp?codigo="+filtro
		xmlhttp.open("POST", page ,true);
		xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		xmlhttp.onreadystatechange=function() { 
					document.getElementById('imgFull').innerHTML = '<font size="1" face="tahoma"><img src="img/loading.gif" width="15" height="15" /> Carregando...</font>'
		   if(xmlhttp.readyState == 4){
					document.getElementById('imgFull').innerHTML = xmlhttp.responseText
				}}
			xmlhttp.send('') 
}
function ajaxThumb(filtro) {
		var page = "fotoThumb.asp?"+filtro
		xmlhttp.open("POST", page ,true);
		xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		xmlhttp.onreadystatechange=function() { 
					document.getElementById('thumbnails').innerHTML = '<img src="img/loading.gif" width="15" height="15" />'
		   if(xmlhttp.readyState == 4){
					document.getElementById('thumbnails').innerHTML = xmlhttp.responseText
				}}
			xmlhttp.send('') 
}
function ajaxCompare(codigo) {
		var urlCompare = "addCompare.asp?action=add&codigo="+codigo
		xmlhttp.open("POST", urlCompare, true);
		xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		xmlhttp.onreadystatechange=function() { 
					document.getElementById('divcompare').innerHTML = '<img src="img/loading2.gif"/>'
		   if(xmlhttp.readyState == 4){
					document.getElementById('divcompare').innerHTML = xmlhttp.responseText
				}}
			xmlhttp.send('') 
}
function ajaxExcluirCompare(codigo) {
		var urlDelCompare = "removeCompare.asp?"+codigo
		xmlhttp.open("POST", urlDelCompare, true);
		xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
		xmlhttp.onreadystatechange=function() { 
					document.getElementById('tdcompare').innerHTML = '<img src="img/loading2.gif"/>'
		   if(xmlhttp.readyState == 4){
					document.getElementById('tdcompare').innerHTML = xmlhttp.responseText
				}}
			xmlhttp.send('') 
}

