function ProgCientifica() {
  var tot = 0;
  var tox = 0;
  var max = document.frmProgCientifica.area.length;
  missinginfo = "";

  for (var ida = 0; ida < max; ida++) {
      if (eval("document.frmProgCientifica.area[" + ida + "].checked") == true) {
         tot += 1;
         }
      }
  if (tot == 0) {
     missinginfo += "\n     -  Área a Enquadrar";
  }

/*
  if (document.frmProgCientifica.area[25].checked) {
     if (document.frmProgCientifica.outraarea.value == "") {
        missinginfo += "\n     -  Especificação da Área a Enquadrar";
     }
  }
*/

  if (Trim(document.frmProgCientifica.titcurso_1.value) == "") {
     missinginfo += "\n     -  Título do Curso";
  }
  
  if (Trim(document.frmProgCientifica.curriculo.value) == "") {
     missinginfo += "\n     -  Curriculum";
  }
   
  if (document.frmProgCientifica.curriculo.value.length > 4000) {
     missinginfo += "\n     -  Curriculum contém mais de 4000 Caracteres";
  }
  
  if (Trim(document.frmProgCientifica.programa_1.value) == "") {
     missinginfo += "\n     -  Programa";
  }
 
  if (document.frmProgCientifica.programa_1.value.length > 4000) {
     missinginfo += "\n     -  Programa contém mais de 4000 Caracteres";
  }

 if (missinginfo != "") {
    missinginfo = "Campo(s) de preenchimento obrigatório:\n" +
    "___________________________________          \n" +
    missinginfo + "\n___________________________________" +
    "\nFavor preencher o(s) campo(s) indicado(s)";
    alert(missinginfo);
    return false;
    }
 else {
       return true;
      }
}


function checkform(form) {
	var numElement = eval(document.getElementById(form).length);
	var i;
	var Obj = document.getElementById(form);
	var ObjAnt;
	var erro = "";
	var fistind = 0;

	for (i = 0; i < numElement; i++) {
		//valor do select
		var index = Obj.elements[i].selectedIndex;

		//Campo de Texto
		if ((Obj.elements[i].type == "text") && (Obj.elements[i].title != "") && (Trim(Obj.elements[i].value) == "")) {
			erro += "- " +Obj.elements[i].title+".\n";
		}
		
		if ((Obj.elements[i].type == "textarea") && (Obj.elements[i].title != "") && (Trim(Obj.elements[i].value) == "")) {
			erro += "- " +Obj.elements[i].title+".\n";
		}

		//Campo de select
		if ((Obj.elements[i].type == "select-one") && (Obj.elements[i].title != "") && (Obj.elements[i].options[index].index == 0)) {
			erro += "- " +Obj.elements[i].title+"\n";
		}
/*
		//Campo de radio
		if ((Obj.elements[i].type == "radio") && (Obj.elements[i].title != "") && (ObjAnt.elements[i].name != Obj.elements[i].name)) {
			if (GetIndex(Obj.elements[i]) < 0) { 
			   	ObjAnt.elements[i].name = Obj.elements[i].name;
				erro += "- " +Obj.elements[i].title+"\n";
			}
		}
*/		
		//Campo password
		if ((Obj.elements[i].type == "password") && (Obj.elements[i].title != "") && (Obj.elements[i].value == "")) {
			erro += "- " +Obj.elements[i].title+".\n";
		}

		if ((erro != "") && (fistind == 0)) {
			fistind = i;
		}
	}

	if (erro != "") {
		alert("Por favor verifique o(s) Campo(s):\n\n"+erro);
		Obj.elements[fistind].focus();
		return false;
	} else {
		return true;
	}
}



function Critica_est() {
 missinginfo = "";
    if (document.frmEstrangeiros.nome.value == "") {
       missinginfo += "\n     -  Name";
	   document.frmEstrangeiros.nome.focus();
    }
    if (document.frmEstrangeiros.endereco.value == "") {
       missinginfo += "\n     -  Address";
    }
    if (document.frmEstrangeiros.cidade.value == "") {
       missinginfo += "\n     -  City";
    }
    if (document.frmEstrangeiros.estado.value == "") {
       missinginfo += "\n     -  State";
    }
    if (document.frmEstrangeiros.pais.value == "") {
       missinginfo += "\n     -  Country";
    }
    if (document.frmEstrangeiros.cep.value == "") {
       missinginfo += "\n     -  Zip Code";
    }
    if (document.frmEstrangeiros.telefone.value == "") {
       missinginfo += "\n     -  Phone";
    }
    if (document.frmEstrangeiros.sexo.value == "") {
       missinginfo += "\n     -  Gender";
    }
    if (document.frmEstrangeiros.email.value == "") {
       missinginfo += "\n     -  E-Mail";
    }
    if (document.frmEstrangeiros.categoria.value == "") {
	    missinginfo += "\n     -  Category";
    }
    if ((document.frmEstrangeiros.categoria.value == 3) && (document.frmEstrangeiros.other.value == "")) {	
	    missinginfo += "\n     -  Which";
    }

if (missinginfo != "") {
    missinginfo = "Field(s) Obligator Fulfilling:\n" +
    "___________________________________          \n" +
    missinginfo + "\n___________________________________" +
    "\nFill(s) the field(s) indicated(s)";
    alert(missinginfo);
    return false;
    }
 else {
       return true;
      }
}

function CriticaTalentos() {
  var tot = 0;
  var tox = 0;
  var max = document.frmTrabalhoTalento.area.length;
  missinginfo = "";
  
  if (document.frmTrabalhoTalento.cat.value == "") {
     missinginfo += "\n     -  Qualificação do(a) Autor(a)";
  }

  if (document.frmTrabalhoTalento.orienta.value == "") {
     missinginfo += "\n     -  Orientador";
  }

  if (document.frmTrabalhoTalento.chknorma.checked == false) {
     missinginfo += "\n     -  Leitura das Instruções Gerais";
  }
  
  if (document.frmTrabalhoTalento.titulo.value == "") {
     missinginfo += "\n     -  Título da Orientação";
  }

  for (var idx = 0; idx < document.frmTrabalhoTalento.subcat.length; idx++) {
      if (eval("document.frmTrabalhoTalento.subcat[" + idx + "].checked") == true) {
         tox += 1;
      }
   }
  if (tox == 0) {
     missinginfo += "\n     -  Categoria";
  }

  for (var ida = 0; ida < max; ida++) {
      if (eval("document.frmTrabalhoTalento.area[" + ida + "].checked") == true) {
         tot += 1;
         }
      }
  if (tot == 0) {
     missinginfo += "\n     -  Área a Enquadrar";
  }
  

  if (Trim(document.frmTrabalhoTalento.resumo.value) == "") {
     missinginfo += "\n     -  Resumo";
  } /*else {
           if (document.frmTrabalhoTalento.resumo.value.length < 500) {
              missinginfo += "\n     -  Resumo com " + document.frmTrabalhoTalento.resumo.value.length + " dos 500 Caracteres Exigidos";
           }
  
           if (document.frmTrabalhoTalento.resumo.value.length > 2000) {
              missinginfo += "\n     -  Resumo contém mais de 2000 Caracteres";
           } 
  } */

if (missinginfo != "") {
    missinginfo = "Campo(s) de preenchimento obrigatório:\n" +
    "___________________________________          \n" +
    missinginfo + "\n___________________________________" +
    "\nFavor preencher o(s) campo(s) indicado(s)";
    alert(missinginfo);
    return false;
    }
  else {
       return true;
      }
}

function TrataTalento(objeto) {
  if (objeto.name == 'rgrad') {
	 if (objeto.value == 1) {
        document.getElementById('pgrad2').value = '';
        document.getElementById('igrad2').value = '';
        document.getElementById('pgrad1').disabled = false;
        document.getElementById('igrad1').disabled = false;
        document.getElementById('pgrad2').disabled = true;
        document.getElementById('igrad2').disabled = true;
		document.getElementById('pgrad1').focus();
	 } 
	 if (objeto.value == 2) {
        document.getElementById('pgrad1').value = '';
        document.getElementById('igrad1').value = '';
        document.getElementById('pgrad2').disabled = false;
        document.getElementById('igrad2').disabled = false;
        document.getElementById('pgrad1').disabled = true;
        document.getElementById('igrad1').disabled = true;
		document.getElementById('pgrad2').focus();
	 } 
  }
  
  if (objeto.name == 'respe') {
	 if (objeto.value == 1) {
        document.getElementById('pespe2').value = '';
        document.getElementById('iespe2').value = '';
        document.getElementById('aespe2').value = '';
        document.getElementById('pespe1').disabled = false;
        document.getElementById('iespe1').disabled = false;
        document.getElementById('pespe2').disabled = true;
        document.getElementById('iespe2').disabled = true;
        document.getElementById('aespe2').disabled = true;
		document.getElementById('pespe1').focus();
	 }
	 if (objeto.value == 2) {
        document.getElementById('pespe1').value = '';
        document.getElementById('iespe1').value = '';
        document.getElementById('pespe2').disabled = false;
        document.getElementById('iespe2').disabled = false;
        document.getElementById('aespe2').disabled = false;
        document.getElementById('pespe1').disabled = true;
        document.getElementById('iespe1').disabled = true;
		document.getElementById('pespe2').focus();
	 }
  }

  if (objeto.name == 'rmest') {
	 if (objeto.value == 1) {
        document.getElementById('pmest2').value = '';
        document.getElementById('imest2').value = '';
        document.getElementById('amest2').value = '';
        document.getElementById('pmest1').disabled = false;
        document.getElementById('imest1').disabled = false;
        document.getElementById('pmest2').disabled = true;
        document.getElementById('imest2').disabled = true;
        document.getElementById('amest2').disabled = true;
		document.getElementById('pmest1').focus();
	 }
	 if (objeto.value == 2) {
        document.getElementById('pmest1').value = '';
        document.getElementById('imest1').value = '';
        document.getElementById('pmest2').disabled = false;
        document.getElementById('imest2').disabled = false;
        document.getElementById('amest2').disabled = false;
        document.getElementById('pmest1').disabled = true;
        document.getElementById('imest1').disabled = true;
		document.getElementById('pmest2').focus();
	 }
  }

  if (objeto.name == 'rdout') {
	 if (objeto.value == 1) {
        document.getElementById('pdout2').value = '';
        document.getElementById('idout2').value = '';
        document.getElementById('adout2').value = '';
        document.getElementById('pdout1').disabled = false;
        document.getElementById('idout1').disabled = false;
        document.getElementById('pdout2').disabled = true;
        document.getElementById('idout2').disabled = true;
        document.getElementById('adout2').disabled = true;
		document.getElementById('pdout1').focus();
	 }
	 if (objeto.value == 2) {
        document.getElementById('pdout1').value = '';
        document.getElementById('idout1').value = '';
        document.getElementById('pdout2').disabled = false;
        document.getElementById('idout2').disabled = false;
        document.getElementById('adout2').disabled = false;
        document.getElementById('pdout1').disabled = true;
        document.getElementById('idout1').disabled = true;
		document.getElementById('pdout2').focus();
	 }
  }
}


function fireOnclick(objID) {
var target=document.getElementById(objID);
alert(target);
if(document.dispatchEvent) { // W3C
    var oEvent = document.createEvent( "MouseEvents" );
    oEvent.initMouseEvent("click", true, true,window, 1, 1, 1, 1, 1, false, false, false, false, 0, target);
    target.dispatchEvent( oEvent );
    }
else if(document.fireEvent) { // IE
    target.fireEvent("onclick");
    }    
}


function IsNumeric(sText) {
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}


function formSemPopup(objID) {
   if (document.dispatchEvent) { // W3C
      if (IsNumeric(objID) == false) {
		 document.getElementById(objID).click() 
	  } else {
		 window.location.href = document.getElementById(objID).href; 
	  }
   }
   else if (document.fireEvent) { // IE
           document.getElementById(objID).click();
        }    
}


function confirmSubmit() {
var agree = confirm("Confirma a Exclusão?                         ");
if (agree)
	return true ;
else
	return false ;
}


function EmptyKvaExtra() {
  if (document.frmEletricaHidraulica.kvaextra.value == "") {
     var agree=confirm("ATENÇÃO\n\nNão foi preenchido o campo de Energia Elétrica          \nAdicional. Confirma esta opção?");
	 if (agree) {
	    return true ;
	 } else {
	    return false }
  } else { return true }
}


function checkLogin() {
 missinginfo = "";
 if (document.frmInicio.cpf.value == "") {
    missinginfo += "\n     -  CPF não Informado";
	}
 if (document.frmInicio.senha.value == "") {
    missinginfo += "\n     -  Senha não Informada";
 }

 if (missinginfo != "") {
    missinginfo = "Campo de preenchimento obrigatório:\n" +
    "___________________________________          \n" +
    missinginfo + "\n___________________________________" +
    "\nFavor preencher o campo indicado";
    alert(missinginfo);

	if (document.frmInicio.cpf.value == "") {
        document.frmInicio.cpf.focus();
		}
	else {
	if (document.frmInicio.senha.value == "") {
        document.frmInicio.senha.focus();
		}
	  }
    return false;
    }
 else {
       return true;
      }
}


function checkCPFSnh() {
 missinginfo = "";
 if (document.frmInicio.cpfsnh.value == "") {
    missinginfo += "\n     -  CPF não Informado";
	}

 if (missinginfo != "") {
    missinginfo = "Campo de preenchimento obrigatório:\n" +
    "___________________________________          \n" +
    missinginfo + "\n___________________________________" +
    "\nFavor preencher o campo indicado";
    alert(missinginfo);
    document.frmInicio.cpfsnh.focus();
    return false;
    }
 else {
       return true;
      }
}


function TemEspaco(sText) {
   var Char;
   var IsSpace=false;
   for (i = 0; i < sText.length; i++) { 
      Char = sText.charAt(i); 
      if (Char == " ") {
         IsSpace = true;
         }
      }
   return IsSpace;
}


function checkPJ() {
 missinginfo = "";
 if ((document.frmIdPJ.cnpj.value == "") && (document.frmIdPJ.cpfpj.value == "")) {
    missinginfo += "\n     -  CNPJ / CPF";
	}

 if ((document.frmIdPJ.cnpj.value == "") && (document.frmIdPJ.cpfpj.value != "")) {
    document.frmIdPJ.cnpj.value = document.frmIdPJ.cpfpj.value;
 }
	
 if (IsNumeric(document.frmIdPJ.senha.value) == false) {
    document.frmIdPJ.senha.value = "";
    missinginfo += "\n     -  Número do Contrato Inválido";
 } else {
         if (document.frmIdPJ.senha.value == "") {
            missinginfo += "\n     -  Número do Contrato";
		 }
  }

 if (missinginfo != "") {
    missinginfo = "Campo de preenchimento obrigatório:\n" +
    "___________________________________          \n" +
    missinginfo + "\n___________________________________" +
    "\nFavor preencher o campo indicado";
    alert(missinginfo);
	if (document.frmIdPJ.cnpj.value == "") {
        document.frmIdPJ.cnpj.focus();
		}
	else {
	if (document.frmIdPJ.senha.value == "") {
        document.frmIdPJ.senha.focus();
		}
	  }
    return false;
    }
 else {
       return true;
      }
}


function CriticaCadastro() {
    var IsSpace=false;
    missinginfo = "";	
	document.getElementById("c01").style.color = "#666666";
	document.getElementById("c02").style.color = "#666666";
	document.getElementById("c03").style.color = "#666666";
	document.getElementById("c04").style.color = "#666666";
	document.getElementById("c05").style.color = "#666666";
	document.getElementById("c06").style.color = "#666666";
	document.getElementById("c07").style.color = "#666666";
	document.getElementById("c08").style.color = "#666666";
	document.getElementById("c09").style.color = "#666666";
	document.getElementById("c10").style.color = "#666666";
	document.getElementById("c11").style.color = "#666666";
	document.getElementById("c12").style.color = "#666666";
	document.getElementById("c13").style.color = "#666666";
	document.getElementById("c14").style.color = "#666666";
	document.getElementById("c15").style.color = "#666666";
	document.getElementById("c16").style.color = "#666666";
	document.getElementById("c17").style.color = "#666666";
	document.getElementById("c18").style.color = "#666666";
	document.getElementById("c19").style.color = "#666666";
	document.getElementById("c20").style.color = "#666666";
    if (document.frmCadastro.cpf.value == "") {
	   document.getElementById("c01").style.color = "red";
       missinginfo += "\n     -  CPF";
	   }
    if (document.frmCadastro.nasc.value == "") {
	   document.getElementById("c02").style.color = "red";
       missinginfo += "\n     -  Nascimento";
    }
    if (document.frmCadastro.nome.value == "") {
	   document.getElementById("c03").style.color = "red";
       missinginfo += "\n     -  Nome";
    }

    if (TemEspaco(document.frmCadastro.nome.value) == false) {
	   document.getElementById("c03").style.color = "red";
       missinginfo += "\n     -  Nome está Incompleto";
    }
	
    if ((document.frmCadastro.rdsexo[0].checked == false) && 
	    (document.frmCadastro.rdsexo[1].checked == false)) {
	   document.getElementById("c04").style.color = "red";
       missinginfo += "\n     -  Sexo";
    }
    if (document.frmCadastro.ecivil.value == "") {
	   document.getElementById("c05").style.color = "red";
       missinginfo += "\n     -  Estado Civil";
    }
    if ((document.frmCadastro.categoria[0].checked  == false) && 
	    (document.frmCadastro.categoria[1].checked  == false) &&
	    (document.frmCadastro.categoria[2].checked  == false) &&
		(document.frmCadastro.categoria[3].checked  == false) &&
		(document.frmCadastro.categoria[4].checked  == false) && 
		(document.frmCadastro.categoria[5].checked  == false) && 
		(document.frmCadastro.categoria[6].checked  == false) && 
		(document.frmCadastro.categoria[7].checked  == false) && 
		(document.frmCadastro.categoria[8].checked  == false) && 
		(document.frmCadastro.categoria[9].checked  == false) ) {
	   document.getElementById("c20").style.color = "red";
       missinginfo += "\n     -  Categoria";
    }
    if (document.frmCadastro.cep.value == "") {
	   document.getElementById("c06").style.color = "red";
       missinginfo += "\n     -  CEP";
    }
    if (document.frmCadastro.uf.value == "") {
	   document.getElementById("c07").style.color = "red";
       missinginfo += "\n     -  UF";
    }
    if (document.frmCadastro.tpend.value == "") {
	   document.getElementById("c08").style.color = "red";
       missinginfo += "\n     -  Tipo de Endereço";
    }
    if (document.frmCadastro.tplog.value == "") {
	   document.getElementById("c09").style.color = "red";
       missinginfo += "\n     -  Tipo de Logradouro";
    }
    if (document.frmCadastro.logradouro.value == "") {
	   document.getElementById("c10").style.color = "red";
       missinginfo += "\n     -  Logradouro";
    }
    if (document.frmCadastro.numero.value == "") {
	   document.getElementById("c11").style.color = "red";
       missinginfo += "\n     -  Número do Logradouro";
    }
    if (document.frmCadastro.bairro.value == "") {
	   document.getElementById("c12").style.color = "red";
       missinginfo += "\n     -  Bairro";
    }
    if (document.frmCadastro.cidade.value == "") {
	   document.getElementById("c13").style.color = "red";
       missinginfo += "\n     -  Cidade";
    }
    if ((document.frmCadastro.telcom.value == "") && (document.frmCadastro.telres.value == "") &&
	    (document.frmCadastro.telcel.value == "") && (document.frmCadastro.telfax.value == "") &&
	    (document.frmCadastro.email.value  == "")) {
	   document.getElementById("c14").style.color = "red";
	   document.getElementById("c15").style.color = "red";
	   document.getElementById("c16").style.color = "red";
	   document.getElementById("c17").style.color = "red";
       missinginfo += "\n     -  Pelo menos um Telefone ou E-Mail";
    }

    if (document.frmCadastro.senha.value != "jácadastrado") {
	   if (document.frmCadastro.senha.value == "") {
	      document.getElementById("c18").style.color = "red";
          missinginfo += "\n     -  Senha";
		  }
    }
    if (document.frmCadastro.confsnh.value != "jácadastrado") {
	   if (document.frmCadastro.confsnh.value == "") {
	      document.getElementById("c19").style.color = "red";
          missinginfo += "\n     -  Confirmação da Senha";
		  }
    }
    if (document.frmCadastro.senha.value != "jácadastrado") {
	   if (document.frmCadastro.senha.value != document.frmCadastro.confsnh.value) {
          missinginfo += "\n     -  Senhas não Conferem";
		  }
    }

 if (missinginfo != "") {
    missinginfo = "Campo(s) de preenchimento obrigatório:\n" +
    "___________________________________          \n" +
    missinginfo + "\n___________________________________" +
    "\nFavor preencher o(s) campo(s) indicado(s)";
    alert(missinginfo);
    return false;
    }
 else {
       return true;
      }
}


function CriticaVisitante() {
    var IsSpace=false;
    missinginfo = "";	
	document.getElementById("c01").style.color = "#919191";
	document.getElementById("c02").style.color = "#919191";
	document.getElementById("c03").style.color = "#919191";
	document.getElementById("c04").style.color = "#919191";
	document.getElementById("c05").style.color = "#919191";
	document.getElementById("c06").style.color = "#919191";
	document.getElementById("c07").style.color = "#919191";
	document.getElementById("c08").style.color = "#919191";
	document.getElementById("c09").style.color = "#919191";
	document.getElementById("c10").style.color = "#919191";
	document.getElementById("c11").style.color = "#919191";
	document.getElementById("c12").style.color = "#919191";
	document.getElementById("c13").style.color = "#919191";
	document.getElementById("c14").style.color = "#919191";
	document.getElementById("c15").style.color = "#919191";
	document.getElementById("c16").style.color = "#919191";

    if ((document.frmVisitante.rdsexo[0].checked == false) && 
	    (document.frmVisitante.rdsexo[1].checked == false)) {
	   document.getElementById("c01").style.color = "red";
       missinginfo += "\n     -  Sexo";
    }

    if (document.frmVisitante.nmconvida.value == "") {
	   document.getElementById("c02").style.color = "red";
       missinginfo += "\n     -  Nome Completo";
    } else {
           if (TemEspaco(document.frmVisitante.nmconvida.value) == false) {
	          document.getElementById("c02").style.color = "red";
              missinginfo += "\n     -  Nome está Incompleto";
		   }
    }
	
    if ((document.frmVisitante.categoria[0].checked  == false) && 
	    (document.frmVisitante.categoria[2].checked  == false) &&
		(document.frmVisitante.categoria[3].checked  == false) &&
		(document.frmVisitante.categoria[4].checked  == false) && 
		(document.frmVisitante.categoria[5].checked  == false) && 
		(document.frmVisitante.categoria[6].checked  == false) && 
		(document.frmVisitante.categoria[7].checked  == false) && 
		(document.frmVisitante.categoria[8].checked  == false) && 
		(document.frmVisitante.categoria[9].checked  == false) ) {
	   document.getElementById("c03").style.color = "red";
       missinginfo += "\n     -  Categoria";
    }
	
    if (document.frmVisitante.cep.value == "") {
	   document.getElementById("c04").style.color = "red";
       missinginfo += "\n     -  CEP";
    }
    if (document.frmVisitante.uf.value == "") {
	   document.getElementById("c05").style.color = "red";
       missinginfo += "\n     -  UF";
    }
    if (document.frmVisitante.tpend.value == "") {
	   document.getElementById("c06").style.color = "red";
       missinginfo += "\n     -  Tipo de Endereço";
    }
    if (document.frmVisitante.tplog.value == "") {
	   document.getElementById("c07").style.color = "red";
       missinginfo += "\n     -  Tipo de Logradouro";
    }
    if (document.frmVisitante.logradouro.value == "") {
	   document.getElementById("c08").style.color = "red";
       missinginfo += "\n     -  Logradouro";
    }
    if (document.frmVisitante.numero.value == "") {
	   document.getElementById("c09").style.color = "red";
       missinginfo += "\n     -  Número do Logradouro";
    }
    if (document.frmVisitante.bairro.value == "") {
	   document.getElementById("c10").style.color = "red";
       missinginfo += "\n     -  Bairro";
    }
    if (document.frmVisitante.cidade.value == "") {
	   document.getElementById("c11").style.color = "red";
       missinginfo += "\n     -  Cidade";
    }
    if ((document.frmVisitante.telcom.value == "") && (document.frmVisitante.telres.value == "") &&
	    (document.frmVisitante.telcel.value == "") && (document.frmVisitante.telfax.value == "") &&
	    (document.frmVisitante.email.value  == "")) {
	   document.getElementById("c12").style.color = "red";
	   document.getElementById("c13").style.color = "red";
	   document.getElementById("c14").style.color = "red";
	   document.getElementById("c15").style.color = "red";
	   document.getElementById("c16").style.color = "red";
       missinginfo += "\n     -  Pelo menos um Telefone ou E-Mail";
    }

 if (missinginfo != "") {
    missinginfo = "Campo(s) de preenchimento obrigatório:\n" +
    "___________________________________          \n" +
    missinginfo + "\n___________________________________" +
    "\nFavor preencher o(s) campo(s) indicado(s)";
    alert(missinginfo);
    return false;
    }
 else {
       return true;
      }
}


function CriticaMontadora() {
    missinginfo = "";
    if (document.frmMontadora.rsocial.value == "") {
       missinginfo += "\n     -  Razão Social";
	   }
    if (document.frmMontadora.cnpj.value == "") {
       missinginfo += "\n     -  CNPJ";
    }
/*
    if (document.frmMontadora.endereco.value == "") {
       missinginfo += "\n     -  Endereço";
    }
    if (document.frmMontadora.bairro.value == "") {
       missinginfo += "\n     -  Bairro";
    }
    if (document.frmMontadora.cidade.value == "") {
       missinginfo += "\n     -  Cidade";
    }
    if (document.frmMontadora.cep.value == "") {
       missinginfo += "\n     -  CEP";
    }
    if (document.frmMontadora.uf.value == "") {
       missinginfo += "\n     -  UF";
    }
*/	
    if (document.frmMontadora.telefone.value == "") {
       missinginfo += "\n     -  Telefone";
    }

 if (missinginfo != "") {
    missinginfo = "Campo(s) de preenchimento obrigatório:\n" +
    "___________________________________          \n" +
    missinginfo + "\n___________________________________" +
    "\nFavor preencher o(s) campo(s) indicado(s)";
    alert(missinginfo);
    return false;
    }
 else {
       return true;
      }
}


function CriticaSeguranca() {
    missinginfo = "";
    if (document.frmSeguranca.ddhhage.value == "") {
       missinginfo += "\n     -  Data(s) e Hora(s) de Atuação do Agente";
    }

 if (missinginfo != "") {
    missinginfo = "Campo(s) de preenchimento obrigatório:\n" +
    "___________________________________          \n" +
    missinginfo + "\n___________________________________" +
    "\nFavor preencher o(s) campo(s) indicado(s)";
    alert(missinginfo);
    return false;
    }
 else {
       return true;
      }
}


function TrataCategoria(objeto) {
  if (objeto.value == 3) {
	 document.getElementById("doc1").value = "Docente Orientador(a)";
  } else {
	   document.getElementById("doc1").value = "";
  }
   return true;
}


function CriticaMesa(tipo) {
  var tot = 0;
  var tox = 0;
  var max = document.frmTrabalho.area.length;
  missinginfo = "";
  if (document.frmTrabalho.cat.value == "") {
     missinginfo += "\n     -  Qaulificação do Autor";
  }

  if (document.frmTrabalho.nome1.value == "") {
     missinginfo += "\n     -  Autor(a)";
  }

  if (document.frmTrabalho.escola.value == "") {
     missinginfo += "\n     -  Instituição de Ensino";
  }

/*
  if (document.frmTrabalho.cat.value > 0) {
     if (document.frmTrabalho.cat.value != 1) {
	    if (document.frmTrabalho.orienta.value == "") {
           missinginfo += "\n     -  Docente Orientador(a)";
        }
	 }
  }
*/
  if (document.frmTrabalho.chknorma.checked == false) {
     missinginfo += "\n     -  Leitura das Instruções Gerais";
  }

/*
  if (tipo < 4) {
     for (var idx = 0; idx < document.frmTrabalho.subcat.length; idx++) {
         if (eval("document.frmTrabalho.subcat[" + idx + "].checked") == true) {
            tox += 1;
         }
      }
     if (tox == 0) {
        missinginfo += "\n     -  Categoria";
     }
  }
*/
 
  if (document.frmTrabalho.area.value == "") {
     missinginfo += "\n     -  Área a Enquadrar";
  }
  
  if (document.frmTrabalho.titulo.value == "") {
     missinginfo += "\n     -  Título";
  }

  if (Trim(document.frmTrabalho.resumo.value) == "") {
     missinginfo += "\n     -  Resumo";
  } else {
       if (document.frmTrabalho.resumo.value.length < 1200) {
          missinginfo += "\n     -  Resumo com " + document.frmTrabalho.resumo.value.length + " dos 1200 Caracteres Mínimos Exigidos";
       }
  
       if (document.frmTrabalho.resumo.value.length > 1400) {
          missinginfo += "\n     -  Resumo contém mais de 1400 Caracteres";
       }
  }

 if (missinginfo != "") {
    missinginfo = "Campo(s) de preenchimento obrigatório:\n" +
    "___________________________________          \n" +
    missinginfo + "\n___________________________________" +
    "\nFavor preencher o(s) campo(s) indicado(s)";
    alert(missinginfo);
    return false;
    }
 else {
       return true;
      }
}


function Trim(str) {
  if (str.length < 1) {
     return "";
     }
  str = RTrim(str);
  str = LTrim(str);
  if (str == "") {
     return "";
     }
  else {
     return str;
     }
} 


function RTrim(str) {
  var w_space = String.fromCharCode(32); 
  var v_length = str.length;
  var strTemp = "";
  if (v_length < 1) {
     return "";
     }
  var iTemp = v_length - 1;
  while (iTemp > -1) {
      if (str.charAt(iTemp) == w_space) {
         }
      else {
          strTemp = str.substring(0,iTemp +1);
      break;
      }
  iTemp = iTemp-1;
  } //End While
  return strTemp;
} //End Function


function LTrim(str) {
  var w_space = String.fromCharCode(32); 
  var v_length = str.length;
  var strTemp = "";
  if (v_length < 1) {
     return "";
     }
  var iTemp = 0;
  while (iTemp < v_length) {
      if (str.charAt(iTemp) == w_space) {
         }
     else {
         strTemp = str.substring(iTemp,v_length);
     break;
     }
  iTemp = iTemp + 1;
  } //End While
  return strTemp;
} //End Function


function validDate(obj){
  date=obj.value
  if (/[^\d/]|(\/\/)/g.test(date)) {
     obj.value=obj.value.replace(/[^\d/]/g,'');obj.value=obj.value.replace(/\/{2}/g,'/'); 
	 return;
  }
  if (/^\d{2}$/.test(date)) {
     obj.value=obj.value+'/'; 
	 return;
  }
  if (/^\d{2}\/\d{2}$/.test(date)) {
     obj.value=obj.value+'/'; 
	 return;
  }
  if (!/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(date)) return;

  test1=(/^\d{1,2}\/?\d{1,2}\/\d{4}$/.test(date));
  date=date.split('/');
  d=new Date(date[2],date[1]-1,date[0]);
  test2=(1*date[0]==d.getDate() && 1*date[1]==(d.getMonth()+1) && 1*date[2]==d.getFullYear());
  if (test1 && test2) return true;
  alert("Data Inválida");
  obj.value="";
  obj.focus();
  return false;
}

function checkContato() {
         missinginfo = "";
		 if (document.frmContato.meuemail.value == "") {
            missinginfo += "\n     -  E-mail";
			}
			   
         if (document.frmContato.meunome.value == "") {
            missinginfo += "\n     -  Nome";
            }  
	
         if (document.frmContato.assunto.value == "") {
            missinginfo += "\n     -  Assunto";
		    }
	
         if (document.frmContato.mensagem.value == "") {
            missinginfo += "\n     -  Mensagem";
		    }

         if (missinginfo != "") {
            missinginfo = "Campo(s) de preenchimento obrigatório:\n" +
            "___________________________________          \n" +
            missinginfo + "\n___________________________________" +
            "\nFavor preencher o(s) campo(s) indicado(s)!";
            alert(missinginfo);
            return false;
         }

 return true;
}


function validaEmail(email) {
  var pos, aux, pos2, dominio, carac, i
  email = email.toLowerCase() //gutoasp@pop.com.br

  if (email.indexOf("@",0) == -1 || email.length <= 10) {
     alert('"' + email + '"' + ' não é um endereço de e-mail válido.');
     return false;
	 }
  pos = email.indexOf("@",0);
  aux = email.substring(pos+1);

  if (aux.indexOf(".",0) < 3) {
     alert('"' + email + '"' + ' não é um endereço de e-mail válido.');
   	 return false;
	 }

  pos2 = aux.indexOf(".",0);
  dominio = aux.substr(0,pos2);

  if (dominio.length < 3) {
     alert('"' + email + '"' + ' não é um endereço de e-mail válido.');
     return false;
	 }

  carac = new Array("!","#","$","%","&","*","(",")","+","=","/","\\","|","?","'","\"","{","}","[","]","ª","º",":",",",";","§","°","<",">");
  for (i=0; i<carac.length; i++) {
     if (email.indexOf(carac[i],0) != -1) {
        alert('"' + email + '"' + ' não é um endereço de e-mail válido.');
	    return false;
		}
  }

  return true;
}


function getCheckedValue(radioObj) {
	if (!radioObj)
	   return "";
	var radioLength = radioObj.length;
	if (radioLength == undefined)
	   if (radioObj.checked)
		  return radioObj.value;
	   else
		  return "";
	for (var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


function GetIndex(Objeto) { 
  var indice=-1;
  for ( i=0; i < Objeto.length; i++ ) {   
      if (Objeto[i].checked) {
         indice = i;
	  }
  }
  return indice;
}  
  
  
function SetIndex(txt,cbo) { 
  var achou=false; 
  if (txt.value != "") { 
     for (x = 0; x < cbo.length; x++) { 
         if (cbo[x].value == txt.value) { 
            achou=true; 
            pos=x; 
            x=cbo.length; 
         } 
     } 
  } 

  if (achou == true) { 
     cbo.selectedIndex = pos; 
     return true; 
  } 
   else 
  { 
   cbo.selectedIndex = -1; 
   return false; 
  } 
} 


function maxLength(textAreaField, limit) {
  var ta = document.getElementById(textAreaField);
  if (ta.name == "resumo") {
	  document.getElementById('totcar').value = 'Resumo com ' + (ta.value.length = ta.value.length -1) + ' caractere(s)';
  }
  if (ta.value.length > limit) {
     ta.value = ta.value.substring(0, limit);
  }
}


function goPagina(url) {
  if (url.indexOf('?') > 0) {
     url = url + '&uUrl=' + new Date();
  } else { 
     url = url + '?uUrl=' + new Date();
	 }
 window.location = url;
//  window.location = 'mSuperior.asp'; 
//  window.open(url, 'Principal');
}


function ValidaMod10(objeto) {
	var i;
  	var mult = 2;
  	var soma = 0;
  	var s = "";
	var dv = objeto.substring(12, 13);
	Dado = objeto.substring(0,3) + objeto.substring(4,7) + objeto.substring(8,11);
	if ((Dado == '000000000') || (Dado == '222222222') || (Dado == '444444444') || 
	    (Dado == '555555555') || (Dado == '777777777') || (Dado == '999999999') ||
		(Dado.length < 9)) {
       alert(objeto + ' não é um código válido. ');
	   document.getElementById('cpf').value = "";
	   document.getElementById('cpf').focus();
       return false;
	   }
	else 
		{	
   		for (i=Dado.length-1; i>=0; i--) {
    		s = (mult * parseInt(Dado.charAt(i))) + s;
    		if (--mult<1) {
      			mult = 2;
      		}
    	}
  		for (i=0; i<s.length; i++) {
    		soma = soma + parseInt(s.charAt(i));
    	}
  		soma = soma % 10;
  		if (soma != 0) {
    		soma = 10 - soma;
    	}
  		if (soma == dv) {
		   return true;
		   }
		else
			{
			alert(objeto + ' não é um código válido. ');
	        document.getElementById('cpf').value = "";
	        document.getElementById('cpf').focus();
			return false;
			}
		}
}


function openWindow(x, y, cpfcod) {
   result = window.open('popup.asp?cpfcod=' + cpfcod + '&uUrl=' + new Date(), 'popup', 'height=150, width=400, outerWidth=410, left=' + x + ', top=' + y + ', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, copyhistory=no, directories=no');
   if (result != null) {
   }
   else {
         window.close();
         alert("Favor Desabiltar o Bloqueador de Popup do seu Navegador Web          ");
   }
}


function NewWindow(x, y) {
   result = window.open('/expositores/mapa_ciorj.asp?uUrl=' + new Date(), 'popupNew', 'height=480, width=630, outerWidth=640, left=' + x + ', top=' + y + ', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=yes, resizable=yes, fullscreen=no, copyhistory=no, directories=no');
   if (result != null) {
   }
   else {
         window.close();
         alert("Favor Desabiltar o Bloqueador de Popup do seu Navegador Web          ");
   }
}


function openComprovante(x, y, nome, categ) {
   result = window.open('/adesao/comprovante.asp?nome=' + nome + '&categ=' + categ + '&uUrl=' + new Date(), 'popupCompro', 'height=480, width=380, outerWidth=390, left=' + x + ', top=' + y + ', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, copyhistory=no, directories=no');
   if (result != null) {
   }
   else {
         window.close();
         alert("Favor Desabiltar o Bloqueador de Popup do seu Navegador Web          ");
   }
}


function openBoletoReal(x, y, nnumero) {
   result = window.open('/boleto/boleto-real.asp?nnumero=' + nnumero + '&uUrl=' + new Date(), 'popupReal', 'height=400, width=750, outerWidth=760, left=' + x + ', top=' + y + ', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=yes, fullscreen=no, copyhistory=no');
   if (result != null) {
   }
   else {
         window.close();
         alert("Favor Desabiltar o Bloqueador de Popup do seu Navegador Web          ");
   }
}


function openBoletoHsbc(x, y, nnumero) {
   result = window.open('/boleto/boleto-hsbc.asp?nnumero=' + nnumero + '&uUrl=' + new Date(), 'popupHSBC', 'height=400, width=750, outerWidth=760, left=' + x + ', top=' + y + ', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=yes, fullscreen=no, copyhistory=no');
   if (result != null) {
   }
   else {
         window.close();
         alert("Favor Desabiltar o Bloqueador de Popup do seu Navegador Web          ");
   }
}


function openBoletoSR(x, y, codclie, nnumero, newvenc, opcao) {
   result = window.open('/boleto/boleto_sr.asp?codclie=' + codclie + '&nnumero=' + nnumero + '&newvenc=' + newvenc + '&uUrl=' + new Date(), 'boletoSR', 'height=400, outerWidth=410, width=750, left=' + x + ', top=' + y + ', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=yes, fullscreen=no, copyhistory=no');
   if (result != null) { 
      if (opcao == 88) {
         goPagina('/default.asp?menu=8&opcao=8&acao=0');
	  }
   }
   else {
         window.close();
         alert("Favor Desabiltar o Bloqueador de Popup do seu Navegador Web          ");
   }
}

function openUpdTrabalho(x, y, tipo, evento, seq, cdautor, nmautor, titulo) {
   result = window.open('/administrador/update_trabalho.asp?tipo=' + tipo + '&evento=' + evento + '&seq=' + seq + '&cdautor=' + cdautor + '&nmautor=' + nmautor + '&titulo=' + titulo + '&uUrl=' + new Date(), 'UpdTrabalho', 'height=200, outerWidth=410, width=400, left=' + x + ', top=' + y + ', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, copyhistory=no');
   if (result != null) { 
   }
   else {
         window.close();
         alert("Favor Desabiltar o Bloqueador de Popup do seu Navegador Web          ");
   }
}


function openCurso(x, y, codcurso) {
   result = window.open('/inscricao/detalhe_curso.asp?codcurso=' + codcurso + '&uUrl=' + new Date(), 'popupCurso', 'height=480, width=600, outerWidth=610, left=' + x + ', top=' + y + ', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, copyhistory=no, directories=no');
   if (result != null) {
   }
   else {
         window.close();
         alert("Favor Desabiltar o Bloqueador de Popup do seu Navegador Web");
   }
}


function openMapa(x, y, endereco, cidade, uf) {
   result = window.open('/cadastro/mapa_endereco.asp?endereco=' + endereco + '&cidade=' + cidade + '&uf=' + uf + '&uUrl=' + new Date(), 'popupCurso', 'height=480, width=600, outerWidth=610, left=' + x + ', top=' + y + ', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, copyhistory=no, directories=no');
   if (result != null) {
   }
   else {
         window.close();
         alert("Favor Desabiltar o Bloqueador de Popup do seu Navegador Web");
   }
}


function openCertificado(x, y, tipo, chave) {
   result = window.open('/inscricao/certificado.asp?tipo=' + tipo + '&chave=' + chave + '&uUrl=' + new Date(), 'popupCerticado', 'height=465, width=800, outerWidth=810, left=' + x + ', top=' + y + ', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, copyhistory=no, directories=no, titlebar=no, channelmode=no');
   if (result != null) {
   }
   else {
         window.close();
         alert("Favor Desabiltar o Bloqueador de Popup do seu Navegador Web");
   }
}

function openCurriculo(x, y, texto, ministrador) {
   result = window.open('/inscricao/curriculo.asp?txtcurriculo=' + texto + '&ministrador=' + ministrador + '&uUrl=' + new Date(), 'popupCurriculo', 'height=200, width=600, outerWidth=610, left=' + x + ', top=' + y + ', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, copyhistory=no, directories=no, titlebar=no, channelmode=no');
   if (result != null) {
   }
   else {
         window.close();
         alert("Favor Desabiltar o Bloqueador de Popup do seu Navegador Web");
   }
}


function CountWords (this_field, show_word_count, show_char_count) {
	if (show_word_count == null) {
		show_word_count = true;
	}
	if (show_char_count == null) {
		show_char_count = false;
	}
	var char_count = this_field.value.length;
	var fullStr = this_field.value + " ";
	var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
	var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
	var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
	var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
	var splitString = cleanedStr.split(" ");
	var word_count = splitString.length -1;
	if (fullStr.length < 2) {
		word_count = 0;
	}
/*
	if (word_count <= 1) {
		wordOrWords = " Palavra";
	}
	else {
		wordOrWords = " Palavras";
	}
	if (char_count <= 1) {
		charOrChars = " Caracter";
	} else {
		charOrChars = " Caracteres";
	}
	if (show_word_count & show_char_count) {
		alert ("Quantidade de Palavras:          \n" + "    " + word_count + wordOrWords + "\n" + "    " + char_count + charOrChars + "          ");
	}
	else {
		if (show_word_count) {
			alert ("Quantidade de Palavras:          " + word_count + wordOrWords + "          ");
		}
		else {
			if (show_char_count) {
				alert ("Quantidade de Caracteres:          " + char_count + charOrChars + "          ");
      		}
   		}
	}
*/
	return word_count;
}


function CriticaAdesao() {
  var tot = 0;
  var max = document.frmAdesao.chkcategoria.length;
  missinginfo = "";
  if (document.frmAdesao.ret.value < 3) {
     alert("Já existe Adesão para o CPF " + document.frmAdesao.cpf.value + "\n\nAdesão com outro CPF, primeiro clique em SAIR          ");
     return false;
  }
  if (document.frmAdesao.chkcategoria.checked == true) {
     tot += 1;
  }
  for (var idx = 0; idx < max; idx++) {
      if (eval("document.frmAdesao.chkcategoria[" + idx + "].checked") == true) {
         tot += 1;
         }
      }
	  
  if (tot == 0) {
     missinginfo += "\n     -  Tipos de Adesão";
  }
  
  if (document.getElementById('tabadesao').style.display == 'list-item') {
	 if ((document.frmAdesao.vale1.value == "") || (document.frmAdesao.vale2.value == "") ||
	     (document.frmAdesao.vale3.value == "") || (document.frmAdesao.vale4.value == "")) {
        missinginfo += "\n     -  Código de Autorização"; 
	 }
  }
  
  if (missinginfo != "") {
     missinginfo = "Campo(s) de preenchimento obrigatório:\n" +
     "___________________________________          \n" +
     missinginfo + "\n___________________________________" +
     "\nFavor preencher o(s) campo(s) indicado(s)";
     alert(missinginfo);
     return false;
     }
  else {
        return true;
       }
}

function CriticaInscricao() {
  var tot = 0;
  var max = document.frmInscricao.chkcategoria.length;
/*
  if (document.frmInscricao.ret.value == 3) {
     alert("Inexiste Adesão para o CPF " + document.frmInscricao.cpf.value + "       ");
     return false;
  }
*/  
  missinginfo = "";
  if (document.frmInscricao.chkcategoria.checked == true) {
     tot += 1;
  }
  for (var idx = 0; idx < max; idx++) {
      if (eval("document.frmInscricao.chkcategoria[" + idx + "].checked") == true) {
         tot += 1;
         }
      } 
  
  if (tot == 0) {
     missinginfo += "\n     -  Curso(s) não Selecionado(s)";
  }
  
 if (missinginfo != "") {
    missinginfo = "Campo(s) de preenchimento obrigatório:\n" +
    "___________________________________          \n" +
    missinginfo + "\n___________________________________" +
    "\nFavor preencher o(s) campo(s) indicado(s)";
    alert(missinginfo);
    return false;
    }
 else {
       return true;
      }
}


function formatNumber(num,dec,thou,pnt,curr1,curr2,n1,n2) {
     var x = Math.round(num * Math.pow(10,dec));
	 if (x >= 0) n1=n2='';
	 var y = (''+Math.abs(x)).split('');
	 var z = y.length - dec; 
	 if (z<0) z--; 
	 for(var i = z; i < 0; i++) y.unshift('0');y.splice(z, 0, pnt); 
	 while (z > 3) {
	       z-=3; y.splice(z,0,thou);
     }
	 var r = curr1+n1+y.join('')+n2+curr2;
	 return r;
}


function Calcula(TheForm,Check,Objeto) {
    var dsc = 0;
	if (TheForm.desconto.value != "") {
	   dsc = TheForm.desconto.value.replace(",",".");
	   dsc = parseFloat(dsc.replace("R$ ",""));
    }
	
    if (Check == true) {
       TheForm.cmp.value = parseFloat(TheForm.cmp.value) + parseFloat(Objeto.value);
       }
    else {
       TheForm.cmp.value = parseFloat(TheForm.cmp.value) - parseFloat(Objeto.value);
    }
	
   TheForm.sdo.value = parseFloat(TheForm.cmp.value) - dsc;
	
   if (TheForm.cmp.value > 0) {
      TheForm.compras.value = formatNumber(TheForm.cmp.value,2,' ',',','R$ ','','-','');
	  TheForm.saldo.value   = formatNumber(TheForm.sdo.value,2,' ',',','R$ ','','-','');
      }
   else {
      TheForm.compras.value = "";
	  TheForm.saldo.value   = "";
   }
}


function Calcula_a(TheForm,Check,Objeto) {
    var dsc = 0;
	if (Objeto.value != "Gratuito") { 
       if (TheForm.desconto.value != "") {
	      dsc = TheForm.desconto.value.replace(",",".");
	      dsc = parseFloat(dsc.replace("R$ ",""));
       } 

      TheForm.cmp.value = parseFloat(Objeto.value);
      TheForm.sdo.value = parseFloat(TheForm.cmp.value) - dsc;
      TheForm.compras.value = formatNumber(TheForm.cmp.value,2,' ',',','R$ ','','-','');
	  TheForm.saldo.value   = formatNumber(TheForm.sdo.value,2,' ',',','R$ ','','-','');
	  document.getElementById("tabadesao").style.display = "none";
	  document.getElementById("tabvalor").style.display  = "list-item";
     }
    else {
      TheForm.compras.value = formatNumber(0,2,' ',',','R$ ','','-','');
	  TheForm.saldo.value   = formatNumber(0,2,' ',',','R$ ','','-','');
	  document.getElementById("tabvalor").style.display  = "none";
	  document.getElementById("tabadesao").style.display = "list-item";
	  document.getElementById("vale1").focus();
	}
}


function createXMLHTTP() {
   var ajax;
   try {
       ajax = new ActiveXObject("Microsoft.XMLHTTP");
   } 
   catch(e) {
     try {
         ajax = new ActiveXObject("Msxml2.XMLHTTP");
         alert(ajax);
     }
     catch(ex) {
       try {
           ajax = new XMLHttpRequest();
       }
       catch(exc) {
         alert("Esse browser não tem recursos para uso do Ajax");
         ajax = null;
       }
   }
   return ajax;
   }
 
   var arrSignatures = ["MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
   for (var i=0; i < arrSignatures.length; i++) {
       try {
           var oRequest = new ActiveXObject(arrSignatures[i]);
           return oRequest;
       } 
       catch (oError) {
       }
   }
   throw new Error("MSXML is not installed on your system.");
}


function GetWithAjax(MyForm,url,inputVar) {
   oHTTPRequest = null;
   // criacao do objeto XMLHTTP do arquivo ajax.js
   var oHTTPRequest = createXMLHTTP(); 
   oHTTPRequest.open("post", url, true); 
   //enviamos para a página que faz o select do que foi digitado e traz a lista preenchida.
   // para solicitacoes utilizando o metodo post deve ser acrescentado 
   // este cabecalho HTTP
   oHTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
   // a funcao abaixo e executada sempre que o estado do objeto muda (onreadystatechange)
   oHTTPRequest.onreadystatechange = function() {
      // o valor 4 significa que o objeto ja completou a solicitacao
      if (oHTTPRequest.readyState == 4) {// abaixo o texto gerado no arquivo executa.asp e colocado no div
         document.all.divEmpresa.innerHTML = oHTTPRequest.responseText;
      }
   }
   oHTTPRequest.send(inputVar);
}


function fechar(janela){
    document.getElementById(janela).style.display = 'none';
}

// Aqui definimos o tempo para fechar o pop-up
function abrir(tipo, evento, seq, cdautor, nmautor, titulo, status, exibir, flpainel){
    document.getElementById('cdautor').value = cdautor;
	document.getElementById('nmautor').value = nmautor;
	document.getElementById('titulo').value = titulo;
	document.getElementById('tipo').value = tipo;
	document.getElementById('evento').value = evento;
	document.getElementById('seq').value = seq;
	document.getElementById('flpainel').value = flpainel;
	if (exibir > 0) {
       document.getElementById('cdexibir').value = exibir;
	   SetIndex(document.getElementById('cdexibir'),document.getElementById('cmbexibir'));
	}
    document.frmMyWindow.situacao[status].checked = true;
    document.getElementById('mywindow').style.display = 'block';
//    setTimeout ("fechar()", 10000);
}

