/***********************************************************************************************
'Autor.....: Otto 
'Data......: 17/07/2008
'Comentário: Manutenção Aptativa direcionado a apresentação do território escolhido sobre o 
			 mapa para visualizar dados dos municípios em pdf.
************************************************************************************************/



/*****************************************
Variaveis para utilização na função voltar
*****************************************/
var contVoltar=0;
var _pag = new Array();
var _esc = new Array();
var _cod = new Array();
var tituloSIG = "";
var textoSIG = "";
//****************************************

// JavaScript Document
/***********************************************************************************************
AJAX
************************************************************************************************/
var ajaxRS = new Array();

function makeRequest(url) {
	var http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Não foi possível criar o objeto XMLHTTP!');
		return false;
	}
	
	http_request.onreadystatechange = function(){ alertContents(http_request); };
	http_request.open('GET', url, false);
	http_request.send(null);
	
}

function alertContents(http_request) {
	if (http_request.readyState == 4) {		
//		alert(http_request.status);
		if (http_request.status == 200) {
			//var t  = new Array();
			ajaxRS = carregaRS(unescape(http_request.responseText.replace(/\+/g," ")));
			//ajaxRS = carregaRS(http_request.responseText);
		} else {

			alert('Houve um problema com a requisição!');
		}
	}

}

function ExibirNotasExplicativas(lcodNota,flagSigExterno) {	
	if (lcodNota != '') {
		window.open("../../sigNotas.asp?codNota=" + lcodNota + "&flagSigExterno="+flagSigExterno, "Notas","top=150,left=150,width=510,height=316");		
	}
}
	
function carregaRS(str){
	var lin = new Array();
	var rs = new Array();

	lin = str.split('|');
	
	for(var i = 0; i<lin.length; i++){
		rs[i] = lin[i].split('#');
	}
	
	return rs;
}

/***********************************************************************************************
************************************************************************************************/


function formatCurrency(campooriginal,decimais)
{
  var posicaoPontoDecimal;
  var campo = '';
  var resultado = '';
  var pos,sep,dec;

  //Retira possiveis separadores de milhar
  for (pos=0; pos < campooriginal.length; pos ++){
    if (campooriginal.charAt(pos)!='.')
        campo = campo + campooriginal.charAt(pos);
  }     

  //Formata valor monetário com decimais
  posicaoPontoDecimal = campo.indexOf(',');
  if (posicaoPontoDecimal != -1){
      sep = 0;
      for (pos=posicaoPontoDecimal-1;pos >= 0;pos--){
        sep ++;
        if (sep > 3){
           resultado = '.' + resultado;
           sep = 1;
        }
        resultado = campo.charAt(pos) + resultado;   
      }

      // Trata parte decimal
      if (parseInt(decimais) > 0 ){
         resultado = resultado + ',';
      
         pos=posicaoPontoDecimal+1;
         for (dec = 1;dec <= parseInt(decimais); dec++){
           if (pos < campo.length){
              resultado = resultado + campo.charAt(pos);
              pos++;
           }
           else
              resultado = resultado + '0';   
         }

      } // trata decimais
   }
   // Trata valor monetário sem decimais
   else{
      sep = 0;
      for (pos=campo.length-1;pos >= 0;pos--){
        sep ++;
        if (sep > 3){
           resultado = '.' + resultado;
           sep = 1;
        }
        resultado = campo.charAt(pos) + resultado;   
      }

      // Trata parte decimal
      if (parseInt(decimais) > 0 ){
         resultado = resultado + ',';
         for (dec = 1;dec <= parseInt(decimais); dec++){
              resultado = resultado + '0';   
         }
      } // trata decimais
   }
   return resultado;
}


<!--
//alert("oi");
//alert(window.parent.frames("perCentro").document.frames("perLinha").document.title);
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the the FSCommand messages in a Flash movie
function mapPer_DoFSCommand(command, args, codOrigem) 
{	
    var mapPerObj = InternetExplorer ? perMapa.mapPer : perMapa.mapPer;
 // funcionando												
    lcodChave = args;
	txtCodChave.value = lcodChave;
    lcodEscopo="";

//alert(command); //regiao
//alert(lcodChave); //5
//alert(codOrigem); //1
    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    //Região
	//////////////////////////////////////////////////////////////////////////////////////////////////////////
	if (command == "regiao"){	  	 
       lcodEscopo = "R";
       txtMunicipio.value="";
	   hOrigem.value=lcodEscopo;
       //veio do mapa
       if (codOrigem=="1"){
			//Código da Eixo Economico
			if (lstRegiao.value.substr(0,2)=="12"){
			   lcodChave=parseInt(lcodChave)+400;
			   lcodChave=lcodChave.toString();
			} 

			//Código da Região Economica
			if (lstRegiao.value.substr(0,2)=="06"){
			   lcodChave=parseInt(lcodChave);
			   lcodChave=lcodChave.toString();
			} 
	   }else
	        lcodChave = txtRegiao.value;	

       //Código da Semi-Árido e Faz-Cidadao
       if (lstRegiao.value.substr(0,2)=="11"){
           lcodChave=parseInt(lstRegiao.value.substr(2)).toString();
		   ldesSql="select des_divisao_regional,'' des_municipio, num_frame from divisao_regional " +
		           "where cod_tipo_divisao=11 and cod_divisao_regional="+lcodChave;
	   }	           
       else{
		   ldesSql="select des_divisao_regional,'' des_municipio,num_frame from divisao_regional " +
		           "where cod_divisao_regional="+lcodChave;
       }

		// AJAX
		//alert("Perfil/sigCargaInfMapaNovo.asp?desSql="+ldesSql);
		makeRequest("Perfil/sigCargaInfMapaNovo.asp?desSql="+ldesSql);
		//alert(ajaxRS[0][2]);
		if (lstRegiao.value.substr(0,2)!="63")
			lblEscopo.innerText = "Região "+ajaxRS[0][2];
		else
			lblEscopo.innerText = ajaxRS[0][2];
		lblMunicipio.innerHTML = "&nbsp;";

       //Muda o frame p/ o retorno de municipio p/ inspetoria
	   if (codOrigem=="2")
		   perMapa.mapPer.GotoFrame(parseInt(ajaxRS[0][0]));


       //Atualiza o frame de rodape 
		txtMunicipio.value="0";
		txtRegiao.value=lcodChave;
		carrega_conteudo('R', lcodChave, txtPagina.value);
    }   

	//////////////////////////////////////////////////////////////////////////////////////////////////////////
	//Municipio
	//////////////////////////////////////////////////////////////////////////////////////////////////////////
    if (command == "municipio"){
       lcodEscopo = "M";
	   hOrigem.value=lcodEscopo;

       //Muda o frame p/ o retorno de municipio p/ inspetoria
       if ((codOrigem=="2") && (lstRegiao.value.substr(0,2)!=11)){
			ldesSql="select des_divisao_regional,'' des_municipio,num_frame from divisao_regional " +
			        "where cod_divisao_regional="+txtRegiao.value;

	        makeRequest("Perfil/sigCargaInfMapaNovo.asp?desSql="+ldesSql);
			perMapa.mapPer.GotoFrame(parseInt(ajaxRS[0][0]));
	   }   

       //Atualiza o frame de rodape 
	   txtMunicipio.value=lcodChave;
	   carrega_conteudo('M', lcodChave, txtPagina.value);

	   
    }
	
	//////////////////////////////////////////////////////////////////////////////////////////////////////////
    //Estado
	//////////////////////////////////////////////////////////////////////////////////////////////////////////
    if (command == "volta"){
       lcodEscopo = "E";
	   hOrigem.value=lcodEscopo;
       txtMunicipio.value="";

	   try{
	   	txtMunicipio.value="0";
		txtRegiao.value="0";
	   }catch(er){}
	   

	   if (codOrigem=='3'){
           if (lstRegiao.value.substr(0,2)!="06"){
				document.perMapa.mapPer.GotoFrame(1);
				document.perMapa.mapPer.TGotoFrame("_flash0",0);
				document.perMapa.mapPer.TGotoFrame("selecao_de_municipio", 0);
				document.perMapa.mapPer.TGotoFrame("nomes", 0);
	       }
		   
		   if(lstRegiao.value.substr(0,2)!="63"){
   				document.perMapa.mapPer.GotoFrame(6);
				document.perMapa.mapPer.TGotoFrame("_level1/",0);
				document.perMapa.mapPer.TGotoFrame("nomes", 0);
		   }else{
	            //Mapa de região econômica	
				document.perMapa.mapPer.GotoFrame(6);
				document.perMapa.mapPer.TGotoFrame("_level1/",0);
				document.perMapa.mapPer.TGotoFrame("selecao_de_municipio", 0);
				document.perMapa.mapPer.TGotoFrame("nomes", 0);
		   }	
	   }else{
		   if(lstRegiao.value.substr(0,2)=="63"){
   				document.perMapa.mapPer.GotoFrame(6);
				document.perMapa.mapPer.TGotoFrame("_level1/",0);
				document.perMapa.mapPer.TGotoFrame("nomes", 0);
		   }
		   
		   if (lstRegiao.value.substr(0,2)=="06"){
			  document.perMapa.mapPer.GotoFrame(6);
			  document.perMapa.mapPer.TGotoFrame("_level1/",0);
			  document.perMapa.mapPer.TGotoFrame("selecao_de_municipio", 0);
			  document.perMapa.mapPer.TGotoFrame("nomes", 0);
		   }
	   }
	   lblEscopo.innerText = "Estado da Bahia";    
       lblMunicipio.innerHTML ="&nbsp;";
	   carrega_conteudo('E', '', txtPagina.value);
    }

	//Turistico - destacar municipio
	if ((lstRegiao.value.substr(0,2)=="13") && (!perMapa.mapPer.Playing))
	{
	    if 	(lcodEscopo=="M")
	    {
		    ldesSql="select mdr.num_frame,dr.des_divisao_regional,m.des_municipio from municipio_divisao_regional mdr " +
		            "join municipio m on mdr.cod_municipio=m.cod_municipio " +
		            "join divisao_regional dr on mdr.cod_divisao_regional=dr.cod_divisao_regional " +
		            "where dr.cod_divisao_regional between 217 and 224 and m.cod_municipio="+lcodChave;
		    makeRequest("Perfil/sigCargaInfMapaNovo.asp?desSql="+ldesSql);
		    document.perMapa.mapPer.TGotoFrame("_level1/",parseInt(ajaxRS[0][0]));
		    lblMunicipio.innerText=ajaxRS[0][1];
     		perMapa.mapPer.TSetProperty("/" + lcodChave.toString(), 6, "90");
     		
     	    if ((parseInt(txtMunicipio.value)!=parseInt(lcodChave)) && (txtMunicipio.value!=""))    
     		    perMapa.mapPer.TSetProperty("/" + txtMunicipio.value.toString(), 6, "5");	
     		    
			txtMunicipio.value=lcodChave;
     	    
     	}
     		
	    if 	((command=="munout") && (txtMunicipio.value!=""))
	    {
	       if (parseInt(txtMunicipio.value)==parseInt(lcodChave))
     		   perMapa.mapPer.TSetProperty("/" + lcodChave.toString(), 6, "90");
     	}
    }

	//Semi-Árido e Faz-Cidadao - destacar municipio
	if ((lstRegiao.value.substr(0,2)=="11") && (!perMapa.mapPer.Playing))
	{
	    if 	(lcodEscopo=="M")
	    {
		    ldesSql="select mdr.num_frame,dr.des_divisao_regional,m.des_municipio from municipio_divisao_regional mdr " +
		            "join municipio m on mdr.cod_municipio=m.cod_municipio " +
		            "join divisao_regional dr on mdr.cod_divisao_regional=dr.cod_divisao_regional " +
		            "where dr.cod_divisao_regional="+lstRegiao.value.substr(2)+" and m.cod_municipio="+lcodChave;
		    makeRequest("Perfil/sigCargaInfMapaNovo.asp?desSql="+ldesSql);
		    lblEscopo.innerText="Região "+ajaxRS[0][2];
	        lblMunicipio.innerText=ajaxRS[0][1];
	        
		    //Semi-Árido
		    if (parseInt(lstRegiao.value.substr(2))==208)
		    {
				perMapa.mapPer.GotoFrame(1);
				perMapa.mapPer.GotoFrame(5);
     		    perMapa.mapPer.TSetProperty("/" + lcodChave.toString(), 6, "70");
   				if ((parseInt(txtMunicipio.value)!=parseInt(lcodChave)) && (txtMunicipio.value!=""))    
   				    perMapa.mapPer.TSetProperty("/" + txtMunicipio.value, 6, "0");	
     		}    
     		else
      		{
				perMapa.mapPer.GotoFrame(1);
                //perMapa.mapPer.TSetProperty("/" + lcodChave.toString(), 6, "90");
     		}    
    		    
			txtMunicipio.value=lcodChave;
     	    
     	}
     		
		//Semi-Árido & Faz-Cidadao
		if ((command=="munout") && (txtMunicipio.value!=""))
		{
            if (parseInt(txtMunicipio.value)==parseInt(lcodChave))
            {
		       if (parseInt(lstRegiao.value.substr(2))==208)
     			   perMapa.mapPer.TSetProperty("/" + lcodChave.toString(), 6, "70");
     		}
     	}
    }

	//Econômico/Eixo desenvolvimento - destacar municipio
	if ((lcodEscopo=="M") && ((lstRegiao.value=="12") || (lstRegiao.value=="06") || (lstRegiao.value=="63"))) 
	{
        ldesSql="select mdr.num_frame,dr.des_divisao_regional,m.des_municipio from municipio_divisao_regional mdr " +
                "join municipio m on mdr.cod_municipio=m.cod_municipio " +
                "join divisao_regional dr on mdr.cod_divisao_regional=dr.cod_divisao_regional " +
                "where dr.cod_tipo_divisao="+parseInt(lstRegiao.value.substr(0,2))+" and m.cod_municipio="+lcodChave;
		
		//alert(ldesSql);
		
// ALTERAÇÃO PARA INCLUSÃO DE EXECUÇÃO VIA AJAX				
//	    Proxylet.getURL("../Financeiro/sigFinCargaInfMapa.asp?desSql="+ldesSql);
		
		makeRequest("Perfil/sigCargaInfMapaNovo.asp?desSql="+ldesSql);
		
	    if (lstRegiao.value=="06")
	    {
			//perMapa.mapPer.TGotoFrame("_level1/",parseInt(Proxylet.getColumn(0)));
			perMapa.mapPer.TGotoFrame("_level1/",parseInt(ajaxRS[0][0]));
		    perMapa.mapPer.TGotoLabel("_level0.municipio_selecionar", parseInt(lcodChave));
			lblEscopo.innerText="Região "+ajaxRS[0][2];
		}  
		
		if (lstRegiao.value=="12")
		{
			perMapa.mapPer.TGotoFrame("_level1/",parseInt(lcodChave));
		    perMapa.mapPer.TGotoLabel("selecao_de_municipio", parseInt(lcodChave));
			lblEscopo.innerText="Região "+ajaxRS[0][2];
		}
		
		if(lstRegiao.value=="63"){
			perMapa.mapPer.TGotoFrame("_level1/",parseInt(ajaxRS[0][0]));
			lblEscopo.innerText=ajaxRS[0][2];
		}
			
		//lblEscopo.innerText=Proxylet.getColumn(2);
        //lblMunicipio.innerText=Proxylet.getColumn(1);
		
        lblMunicipio.innerText=ajaxRS[0][1];
     
    }
	//alert(lcodEscopo);
    //Atualiza o frame dos valores do perfil
    if (lcodEscopo!="")
    { 
		//Atualiza a descrição do contexto na pagina de detalhe
		if (lblMunicipio.innerHTML!="&nbsp;")
		{ 
		   ldesEscopo=lblEscopo.outerText+" - "+
		              lblMunicipio.outerText;
		}
		else              
		 {  ldesEscopo=lblEscopo.outerText;}
		  
				
	 if ( (document.title != "sigPerSocialCabInfoGerais2") && (document.title != "sigPerSocialCabEconomico2") )
       {

		if ((document.title != "sigPerSocial") && (document.title != "sigPerSocialSEGeral"))
		{
		    lnomPagina = document.title;
		    lnomPagina = lnomPagina + ".asp";
		  
		    //alert(lnomPagina);
		    	    
		    //Educação - Saude
		    if ((lnomPagina=="sigPerSocialEdDocentes.asp") || (lnomPagina=="sigPerSocialEdEstabelecimentos.asp")
		        || (lnomPagina=="sigPerSocialEdIndicadores.asp") || ( lnomPagina == "sigPerSocialEdIndicadoresRegiao.asp")  ||(lnomPagina.indexOf('sigPerSocialSa')!=-1)
		        || (lnomPagina=="sigPerSocialSTGeral.asp") || (lnomPagina=="sigPerSocialSeguranca.asp"))
		    {
			    obj=document.body.style;
				obj.cursor='wait';
				
				try{
					lnumAno = lstAno.value;
				}catch(e){}
				lnumMes = 0;

		
				if ( (lnomPagina=="sigPerSocialSTGeral.asp") && (lcodEscopo!='E') )
					{
					alert('Os dados de Social, Trabalho e Esporte estão disponíveis apenas para o escopo de estado!');
					mapPer_DoFSCommand('volta','',3); 
					}								
				// pagina de regiao para indicadores
				if ( ( lnomPagina == "sigPerSocialEdIndicadores.asp") && (lcodEscopo=='R') )
				{lnomPagina = "sigPerSocialEdIndicadores.asp";
		     document.location.href=lnomPagina+"?codRegiao="+lcodChave+"&anoReferencia="+lnumAno+
		             "&mesReferencia="+lnumMes;
				}
				// pagina de indicadores para municipio
				if ( ( lnomPagina == "sigPerSocialEdIndicadoresRegiao.asp") && (lcodEscopo=='M') )
				{lnomPagina = "sigPerSocialEdIndicadores.asp";
		     document.location.href=lnomPagina+"?codRegiao="+lcodChave+"&anoReferencia="+lnumAno+
		             "&mesReferencia="+lnumMes;
				}
				
				// pagina de indicadores para municipio
				if ( ( lnomPagina == "sigPerSocialEdIndicadoresRegiao.asp") && (lcodEscopo=='E') )
				{lnomPagina = "sigPerSocialEdIndicadores.asp";
		     document.location.href=lnomPagina+"?codRegiao="+lcodChave+"&anoReferencia="+lnumAno+
		             "&mesReferencia="+lnumMes;
				}
				
				//Lê o mês de perfil segurança
				if (lnomPagina=="sigPerSocialSeguranca.asp"){
					try{
				    	lnumMes = lstMes.value;
					}catch(e){}
				}
				
		        if (lcodEscopo=='R')
		            document.location.href=lnomPagina+"?codRegiao="+lcodChave+"&anoReferencia="+lnumAno+
		             "&mesReferencia="+lnumMes;

		        if (lcodEscopo=='M')
		            document.location.href=lnomPagina+"?codMunicipio="+lcodChave+"&anoReferencia="+lnumAno+
		             "&mesReferencia="+lnumMes;
		            
				if (lcodEscopo=='E')
				    document.location.href=lnomPagina+"?anoReferencia="+lnumAno+
		             "&mesReferencia="+lnumMes;

			    return true;    
		    }
		}


	}    
	
        // atualizando telas centrais
        
        if (document.title == "sigPerSocialCabInfoGerais")
              {
			if (btnDadosGerais.alt=='1')
			{
				if (lcodEscopo=='E')
				    document.location.href="sigPerSocialSEGeral.asp";  
				if (lcodEscopo=='R')   
				    document.location.href="sigPerSocialSEGeralRegiao.asp"+"?codRegiao="+lcodChave;  
				if (lcodEscopo=='M')
					document.location.href="sigPerSocialSEGeralMunicipio.asp"+"?codMunicipio="+lcodChave;  
			} 
		    else if (window.parent.frames("perCentro").btnInfra.alt=='1')
		    {
				if (lcodEscopo=='E')
				    document.location.href="sigPerSocialSEInfra.asp";  
				if (lcodEscopo=='R')   
				    { var_regiao = lcodChave;
				    document.location.href="sigPerSocialSEInfraRegiao.asp"+"?codRegiao="+lcodChave;  
				    }
				if (lcodEscopo=='M')
					document.location.href="sigPerSocialSEInfraMunicipio.asp"+"?codRegiao="+lstRegiao.value+"&codMunicipio="+lcodChave;  
			} 
		   	
			else
			document.location.href="sigPerSocialSEGeral.asp";  
	    }
        else if (document.title == "sigPerSocialCabEconomico")
        {
//			if (window.parent.frames("perCentro").btnPAgricola.alt=='1')
			if (window.parent.frames("perCentro").btnPAgricola.className=='nav2')
			{ // PRODUÇÃO AGRICOLA
				if (lcodEscopo=='E')
				    document.location.href="sigPerSocialPAgricola.asp";  
				if (lcodEscopo=='R')   
				    document.location.href="sigPerSocialPAgricola.asp"+"?codRegiao="+lcodChave;  
				if (lcodEscopo=='M')
					document.location.href="sigPerSocialPAgricola.asp"+"?codMunicipio="+lcodChave;  
			} 
//		    else if (window.parent.frames("perCentro").btnPAnimal.alt=='1')
		    else if (window.parent.frames("perCentro").btnPAnimal.className=='nav2')
		    {// PRODUÇÃO ANIMAL
				if (lcodEscopo=='E')
				    document.location.href="sigPerSocialPAnimal.asp";  
				if (lcodEscopo=='R')   
				    { //var_regiao = lcodChave;
				    document.location.href="sigPerSocialPAnimal.asp"+"?codRegiao="+lcodChave;  
				    }
				if (lcodEscopo=='M')
					document.location.href="sigPerSocialPAnimal.asp"+"?codRegiao=0&codMunicipio="+lcodChave;  
			}
//			else if (window.parent.frames("perCentro").btnPMineral.alt=='1')
			else if (window.parent.frames("perCentro").btnPMineral.className=='nav2')			
		    {// PRODUÇÃO MINERAL
				window.hOrigem.value=lcodEscopo;
				if (lcodEscopo=='E'){
				    document.location.href="sigPerSocialEcoMinerioMunicipio.asp";  
				}
				if (lcodEscopo=='R'){ 
					var_regiao = lcodChave;
				    document.location.href="sigPerSocialEcoMinerioMunicipio.asp"+"?codRegiao="+lcodChave;  
				}
				if (lcodEscopo=='M'){
					document.location.href="sigPerSocialEcoMinerioMunicipio.asp"+"?codRegiao=0&codMunicipio="+lcodChave;  
				}
			}
			else 
			document.location.href="sigPerSocialPAgricola.asp";  
        }
        else if (document.title == "sigPerSocialCab")
        {	//Educação
			if (window.parent.frames("perCentro").btnEducacao.alt=='1')
			{
				if (lcodEscopo=='E')
				    document.location.href="sigPerSocialEd.asp";  
				else    
				    document.location.href="sigPerSocialEdRegMun.asp";  
			} 
			//Perfil Social Justiça
			if (window.parent.frames("perCentro").btnJustica.alt=='1' && lcodEscopo!='E')
			{
				alert('Só existem informações para o estado!');   
				mapPer_DoFSCommand('volta','',3); 
			}
        }
        else {}    
    }     

}

// Hook for Internet Explorer 

if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
		  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) 
{
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub mapPer_FSCommand(ByVal command, ByVal args)\n');
	document.write('  call mapPer_DoFSCommand(command, args,1)\n');
	document.write('end sub\n');
	document.write('</SCRIPT\> \n');
}
//-->

function carrega_municipio(pcodRegiao,pcodDivisao){
	var i = lstMunicipio.selectedIndex;
	var j = 0;
	lstMunicipio.length = 0;
	lstMunicipio.options[0] = new Option("Carregando...");
	lstMunicipio.selectedIndex = 0;
	//Proxylet.getURL("../ProgGoverno/sigCargaMunicipio.asp?codRegiao="+pcodRegiao+"&codDivisao="+pcodDivisao);
	//alert("Perfil/sigCargaMunicipioNovo.asp?codRegiao="+pcodRegiao+"&codDivisao="+pcodDivisao);
	makeRequest("Perfil/sigCargaMunicipioNovo.asp?codRegiao="+pcodRegiao+"&codDivisao="+pcodDivisao);
	//alert(ajaxRS[0][0]);
	while ((ajaxRS.length-1) > j){
		i = lstMunicipio.length;
		lstMunicipio.options[i] = new Option(ajaxRS[j][1],ajaxRS[j][0]);
		j++;
	}
	lstMunicipio.options[0] = null;
}

function mudaMapa(codOrigem){
    window.Status="Carregando. Aguarde ...";
	
    switch (lstRegiao.value){
      case "06":
         perMapa.mapPer.LoadMovie(0,"flash/economico0.swf");
         perMapa.mapPer.LoadMovie(1,"flash/economico1.swf");
		 perMapa.mapPer.BGColor = 'D7D7D7';
		 divMapa.style.background = '#D6D7D6';
		 carrega_municipio(06, '');  
         break;
	  case "63":
         perMapa.mapPer.LoadMovie(0,"flash/territorio_identidade.swf");
		 perMapa.mapPer.LoadMovie(1,"flash/territorio_identidade_brancos2.swf");
		 perMapa.mapPer.BGColor = '73A0D2';
		 divMapa.style.background = '#73A0D2';
		 carrega_municipio(63, '');  
         break;
    }

	lcommand = "volta";
	lcodChave = "";


	
    //Atualiza do frame de rodapé
    if (document.title!=""){
		try{
			txtMunicipio.value="0";
			txtRegiao.value="0";
		}
		catch (er){}		
    }
	

	
    lcodRegiao = "0";
    lcodMunicipio="0";

    if (lcodRegiao!='0'){
        lcodChave=lcodRegiao;
        lcommand="regiao";
    }
    if (lcodMunicipio!='0'){
        lcodChave=lcodMunicipio;
        lcommand="municipio";
    }
	mapPer_DoFSCommand(lcommand, lcodChave,2);
}

function atualiza_escopo(){
/*****************************************************************************************************

Esta função atualiza o flash, os nomes de município e região e os dados na tela principal.

*****************************************************************************************************/

	lcodChave = lstMunicipio.value;
	window.hOrigem.value='M';
 
	if (lcodChave != ""){

		lnomPagina = document.title;
		obj=document.body.style;
		obj.cursor='wait';
		
		lcodFrameRegiao = lcodChave.substr(0,3);
		lcodRegiao = lcodChave.substr(4,6);
		lcodMunicipio = parseInt(lcodChave.substr(11,6)); 
		lcodFrameMunicipio = parseInt(lcodChave.substr(18,3));
		txtMunicipio.value=lcodMunicipio;

		ldesSql= "select 0 num_frame,'' des_municipio,des_divisao_regional " +
				 "from divisao_regional where cod_divisao_regional="+parseInt(lcodRegiao);
		
		makeRequest("Perfil/sigCargaInfMapaNovo.asp?desSql="+ldesSql);

		// Inserido dia 04/04/2007 - Leo e Adson - Corrigindo o problema de navegação pelo menu
		/////////////////////////////////////////////////////////////////////////////////////////
		txtCodChave.value=lcodMunicipio; 
		/////////////////////////////////////////////////////////////////////////////////////////
		txtMunicipio.value=lcodMunicipio;
		txtRegiao.value=lcodRegiao;
		
		// Atualiza Mapa
		document.perMapa.mapPer.GotoFrame(parseInt(lcodFrameRegiao));			

		//Territorio Identidade - destacar municipio
		if (lstRegiao.value.substr(0,2)=="63"){
			document.perMapa.mapPer.TGotoFrame("_level1/", lcodFrameMunicipio);
			lblEscopo.innerText = ajaxRS[0][2];
		}
		//Eixo de desenvolvimento - destacar municipio
		if (lstRegiao.value.substr(0,2)==12) 
			document.perMapa.mapPer.tGotoLabel("selecao_de_municipio", lcodMunicipio);
		//Economico - destacar municipio
		if (lstRegiao.value.substr(0,2)=="06"){
			document.perMapa.mapPer.TGotoFrame("_level1/",lcodFrameMunicipio);
			lblEscopo.innerText = "Região "+ajaxRS[0][2];
		}
		//Turistico - destacar municipio
		if (lstRegiao.value.substr(0,2)=="13") 
			document.perMapa.mapPer.TSetProperty("/" + lcodMunicipio.toString(), 6, "90");	
		//Semi-Arido - destacar municipio
		if (lstRegiao.value=="11208"){
			perMapa.mapPer.GotoFrame(1);
			perMapa.mapPer.GotoFrame(5);
			perMapa.mapPer.TSetProperty("/" + lcodMunicipio.toString(), 6, "70");
		}
		
		lblMunicipio.innerText=lstMunicipio.item(lstMunicipio.selectedIndex).outerText;     
		perMapa.mapPer.tGotoLabel("nomes", lcodMunicipio);
		lstMunicipio.value = "";
		
		carrega_conteudo('M', txtMunicipio.value, txtPagina.value);
		obj.cursor='default';
	}else{
	  alert("Escolha um município para pesquisar !!");
	}
}


function carrega_conteudo(escopo, cod_chave, pag, voltou){
	rodape.style.display='none';
	listaRM.style.display='none';
	pagInicial.style.display='none';
	pagMeio.style.display='none';
//	pagMeio3.style.display='none';
//	pagMeio4.style.display='none';
	conteudo.style.display='block';
	conteudo2.style.display='block';
	// Corpo de Cotação Agrícola
	conteudo3.style.display='block';
	//conteudo4.style.display='block';
	
	conteudo2.style.width='530px';
	if(!voltou){
		try{
			_esc[contVoltar] = escopo;
			_cod[contVoltar] = cod_chave;
			_pag[contVoltar] = pag;
			contVoltar++;
		}catch(e){
			alert('Erro ao gravar historico!');
		}
	}
	
	switch(parseInt(pag)){
		case 1:// Informações Gerais / Dados Gerais
			if(escopo=='E') // ESTADO
				makeRequest('Perfil/sigCargaDadosGerais.asp?escopo='+escopo);
			if(escopo=='R') // REGIAO
				makeRequest('Perfil/sigCargaDadosGerais.asp?escopo='+escopo+'&cod_regiao='+cod_chave+'&des_regiao='+lblEscopo.outerText);
			if(escopo=='M') // MUNICIPIO
				makeRequest('Perfil/sigCargaDadosGerais.asp?escopo='+escopo+'&cod_municipio='+cod_chave);	
			pagMeio.innerHTML = ajaxRS[0][0];
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';
			
			break;
		case 2:// Informações Gerais / Infra Estrutura
		//alert(lstRegiao.value);
			if(escopo=='E')
				makeRequest('Perfil/sigCargaInfraEstrutura.asp?escopo='+escopo+'&cod_tipo_divisao='+lstRegiao.value);
			if(escopo=='R')
				makeRequest('Perfil/sigCargaInfraEstrutura.asp?escopo='+escopo+'&cod_regiao='+cod_chave+'&des_regiao='+lblEscopo.outerText+'&cod_tipo_divisao='+lstRegiao.value);
			if(escopo=='M')
				makeRequest('Perfil/sigCargaInfraEstrutura.asp?escopo='+escopo+'&cod_municipio='+cod_chave+'&cod_tipo_divisao='+lstRegiao.value);	
			pagMeio.innerHTML = ajaxRS[0][0];
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';
			
			break;
		case 3:// Perfil Social / Educação / Geral
			if(escopo=='E')
				makeRequest('Perfil/sigCargaSocialEduGeral.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&anoReferencia1='+txtAnoReferencia1.value);
			if(escopo=='R')
				makeRequest('Perfil/sigCargaSocialEduGeral.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&anoReferencia1='+txtAnoReferencia1.value+'&cod_regiao='+cod_chave+'&des_regiao='+lblEscopo.outerText+'&cod_tipo_divisao='+lstRegiao.value);
			if(escopo=='M')
				makeRequest('Perfil/sigCargaSocialEduGeral.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&anoReferencia1='+txtAnoReferencia1.value+'&cod_municipio='+cod_chave+'&cod_tipo_divisao='+lstRegiao.value);	
/*
			if(escopo=='R'){
				alert('Informações disponíveis apenas para o Estado da Bahia');
				mapPer_DoFSCommand('volta','',3);
			}
			if(escopo=='M'){
				alert('Informações disponíveis apenas para o Estado da Bahia');
				mapPer_DoFSCommand('volta','',3);
			}
*/
			pagMeio.innerHTML = ajaxRS[0][0];
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';
			
			break;
		case 4:// Perfil Social / Educação / Analfabetismo
			if(escopo=='E'){
				makeRequest('Perfil/sigCargaSocialEduAnalf.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value);
				pagMeio.innerHTML = ajaxRS[0][0];
			}
			if(escopo=='R'){
				alert('Só existem informações de analfabetismo em educação para o estado da Bahia');
				mapPer_DoFSCommand('volta','',3);
			}
			if(escopo=='M'){
				alert('Só existem informações de analfabetismo em educação para o estado da Bahia');
				mapPer_DoFSCommand('volta','',3);
			}
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';
			
			break;
		case 5:// Perfil Social / Educação / Indicadores
			if(escopo=='E')
				makeRequest('Perfil/sigCargaSocialEduIndica.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&anoReferencia1='+txtAnoReferencia1.value);
			if(escopo=='R'){
//				makeRequest('Perfil/sigCargaSocialEduIndica.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&anoReferencia1='+txtAnoReferencia1.value+'&cod_regiao='+cod_chave+'&des_regiao='+lblEscopo.outerText);
				alert('Informações disponíveis apenas para o Estado da Bahia');
				mapPer_DoFSCommand('volta','',3);
			}
			if(escopo=='M'){
//				makeRequest('Perfil/sigCargaSocialEduIndica.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&anoReferencia1='+txtAnoReferencia1.value+'&cod_municipio='+cod_chave);	
				alert('Informações disponíveis apenas para o Estado da Bahia');
				mapPer_DoFSCommand('volta','',3);
			}
			pagMeio.innerHTML = ajaxRS[0][0];
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';
			
			break;
		case 6:// Perfil Social / Educação / Docentes
			if(escopo=='E')
				makeRequest('Perfil/sigCargaSocialEduDocentes.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value);
			if(escopo=='R')
				makeRequest('Perfil/sigCargaSocialEduDocentes.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_regiao='+cod_chave+'&des_regiao='+lblEscopo.outerText);
			if(escopo=='M')
				makeRequest('Perfil/sigCargaSocialEduDocentes.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_municipio='+cod_chave);	
			pagMeio.innerHTML = ajaxRS[0][0];
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';
			
			break;
		case 7:// Perfil Social / Educação / Estabelecimentos
			if(escopo=='E')
				makeRequest('Perfil/sigCargaSocialEduEstab.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value);
			if(escopo=='R')
				makeRequest('Perfil/sigCargaSocialEduEstab.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_regiao='+cod_chave+'&des_regiao='+lblEscopo.outerText);
			if(escopo=='M')
				makeRequest('Perfil/sigCargaSocialEduEstab.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_municipio='+cod_chave);	
			pagMeio.innerHTML = ajaxRS[0][0];
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';
			
			break;
		case 8:// Perfil Social / Saude / Geral
			if(escopo=='E')
				makeRequest('Perfil/sigCargaSocialSaGeral.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value);
			if(escopo=='R')
				makeRequest('Perfil/sigCargaSocialSaGeral.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_regiao='+cod_chave+'&des_regiao='+lblEscopo.outerText);
			if(escopo=='M')
				makeRequest('Perfil/sigCargaSocialSaGeral.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_municipio='+cod_chave);	
			pagMeio.innerHTML = ajaxRS[0][0];
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';
			
			break;
		case 9:// Perfil Social / Saude / Doenças
			if(escopo=='E')
				makeRequest('Perfil/sigCargaSocialSaDoencas.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value);
			if(escopo=='R')
				makeRequest('Perfil/sigCargaSocialSaDoencas.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_regiao='+cod_chave+'&des_regiao='+lblEscopo.outerText);
			if(escopo=='M')
				makeRequest('Perfil/sigCargaSocialSaDoencas.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_municipio='+cod_chave);	
			pagMeio.innerHTML = ajaxRS[0][0];
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';
			
			break;
		case 10:// Perfil Social / Saude / Profissionais
			if(escopo=='E')
				makeRequest('Perfil/sigCargaSocialSaPro.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value);
			if(escopo=='R')
				makeRequest('Perfil/sigCargaSocialSaPro.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_regiao='+cod_chave+'&des_regiao='+lblEscopo.outerText);
			if(escopo=='M')
				makeRequest('Perfil/sigCargaSocialSaPro.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_municipio='+cod_chave);	
			pagMeio.innerHTML = ajaxRS[0][0];
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';
			
			break;
		case 11:// Perfil Social / Saude / Unidades de Saúde
			if(escopo=='E')
				makeRequest('Perfil/sigCargaSocialSaUnidades.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value);
			if(escopo=='R')
				makeRequest('Perfil/sigCargaSocialSaUnidades.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_regiao='+cod_chave+'&des_regiao='+lblEscopo.outerText);
			if(escopo=='M')
				makeRequest('Perfil/sigCargaSocialSaUnidades.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_municipio='+cod_chave);	
			pagMeio.innerHTML = ajaxRS[0][0];
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';
			
			break;
		case 12:// Perfil Social / Saude / Vacinação
			if(escopo=='E')
				makeRequest('Perfil/sigCargaSocialSaVacinacao.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value);
			if(escopo=='R')
				makeRequest('Perfil/sigCargaSocialSaVacinacao.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_regiao='+cod_chave+'&des_regiao='+lblEscopo.outerText);
			if(escopo=='M')
				makeRequest('Perfil/sigCargaSocialSaVacinacao.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_municipio='+cod_chave);	
			pagMeio.innerHTML = ajaxRS[0][0];
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';
			
			break;
		case 13:// Perfil Social / Justiça / Geral
			if(escopo=='E'){
				makeRequest('Perfil/sigCargaSocialJustica.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value);
				pagMeio.innerHTML = ajaxRS[0][0];
			}
			if(escopo=='R'){
				alert('Só existem informações de justiça para o estado da Bahia');
				mapPer_DoFSCommand('volta','',3);
			}
			if(escopo=='M'){
				alert('Só existem informações de justiça para o estado da Bahia');
				mapPer_DoFSCommand('volta','',3);
			}
			// Corpo de Cotação Agrícola
			conteudo.style.display='none';
			conteudo2.style.width='755px';
			conteudo2.style.align='center';
			//style ='width:700px;align=center;'
			conteudo3.style.display='none';
			//conteudo4.style.display='none';
			
			break;
		case 14:// Perfil Social / Justiça / Justiça Prisional
			if(escopo=='E'){
				makeRequest('Perfil/sigCargaSocialJuPrisional.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value);
				pagMeio.innerHTML = ajaxRS[0][0];
			}
			if(escopo=='R'){
				alert('Só existem informações de justiça para o estado da Bahia');
				mapPer_DoFSCommand('volta','',3);
			}
			if(escopo=='M'){
				alert('Só existem informações de justiça para o estado da Bahia');
				mapPer_DoFSCommand('volta','',3);
			}
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';
			
			break;
		case 15:// Perfil Social / Trabalho
			if(escopo=='E'){
				makeRequest('Perfil/sigCargaSocialTrabalho.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value);
				pagMeio.innerHTML = ajaxRS[0][0];
			}
			if(escopo=='R'){
				alert('Só existem informações de trabalho para o estado da Bahia');
				mapPer_DoFSCommand('volta','',3);
			}
			if(escopo=='M'){
				alert('Só existem informações de trabalho para o estado da Bahia');
				mapPer_DoFSCommand('volta','',3);
			}
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';
			
			break;
		case 16:// Perfil Social / Segurança
			if(escopo=='E')
				makeRequest('Perfil/sigCargaSocialSeguranca.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value);
			if(escopo=='R')
				makeRequest('Perfil/sigCargaSocialSeguranca.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_regiao='+cod_chave+'&des_regiao='+lblEscopo.outerText);
			if(escopo=='M')
				makeRequest('Perfil/sigCargaSocialSeguranca.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_municipio='+cod_chave);	
			pagMeio.innerHTML = ajaxRS[0][0];
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';

			
			break;
		case 17:// Perfil Economico / Produção Agricola
			if(escopo=='E')
				makeRequest('Perfil/sigCargaEcoPAgricola.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value);
			if(escopo=='R')
				makeRequest('Perfil/sigCargaEcoPAgricola.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_regiao='+cod_chave+'&des_regiao='+lblEscopo.outerText);
			if(escopo=='M')
				makeRequest('Perfil/sigCargaEcoPAgricola.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_municipio='+cod_chave);	
				
			pagMeio.innerHTML = ajaxRS[0][0];
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';

			break;
			
		case 18:// Perfil Economico / Produção Animal
			if(escopo=='E')
				makeRequest('Perfil/sigCargaEcoPAnimal.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value);
			if(escopo=='R')
				makeRequest('Perfil/sigCargaEcoPAnimal.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_regiao='+cod_chave+'&des_regiao='+lblEscopo.outerText);
			if(escopo=='M')
				makeRequest('Perfil/sigCargaEcoPAnimal.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_municipio='+cod_chave);	
			pagMeio.innerHTML = ajaxRS[0][0];
			
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';

			
			break;
		case 19:// Perfil Economico / Recursos Minerais / Por Recurso
/*			if(escopo=='E')
				makeRequest('Perfil/sigCargaEcoPAnimal.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value);
			if(escopo=='R')
				makeRequest('Perfil/sigCargaEcoPAnimal.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_regiao='+cod_chave+'&des_regiao='+lblEscopo.outerText);
			if(escopo=='M')
				makeRequest('Perfil/sigCargaEcoPAnimal.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_municipio='+cod_chave);	
			pagMeio.innerHTML = ajaxRS[0][0];
*/			listaRM.style.display='block';
			conteudo.style.display='none';
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';
			
			pesquisaMineral();
			break;
		case 20:// Perfil Economico / Recursos Minerais / Por Município 
			if(escopo=='E')
				makeRequest('Perfil/sigCargaEcoRMPorMunic.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_tipo_divisao='+lstRegiao.value);
			if(escopo=='R')
				makeRequest('Perfil/sigCargaEcoRMPorMunic.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_regiao='+cod_chave+'&des_regiao='+lblEscopo.outerText+'&cod_tipo_divisao='+lstRegiao.value);
			if(escopo=='M')
				makeRequest('Perfil/sigCargaEcoRMPorMunic.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_municipio='+cod_chave+'&cod_tipo_divisao='+lstRegiao.value);	
			pagMeio.innerHTML = ajaxRS[0][0];
			
			// Corpo de Cotação Agrícola
			conteudo3.style.display='none';
			//conteudo4.style.display='none';
			
			break;
			
			
		case 21:// Perfil Economico / Recursos Minerais / Por Município 
			//if(escopo=='E')
			//makeRequest('Perfil/sigCargaEcoCotAgri.asp?escopo='+escopo);
			//if(escopo=='R')
//				makeRequest('Perfil/sigCargaEcoRMPorMunic.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_regiao='+cod_chave+'&des_regiao='+lblEscopo.outerText);
//			if(escopo=='M')
//				makeRequest('Perfil/sigCargaEcoRMPorMunic.asp?escopo='+escopo+'&anoReferencia='+txtAnoReferencia.value+'&cod_municipio='+cod_chave);	
			//pagMeio.innerHTML = ajaxRS[0][0];
			//conteudo.style.display='none';
			conteudo.style.display='none';
			conteudo2.style.display='none';
			// Corpo de Cotação Agrícola
			conteudo3.style.display='block';
			//conteudo4.style.display='block';
			cotacaoAgricola();
			break;
		
		default:
			break;
	}
	pagMeio.style.display='block';
//	alert('Perfil/sigCargaDadosGerais.asp?escopo='+escopo+'&cod_municipio='+cod_chave);
}

function recargaAno(anoRef, anoRef1){
//	alert(hOrigem.value+' - '+txtCodChave.value+' - '+txtPagina.value);
	if(anoRef1)
		txtAnoReferencia1.value = anoRef1;
	txtAnoReferencia.value = anoRef;
	carrega_conteudo(hOrigem.value, txtCodChave.value, txtPagina.value);
	if(anoRef1)
		lstAno1.value = anoRef1;
	lstAno.value = anoRef;
}

function carga_dados(){
//alert(stsMenu.value);
	window.defaultStatus ="Carregando. Aguarde ...";
//    if (window.parent.frames("perRodape").document.title==""){
	<!-- Região Economica -->
		//carrega_municipio(06,'');
		//perMapa.mapPer.LoadMovie(0,"flash/economico0.swf");
		//perMapa.mapPer.LoadMovie(1,"flash/economico1.swf");
	<!-- Região Economica -->
	
	<!-- Território de identidade -->
	 	 perMapa.mapPer.LoadMovie(0,"flash/territorio_identidade.swf");
		 perMapa.mapPer.LoadMovie(1,"flash/territorio_identidade_brancos2.swf");
		 perMapa.mapPer.BGColor = '73A0D2';
		 divMapa.style.background = '#73A0D2';
		 carrega_municipio(63, '');  
	<!-- Território de identidade -->		 
	
	
//	carrega_conteudo('E', '', txtPagina.value);	 


	window.defaultStatus ="Concluído.";
/*        window.parent.frames("perRodape").location.href="sigPerSocialRodape.asp";
		window.parent.frames("perCentro").location.href="sigPerSocialCab.asp";
		
	}	
	else{
        if ((window.parent.frames("perCentro").document.title != "sigPerSocialCabInfoGerais.asp") &&
			(window.parent.frames("perCentro").document.title != "sigPerSocialCabEconomico.asp")){
			
        //lstRegiao.value = window.parent.frames("perRodape").txtMapa.value;
			lstRegiao.value = '06';
        	mudaMapa(2);
        }
    }    
*/
}


function cotacaoAgricola(){
	makeRequest('Perfil/sigCargaEcoCotAgri.asp');
	pagMeio1.innerHTML = ajaxRS[0][0];
}



function pesquisaMineral(){
	var codRecursoMineral;
	var des_recurso_mineral;
	codRecursoMineral = document.frmRecursoMineral.lstRecursoMineral.value;
	des_recurso_mineral = document.frmRecursoMineral.lstRecursoMineral.options[document.frmRecursoMineral.lstRecursoMineral.selectedIndex].text;
	if (codRecursoMineral != ""){
		document.frmRecursoMineral.txtRecursoMineral.value=codRecursoMineral;
		
//		alert('perfil/sigCargaEcoRMNoEstado.asp?codRecursoMineral='+codRecursoMineral+'&des_recurso_mineral='+des_recurso_mineral);
	
		makeRequest('perfil/sigCargaEcoRMNoEstado.asp?codRecursoMineral='+codRecursoMineral+'&des_recurso_mineral='+des_recurso_mineral);
		pagMeio.innerHTML = ajaxRS[0][0];
	}
}


function pagina_principal(){
	   window.parent.location.href ="index.asp";
}


function voltar(){
	try{
		
		if(contVoltar >= 2){
//			alert('Escopo: '+_esc[contVoltar-2]);
//			alert('Codigo: '+_cod[contVoltar-2]);
//			alert('Página: '+_pag[contVoltar-2]);


			carrega_conteudo(_esc[contVoltar-2], _cod[contVoltar-2], _pag[contVoltar-2], true);

//##############################
// MODIFICAR A POSIÇÃO DO MAPA. VER DEPOIS.
//##############################

/*
			if(_esc[contVoltar-2]!='E' || _esc[contVoltar-1]!='E'){
				mapPer_DoFSCommand('volta', 'volta', 1);
			}else{
				carrega_conteudo(_esc[contVoltar-2], _cod[contVoltar-2], _pag[contVoltar-2], true);
			}
*/

/*
			if(_esc[contVoltar-2]=='E')
				mapPer_DoFSCommand('volta', 'volta', 1);
			else if(_esc[contVoltar-2]=='R')
				mapPer_DoFSCommand('regiao', _cod[contVoltar-2], 1);
			else if(_esc[contVoltar-2]=='M')
				mapPer_DoFSCommand('municipio', _cod[contVoltar-2], 1);
*/			

//			document.perMapa.mapPer.GotoFrame(6);
//			document.perMapa.mapPer.TGotoFrame("_level1/",0);
//			document.perMapa.mapPer.TGotoFrame("selecao_de_municipio", 0);
//			document.perMapa.mapPer.TGotoFrame("nomes", 0);
			contVoltar--;
		}else{
			listaRM.style.display='none';
			pagInicial.style.display='block';
			pagMeio.style.display='none';
			conteudo.style.display='none';
			conteudo2.style.display='none';
			conteudo3.style.display='none';
		}

	}catch(e){
		alert('Erro: '+contVoltar);
	}
}

function efetuarLogin(){
	if(frmLogin.txtLogin.value != '' && frmLogin.txtSenha.value != ''){
		frmLogin.action='index_log.asp';
		frmLogin.submit();
	}
}

function checaEnter(e){
	if (window.event){
		keycode = window.event.keyCode;
	}
	else if (e){
		keycode = e.which;
	} 
	
	if(keycode==13)
		efetuarLogin();
	
}

function destaqueOver(municipio){
	window.status=municipio; 
//	spanDestaque.class='destLink';
}



function sobre_sig_Click(){
	
	makeRequest('Perfil/sigCargaSobreSigBahia.asp?')

//	divDestaque.innerHTML = "<strong>" + ajaxRS[0][0] + "</strong><br>" + ajaxRS[0][1] + "<br><br><input type='button' value='Fechar' style='width:*; border: 1px solid black;'>";
//	divDestaque.style.display = 'block';
	
	if(tituloSIG=="" && textoSIG==""){
		tituloSIG = spanTexto1.innerHTML;
		textoSIG = boxTexto1.innerHTML;
	}

	spanTexto1.innerHTML = "Sobre o SIG-BAHIA"
	boxTexto1.innerHTML =  ajaxRS[0][0] + "<br><br><input type='button' value='Fechar' style='width:*; border: 1px solid black;' onClick='voltaSIG();'>";
	
}


function destaqueClick(codMunicipio){
	
	makeRequest('Perfil/sigCargaDestaqueMunicipios.asp?cod_municipio='+codMunicipio)
//	divDestaque.innerHTML = "<strong>" + ajaxRS[0][0] + "</strong><br>" + ajaxRS[0][1] + "<br><br><input type='button' value='Fechar' style='width:*; border: 1px solid black;'>";
//	divDestaque.style.display = 'block';
	
	if(tituloSIG=="" && textoSIG==""){
		tituloSIG = spanTexto1.innerHTML;
		textoSIG = boxTexto1.innerHTML;
	}

	spanTexto1.innerHTML = "Destaque do município"
	boxTexto1.innerHTML =  "<strong>" + ajaxRS[0][0] + "</strong><br>" + ajaxRS[0][1] + "<br><br><input type='button' value='Fechar' style='width:*; border: 1px solid black;' onClick='voltaSIG();'>";
	
}


function noticiaClick(codNoticia){
	/*
	  Essa função exibe dados(conteúdo das notícias listadas)
	  retornados da página "sigCargaNoticia.asp"
	  Na DIV da página incial "SOBRE O SIG"
    */
	makeRequest('Perfil/sigCargaNoticia.asp?cod_noticia='+codNoticia)
//	divDestaque.innerHTML = "<strong>" + ajaxRS[0][0] + "</strong><br>" + ajaxRS[0][1] + "<br><br><input type='button' value='Fechar' style='width:*; border: 1px solid black;'>";
//	divDestaque.style.display = 'block';
	
	if(tituloSIG=="" && textoSIG==""){
		tituloSIG = spanTexto1.innerHTML;
		textoSIG = boxTexto1.innerHTML;
	}

	spanTexto1.innerHTML = "Conteúdo da notícia" 
	//boxTexto1.innerHTML =  "<strong>" + ajaxRS[0][0] + "</strong><br><br>" + ajaxRS[0][1] +  "<br><br> Fonte:&nbsp;" + ajaxRS[0][2] + "<br><br><br><br><input type='button' value='Fechar' style='width:*; border: 1px solid black;' onClick='voltaSIG();'>";
	boxTexto1.innerHTML =  "<strong>" + ajaxRS[0][0] + "</strong><br>" + ajaxRS[0][1] + "<br>Fonte:&nbsp;" + ajaxRS[0][2] + " (" + ajaxRS[0][3] + ")." +"<br><br><input type='button' value='Fechar' style='width:*; border: 1px solid black;' onClick='voltaSIG();'>";
}


function voltaSIG(){
	spanTexto1.innerHTML = tituloSIG;
	boxTexto1.innerHTML = textoSIG;
}

function mostraNoticias(codNoticia){
	
	var i = 0;
	
	while(i < notic.length){
		if(i == codNoticia){
			if(notic[i].style.display=='block')
				notic[i].style.display = 'none';
			else
				notic[i].style.display = 'block';
		}else{
			notic[i].style.display = 'none';
		}
		i++;
	}
}

function mostraTT(obj, x, y, tipo){

	
	var texto = '';
	var tam = 0;
	var ajuste = 0;
	
	if(screen.width==800)
		ajuste = 110;


	switch(tipo){
		case 1:
			texto = 'Produto Interno Bruto'; // PIB
			tam = 180-ajuste;
			break;
		case 2:
			texto = 'Índice de Desenvolvimento Humano'; // IDH
			tam = 170-ajuste;
			break;
		case 3:
			texto = 'Índice de Desenvolvimento Econômico'; // IDE
			tam = 175-ajuste;
			break;
		case 4:
			texto = 'Índice de Desenvolvimento Social'; // IDS
			tam = 170-ajuste;
			break;
	}

	if((x-tam)<=0)
		x = 5;
	else
		x = (x-tam);

	y = (y-80);

	obj.style.cursor = 'hand';
	dica.innerText = texto;
	dica.style.top = (y)+'px';
	dica.style.left = (x)+'px';
	dica.style.display = 'block';
	
}

function escondeTT(){
	
//	dica.innerText = '';
	dica.style.display = 'none';
	
}

function recargaDadoSTAno(tp,lstAnoST,lstAnoCred,lstMesST,lstMesCred)
{
//	alert(lstAnoCred);
	if (lstAnoST < 2006){			
			if (tp==1){
				alert("Para os anos menores que 2006, serão exibidos apenas os valores acumulados no ano.")
			}
			if (lstAnoCred < 2006){					
				//alert('sigCargaSocialTrabalho.asp?anoReferencia='+lstAnoST+'&mesReferencia=12&anoReferenciaCred='+lstAnoCred+'&mesReferenciaCred=12');
				
				makeRequest('perfil/sigCargaSocialTrabalho.asp?anoReferencia='+lstAnoST+'&mesReferencia=12&anoReferenciaCred='+lstAnoCred+'&mesReferenciaCred=12&teste=1');
				pagMeio.innerHTML = ajaxRS[0][0];								

			}else{
				//alert('sigCargaSocialTrabalho.asp?anoReferencia='+lstAnoST+'&mesReferencia=12&anoReferenciaCred='+lstAnoCred+'&mesReferenciaCred='+lstMesCred);
				makeRequest('perfil/sigCargaSocialTrabalho.asp?anoReferencia='+lstAnoST+'&mesReferencia=12&anoReferenciaCred='+lstAnoCred+'&mesReferenciaCred='+lstMesCred);								
				pagMeio.innerHTML = ajaxRS[0][0];										    	 
			}
	}else{	
			if (lstAnoCred < 2006){
				if (tp==2){
					alert("Para os anos menores que 2006, serão exibidos apenas os valores acumulados no ano.")
				}
				makeRequest('perfil/sigCargaSocialTrabalho.asp?anoReferencia='+lstAnoST+'&mesReferencia='+lstMesST+'&anoReferenciaCred='+lstAnoCred+'&mesReferenciaCred=12');
				pagMeio.innerHTML = ajaxRS[0][0];
			}else{	
				//alert('perfil/sigCargaSocialTrabalho.asp?anoReferencia='+lstAnoST+'&mesReferencia='+lstMesST+'&anoReferenciaCred='+lstAnoCred+'&mesReferenciaCred='+lstMesCred);
				makeRequest('perfil/sigCargaSocialTrabalho.asp?anoReferencia='+lstAnoST+'&mesReferencia='+lstMesST+'&anoReferenciaCred='+lstAnoCred+'&mesReferenciaCred='+lstMesCred);
				pagMeio.innerHTML = ajaxRS[0][0];
			}
	}
}

function ocultarComboDoMenu(tipo){
	
		//if (document.getElementyById('lstAnoST').value) {
 		  try {			  	
				//alert(document.getElementyById('lstAnoST').value);					
				//	document.all.referencia.style.visibility = 'hidden';	
					document.all.referencia.style.display = 'none';	
					if (tipo = 'on'){
						document.all.referencia2.style.display = 'block';													
					}else{
						document.all.referencia2.style.display = 'none';							
					}					
					//document.meio.referencia.style.display = 'none';						
					//alert("entrou");
					
					
			  	
		  } catch (e) {	
				//alert("erro");
		  }
		//}
		
}

function MostrarComboDoMenu(){
	
		//if (document.getElementyById('lstAnoST').value) {
 		  try {			  	
				//alert(document.getElementyById('lstAnoST').value);	
				//	document.all.referencia.style.visibility = 'visible';	
					document.all.referencia.style.display = 'block';
					document.all.referencia2.style.display = 'none';							
					//document.all.referencia2.style.display = 'none';	
					//document.meio.getElementyById('referencia').style.display = 'block';					
					//alert("entrou");			  	
		  } catch (e) {	
				//alert("erro");
		  }
		//}
		
}
