
//**********************************************************************************************//
//																																															//	
// Pagina pra jogar as funções js para separar um pouco ja que aparentemente vão haver muitas		//
//																																															//
//**********************************************************************************************//

//funcao que constroi o objeto ajax de acordo com o tipo de navegador - uma "zona" devido a falta de padrao W3C
var xmlhttp = getXmlHttpRequest();
var controle;
var valor2;
var tipo2;

function getXmlHttpRequest(){
       if (window.XMLHttpRequest){
          return new XMLHttpRequest();
       }else if (window.ActiveXObject){
          try{
             return new ActiveXObject("Msxml2.XMLHTTP");
          }catch (e){
             try{
                return new ActiveXObject("Microsoft.XMLHTTP");
             }catch (e){}
          }
       }
 }
 
// Essa função faz a requisicao da pagina que deseja e inseri o seu conteudo estátio na div desejada, enquanto esta
// na requisicao ele exibe uma imagem de carregamento
function requisicao(_strNomePagina,divId)
{
 		  var d = new Date()
      xmlhttp.open("GET", _strNomePagina, true);
      xmlhttp.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1"); //
      xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
      xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
      xmlhttp.setRequestHeader("Pragma", "no-cache");
      xmlhttp.onreadystatechange = function()
      {
			   document.getElementById(divId).innerHTML="<div align=center style='margin:0px;padding:0px;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='imagens/loading.gif' />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>"
         if (xmlhttp.readyState==4)
		  	 		document.getElementById(divId).innerHTML = xmlhttp.responseText;
      }
      xmlhttp.send(null);
} 

function AbreJanela(arquivo,width,height)
{
   var janela =window.open(arquivo,'nenWin','width='+width+',height='+height+',resizable=yes,toolbar=no,status=no,menubar=no,scrollbars=no, personalbar=no');
	 if(janela == null){
	 		alert("A janela solicitada foi bloqueada pelo navegador. Desative o seu bloqueador de Pop-up para esse site");
	 }
}

function mostra_pesquisa(){
				document.getElementById("form_busca").style.display="block";	
}
/*index.asp*/
function mostra_assunto(valorPesquisa){
	 requisicao("retornos.asp?tipo=retorna_revistas&id_area="+valorPesquisa,"Revista_assunto"); }

/*cadastro_rev.asp*/
function Atualiza(valor){
 	 requisicao("retornos.asp?tipo=retorna_sub_areas&id_area="+valor,"sub_areas"); }
	
	 
/*revistas.asp*/
function mostraSumario(id_sumario){
	inicia();
   requisicao("retornos.asp?tipo=retorna_volume&id_sumario="+id_sumario,"SumariosClicado");}	 

/*inserir_instituicao.asp*/
function mostraInsti(){
	 requisicao("retornos.asp?tipo=retorna_insti","Instituicao");}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' deve ser um e-mail válido.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' deve conter apenas números.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' deve estar no intervalo de '+min+' a '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' é um campo obrigatório (*).\n'; }
  } if (errors) alert('Preencha todos os compos obrigatórios(s)');
  document.MM_returnValue = (errors == '');
}

function inicia(){
	controle = false;
	valor2 = "";
	tipo2 = "";
}
function mostraResumo(that){
	valor = that.value;
	that.options[0].selected = true;
	
	if(valor=="null" || valor =="none"){
		controle = false;
		document.getElementById(valor2).style.display = "none";
	}
	
	if(valor2 == ""){
		 valor2 = valor;
	}
	
//	window.alert("valor: "+valor+"valor2: "+valor2+"controle: "+controle);
	
	if(controle==false && valor!="null" && valor!="none"){
		if(valor2 == valor){
			controle = true;
			document.getElementById(valor2).style.display = "none";
			document.getElementById(valor).style.display = "inline";
		}else{
			controle = true;
			document.getElementById(valor2).style.display = "none";
			document.getElementById(valor).style.display = "inline";
			valor2 = valor;
		}
	}else{
		if(valor2 == valor){
			controle = false;
			document.getElementById(valor).style.display = "none";
		}else{
			controle = false;
			document.getElementById(valor2).style.display = "none";
		 	document.getElementById(valor).style.display = "inline";
		 	valor2 = valor;
		}
	}
}


