var NUM_CHARS = '0123456789';

function ValidateCNPJ(valuePar) {
  var mv;
  var d1, r, pd, sd;
  var tmpValue, value;

  value = valuePar;

  tmpValue='';
  for (var i=0; i<value.length; i++)
    if (NUM_CHARS.indexOf(value.charAt(i))!=-1)
      tmpValue = tmpValue + value.charAt(i);

  value = tmpValue;

  if (value.length==15)
    value = value.substring(1,15);

  if (value.length!=14)
    return false;
  else if (value=='00000000000000')
    return true;
  else {
    for (var i=0; i<14; i++)
      if (NUM_CHARS.indexOf(value.charAt(i))==-1)
        return false;

    mv = '543298765432';
    d1 = 0; for (var i=0; i<12; i++)  d1 += parseInt(value.charAt(i)) * parseInt(mv.charAt(i));
    r = d1 - parseInt(d1/11) * 11;
    pd = r<2 ? 0 : 11 - r;

    mv = '6543298765432';
    d1 = 0; for (var i=0; i<13; i++)  d1 += parseInt(value.charAt(i)) * parseInt(mv.charAt(i));
    r = d1 - parseInt(d1/11) * 11;
    sd = r<2 ? 0 : 11 - r;

    return (pd+''+sd==value.substring(12,14));
  }
}

function ValidateCPF(valuePar) {

  value = valuePar;

  tmpValue='';
  for (var i=0; i<value.length; i++)
    if (NUM_CHARS.indexOf(value.charAt(i))!=-1)
      tmpValue = tmpValue + value.charAt(i);

  value = tmpValue;

  if (value.length!=11)
    return false;
  else {
    for (var i=0; i<11; i++)
      if (NUM_CHARS.indexOf(value.charAt(i))==-1)
        return false;

    var d1 = 0; for (var i=0; i<9; i++) d1 += parseInt(value.charAt(i)) * (i+1);
    d1 %= 11; if (d1 == 10) d1 = 0;

    var d2 = 0; for (var i=1; i<9; i++) d2 += parseInt(value.charAt(i)) * i;
    d2 += d1 * 9; d2 %= 11; if (d2 == 10) d2 = 0;

    return (d1+''+d2==value.substring(9,11));
  }
}

function ValidateCNPJCPF(value) {

  var Temp;

  Temp = '';

  for (var i=0; i<value.length; i++)
    if (NUM_CHARS.indexOf(value.charAt(i))!=-1)
      Temp = Temp + value.charAt(i);

  value = Temp;

  if (value.length == 11)
    return ValidateCPF(value);
  else if (value.length == 14)
    return ValidateCNPJ(value);
  else
    return false;
}

function y2k(number) {
  return (number<1000) ? number + 1900 : number;
}

function ValidateDate(value) {

  if ( (value.length != 10) || (value.substring(2,3) != sep) || (value.substring(5,6) != sep) )
    return false;
  else {
    var date  = value.substring(0,2);
    var month = value.substring(3,5);
    var year  = value.substring(6,10);
    var test  = new Date(year,month-1,date);

    if ( (year != y2k(test.getYear())) || (month-1 != test.getMonth()) || (date != test.getDate()) )
      return false;
  }
}

function ValidateEmail(value) {
  return ( (value.length>3) && (value.indexOf('@')>0) );
}

function convertToUpper (field)
{
  field.value=field.value.toUpperCase();
}

function convertToLower (field)
{
  field.value=field.value.toLowerCase();
}

function icListMarkAll(){
  for (var i=0;i<document.icList.elements.length;i++)
  {
    var e = document.icList.elements[i];
    if ((e.name != 'icbMarkAll') && (e.type=='checkbox'))
    {
      e.checked = document.icList.icbMarkAll.checked;
    }
  }
}

function ShowWindowCad(link,windowname)
{
  window.open(link,windowname,'top=20, left=50, width=700, height=500, toolbar=1, status=1, menubar=0, location=0, directories=0, scrollbars=1, resizable=1');
}

function ShowWindowCadNotHaveMenu(link,windowname)
{
  window.open(link+'&NotHaveMenu=S',windowname,'top=20, left=50, width=700, height=500, toolbar=1, status=1, menubar=0, location=0, directories=0, scrollbars=1, resizable=1');
}

function ShowWindow(link,width,height,top,left)
{
  window.open(link,'','top='+top+', left='+left+', width='+width+', height='+height+', toolbar=0, status=0, menubar=0, location=0, directories=0, scrollbars=0, resizable=0');
}

function ShowWindowNotHaveMenu(link,width,height,top,left)
{
  window.open(link+'&NotHaveMenu=S','','top='+top+', left='+left+', width='+width+', height='+height+', toolbar=0, status=0, menubar=0, location=0, directories=0, scrollbars=0, resizable=0');
}

function ShowWindowDefineHW(link,height,width)
{
  window.open(link,'','top=100, left=100, width='+width+', height='+height+', toolbar=0, status=0, menubar=0, location=0, directories=0, scrollbars=1, resizable=0');
}

function ShowWindowDefineHWNotHaveMenu(link,height,width)
{
  window.open(link+'&NotHaveMenu=S','','top=100, left=100, width='+width+', height='+height+', toolbar=0, status=0, menubar=0, location=0, directories=0, scrollbars=1, resizable=0');
}

function ShowNewWindow(link)
{
  window.open(link,'','top=0, left=0, width=800, height=600, toolbar=1, status=1, menubar=0, location=0, directories=0, scrollbars=1, resizable=1');
}

function ShowNewWindowNotHaveMenu(link)
{
  window.open(link+'&NotHaveMenu=S','','top=0, left=0');
}

function ShowHelp(link)
{
  var w = 480, h = 340;

  if (document.all) {
     /* the following is only
        available after onLoad */
     w = document.body.clientWidth;
     h = document.body.clientHeight;
  }
  else if (document.layers) {
     w = window.innerWidth;
     h = window.innerHeight;
  }

  var popW = 300, popH = 200;

  var leftPos = (w-popW)/2, topPos = (h-popH)/2;

  msgWindow = window.open(link, 'windowduvida', 'top='+topPos+', left='+leftPos+', width=332, height=129, toolbar=0, status=0, menubar=0, location=0, directories=0, scrollbars=0, resizable=0');
  if (msgWindow.opener == null)
    msgWindow.opener = self;
}

function ClearDesc(Desc)
{
  var Result;
  var i;
  var LengthString;

  LengthString = Desc.length;
  Result = '';

  for (i=0; i<=LengthString; i++)
  {
    if (Desc.charAt(i)!='+')
      Result = Result + Desc.charAt(i);
    else
      Result = Result + ' ';
  }
  return Result;
}

function mascara_data(dt_field){
    var mydata = '';
    mydata = mydata + dt_field.value;
    if (mydata.length == 2){
        mydata = mydata + '/';
        dt_field.value = mydata;
    }
    if (mydata.length == 5){
	    data = new Date()
        mydata = mydata + '/';
        dt_field.value = mydata;
    }
}

function mascara_mes_ano(dt_field){
    var mydata = '';
    mydata = mydata + dt_field.value;
    if (mydata.length == 2){
        mydata = mydata + '/';
        dt_field.value = mydata;
    }
}

function mascara_hora(hr_field){
    var myhora = '';
    myhora = myhora + hr_field.value;
    if (myhora.length == 2){
        myhora = myhora + ':';
        hr_field.value = myhora;
    }
    if (myhora.length == 5){
        myhora = myhora + ':00';
        hr_field.value = myhora;
    }
}

function mascara_conta(conta){
  var contaformatada = '';
  contaformatada = contaformatada + conta.value;
  if (contaformatada.length == 2){
      contaformatada = contaformatada + '.';
  }
  if (contaformatada.length == 5){
      contaformatada = contaformatada + '.';
  }
  if (contaformatada.length == 8){
      contaformatada = contaformatada + '.';
  }
  if (contaformatada.length == 11){
      contaformatada = contaformatada + '.';
  }
  conta.value = contaformatada;
}

function displaydatetime()
{
  if (!document.layers && !document.all)
    return;
  var today;
  var timeLocal;
  today = new Date();
  timeLocal = today.toLocaleString();
  //timeLocal = today.getHours()+':'+today.getMinutes()+':'+today.getSecondes();
  if (document.layers)
  {
    document.layers.clockLocal.document.write(timeLocal);
    document.layers.clockLocal.document.close();
  }
  else if (document.all)
  {
  clockLocal.innerHTML = timeLocal;
  }
  setTimeout("displaydatetime()", 500)
}

function LogoutFlexTool()
{
  parent.ibMenu.location.href='/cgi-bin/flextool.dll/html/pub/menu';
  parent.ibMain.location.href='/cgi-bin/flextool.dll/html/pub/LoginUser.ipMain?Logout=S';
}

function LogoutDMSRio()
{
  parent.ibMenu.location.href='menu';
  parent.ibMain.location.href='LoginUser.ipMain?Logout=S';
}

function LogoutApp()
{
  parent.ibMenu.location.href='menu';
  parent.ibMain.location.href='LoginUser.ipMain?Logout=S';
}

function NewLogoutApp()
{
  parent.ibMain.location.href='LoginSystem.ipMain?Logout=S';
}

function GoAcompanhamento2()
{
  parent.ibMain.location.href='/cgi-bin/flextool.dll/html/app/AcompanhamentoAtendimento';
}

function GoAcompanhamento()
{
  parent.ibMain.location.href='/cgi-bin/flextool.dll/html/app/CadNovoAtendimento';
}

function ActionButtons(elementButton) {

  if (elementButton.name.toUpperCase() == 'ILSEARCH') {
    document.icSearch.ibtnSearch.value='S';
    document.icSearch.submit();
  }

  if (elementButton.name.toUpperCase() == 'ILINSERT') {
    document.icSearch.ibtnInsert.value='I';
    document.icSearch.submit();
  }

  if (elementButton.name.toUpperCase() == 'ILPOST') {
    document.icEdit.ibtnPost.value='P';
    document.icEdit.submit();
  }

  if (elementButton.name.toUpperCase() == 'ILDELETE') {
    document.icEdit.ibtnDelete.value='D';
    document.icEdit.submit();
  }

}

function checkEnter(e){
var characterCode
	 if(e && e.which){
	 e = e
	 characterCode = e.which
	 }
	 else{
	 e = event
	 characterCode = e.keyCode
	 }	 
	 if(characterCode == 13){
 	 document.forms[0].submit()
 	 return false
	 }
return true

}

function EnterSubmitForm(e,varElement){
var characterCode
	 if(e && e.which){
	 e = e;
	 characterCode = e.which;
	 }
	 else{
	 e = event;
	 characterCode = e.keyCode;
	 }	 
	 if(characterCode == 13){
	 alert('ola');
 	 varElement.form.submit();
 	 return false;
	 }
return true

}

function checkEnterKey(){
   var x =event.keyCode;
   if (x==13)
   {
     document.forms[0].OK.value='S';
     document.forms[0].submit(); 
 	 return false;
   }
}

var DivAnteriorNivel01='';
var DivAnteriorNivel02='';

function SetDivAnteriorNivel01(object)
{
  DivAnteriorNivel01=object;
}

function SetDivAnteriorNivel02(object)
{
  DivAnteriorNivel02=object;
}
                                                                     
function ShowOrNotShowDivAnteriorNivel01()                           
{                                                                    
  if (DivAnteriorNivel01!='') {ShowOrNotShowDiv(DivAnteriorNivel01);}            
}

function ShowOrNotShowDivAnteriorNivel02()
{
  if (DivAnteriorNivel02!='') {ShowOrNotShowDiv(DivAnteriorNivel02);}
}

function ShowOrNotShowDivAnterior()
{                                                                    
  if (DivAnterior != ''){                                          
    ShowOrNotShowDiv(DivAnterior); }                                 
}                                                                    
                                                                     
function ShowOrNotShowDiv(object)                                    
{                                                                    
  if (document.getElementById) {                                     
    if (document.getElementById(object).style.display == 'inline'){
      document.getElementById(object).style.display = 'none';     
    } else {                                                         
      document.getElementById(object).style.display = 'inline';    
    }                                                                
  }                                                                  
  else if (document.layers && document.layers[object]) {             
    if (document.layers[object].display == 'inline') {             
      document.layers[object].display = 'none';                    
    } else {                                                         
      document.layers[object].display = 'inline';                  
    }                                                                
  }                                                                  
  else if (document.all) {
    if (document.all[object].style.display == 'inline') {          
      document.all[object].style.display = 'none';                 
    } else {                                                         
      document.all[object].style.display = 'inline';               
    }                                                                
  }                                                                  
}                                                                    
                                                                     
var ShowMenuLeft = 0;

function HideShowMenuLeft(){

  if ( ShowMenuLeft == 1){
    parent.document.all("ibFrameApp").all("ibLeftMainFrame").cols="0,*";
    //document.all("ibFrameApp").all("ibLeftMainFrame").cols="0,*";
    ShowMenuLeft = 0;
  }
  else if ( ShowMenuLeft == 0){
    parent.document.all("ibFrameApp").all("ibLeftMainFrame").cols="200,*";
    //document.all("ibFrameApp").all("ibLeftMainFrame").cols="200,*";
    ShowMenuLeft = 1;
  }

}

function ChangeStatusImageIncluir(Enabled) {
  if (Enabled) {
    iiIncluir.src='/images/new_document_h.gif';
  } else {
    iiIncluir.src='/images/new_document_d.gif';
  }
}

function ChangeStatusImagePesquisar(Enabled) {
  if (Enabled) {
    iiPesquisar.src='/images/search_h.gif';
  } else {
    iiPesquisar.src='/images/search_d.gif';
  }
}

var iiGravarEnabled = false;
function ChangeStatusImageGravar(Enabled) {
  if (Enabled) {
    iiGravar.src='/images/save_h.gif';
  } else {
    iiGravar.src='/images/save_d.gif';
  }
  iiGravarEnabled = Enabled;
}

var iiExcluirEnabled = false;
function ChangeStatusImageExcluir(Enabled) {
  if (Enabled) {
    iiExcluir.src='/images/delete_x_h.gif';
  } else {
    iiExcluir.src='/images/delete_x_d.gif';
  }
  iiExcluirEnabled = Enabled;
}

function ChangeStatusImageListarRegs(Enabled) {
  if (Enabled) {
    iiListarRegs.src='/images/listar_h.gif';
  } else {
    iiListarRegs.src='/images/listar_d.gif';
  }
}

function ChangeStatusImageImprimir(Enabled) {
  if (Enabled) {
    iiImprimir.src='/images/print_h.gif';
  } else {
    iiImprimir.src='/images/print_d.gif';
  }
}

function ChangeStatusImageVoltar(Enabled) {
  if (Enabled) {
    iiVoltar.src='/images/undo_h.gif';
  } else {
    iiVoltar.src='/images/undo_d.gif';
  }
}

function ChangeStatusImageVoltarReg(Enabled) {
  if (Enabled) {
    iiVoltarReg.src='/images/arrowleft_green_h.gif';
  } else {
    iiVoltarReg.src='/images/arrowleft_green_d.gif';
  }
}

function ChangeStatusImageIrReg(Enabled) {
  if (Enabled) {
    iiIrReg.src='/images/arrowright_green_h.gif';
  } else {
    iiIrReg.src='/images/arrowright_green_d.gif';
  }
}

function ShowIcSearch(object)
{
  if (document.getElementById) {
    document.getElementById(object).style.display = 'inline';
    document.icSearch.ieSearchField.focus();
  }

  else if (document.layers && document.layers[object]) {
    document.layers[object].display = 'inline';
    document.icSearch.ieSearchField.focus();
  }

  else if (document.all) {
    document.all[object].style.display = 'inline';
    document.icSearch.ieSearchField.focus();
  }
}

function NotShowDiv(object)
{
  if (document.getElementById) {
    document.getElementById(object).style.display = 'none';
  }

  else if (document.layers && document.layers[object]) {
    document.layers[object].display = 'none';
  }

  else if (document.all) {
    document.all[object].style.display = 'none';
  }
}

function ShowDiv(object)
{
  if (document.getElementById) {
    document.getElementById(object).style.display = 'inline';
  }

  else if (document.layers && document.layers[object]) {
    document.layers[object].display = 'inline';
  }

  else if (document.all) {
    document.all[object].style.display = 'inline';
  }
}

function ChangeDisplayDiv(object)
{
  if (document.getElementById) {
    if (document.getElementById(object).style.display == 'inline') {
      document.getElementById(object).style.display = 'none';
    } else {
      document.getElementById(object).style.display = 'inline';
    }
  }

  else if (document.layers && document.layers[object]) {
    if (document.layers[object].display == 'inline') {
      document.layers[object].display = 'none';
    } else {
      document.layers[object].display = 'inline';
    }
  }

  else if (document.all) {
    if (document.all[object].style.display == 'inline') {
      document.all[object].style.display = 'none';
    } else {
      document.all[object].style.display = 'inline';
    }
  }
}

function ChangeHeight(object,varHeight)
{
  if (document.getElementById) {
    document.getElementById(object).style.height = varHeight;
  }

  else if (document.layers && document.layers[object]) {
    document.layers[object].height = varHeight;
  }

  else if (document.all) {
    document.layers[object].height = varHeight;
  }
}

var ColumnClassNormal = 'coluna';

function flipNormal(obj)
{
  var icount = 0;
  var i = 0;
  icount = obj.cells.length
  for(i=0;i<icount;i++)
  {
    obj.cells.item(i).className  = ColumnClassNormal;
  }
}

var ColumnClassHover = 'colunahover';

function flipSelected(obj)
{
  var icount = 0;
  var i = 0;
  icount = obj.cells.length;
  for(i=0;i<icount;i++)
  {
    obj.cells.item(i).className  = ColumnClassHover;
  }
}

function SetColumnClassNormal(Class){
  ColumnClassNormal = Class;
}

function SetColumnClassHover(Class){
  ColumnClassHover = Class;
}

function PegaDataHoje(edit) {
var hoje = new Date()
var data

  if (hoje.getDate() < 10)
    data = '0' + hoje.getDate()
  else
    data = hoje.getDate();

  if (hoje.getMonth() < 10)
    data = data + '/' + (hoje.getMonth()+1)
  else
    data = data + '/' + (hoje.getMonth()+1);

  data = data + '/' + hoje.getYear();

  if (edit.value == '') edit.value = data;

}

function FormatValorUs(valor) {

  var PosVirgula = valor.indexOf(',');

  if (PosVirgula!=-1) {

    var InicioDecimal = PosVirgula+1;
    var QtdCarDecimal = valor.length-InicioDecimal;

    var inteiro = valor.substr(0,PosVirgula);
    var decimal = valor.substr(InicioDecimal,QtdCarDecimal);

    return( inteiro + '.' + decimal );

  } else {

    return( valor );

  }

}

function FormatValorBr(valor) {

  var PosPonto = valor.indexOf('.');

  if (PosVirgula!=-1) {

    var InicioDecimal = PosPonto+1;
    var QtdCarDecimal = valor.length-InicioDecimal;

    var inteiro = valor.substr(0,PosPonto);
    var decimal = valor.substr(InicioDecimal,QtdCarDecimal);

    return( inteiro + ',' + decimal );

  } else {

    return( valor );

  }

}

function AllowOnlyNumbers()
{
   var x =event.keyCode;
   if (!(x>=48 && x <=57))
   {
       event.returnValue=false;
   }
}

function AllowOnlyCurrency()
{
   var x =event.keyCode;
   if ( !( (x>=48 && x<=57) || (x=44) ) )
   {
       event.returnValue=false;
   }
}

var dtCh= "/";
var minYear=2000;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (dtStr != '') {
	
	if (pos1==-1 || pos2==-1){
		alert("Formato obrigatório : dd/mm/aaaa")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Mês inválido")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Dia inválido")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Ano inválido, o ano deve esta compreendido entre: "+minYear+" e "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Data inválida")
		return false
	}
	
	}
return true
}

function IncreaseDateInOneYear(ed) {

  return ed.value.substring(0,9) + eval("f=eval(ed.value.charAt(9)); s=1; f+s;");

}

function CalculatePerc(total, vr) {
  total = FormatValorUs(total);
  vr = FormatValorUs(vr);
  var perc = parseInt((eval(vr)*100)/eval(total));
  if ( perc > 0){
    return perc;
  } else {
    return 0;
  }
}

function JumpNext(edS, edD, mx) {

  if (edS.value.length >= mx) {
    edD.focus();
  
  }

}

function CheckIfDateIsBeforeToday(dateString,dateType) {
/*
   function isitToday 
   parameters: dateString dateType
   returns: boolean
   
   dateString is a date passed as a string in the following
   formats:

   type 1 : 19970529
   type 2 : 970529
   type 3 : 29/05/1997
   type 4 : 29/05/97
   
   dateType is a numeric integer from 1 to 4, representing
   the type of dateString passed, as defined above.

   Returns true if the date passed is equal to todays date
   Returns false if the date passed is NOT equal to todays
   date or if dateType is not 1 to 4.
*/


    var now = new Date();
    var today = new Date(now.getYear(),now.getMonth(),now.getDate());

    if (dateType == 1)
        var date = new Date(dateString.substring(0,4),
                            dateString.substring(4,6)-1,
                            dateString.substring(6,8));
    else if (dateType == 2)
        var date = new Date(dateString.substring(0,2),
                            dateString.substring(2,4)-1,
                            dateString.substring(4,6));
    else if (dateType == 3)
        var date = new Date(dateString.substring(6,10),
                            dateString.substring(3,5)-1,
                            dateString.substring(0,2));
    else if (dateType == 4)
        var date = new Date(dateString.substring(6,8),
                            dateString.substring(3,5)-1,
                            dateString.substring(0,2));
    else
        return false;
        
    if (date < today)
        return true;
    else
        return false;
}

function CompleteDateCheck(edt) {
  
  if (isDate(edt.value)) {
    if (CheckIfDateIsBeforeToday(edt.value,3)){
      alert('A data deve ser maior ou igual a hoje.');
      return true;  
    } 
    else 
    { 
      return false; 
    }
  } 
  else 
  { 
    return false; 
  } 
 
}

function ChangeComboState(cb, st) {

  // 0 - tranca
  // 1 - zera e tranca
  // 2 - zera ,tranca e poem o carregando
  if ((st == 0) || (st == 1) || (st == 2)) {
    cb.disabled=true;
    if (st == 1) {
      cb.length=0;
    }
    if (st == 2) {
      cb.options[0] = new Option('Carregando ...','');
    }
  }
  else
  {
    cb.disabled=false;
  }
  
}

function SetVigenciaEndDate (edtFieldInicio, edtFieldFim) {

  if (edtFieldInicio.value != '' ){

    if (!CompleteDateCheck(edtFieldInicio)) {

      edtFieldFim.value = IncreaseDateInOneYear(edtFieldInicio);

    }
    else {
      edtFieldInicio.value = '';
      edtFieldFim.value = '';
      edtFieldInicio.focus();
    }
  }
}

function CheckDateFormat(edt) {

if (!isDate(edt.value)) {
      edt.focus();
    }
}

function SearchTitulo(obj, pg, para) {
  if (obj.value !='') {                                
    document.icEdit.NM_NOME.value = 'Carregando...'; 
    parent.ibGhost.location.href = pg+'.ipGhost?BuscaTitulo=S&NR_TITULO='+obj.value+'&CD_LANCTOPARA='+para.value
  }
  else  {                                              
    document.icEdit.NM_NOME.value = '';
    document.icEdit.ID_ASSOCIADO.value = '';
  }

}

function InserirRegistro() 
{
  document.icSearch.InsertRegister.value='I';
  document.icSearch.submit();
  document.icSearch.InsertRegister.value='';
  return false;
}

function GravarRegistro() 
{
  document.icEdit.PostData.value='P';
  document.icEdit.submit();
  document.icEdit.PostData.value='';
  return false;
}

function DeletarRegistro()
{
  document.icEdit.DeleteRegister.value='D';
  document.icEdit.submit();
  document.icEdit.DeleteRegister.value='';
  return false;
}

function AcionarOpcaoListar()
{
  document.icSearch.SearchData.value='S';
  document.icSearch.submit();
  document.icSearch.SearchData.value='';
  return false;
}
