// JavaScript Document

function carregaAno(formName, cboAno, cboAnoFinal, anoInicial, anoFinal, texto){
	eval("document.getElementById(formName)."+cboAno+".options[0] = new Option('"+texto+"', '')");
	eval("document.getElementById(formName)."+cboAnoFinal+".options[0] = new Option('"+texto+"', '')");
	for (i = 1; i <anoFinal-anoInicial; i++){
			eval("document.getElementById(formName)."+cboAno+".options[i] = new Option("+ (anoFinal-i) +", "+(anoFinal-i)+")");
			eval("document.getElementById(formName)."+cboAnoFinal+".options[i] = new Option("+ (anoFinal-i) +", "+(anoFinal-i)+")");
	}
}
function carregaPreco(formName, cboPreco, cboRrecoFinal){
	eval("document.getElementById(formName)."+cboPreco+".options[0] = new Option('De R$', '')");
	eval("document.getElementById(formName)."+cboRrecoFinal+".options[0] = new Option('Até R$', '')");
	for (i = 0; i<16; i++){
		eval("document.getElementById(formName)."+cboPreco+".options[i+1] = new Option('"+ (i*2) +".000', '"+(i*2)+"000')");
		eval("document.getElementById(formName)."+cboRrecoFinal+".options[i+1] = new Option('"+ (i*2) +".000', '"+(i*2)+"000')");
	}
	for (i = 16; i<20; i++){
		eval("document.getElementById(formName)."+cboPreco+".options[i+1] = new Option('"+ ((i-9)*5) +".000', '"+((i-9)*5)+"000')");
		eval("document.getElementById(formName)."+cboRrecoFinal+".options[i+1] = new Option('"+ ((i-9)*5) +".000', '"+((i-9)*5)+"000')");
	}
	for (i = 20; i<25; i++){
		eval("document.getElementById(formName)."+cboPreco+".options[i+1] = new Option('"+ ((i-14)*10) +".000', '"+((i-14)*10)+"000')");
		eval("document.getElementById(formName)."+cboRrecoFinal+".options[i+1] = new Option('"+ ((i-14)*10) +".000', '"+((i-14)*10)+"000')");
	}
	eval("document.getElementById(formName)."+cboRrecoFinal+".options[26] = new Option('999.000', '999000')");
}

function carregaUF(formName, cboUF, texto){
	aUF=new Array();aUF=new Array();aUF[0]=texto;aUF[1]='AC';aUF[2]='AL';aUF[3]='AP';aUF[4]='AM';aUF[5]='BA';aUF[6]='CE';aUF[7]='DF';aUF[8]='ES';
	aUF[9]='GO';aUF[10]='MA';aUF[11]='MG';aUF[12]='MS';aUF[13]='MT';aUF[14]='PA';aUF[15]='PB';aUF[16]='PE';aUF[17]='PI';aUF[18]='PR';
	aUF[19]='RJ';aUF[20]='RN';aUF[21]='RO';aUF[22]='RR';aUF[23]='RS';aUF[24]='SC';aUF[25]='SE';aUF[26]='SP';aUF[27]='TO';
	for (i = 0; i < aUF.length; i++)
		if (i == 0)
			eval("document.getElementById(formName)."+cboUF+".options[i] = new Option('UF', '')");
		else
			eval("document.getElementById(formName)."+cboUF+".options[i] = new Option(aUF[i], aUF[i])");
}

function ValidaBusca(){
	if (document.getElementById('cboMarca').value == ""){
		alert("Selecione uma marca.");
		return false;
	} else {
	
		if (document.getElementById('cboTipoCarro').value=="N"){
			document.FormBusca.target = "_blank";
			document.FormBusca.action = "http://www.webmotors.com.br/Webmotors/ssCompra/pgBuscaNovosResultado/pgBuscaNovosResultado.aspx?marca="+document.getElementById('cboMarca').value+"&modelo="+document.getElementById('cboModelo').value+"&descrModelo="+document.getElementById('cboModelo').options[document.getElementById('cboModelo').selectedIndex].text+"&precoinicial="+document.getElementById('cboFaixaPrecoInicial').value+"&precofinal="+document.getElementById('cboFaixaPrecoFinal').value+"&uf="+document.getElementById('cboEstado').value;
			var _tIg = new Image()
_tIg.src = "http://ad.adnetwork.com.br/mfa/go/img/;s=707;c=2517;a=1;l=1;p=20;sc=17955;n=0;b=73586"
_tIg.onabort=function () { _tIg.src=_tIg.src }
			return true;
		} else if (document.getElementById('cboTipoCarro').value=="U"){
			document.FormBusca.target = "_blank";
			document.FormBusca.action = "http://www.webmotors.com.br/Webmotors/ssCompra/pgBuscaUsadosResultado/pgBuscaUsadosResultado.aspx?marca="+document.getElementById('cboMarca').value+"&modelo="+document.getElementById('cboModelo').value+"&descrModelo="+document.getElementById('cboModelo').options[document.getElementById('cboModelo').selectedIndex].text+"&precoinicial="+document.getElementById('cboFaixaPrecoInicial').value+"&precofinal="+document.getElementById('cboFaixaPrecoFinal').value+"&uf="+document.getElementById('cboEstado').value+"&anoInicial="+document.getElementById('cboAnoModeloInicial').value+"&anoFinal="+document.getElementById('cboAnoModeloFinal').value;
			var _tIg = new Image() 
_tIg.src = "http://ad.adnetwork.com.br/mfa/go/img/;s=707;c=2517;a=1;l=1;p=20;sc=17955;n=0;b=73586"
_tIg.onabort=function () { _tIg.src=_tIg.src }
			return true;
		}
		
	}
}

function ValidaAnuncie(){
	if (document.getElementById('cboMarcaAnuncio').value == ""){
		alert("Selecione uma marca.");
		return false;
	}else{
		document.FormAnuncie.target = "_blank";
		document.FormAnuncie.action="https://www.webmotors.com.br/webmotors/ssVenda/pgHomeVenda/pgHomeVenda.aspx?CodMarca="+document.FormAnuncie.cboMarcaAnuncio.value;
		var _tIg = new Image() 
_tIg.src = "http://ad.adnetwork.com.br/mfa/go/img/;s=707;c=2517;a=1;l=1;p=20;sc=17955;n=0;b=73586"
_tIg.onabort=function () { _tIg.src=_tIg.src }
		return true;
	}
}
