//** IntaNet Curriculo Lattes 
//** JR Sistemas
//** Copyright 2009

//** Excluir Dados Curriculares *****************************************************************************************************

function IWCL_ExcluirCurriculo(Expand)
{
 var CodCurriculos = new Array();
 
 var Index = 0;
 var Idx = 0;
 var CheckBox = document.getElementById("chk[" + Index + "]");
 
 while (CheckBox != null)
 {
  if (CheckBox.checked)
  {
   var ObjCurriculo = document.getElementById("Curriculo[" + Index + "].CodCurriculo");
   
   if ((ObjCurriculo != null))
   {
    CodCurriculos[Idx] = ObjCurriculo.value;
    Idx++;
   }
  }
 
  Index++;
  var CheckBox = document.getElementById("chk[" + Index + "]");
 }
 
 if (confirm('Deseja excluir os registros selecionados?'))
 try
 {
  ShowAguarde(true);  
  JRAjax.IWCL_ExcluirCurriculo(ID, SessionID, CodCurriculos, Expand, cbk_GenericCallBack);
 }
 catch(E)
 {
  ShowAguarde(false);
  return alert(AjaxNotFound); 
 }
}

//** Adicionar Curriculo ************************************************************************************************************

function IWCL_AdicionarCurriculo(FormName, Matricula, CodCurriculo, Expand)
{
 var lstEscolaridade = document.getElementById("lstEscolaridade");
 var chkCompletoNao  = document.getElementById("chkCompletoNao");
 var chkCompletoSim  = document.getElementById("chkCompletoSim");
 var lstAreaAtuacao  = document.getElementById("lstAreaAtuacao");
 var edtCurso        = document.getElementById("edtCurso");
 var edtInstituicao  = document.getElementById("edtInstituicao");
 var edtCidade       = document.getElementById("edtCidade");
 var edtUF           = document.getElementById("edtUF");
 var edtPais         = document.getElementById("edtPais");
 var edtAnoInicio    = document.getElementById("edtAnoInicio");
 var edtAnoConclusao = document.getElementById("edtAnoConclusao");
 var edtObservacao   = document.getElementById("edtObservacao");

 if (!FormName         ||
     !Matricula        ||
     !chkCompletoNao   ||
     !chkCompletoSim   ||
     !lstEscolaridade  ||
     !lstAreaAtuacao   ||
     !edtCurso         ||
     !edtInstituicao   ||
     !edtCidade        ||
     !edtUF            ||
     !edtPais          ||
     !edtAnoInicio     ||
     !edtAnoConclusao  ||
     !edtObservacao    
    )
  return alert(ComponentNotFound);
  
 CodCurriculo = ((CodCurriculo == null) || (CodCurriculo == NaN)) ? 0 : CodCurriculo;
 
 try
 {
  ShowAguarde(true);  
  JRAjax.IWCL_AdicionarCurriculo(ID, SessionID, FormName, Matricula, CodCurriculo, 
                                 lstEscolaridade.value, chkCompletoSim.checked, edtAnoInicio.value,
                                 edtAnoConclusao.value, lstAreaAtuacao.value, edtCurso.value,
                                 edtInstituicao.value, edtCidade.value, edtUF.value, edtPais.value,
                                 edtObservacao.value, Expand,
                                 cbk_GenericCallBack);
 }
 catch(E)
 {
  ShowAguarde(false);
  return alert(AjaxNotFound); 
 }
}

//**** Oculta campo caso a Formação Escolar não esteja concluida ****************************************************************

function CursoImcompletoClick(Sender)
{
 var Visible = Sender.form[Sender.name][0].checked;
 
 var divAnoConclusao = document.getElementById("divAnoConclusao");
 var edtAnoConclusao = document.getElementById("edtAnoConclusao");
 
 if (divAnoConclusao)
 {
  divAnoConclusao.style.visibility = (Visible) ? "visible" : "hidden";
 } 
 
 if (edtAnoConclusao && (!Visible))
 {
  edtAnoConclusao.value = "";
 }
}

//**** Adiciona Escola de Origem **************************************************************************************************

function IWCL_AddEscolaOrigem(CPF, Expand, FormName)
{
 var edtCidade = document.getElementById('edtCidade');
 var lstUF     = document.getElementById('lstUF');
 var edtEscola = document.getElementById('edtEscola');
 
 if (!edtCidade || !lstUF || !edtEscola)
 {
  return alert(ComponentNotFound);
 }
 
 try
 {
  JRAjax.IWCL_AddEscolaOrigem(ID, SessionID, CPF, Expand, edtCidade.value, lstUF.value, edtEscola.value, FormName, cbk_GenericCallBack)
 }
 catch(e)
 {
  return alert(AjaxNotFound);
 }
}
