function ValidaBusca(){
	
	if (document.getElementById('rdoCarro').checked == true){
		if (document.getElementById('cboMarca').value == ""){
			alert("Selecione uma marca.");
			return false
		}
		if (document.getElementById('cboTipoCarro').value=="N")
			document.FormBusca.action = "/WebMotors/ssApontador/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;
		else if (document.getElementById('cboTipoCarro').value=="U")
			document.FormBusca.action = "/WebMotors/ssApontador/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;
		return true;
	}else if (document.getElementById('rdoMoto').checked == true){
		if (document.getElementById('cboMarcaMoto').value == ""){
			alert("Selecione uma marca.");
			return false;
		}
		if (document.getElementById('cboTipoMoto').value=="U")
			document.FormBuscaMoto.action = "/WebMotors/ssApontador/pgBuscaMotosUsadasResultado/pgBuscaMotosUsadasResultado.aspx?precode="+document.getElementById('cboFaixaMotoPrecoInicial').value+"&precoate="+document.getElementById('cboFaixaMotoPrecoFinal').value+"&anoate="+document.getElementById('cboAnoMotoModeloFinal').value+"&descrmarca="+document.getElementById('cboMarcaMoto').options[document.getElementById('cboMarcaMoto').selectedIndex].text+"&marca="+document.getElementById('cboMarcaMoto').value+"&part=S&anode="+document.getElementById('cboAnoMotoModeloInicial').value+"&estilo=&avanc=0&uf="+document.getElementById('cboEstadoMoto').value+"&descrestilo=&descrmodelo="+document.getElementById('cboModeloMoto').options[document.getElementById('cboModeloMoto').selectedIndex].text+"&revend=S&modelo="+document.getElementById('cboModeloMoto').value;
		else if (document.getElementById('cboTipoMoto').value=="N")
			document.FormBuscaMoto.action = "/WebMotors/ssApontador/pgBuscaMotosNovasResultado/pgBuscaMotosNovasResultado.aspx?loja=S&estilo=&precoate="+document.getElementById('cboFaixaMotoPrecoFinal').value+"&descrmarca="+document.getElementById('cboMarcaMoto').options[document.getElementById('cboMarcaMoto').selectedIndex].text+"&marca="+document.getElementById('cboMarcaMoto').value+"&descrmodelo="+document.getElementById('cboModeloMoto').options[document.getElementById('cboModeloMoto').selectedIndex].text+"&modelo="+document.getElementById('cboModeloMoto').value+"&conc=S&avanc=0&uf="+document.getElementById('cboEstadoMoto').value+"&descrestilo=&precode="+document.getElementById('cboFaixaMotoPrecoInicial').value;
	}
}

//Nova função para busca nos clones
function ValidaBuscaClone(){
	if (document.getElementById('rdoCarroClone').checked == true){
		if (document.getElementById('cboMarcaClone').value == ""){
			alert("Selecione uma marca.");
			return false
		}
		if (document.getElementById('cboTipoCarroClone').value=="N"){
			document.FormBuscaClone.action = "http://www.webmotors.com.br/Webmotors/ssApontador/pgBuscaNovosResultado/pgBuscaNovosResultado.aspx?marca="+document.getElementById('cboMarcaClone').value+"&modelo="+document.getElementById('cboModeloClone').value+"&descrModelo="+document.getElementById('cboModeloClone').options[document.getElementById('cboModeloClone').selectedIndex].text+"&uf="+document.getElementById('cboEstadoClone').value;
			document.FormBuscaClone.submit();
		}
		else if (document.getElementById('cboTipoCarroClone').value=="U"){
			document.FormBuscaClone.action = "http://www.webmotors.com.br/Webmotors/ssApontador/pgBuscaUsadosResultado/pgBuscaUsadosResultado.aspx?marca="+document.getElementById('cboMarcaClone').value+"&modelo="+document.getElementById('cboModeloClone').value+"&descrModelo="+document.getElementById('cboModeloClone').options[document.getElementById('cboModeloClone').selectedIndex].text+"&uf="+document.getElementById('cboEstadoClone').value+"&anoInicial="+document.getElementById('cboAnoModeloInicialClone').value+"&anoFinal="+document.getElementById('cboAnoModeloFinalClone').value;
			document.FormBuscaClone.submit();
		}
		return true;
	}else if (document.getElementById('rdoMotoClone').checked == true){
		if (document.getElementById('cboMarcaMotoClone').value == ""){
			alert("Selecione uma marca.");
			return false;
		}
		if (document.getElementById('cboTipoMotoClone').value=="U"){
			document.FormBuscaMotoClone.action = "http://www.webmotors.com.br/Webmotors/ssApontador/pgBuscaMotosUsadasResultado/pgBuscaMotosUsadasResultado.aspx?anoate="+document.getElementById('cboAnoMotoModeloFinalClone').value+"&descrmarca="+document.getElementById('cboMarcaMotoClone').options[document.getElementById('cboMarcaMotoClone').selectedIndex].text+"&marca="+document.getElementById('cboMarcaMotoClone').value+"&part=S&anode="+document.getElementById('cboAnoMotoModeloInicialClone').value+"&estilo=&avanc=0&uf="+document.getElementById('cboEstadoMotoClone').value+"&descrestilo=&descrmodelo="+document.getElementById('cboModeloMotoClone').options[document.getElementById('cboModeloMotoClone').selectedIndex].text+"&revend=S&modelo="+document.getElementById('cboModeloMotoClone').value;
            document.FormBuscaMotoClone.submit();
        }
		else if (document.getElementById('cboTipoMotoClone').value=="N"){
			document.FormBuscaMotoClone.action = "http://www.webmotors.com.br/Webmotors/ssApontador/pgBuscaMotosNovasResultado/pgBuscaMotosNovasResultado.aspx?loja=S&estilo=&descrmarca="+document.getElementById('cboMarcaMotoClone').options[document.getElementById('cboMarcaMotoClone').selectedIndex].text+"&marca="+document.getElementById('cboMarcaMotoClone').value+"&descrmodelo="+document.getElementById('cboModeloMotoClone').options[document.getElementById('cboModeloMotoClone').selectedIndex].text+"&modelo="+document.getElementById('cboModeloMotoClone').value+"&conc=S&avanc=0&uf="+document.getElementById('cboEstadoMotoClone').value;
			document.FormBuscaMotoClone.submit();
	    }
	}
}
function carroMotoClone(){
	if (document.getElementById('rdoCarroClone').checked == true){
		document.getElementById('comprarCarroClone').style.visibility='visible'
		document.getElementById('comprarMotoClone').style.visibility='hidden'
	}else if (document.getElementById('rdoMotoClone').checked == true){
		document.getElementById('comprarCarroClone').style.visibility='hidden';
		document.getElementById('comprarMotoClone').style.visibility='visible'
	}
}
//Fim das funções do Clone

function carroMoto(){
	if (document.getElementById('rdoCarro').checked == true){
		document.getElementById('comprarCarro').style.visibility='visible'
		document.getElementById('comprarMoto').style.visibility='hidden'
	}else if (document.getElementById('rdoMoto').checked == true){
		document.getElementById('comprarCarro').style.visibility='hidden';
		document.getElementById('comprarMoto').style.visibility='visible'
	}
}
function carroMotoAnuncie(){
	if (document.getElementById('carroVender').checked == true){
		document.getElementById('marcaVender').style.visibility='visible';
		document.getElementById('marcaVenderMoto').style.visibility='hidden'
	}else if (document.getElementById('motoVender').checked == true){
		document.getElementById('marcaVender').style.visibility='hidden';
		document.getElementById('marcaVenderMoto').style.visibility='visible'
	}
}
function carroMotoAvaliacao(){
	if (document.getElementById('carroAvaliar').checked == true){
		document.getElementById('avaliacaoCarro').style.visibility='visible';
		document.getElementById('avaliacaoMoto').style.visibility='hidden'
	}else if (document.getElementById('motoAvaliar').checked == true){
		document.getElementById('avaliacaoCarro').style.visibility='hidden';
		document.getElementById('avaliacaoMoto').style.visibility='visible'
	}	
}
function ValidaAvaliacao(){	
	if (document.getElementById('carroAvaliar').checked == true){
		if (FormAvaliacao.cboMarca.value == ""){ 
			window.alert("Selecione a marca.");
			return false;
		}
		if (FormAvaliacao.cboModelo.value == ""){
			window.alert("Selecione o modelo.");
			return false;
		}
		document.FormAvaliacao.submit();
	}else if (document.getElementById('motoAvaliar').checked == true){
		if (document.getElementById('ddlMarca').value == ""){ 
			window.alert("Selecione a marca.");
			return false;
		}
		document.FormAvaliacaoMoto.submit();
	}
}

function ValidaManutencao(){
	if (!VerificaEmail(document.getElementById('txtEmail').value))
	{
		alert("E-mail inválido");return false;
	}
	if ( (document.getElementById('cboDiaNasc').value == "") && (document.getElementById('cboMesNasc').value == "") && (document.getElementById('cboAnoNasc').value == "") )
	{
		window.alert("Informe sua data de nascimento.");
		return false
	}
	document.FormManutencao.action="/WebMotors/ssManutencao/pgAgendadoCarro/AgendadoCarro.asp?email="+document.getElementById('txtEmail').value+"&dia="+document.getElementById('cboDiaNasc').value+"&mes="+document.getElementById('cboMesNasc').value+"&ano="+document.getElementById('cboAnoNasc').value;
	return true;
}
function ValidaAnuncie(){	
	if (document.getElementById('carroVender').checked == true){
		if (document.getElementById('cboMarcaAnuncio').value == ""){
			alert("Selecione uma marca.");
			return false;
		}else{
			document.FormAnuncie.target = '_blank';
			document.FormAnuncie.action="https://h2.webmotors.com.br/Webmotors/ssVenda/pgHomeVenda/pgHomeVenda.aspx?CodMarca="+document.FormAnuncie.cboMarcaAnuncio.value + '&codigoCanal=12';
		}
	}else if (document.getElementById('motoVender').checked == true){
		if (document.getElementById('cboMarcaMotoAnuncio').value == ""){
			alert("Selecione uma marca.");
			return false;
		}else{
			document.FormAnuncie.target = '_blank';
			document.FormAnuncie.action="https://h2.webmotors.com.br/Webmotors/ssVenda/pgHomeVenda/pgHomeVendaMoto.aspx?CodMarca="+document.FormAnuncie.cboMarcaMotoAnuncio.value + '&codigoCanal=12';
		}
	}
}
	
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+"', '')");
	anoFinal = new Date().getFullYear() + 1;
	for (i = 1; i <=anoFinal-anoInicial; i++){
		eval("document.getElementById(formName)."+cboAno+".options[i] = new Option("+ (anoFinal-i) +", "+(anoFinal-i)+")");
	}
	var AnoFinalComboFinal = new Date().getFullYear() + 2;
	for (i = 1; i <=AnoFinalComboFinal-anoInicial; i++){
		eval("document.getElementById(formName)."+cboAnoFinal+".options[i] = new Option("+ (AnoFinalComboFinal-i) +", "+(AnoFinalComboFinal-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 carregaAnoManutencao(formName, cboAno, anoInicial, anoFinal, texto){
	eval("document.getElementById(formName)."+cboAno+".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)+")");
	}
}
function carregaNumeros(formName, cboAno, valorInicial, valorFinal, texto){
	eval("document.getElementById(formName)."+cboAno+".options[0] = new Option('"+texto+"', '')");
	for (i = 1; i <valorFinal; i++){
			if (i < 10)
				eval("document.getElementById(formName)."+cboAno+".options[i] = new Option('0"+ (i) +"', "+(i)+")");
			else
				eval("document.getElementById(formName)."+cboAno+".options[i] = new Option('"+ (i) +"', "+(i)+")");
	}
}
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])");
}

