//carrega uma lista de estados, cidades e regiões 
//A busca é feita no arquivo ajax que está dentro da pasta admin
function buscaEstado(c1)
{	
	var divTipo; 
	var linha;
	var valor = document.getElementById("pais"+prefixo).value;

	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaEstado&idPais="+valor;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	if(c1 == ""){
		document.getElementById('estado'+prefixo).length = 0;	
		document.getElementById('cidade'+prefixo).length = 0;
		document.getElementById('estado'+prefixo).options[0] = new Option(" Não Disponível", "");
		document.getElementById('cidade'+prefixo).options[0] = new Option(" Não Disponível", "");
		return false;
	}

	divTipo = c1.split("***");

	document.getElementById('estado'+prefixo).length = 0;
	document.getElementById('estado'+prefixo).options[0] = new Option(" :: Selecione", "");
	
	for(i=0; i<=divTipo.length-1; i++)
	{
		// Explode cada linha de cada tipo escolhido, ou seja, o *** é a divisão entre os dados
		linha = divTipo[i].split("#");
		for(j=0; j<linha.length-1; j++)
		{
			veiValor = linha[j];
			veiTexto = linha[j+1];
			document.getElementById('estado'+prefixo).options[i+1] = new Option( veiTexto, veiValor );
			
			switch(prefixo){
				case '_inst':
					if(veiValor == estadoInst) document.getElementById('estado'+prefixo).options[i+1].selected = true;
					break;
				case '_rep':
					if(veiValor == estadoRep) document.getElementById('estado'+prefixo).options[i+1].selected = true;
					break;
				default:
					if(veiValor == estado) document.getElementById('estado'+prefixo).options[i+1].selected = true;
				break;
			}
		}
		
	}
	
	return true;
}

function buscaCidade(c1)
{	

	var divTipo; 
	var linha;
	var selecionado = 0;
	var valor = document.getElementById("estado"+prefixo).value;
	
	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaCidade&idEstado="+valor;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	if(c1 == ""){
		document.getElementById('cidade'+prefixo).length = 0;
		document.getElementById('cidade'+prefixo).options[0] = new Option(" Não Disponível", "");
		return false;
	}

	divTipo = c1.split("***");

	document.getElementById('cidade'+prefixo).length = 0;
	document.getElementById('cidade'+prefixo).options[0] = new Option(" :: Selecione", "");
	
	
	for(i=0; i<=divTipo.length-1; i++)
	{
		// Explode cada linha de cada tipo escolhido, ou seja, o *** é a divisão entre os dados
		linha = divTipo[i].split("#");
		
		for(j=0; j<linha.length-1; j++)
		{
			veiValor = linha[0];
			veiTexto = linha[1];
			selecionado = linha[2];
						
			document.getElementById('cidade'+prefixo).options[i+1] = new Option( veiTexto, veiValor );
			
			switch(prefixo){
				case '_inst':
					if(veiValor == cidadeInst || selecionado == 1) document.getElementById('cidade'+prefixo).options[i+1].selected = true;
					break;
				case '_rep':
					if(veiValor == cidadeRep || selecionado == 1) document.getElementById('cidade'+prefixo).options[i+1].selected = true;
					break;
				default:
					if(veiValor == cidade || selecionado == 1)	document.getElementById('cidade').options[i+1].selected = true;
				break;
			}
			
		}
		
	}
	
	tam = document.getElementById('cidade'+prefixo).length;
	document.getElementById('cidade'+prefixo).options[tam] = new Option("Outra Cidade", "o");
	switch(prefixo){
		case '_inst':
			if('o' == cidadeInst) document.getElementById('cidade'+prefixo).options[tam].selected = true;
			break;
		case '_rep':
			if('o' == cidadeRep) document.getElementById('cidade'+prefixo).options[tam].selected = true;
			break;
		default:
			if('o' == cidade) document.getElementById('cidade').options[tam].selected = true;
		break;
	}
	
	if(cidade) { document.getElementById('cidade').value = cidade;}
	
	return true;
}

// Para os filtros
function buscaCidadeFiltros(c1)
{	
	Ext.get(document.body).mask('Consultando Cidades...', 'x-mask-loading');
// ------------------------------------------------------------------------------------------------------------
// Troca imagem do mapa
// ------------------------------------------------------------------------------------------------------------
	var nomeEstado = '';
	
	if( document.getElementById('formNacional') ) {
		var indice = document.formNacional.idEstado.selectedIndex;
		var valorEstado = document.formNacional.idEstado.options[indice].value;
		var nomeEstado = document.formNacional.idEstado.options[indice].text;
	}
	
	if( document.getElementById('formConcurso') ) {
		var indice = document.formConcurso.idEstado.selectedIndex;
		var valorEstado = document.formConcurso.idEstado.options[indice].value;
		var nomeEstado = document.formConcurso.idEstado.options[indice].text;
	}
	
	if( valorEstado != '' )
	{
		nomeEstado = trim(nomeEstado);
		nomeEstado = nomeEstado.toLowerCase();
	
	} else {
	
		nomeEstado = 'default';
	}
	
	document.getElementById('mapa').src = 'images/mapas/'+nomeEstado+'.jpg';
	
// ------------------------------------------------------------------------------------------------------------

	var divTipo; 
	var linha;
	var valor = document.getElementById("estado"+prefixo).value;
	
	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaCidade&idEstado="+valor;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	if(c1 == ""){
		document.getElementById('cidade'+prefixo).length = 0;
		document.getElementById('cidade'+prefixo).options[0] = new Option(" Não Disponível", "");
		return false;
	}

	divTipo = c1.split("***");

	document.getElementById('cidade'+prefixo).length = 0;
	document.getElementById('cidade'+prefixo).options[0] = new Option(" :: Selecione", "");
	
	
	for(i=0; i<=divTipo.length-1; i++)
	{
		// Explode cada linha de cada tipo escolhido, ou seja, o *** é a divisão entre os dados
		linha = divTipo[i].split("#");

		for(j=0; j<linha.length-1; j++)
		{
			veiValor = linha[0];
			veiTexto = linha[1];
			selecionado = linha[2];
			
			document.getElementById('cidade'+prefixo).options[i+1] = new Option( veiTexto, veiValor );

			if(selecionado == 1){
				document.getElementById('cidade').options[i+1].selected = true;
				document.getElementById('visulizarRegiaoTitulo').style.display = "block";
				document.getElementById('visulizarRegiaoConteudo').style.display = "block";
				trocaImagemMapaRegiao();
			}
		}
	}
	Ext.get(document.body).unmask();
	return true;
}

function buscaSubcategorias(c1)
{	
	valor = document.getElementById("idCategoria").value;
	
	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaSubcategorias&idCategoria="+valor;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	if(c1 == ""){
		document.getElementById('idSubcategoria').length = 0;
		document.getElementById('idSubcategoria').options[0] = new Option(" Não Disponível", "");
		return false;
	}

	divTipo = c1.split("***");
	document.getElementById('idSubcategoria').length = 0;
	document.getElementById('idSubcategoria').options[0] = new Option(" :: Selecione", "");
	
	for(i=0; i<=divTipo.length-1; i++)
	{
		// Explode cada linha de cada tipo escolhido, ou seja, o *** é a divisão entre os dados
		linha = divTipo[i].split("#");
		for(j=0; j<linha.length-1; j++)
		{
			veiValor = linha[j];
			veiTexto = linha[j+1];
			document.getElementById('idSubcategoria').options[i+1] = new Option( veiTexto, veiValor );
			
			if(veiValor == subcategorias) document.getElementById('idSubcategoria').options[i+1].selected = true;
		}
		
	}
	
}

function altStatus(c1){
	
	var s = document.getElementById("divStatus"+Bposicao);
	
	if ( c1 == 'getUrl' )		return "ajax.php?page=alterarStatus&idAnuncio="+BidAnuncio+"&status="+Bstatus;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	if(c1 == 1){
		if(Bstatus == 1)	s.innerHTML = '<img src="images/ativo.gif" onClick="alterarStatus('+Bposicao+','+BidAnuncio+', 2);" style="cursor:pointer;">';
		else				s.innerHTML = '<img src="images/inativo.gif" onClick="alterarStatus('+Bposicao+','+BidAnuncio+', 1);" style="cursor:pointer;">';

		showError('Mensagem', 'Anúncio atualizado com sucesso!');
	}else{
		showError('Mensagem de erro', 'Erro ao atualizar o status do anúncio');
	}
}

function altStatusPacote(c1){
	
	var s = document.getElementById("divStatus"+BPacote+"_"+Bposicao);
	
	if ( c1 == 'getUrl' )		return "ajax.php?page=alterarStatusPacote&idAnuncio="+BidAnuncio+"&idPacote="+BPacote+"&status="+Bstatus;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;
	
	switch(c1){
		case '1':
			if(Bstatus == 1)	s.innerHTML = '<img src="images/ativo.gif" onClick="alterarStatusPacote('+BPacote+','+Bposicao+','+BidAnuncio+', 0);">';
			else				s.innerHTML = '<img src="images/inativo.gif" onClick="alterarStatusPacote('+BPacote+','+Bposicao+','+BidAnuncio+', 1);">';
		
			showError('Mensagem', 'Pacote atualizado com sucesso!');
			
		break;
		case '2':
			showError('Mensagem', 'E necessário desativar os outros pacotes!');
		break;
		case '3':
			showError('Mensagem', 'E necessário ativar o pacote institucional!');
		break;
		default:
			showError('Mensagem de erro', 'Erro ao atualizar o status do anúncio');
		break;
	}
}

function altStatusServicos(c1){
	
	var s = document.getElementById("divStatus"+Bposicao);
	
	if ( c1 == 'getUrl' )		return "ajax.php?page=alterarStatusServicos&idAnuncio="+BidAnuncio+"&status="+Bstatus;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;


	if(c1 == 1){
		if(Bstatus == 1)	s.innerHTML = '<img src="images/ativo.gif" onClick="alterarStatusServicos('+Bposicao+','+BidAnuncio+', 0);">';
		else				s.innerHTML = '<img src="images/inativo.gif" onClick="alterarStatusServicos('+Bposicao+','+BidAnuncio+', 1);">';

		showError('Mensagem', 'Pacote atualizado com sucesso!');
	}else{
		showError('Mensagem de erro', 'Erro ao atualizar o status do anúncio');
	}
}


function altStatusClassificados(c1){
	
	var s = document.getElementById("divStatus"+BPacote+"_"+Bposicao);
	
	if ( c1 == 'getUrl' )		return "ajax.php?page=alterarStatusClassificados&idAnuncio="+BidAnuncio+"&idPacote="+BPacote+"&status="+Bstatus;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	if(c1 == 1){
		if(Bstatus == 1)	s.innerHTML = '<img src="images/ativo.gif" onClick="alterarStatusClassificados('+BPacote+','+Bposicao+','+BidAnuncio+', 0);">';
		else				s.innerHTML = '<img src="images/inativo.gif" onClick="alterarStatusClassificados('+BPacote+','+Bposicao+','+BidAnuncio+', 1);">';

		showError('Mensagem', 'Pacote atualizado com sucesso!');
	}else{
		showError('Mensagem de erro', 'Erro ao atualizar o status do anúncio');
	}
}


function buscaPrecoMes(c1){
	
	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaPrecoMes";			
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;
	
	document.getElementById("precoMes").value = c1;
}

function buscaCalendario(c1)
{	
	
	mes = document.getElementById("mes").value;
	ano = document.getElementById("ano").value;
	
	if(document.getElementById("acaoCalendario").value == "somar")	mes++;
	else															mes--;

	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaCalendario&mes="+mes+"&ano="+ano;			
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;
	
	document.getElementById("dadosCalendario").innerHTML = c1;
	//document.getElementById("mesPreco").value = mes + "/" + ano;
	
	//newTask('buscaPrecoMes', 1);

}

function atualizarListaAgenda(c1)
{
	lista = document.getElementById("listaAgenda").value;
	
	if ( c1 == 'getUrl' )		return "ajax.php?page=atualListaAgenda&lista="+lista;			
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;
	
}

function buscaNivelformacao(c1)
{	
	var divTipo; 
	var linha;
	var valor = document.getElementById("idGrauformacao").value;
	
	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaNivelformacao&idGrauformacao="+valor;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	if(c1 == ""){
		document.getElementById('idNivelformacao').length = 0;	
		document.getElementById('idNivelformacao').options[0] = new Option(" Não Disponível", "");
		return false;
	}

	divTipo = c1.split("***");

	document.getElementById('idNivelformacao').length = 0;
	document.getElementById('idTipoformacao').length = 0;
	document.getElementById('idNivelformacao').options[0] = new Option(" :: Selecione", "");
	document.getElementById('idTipoformacao').options[0] = new Option(" :: Selecione", "");
	
	for(i=0; i<=divTipo.length-1; i++)
	{
		// Explode cada linha de cada tipo escolhido, ou seja, o *** é a divisão entre os dados
		linha = divTipo[i].split("#");
		for(j=0; j<linha.length-1; j++)
		{
			veiValor = linha[j];
			veiTexto = linha[j+1];
			document.getElementById('idNivelformacao').options[i+1] = new Option( veiTexto, veiValor );
			
			if(veiValor == idNivelform) document.getElementById('idNivelformacao').options[i+1].selected = true;
		}
		
	}
	return true;
}

function buscaTipoformacao(c1)
{	
	var divTipo; 
	var linha;
	var valor = document.getElementById("idNivelformacao").value;
	
	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaTipoformacao&idNivelformacao="+valor;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	if(c1 == ""){
		document.getElementById('idTipoformacao').length = 0;	
		document.getElementById('idTipoformacao').options[0] = new Option(" Não Disponível", "");
		return false;
	}

	divTipo = c1.split("***");

	document.getElementById('idTipoformacao').length = 0;
	document.getElementById('idTipoformacao').options[0] = new Option(" :: Selecione", "");
	
	for(i=0; i<=divTipo.length-1; i++)
	{
		// Explode cada linha de cada tipo escolhido, ou seja, o *** é a divisão entre os dados
		linha = divTipo[i].split("#");
		for(j=0; j<linha.length-1; j++)
		{
			veiValor = linha[j];
			veiTexto = linha[j+1];
			document.getElementById('idTipoformacao').options[i+1] = new Option( veiTexto, veiValor );

			if(veiValor == idTipoform) document.getElementById('idTipoformacao').options[i+1].selected = true;
		}
		
	}
	return true;
}

function buscaTipoCurso(c1)
{	
	var divTipo; 
	var linha;
	var area = document.getElementById("idAreacurso").value;

	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaTipocurso&idArea="+area;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	if(c1 == ""){
		document.getElementById('idTipocurso').length = 0;	
		document.getElementById('idTipocurso').options[0] = new Option(" Não Disponível", "");
		return false;
	}

	divTipo = c1.split("***");

	document.getElementById('idTipocurso').length = 0;
	document.getElementById('idTipocurso').options[0] = new Option(" :: Selecione", "");

	for(i=0; i<=divTipo.length-1; i++)
	{
		// Explode cada linha de cada tipo escolhido, ou seja, o *** é a divisão entre os dados
		linha = divTipo[i].split("#");
		for(j=0; j<linha.length-1; j++)
		{
			veiValor = linha[j];
			veiTexto = linha[j+1];
			document.getElementById('idTipocurso').options[i+1] = new Option( veiTexto, veiValor );
			
			if(veiValor == idTipocur){
				document.getElementById('idTipocurso').options[i+1].selected = true;
			}
		}
		
	}
	return true;
}

// Busca dos dados dos pacotes do anúncio escolhido

function buscaDadosInstitucional(c1){
		
	var valor 			= document.getElementById("idAnuncioInstitucional").value;
	var dados 			= document.getElementById("dadosInstitucional");
	var valorTipo 		= document.getElementById("idTipoanuncio").value;

	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaDadosInstitucional&idAnuncio="+valor+"&idTipoanuncio="+valorTipo;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	dados.innerHTML = c1;
}

function buscaDadosInformacao(c1){
		
	var valor 			= document.getElementById("idAnuncioInformacao").value;
	var dados 			= document.getElementById("dadosInformacao");
	var valorTipo 		= document.getElementById("idTipoanuncio").value;
	
	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaDadosInformacao&idAnuncio="+valor+"&idTipoanuncio="+valorTipo;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	dados.innerHTML = c1;
	
	if(corporativ != ''){
		if(corporativ == 2){
			document.getElementById("inCompany").style.display = "block";
			document.getElementById("forum").style.display = "none";
		}else{
			document.getElementById("inCompany").style.display = "none";
			document.getElementById("forum").style.display = "block";
		}
	}
}

function buscaDadosConhecadeperto(c1){
		
	var valor 			= document.getElementById("idAnuncioConhecadeperto").value;
	var dados 			= document.getElementById("dadosConhecadeperto");
	var valorTipo 		= document.getElementById("idTipoanuncio").value;
	
	
	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaDadosConhecadeperto&idAnuncio="+valor+"&idTipoanuncio="+valorTipo;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	dados.innerHTML = c1;
}

function buscaDadosValeeducao(c1){
		
	var valor 			= document.getElementById("idAnuncioValeEducacao").value;
	var dados 			= document.getElementById("dadosValeeducacao");
	var valorTipo 		= document.getElementById("idTipoanuncio").value;
	
	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaDadosValeeducacao&idAnuncio="+valor+"&idTipoanuncio="+valorTipo;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	dados.innerHTML = c1;	
}

function buscaDadosBannerInt(c1){
		
	var valor 			= document.getElementById("idAnuncioBanner").value;
	var dados 			= document.getElementById("dadosBanner");
	var valorTipo 		= document.getElementById("idTipoanuncio").value;
	
	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaDadosBannerInt&idAnuncio="+valor+"&idTipoanuncio="+valorTipo;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	dados.innerHTML = c1;	
}

function buscaDadosVisitavirtual(c1){
		
	var valor 			= document.getElementById("idAnuncioVisitavirtual").value;
	var dados 			= document.getElementById("dadosVisitaVirtual");
	var valorTipo 		= document.getElementById("idTipoanuncio").value;
	
	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaDadosVisitavirtual&idAnuncio="+valor+"&idTipoanuncio="+valorTipo;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	dados.innerHTML = c1;	
}



// Fim da busca dos dados dos pacotes

//----------------------------------------------------------------------------------------------------------------------
// Busca dos dados do Site
//----------------------------------------------------------------------------------------------------------------------

function buscaDistancia(c1){
	
	var dados	= document.getElementById("conteudofiltros");
		
	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaDistancia&idTipoanuncio="+tipoSelecionado;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	dados.innerHTML = c1;	
}

function buscaProximoBanner(c1){
	
	var dados	= document.getElementById("conteudoflash");

	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaProximoBanner&idAnuncio="+vetId[proximo];
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	dados.innerHTML = c1;	
}

// Ações do Banner Inteligente
function bannerAnimado(){

	if((proximo+1) == vetId.length)	proximo = 0;
	else							proximo = proximo+1;		
	
	newTask('buscaProximoBanner', 1);
}

function voltar(){

	if((proximo) == 0)	proximo = vetId.length-1;
	else				proximo = proximo-1;
		
	newTask('buscaProximoBanner', 1);
}

function avancar(){

	if((proximo+1) == vetId.length)	proximo = 0;
	else							proximo = proximo+1;
		
	newTask('buscaProximoBanner', 1);
}

function pausar(){
	clearInterval(intervalo);
}

// ------------------------------------------------------------------------------------------
// Estatística Regiões
// -------------------------------------------------------------------------------------------

function buscaEstatisticaRegiaoAjax(c1){

	dados = document.getElementById("conteudoEstatistica");

	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaEstatisticaRegiaoAjax&regiao="+regiaoEst;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	dados.innerHTML = c1;	
}

function buscaEstatisticaEstadoAjax(c1){

	
	dados = document.getElementById("conteudoEstatistica");

	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaEstatisticaEstadoAjax&estado="+estado;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;

	dados.innerHTML = c1;	
}

// --------------------------------------------------------------------------------------------
// Baixa Logos e banners
// --------------------------------------------------------------------------------------------

// Baixa logo com baixa resolução
function logoBaixa(c1){
	
	if ( c1 == 'getUrl' )		return "download.php?page=baixarArquivos&tipo=logoBaixa";
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;
	
	return true;
}

// -------------------------------------------------------------------------------------------
// Visita Virtual
// -------------------------------------------------------------------------------------------

function buscaFlashVisita(c1){
	
	lugar = document.getElementById("flashVisita");
	
	if ( c1 == 'getUrl' )		return "ajax.php?page=buscaFlashVisita&idVisita="+idFlash;
	if ( c1 == 'getMethod' )	return "GET";
	if ( c1 == 'getData' )		return null;
	
	lugar.innerHTML = c1;
	return true;
}

// ------------------------------------------------------------------------------
// Busca as datas em que uma news foi disparada
// ------------------------------------------------------------------------------

function buscaData(c1)
{
	var n = document.getElementById("idNews").value;
	
	switch ( c1 )
	{
		case 'getUrl':		return "ajax.php?page=buscaData&idNews="+n;	break;
		case 'getMethod':	return "GET";								break;
		case 'getData':		return null;								break;
	}

	document.getElementById('data').length = 0;
	document.getElementById('data').options[0] = new Option(':: Selecione','');
	
	divDados = c1.split('|||');
	
	if(c1 != '')
	{
		for(i=0;i<divDados.length-1;i++)
		{
		  valor = divDados[i].split('#');
		  document.getElementById('data').options[i+1] = new Option(valor[1],valor[0]);
		}
	}
}

// ------------------------------------------------------------------------------
// Retorna todos os dados do relatório
// ------------------------------------------------------------------------------

function buscaRelatorio(c1)
{
	var r = document.getElementById('relatorio');
	var tp = document.getElementById("idNews").value;
	var dt = document.getElementById("data").value;
	
	switch ( c1 )
	{
		case 'getUrl':		return "ajax.php?page=buscaRelatorio&idNews="+tp+"&data="+dt;	break;
		case 'getMethod':	return "GET";	break;
		case 'getData':		return null;	break;
	}

	r.innerHTML = c1;
	return true;
}

function buscaCobrancaDia(c1)
{
	var data = document.getElementById('data').value;
	var valor = document.getElementById('valor');
	
	switch ( c1 )
	{
		case 'getUrl':		return "ajax.php?page=buscaCobrancaDia&data="+data;	break;
		case 'getMethod':	return "GET";	break;
		case 'getData':		return null;	break;
	}
	//alert(c1);
	valor.innerHTML = c1;
	return true;
}

// Atualizar a sessão
function atualizarSessao(c1){

	switch ( c1 )
	{
		case 'getUrl':		return "ajax.php?page=atualizarSessao";	break;
		case 'getMethod':	return "GET";	break;
		case 'getData':		return null;	break;
	}
	
	return true;
}


/*// Pega o ID, URL de redirecionamento e e envia os dados para o banco
function enviaDadosBanco(c1){
	
	var r = document.getElementById('formu');
	var preco = r.valor.value;
	
	for(i=0; i<r.tipo.length; i++){
		if(r.tipo[i].checked)	var tp = r.tipo[i].value;
	}
	
	switch ( c1 )
	{
		case 'getUrl':		return "ajax.php?page=enviaDadosBanco&valor="+preco+"&tipo="+tp;	break;
		case 'getMethod':	return "GET";	break;
		case 'getData':		return null;	break;
	}

	if(c1 != 0){
		r.action = c1;
		r.submit();
	}
	
	return true;
	
}*/