function clickSinanNet(){$('sinannet').style.display='';  $('Sinanw').style.display='none'; $('calend').style.display='none';}
function buscaMunicipio(id){
	$('municipios').innerHTML="Carregando..."
	new Ajax.Request("inc/localidade.php?acao=buscaMunicipio&id="+id, {	      
	  onSuccess: function(transport) {   		
   		$('municipios').update(transport.responseText);  	
      }
    });
	
}
function buscaMunicipioNotificacao(id){
	$('municipios').innerHTML="Carregando..."
	new Ajax.Request("inc/localidade.php?acao=buscaMunicipioNotificacao&id="+id, {	      
	  onSuccess: function(transport) {   		
   		$('municipios').update(transport.responseText);  	
      }
    });
	
}function buscaMunicipioNotificacaoUF(id){
	$('municipios').innerHTML="Carregando..."
	new Ajax.Request("inc/localidade.php?acao=buscaMunicipioNotificacaoUF&id="+id, {	      
	  onSuccess: function(transport) {   		
   		$('municipios').update(transport.responseText);  	
      }
    });
	
}

function listar(municipio,uf,ano,agravo,tipo){
$('resultado').setStyle({display:'none'});
$('lista').setStyle({display:'block'});
$('lista').update('<img src="images/loading.gif" align="absmiddle"><span style="font-family:Trebuchet MS; font-size:10px; color:#b46b60">Calculando...</span><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>');
 	new Ajax.Request("oportunidade/lista.php", {	
	  parameters: {
		municipio: municipio,
		uf     : uf,
		ano    : ano,
		agravo : agravo,
		tipo   : tipo
	} ,	  
	  onSuccess: function(transport) {   	
   		$('lista').update(transport.responseText);  
		new Effect.ScrollTo('lista');		
      }
    });
}

function tabelaDuplicidade(form, pasta){
$('resultado').setStyle({display:'block'});
$('lista').setStyle({display:'none'});
var fo=$('formRelatorio');
$('resultado').update('<img src="images/loading.gif" align="absmiddle"><span style="font-family:Trebuchet MS; font-size:10px; color:#b46b60">Calculando...</span><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>');
new Effect.ScrollTo('resultado');
 if(form.uf.value=='brasil')
	new Ajax.Request(pasta + "/tabela_brasil.php", {	
	  parameters: fo.serialize(),	  
	  onSuccess: function(transport) {   		
   		$('resultado').update(transport.responseText); 				
      }
    });
 else	
	new Ajax.Request(pasta + "/tabela.php", {	
	  parameters: fo.serialize(),	  
	  onSuccess: function(transport) {   		
   		$('resultado').update(transport.responseText);  			 
      }
    });
}

function tabelaOportunidade(form){
$('resultado').setStyle({display:'block'});
$('lista').setStyle({display:'none'});
var fo=$('formRelatorio');
$('resultado').update('<img src="images/loading.gif" align="absmiddle"><span style="font-family:Trebuchet MS; font-size:10px; color:#b46b60">Calculando...</span><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>');
new Effect.ScrollTo('resultado');
 if(form.uf.value=='brasil')
	new Ajax.Request("oportunidade/tabela_brasil.php", {	
	  parameters: fo.serialize(),	  
	  onSuccess: function(transport) {   		
   		$('resultado').update(transport.responseText); 				
      }
    });
 else	
	new Ajax.Request("oportunidade/tabela.php", {	
	  parameters: fo.serialize(),	  
	  onSuccess: function(transport) {   		
   		$('resultado').update(transport.responseText);  			 
      }
    });
}

function tabelaCompletitude(form,path){
$('resultado').update('<img src="images/loading.gif" align="absmiddle"><span style="font-family:Trebuchet MS; font-size:10px; color:#b46b60">Calculando...</span><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>');
 if(form.estado.value==0){
  $('resultado').update('<span  style="font-family:Trebuchet MS;  font-size:14px; color:red">Informe a Unidade Federada</span>');
  $('estado').setStyle({
	background: '#ffc'
	})
	return false;
  }else 
	$('estado').setStyle({background: 'white'});
   if(form.agravo){
   if(form.agravo.value==0){
	  $('resultado').update('<span  style="font-family:Trebuchet MS;  font-size:14px; color:red">Escolha um agravo</span>');
	  $('agravo').setStyle({
		background: '#ffc'
		})
		return false;
  }else 
	$('agravo').setStyle({background: 'white'});
	}
if(form.anos.value==0){
	  $('resultado').update('<span  style="font-family:Trebuchet MS;  font-size:14px; color:red">Selecione um ano</span>');
	  $('anos').setStyle({
		background: '#ffc'
		})
		return false;
  }else 
	$('anos').setStyle({background: 'white'});	
  
	new Ajax.Request(path+'/tabela.php', {
	  parameters: form.serialize(),	  
	  onSuccess: function(transport) {   		
   		$('resultado').update(transport.responseText);  
		new Effect.ScrollTo('resultado');		
      }
    });
	
}

function tabelaGerencial(form,url){
var fo=$('formRelatorio');
$('resultado').update('<img src="images/loading.gif" align="absmiddle"><span style="font-family:Trebuchet MS; font-size:10px; color:#b46b60">Calculando...</span><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>');
 if(form.uf.value==0){
  $('resultado').update('<span  style="font-family:Trebuchet MS;  font-size:14px; color:red">Informe o Estado</span>');
  $('uf').setStyle({
	background: '#ffc'
	})
	return false;
  }else 
	$('uf').setStyle({background: 'white'});
   if(form.agravo){
   if(form.agravo.value==0){
	  $('resultado').update('<span  style="font-family:Trebuchet MS;  font-size:14px; color:red">Escolha um agravo</span>');
	  $('ag').setStyle({
		background: '#ffc'
		})
		return false;
  }else 
	$('ag').setStyle({background: 'white'});
	}
if(form.ano.value==0){
	  $('resultado').update('<span  style="font-family:Trebuchet MS;  font-size:14px; color:red">Selecione um ano</span>');
	  $('ano').setStyle({
		background: '#ffc'
		})
		return false;
  }else 
	$('ano').setStyle({background: 'white'});	
  
	new Ajax.Request(url, {	
	  parameters: fo.serialize(),	  
	  onSuccess: function(transport) {   		
   		$('resultado').update(transport.responseText);  
		new Effect.ScrollTo('resultado');		
      }
    });
	
}
function carregar(arquivo,div){	
	var resultado=$(div);
	resultado.update('<img src="images/loading.gif" align="absmiddle"><span style="font-family:Trebuchet MS; font-size:10px; color:#b46b60">Carregando...</span><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>');
	new Ajax.Request(arquivo, {	      
	  onSuccess: function(transport) {   		
   		resultado.update(transport.responseText);  	
      }
    });
}
function expande(id){
	var sub=$$(".submenu");
	for(i=0;i<sub.length;i++){
	  if(id==sub[i].id){
        if (sub[i].style.display=="block")
	      sub[i].style.display="none";
        else
          sub[i].style.display="block";
     
      }
	  else
	   sub[i].style.display="none"; 
	}
}
function init(){carregar('home.php','main');}

