function atualizaEstados(paisId)
{
	parametro = 'tipo=estados&paisid='+paisId;
	doAjax('pesquisa/carregalocalidade.php', parametro);
	
	zerarCidades();
	zerarBairros();	
}

function atualizaCidades(estadoId)
{
	parametro = 'tipo=cidades&estadoid='+estadoId;
	doAjax('pesquisa/carregalocalidade.php', parametro);		
	
	zerarBairros();		
}

function atualizaBairros(cidadeId)
{
	parametro = 'tipo=bairros&cidadeid='+cidadeId;
	doAjax('pesquisa/carregalocalidade.php', parametro);		
}

function trataResposta()
{
	//alert(xmlhttp.responseText)
	eval(xmlhttp.responseText);	
}

function zerarEstados()
{
	document.getElementById('estado').length=0;
	opcao = new Option('SELECIONE UM ESTADO', '0', false, false);
	tam   = document.getElementById('estado').length;			
	document.getElementById('estado').options[tam] = opcao;	
}

function zerarCidades()
{
	document.getElementById('cidade').length=0;
	opcao = new Option('SELECIONE UMA CIDADE', '0', false, false);
	tam   = document.getElementById('cidade').length;			
	document.getElementById('cidade').options[tam] = opcao;	
}

function zerarBairros()
{
	document.getElementById('bairro').length=0;
	opcao = new Option('SELECIONE UM BAIRRO', '0', false, false);
	tam   = document.getElementById('bairro').length;			
	document.getElementById('bairro').options[tam] = opcao;
}

function adicionaOpcao(txt, val, campo)
{
	opcao = new Option(txt, val, false, false);
	tam   = document.getElementById(campo).length;			
	document.getElementById(campo).options[tam] = opcao;	
}

function submeter(tipo)
{
	if ( tipo=='grupos' )
		document.getElementById('frm').action = 'lista_bairros.php';
	else if ( tipo=='eventos' )	
	{
		document.getElementById('frm').action = 'lista_eventos.php';	
	}
	else if ( tipo=='calendario' )	
	{
		document.getElementById('frm').action = 'lista_rodas.php';	
	}
	
	else if ( tipo=='limpar' )	
	{
				
	document.getElementById('frm').action = 'index.php';	

	document.getElementById('pais').length=0;
	opcao = new Option('Selecione o Pais', '0', false, false);
	tam   = document.getElementById('pais').length;			
	document.getElementById('pais').options[tam] = opcao;	

	document.getElementById('estado').length=0;
	opcao = new Option('Selecione o Estado', '0', false, false);
	tam   = document.getElementById('estado').length;			
	document.getElementById('estado').options[tam] = opcao;	
	
	document.getElementById('cidade').length=0;
	opcao = new Option('Selecione a Cidade', '0', false, false);
	tam   = document.getElementById('cidade').length;			
	document.getElementById('cidade').options[tam] = opcao;	
	
	document.getElementById('bairro').length=0;
	opcao = new Option('Selecione o Bairro', '0', false, false);
	tam   = document.getElementById('bairro').length;			
	document.getElementById('bairro').options[tam] = opcao;
	
	}
	
	document.getElementById('frm').submit();
}

function submeterPorImg()
{
	document.getElementById('event').click();
}
