﻿
function retorno_populaCidade(ret)
{var dt=ret.value;var cidade=document.getElementById('cidade');cidade.options.length=0;cidade.options[cidade.options.length]=new Option("Selecione uma Cidade","0");for(var i=0;i<dt.length;i++)
{cidade.options[cidade.options.length]=new Option(dt[i].Nome,dt[i].Codigo_Cidade);}
document.getElementById('img_cidade').style.display="none";}
function populaCidade(value)
{document.getElementById('img_cidade').style.display="";indica_servicos.PopulaCidade(value,retorno_populaCidade);}
function SetaCidade(dropDownCidade,enderecoSite)
{document.getElementById("cidade_hidden").value=dropDownCidade.value;var estado=document.getElementById("estado");var cidade=document.getElementById("cidade");var estadoValor=estado.options[estado.selectedIndex].value;var cidadeValor=cidade.options[cidade.selectedIndex].value;estadoValor=indica_servicos.RetornaCidadeEstado(0,estadoValor).value;cidadeValor=indica_servicos.RetornaCidadeEstado(cidadeValor,0).value;var categoriaID="";var subCategoriaID="";var categoria=window.location.toString();if(categoria.indexOf('/sos/')>-1)
{categoria=categoria.split('.')[0];categoria=categoria.substring(categoria.indexOf('/')+16);}
else
{categoria=categoria.split('.')[3];categoria=categoria.substring(categoria.indexOf('/')+1);}
var parametros=categoria.split('/');if(parametros.length==6)
{window.location=enderecoSite+"bbel_indica/lojas"+"/"+estadoValor+"/lista/"+cidadeValor+"/pg1.aspx";}
else if(parametros.length==5)
{categoriaID=parametros[4];window.location=enderecoSite+"bbel_indica/lojas"+"/"+estadoValor+"/"+cidadeValor+"/"+categoriaID+".aspx";}
else if(parametros.length>5)
{categoriaID=parametros[4];subCategoriaID=parametros[6];window.location=enderecoSite+"bbel_indica/lojas"+"/"+estadoValor+"/"+cidadeValor+"/"+categoriaID+"/"+parametros[5]+"/"+subCategoriaID+"/pg1.aspx";}}
function RedirecionaParaSubcategoria(url,categoria)
{var estado=document.getElementById("estado");var cidade=document.getElementById("cidade");var estadoValor=estado.options[estado.selectedIndex].value;var cidadeValor=cidade.options[cidade.selectedIndex].value;var link;if(estadoValor!=0&&cidadeValor!=0)
{link=element.href+"&estado="+estadoValor+"&cidade="+cidadeValor;}
else
{link=element.href;}
window.location=link;}