/* ajax */
var http_request = false;

function makeRequest(parametros) {
	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('Giving up :( inpossivel criar XMLHTTP instance');
	return false;
}
	var opt = parametros[0];
	var url = parametros[1];
	if(opt==1){//load aprovar artigo
		req=reqAprovarArtigo;
	}
	http_request.onreadystatechange = req;
    http_request.open('GET', url, true);
    http_request.send(null);
}
/* ajax */

function reqAprovarArtigo() {
	if (http_request.readyState == 4) {
    	if (http_request.status == 200) {
        	var r = http_request.responseText;
			if(r=='1'){
			document.getElementById("btAprovar").style.backgroundColor='#006600';
			document.getElementById("btAprovar").disabled=true;
			document.getElementById("btAprovar").value='aprovado';
			document.getElementById("janelaSenhaArtigo").style.display = "none";
			}else{
			document.getElementById("respSenhaArtigo").innerHTML='senha n&atilde;o aprovada!';
			}
        } else {
        	alert('Problemas durante o transporte dos dados.');
        }
    }
}

function eventoOver(id){
	var field = document.getElementById(id);
	field.style.borderColor='#8BA6C2';
}
function eventoOut(id){
	var field = document.getElementById(id);
	field.style.borderColor='#336699';
}

function loadTexto(titulo, historico){
	document.getElementById("titulo_estado").innerHTML=titulo;
	document.getElementById("historico_estado").innerHTML=historico;
}
function abreLink(local){
param = "toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes,fullscreen=no";
janela=window.open(local,"",param);
janela.focus();
if(janela == null){
	alert("ATENÇÃO VOCÊ ESTA USANDO UM BLOQUEADOR DE POPUPS DESABILITE-O PARA QUE O SISTEMA FUNCIONAR CORRETAMENTE");
}
}
function AbreVideo(id,nome){
w = screen.width;
h = screen.height;

//divide a resolução por 2, obtendo o centro do monitor
meio_1 = ((h/2)-(500/2));
meio_2 = ((w/2)-(650/2));

param = "scrollbars=yes,width=640,height=410,top="+meio_1+",left="+meio_2+" ";
janela=window.open("ovideo.php?id="+id+"&nome="+nome,"",param);
janela.focus();
	if(janela == null){
		alert("ATENÇÃO VOCÊ ESTA USANDO UM BLOQUEADOR DE POPUPS DESABILITE-O PARA QUE O SISTEMA FUNCIONAR CORRETAMENTE");
	}
}

function AbreWebCam(local,nome) {
	w = screen.width;
	h = screen.height;
	//divide a resolução por 2, obtendo o centro do monitor
	m1 = ((h/2)-(600/2));
	m2 = ((w/2)-(800/2));
param = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=800,height=600,top="+m1+",left="+m2+""	
janela=window.open(local,nome,param); 
janela.focus();
	if(janela == null){
		alert("ATENÇÃO VOCÊ ESTA USANDO UM BLOQUEADOR DE POPUPS DESABILITE-O PARA QUE O SISTEMA FUNCIONAR CORRETAMENTE");
	}
} 

var gArrResumoPorUF = {};
         
             gArrResumoPorUF["AC"] = {nomeUF:"ACRE", flagAtende:"f", qtdBases:'&nbsp;', qtdOtraCoisa:'&nbsp;'};
         
             gArrResumoPorUF["AL"] = {nomeUF:"ALAGOAS", flagAtende:"t", qtdBases:'01', qtdOtraCoisa:'&nbsp;'};
         
             gArrResumoPorUF["AP"] = {nomeUF:"AMAP&Aacute;", flagAtende:"f", qtdBases:'&nbsp;', qtdOtraCoisa:'&nbsp;'};
         
             gArrResumoPorUF["AM"] = {nomeUF:"AMAZONAS", flagAtende:"t", qtdBases:'01', qtdOtraCoisa:6064};
         
             gArrResumoPorUF["BA"] = {nomeUF:"BAHIA", flagAtende:"t", qtdBases:'04', qtdOtraCoisa:26856};
         
             gArrResumoPorUF["CE"] = {nomeUF:"CEAR&Aacute;", flagAtende:"t", qtdBases:'&nbsp;', qtdOtraCoisa:'&nbsp;'};
         
             gArrResumoPorUF["ES"] = {nomeUF:"ESP&Iacute;RITO SANTO", flagAtende:"t", qtdBases:'05', qtdOtraCoisa:6435};
         
             gArrResumoPorUF["GO"] = {nomeUF:"GOI&Aacute;S", flagAtende:"t", qtdBases:'01', qtdOtraCoisa:14356};
         
             gArrResumoPorUF["MA"] = {nomeUF:"MARANH&Atilde;O", flagAtende:"t", qtdBases:'01', qtdOtraCoisa:14217};
         
             gArrResumoPorUF["MT"] = {nomeUF:"MATO GROSSO", flagAtende:"t", qtdBases:'04', qtdOtraCoisa:8053};
         
             gArrResumoPorUF["MS"] = {nomeUF:"MATO GROSSO DO SUL", flagAtende:"t", qtdBases:'03', qtdOtraCoisa:4932};
         
             gArrResumoPorUF["MG"] = {nomeUF:"MINAS GERAIS", flagAtende:"t", qtdBases:'04', qtdOtraCoisa:55003};
         
             gArrResumoPorUF["PA"] = {nomeUF:"PAR&Aacute;", flagAtende:"t", qtdBases:'01', qtdOtraCoisa:12989};
         
             gArrResumoPorUF["PB"] = {nomeUF:"PARA&Iacute;BA", flagAtende:"t", qtdBases:'01', qtdOtraCoisa:8672};
         
             gArrResumoPorUF["PR"] = {nomeUF:"PARAN&Aacute;", flagAtende:"t", qtdBases:'37', qtdOtraCoisa:23689};
         
             gArrResumoPorUF["PE"] = {nomeUF:"PERNAMBUCO", flagAtende:"t", qtdBases:'01', qtdOtraCoisa:12700};
         
             gArrResumoPorUF["PI"] = {nomeUF:"PIAU&Iacute;", flagAtende:"t", qtdBases:'&nbsp;', qtdOtraCoisa:7394};
         
             gArrResumoPorUF["RJ"] = {nomeUF:"RIO DE JANEIRO", flagAtende:"t", qtdBases:'01', qtdOtraCoisa:14567};
         
             gArrResumoPorUF["RN"] = {nomeUF:"RIO GRANDE DO NORTE", flagAtende:"t", qtdBases:'01', qtdOtraCoisa:6127};
         
             gArrResumoPorUF["RS"] = {nomeUF:"RIO GRANDE DO SUL", flagAtende:"t", qtdBases:'01', qtdOtraCoisa:20974};
         
             gArrResumoPorUF["RO"] = {nomeUF:"ROND&Ocirc;NIA", flagAtende:"t", qtdBases:'01', qtdOtraCoisa:4213};
         
             gArrResumoPorUF["RR"] = {nomeUF:"RORAIMA", flagAtende:"f", qtdBases:'&nbsp;', qtdOtraCoisa:'&nbsp;'};
         
             gArrResumoPorUF["SC"] = {nomeUF:"SANTA CATARINA", flagAtende:"t", qtdBases:'02', qtdOtraCoisa:12850};
         
             gArrResumoPorUF["SP"] = {nomeUF:"S&Atilde;O PAULO", flagAtende:"t", qtdBases:'38', qtdOtraCoisa:59449};
         
             gArrResumoPorUF["SE"] = {nomeUF:"SERGIPE", flagAtende:"t", qtdBases:'01', qtdOtraCoisa:4175};
         
			 gArrResumoPorUF["TO"] = {nomeUF:"TOCANTINS", flagAtende:"f", qtdBases:'&nbsp;', qtdOtraCoisa:'&nbsp;'};
         
             gArrResumoPorUF["BR"] = {nomeUF:"BRASIL", flagAtende:"t", qtdBases:'&nbsp;', qtdOtraCoisa:'&nbsp;'};
         
         
         function visualizarResumoBasePorUF(pSiglaUF) {			 
			//
			
			document.getElementById("divQuadroInfoResumoPorUF").style.display = "";
            document.getElementById("lblNomeUFSelecionada").innerHTML = pSiglaUF + " - " + gArrResumoPorUF[pSiglaUF].nomeUF;
			
            if(gArrResumoPorUF[pSiglaUF].flagAtende=='t'){
				atendemos="<span style='color:#008000;'>Área atendida</span>";
			}else{
				atendemos="<span style='color:#EB5334;'>Área não atendida!</span>";
			}
			
			if(pSiglaUF=='BR'){
				document.getElementById("exibeQuant").style.display = "none";
				atendemos="";
				
			}else{
				document.getElementById("exibeQuant").style.display = "";
			}
			
			document.getElementById("lblAtende").innerHTML = atendemos;
			
            document.getElementById("lblQtdBases").innerHTML = gArrResumoPorUF[pSiglaUF].qtdBases;
            //document.getElementById("lblQtdOtraCoisa").innerHTML = '';/*gArrResumoPorUF[pSiglaUF].qtdOtraCoisa;*/
			
			
        }
		
		function fechaPop(){
			document.getElementById("fundo").style.display = "none";
			document.getElementById("popUp").style.display = "none";
			//cria o flash novamente
			AC_FL_RunContent('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','id','test','width','756','height','51','title','mapa_topo','src','imagens/mapa_topo','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','imagens/mapa_topo' );	
			abre_artigos('1','1','1',0); //abre pagina principal
		}
		function removeFlash(){
			var element = document.getElementById("flashTopo");
			while (element.firstChild) {
  				element.removeChild(element.firstChild);
			}
				
		}
		function submitForm(sigla, local){
			return false;
		}
		function janelaSenhaArtigo(){
			document.getElementById("janelaSenhaArtigo").style.display = "block";
			document.getElementById("passSenhaArtigo").focus();
		}
		function aprovaArtigo(id){
			var senha=document.getElementById("passSenhaArtigo").value;
			parametros = Array(2);
			parametros[0] = 1;//qual req
			parametros[1] = "adm/control_eventos.php"
							+"?id="+id
							+"&senha="+senha;
			makeRequest(parametros);			
		}
		
