/*





























'?Copyright:                Terceiro Milênio Informática Ltda - www.tm3.com.br










*/

var e_erp_tip_brwr = "ff";
if (navigator.appName == "Microsoft Internet Explorer") {
  e_erp_tip_brwr = "ie";
}

function e_erp_attachEvent(in_obj, in_evento, in_proc) {
  /*



























  */
  var evento_atachar = in_evento;
  var arr_evt_ie     = new Array("onchange", "onclick", "ondblclick", "onfocusout", "onkeypress", "onload", "onmousedown", "onmousemove", "onmouseout", "onmouseover", "onmouseup", "onscroll", "onselectstart", "onsubmit");
  var arr_evt_ff     = new Array("change",   "click",   "dblclick",   "focusout",   "keypress",   "load",   "mousedown",   "mousemove",   "mouseout",   "mouseover",   "mouseup",   "scroll",   "select",        "submit");
  if (e_erp_tip_brwr == "ie") {
    in_obj.attachEvent(evento_atachar, in_proc);
  } else {
    // localiza o indice do evento IE passado no parâmetro e substitui o nome do evento
    // pelo correspondente no array dos nomes do FF
    for (i=0; i<=arr_evt_ie.length; i++) {
      if (arr_evt_ie[i] == in_evento) {
        evento_atachar = arr_evt_ff[i];
      }
    }
    /*


    */
    in_obj.addEventListener(evento_atachar, in_proc, true);
  }
}

e_erp_attachEvent(window, "onload", tooltip_title);

function mouseover_menu(in_obj, in_cr_mnu_sel) {
  /*




  */
  if (in_obj.estado != "Ligado") {
    in_obj.style.backgroundColor = "#" + in_cr_mnu_sel;
    in_obj.style.border = "gray 1px solid";
    in_obj.style.paddingLeft = "5px";
  }
}

function mouseout_menu(in_obj, in_fundo_do_menu, in_cr_mnu_lin) {
  /*




  */
  if (in_obj.estado != "Ligado") {
    in_obj.style.backgroundColor = "#" + in_fundo_do_menu;
    in_obj.style.borderTop = "1px solid #" + in_fundo_do_menu;
    in_obj.style.borderRight = "1px solid #" + in_fundo_do_menu;
    in_obj.style.borderBottom = "1px solid #" + in_cr_mnu_lin;
    in_obj.style.borderLeft = "1px solid #" + in_fundo_do_menu;
    in_obj.style.paddingLeft = "5px";
  }
}

function do_mouseover() {
  /*




  */
  obj_gerador = event.srcElement;
  /*

  */
  if (obj_gerador != null) {

  /*

  */
    if (obj_gerador.className.toUpperCase() == 'BOTAO') {
      obj_gerador.style.color = '#000000';
    }
  }
}

function do_mouseout() {
  /*




  */
  obj_gerador = event.srcElement;
  /*

  */
  if (obj_gerador != null) {

    /*

    */
    if (obj_gerador.className.toUpperCase() == 'BOTAO') {
      obj_gerador.style.color = '#776600';
    }
  }
}

function do_click() {
  /*




  */
  obj_gerador = event.srcElement;
  if (obj_gerador.evita_dbl_clk != null) {

    /*

    */
    if (obj_gerador.evita_dbl_clk.toUpperCase() == 'LIGADO') {
      obj_gerador.style.display = 'none';
      obj_gerador.insertAdjacentHTML('afterEnd', '<input disabled class="botao" value="' + obj_gerador.value + '" style="text-align: center; width:' + obj_gerador.style.width.toString() + ';">');
    }

  }
}

function do_load() {
  /*




  */
  var tag = document.all;
  /*

  */
  if (tag != null) {
    for (i_contador = 0; i_contador < tag.length; i_contador++) {

      /*

      */
      if ((((tag[i_contador].className.toUpperCase() == 'TEXTO') || (tag[i_contador].tagName == 'TEXTAREA')) && (tag[i_contador].readOnly)) || (((tag[i_contador].tagName == 'SELECT')) && (tag[i_contador].disabled))) {
        tag[i_contador].style.backgroundColor = '#f0f0f0';
        tag[i_contador].style.color = '#808080';
      }
      else {
        if ((((tag[i_contador].className.toUpperCase() == 'TEXTO') || (tag[i_contador].tagName == 'TEXTAREA')) && (~ tag[i_contador].readOnly)) || (((tag[i_contador].tagName == 'SELECT')) && (~ tag[i_contador].disabled))) {
          tag[i_contador].style.backgroundColor = '#ffffff';
        }
      }

      /*


      */
      if ((tag[i_contador].tagName == 'DIV') && (tag[i_contador].id.toUpperCase() == 'TAG_CMS')) {
        tag[i_contador].innerHTML = e_erp_requisita_url('/Padroes/' + tag[i_contador].pagina, tag[i_contador].parametros);
      }

    }
  }
}

function ajax_call(in_url, in_parametros) {
  /*




  */
  var ac = '';
  ac = ac + '<script language="javascript" for="window" event="onload">';
  ac = ac + '  var tag = document.all.tags("div");';
  ac = ac + '  if (tag != null) {';
  ac = ac + '    for (i_contador = 0; i_contador < tag.length; i_contador++) {';
  ac = ac + '      if (tag[i_contador].id == "tag_cms") {';
  ac = ac + '        tag[i_contador].innerHTML = e_erp_requisita_url(' + '"/Padroes/" + ' + 'tag[i_contador].pagina, tag[i_contador].parametros);';
  ac = ac + '      }';
  ac = ac + '    }';
  ac = ac + '  }';
  ac = ac + '</script>';
  document.write(ac);
}

function dados_load() {
  /*




  */
  var tag = document.all;
  /*

  */
  if (tag != null) {
    for (i_contador = 0; i_contador < tag.length; i_contador++) {

      /*

      */
      if ((((tag[i_contador].className.toUpperCase() == 'TEXTO') || (tag[i_contador].tagName == 'TEXTAREA')) && (tag[i_contador].readOnly)) || (((tag[i_contador].tagName == 'SELECT')) && (tag[i_contador].disabled))) {
        tag[i_contador].style.backgroundColor = '#f5f5f5';
        tag[i_contador].style.color = '#808080';
      }
      else {
        if ((((tag[i_contador].className.toUpperCase() == 'TEXTO') || (tag[i_contador].tagName == 'TEXTAREA')) && (~ tag[i_contador].readOnly)) || (((tag[i_contador].tagName == 'SELECT')) && (~ tag[i_contador].disabled))) {
          tag[i_contador].style.backgroundColor = '#ffffff';
        }
      }

      /*





      */
      if (tag[i_contador].className.toUpperCase() == 'DIV_DADOS') {
        tag[i_contador].style.height = screen.height - 235;
      }

      /*

      */
      if (tag[i_contador].className.toUpperCase() == 'FORM_DADOS') {
        tag[i_contador].style.width = screen.width - 12;
      }

    }
  }
}

function dados_mouseover() {
  /*




  */
  obj_gerador = event.srcElement;
  /*

  */
  if (obj_gerador != null) {

    if ((obj_gerador.className.toUpperCase() == 'BOTAO') || (obj_gerador.className.toUpperCase() == 'RODAPEBOTAO')) {
      obj_gerador.style.color = '#ff6666';
    }
  }

}

function dados_mouseover_linha(in_tr) {
  /*




  */
  if (in_tr.bgColor == '#ffffff') {
    in_tr.bgColor = '#4a5a9c';
  }
}

function dados_mouseout() {
  /*




  */
  obj_gerador = event.srcElement;
  /*

  */
  if (obj_gerador != null) {
    if ((obj_gerador.className.toUpperCase() == 'BOTAO') || (obj_gerador.className.toUpperCase() == 'RODAPEBOTAO')) {
      obj_gerador.style.color = '#4a5a9c';
    }
  }
}

function dados_mouseout_linha(in_tr) {
  /*




  */
  if (in_tr.bgColor == '#4a5a9c') {
    in_tr.bgColor = '#ffffff';
  }
}

function dados_click_linha(in_tr) {
  /*




  */
  var tag = document.all('Linha');
  /*

  */
  if (tag != null) {
    for (i_contador = 0; i_contador < tag.length; i_contador++) {
      tag(i_contador).bgColor = '#ffffff';
    }
  }
    /*

    */
    in_tr.bgColor = "#4a5a9b";
}

var gbl_ponteiro_cria_jnl_alerta = function posiciona_cria_jnl_alerta(id_objeto) {
  var elemento = document.getElementById(id_objeto);
  elemento.style.top = parseInt(53) + parseInt(window.document.body.scrollTop) - parseInt(elemento.style.marginTop);
}

function cria_jnl_alerta(in_titulo, in_mensagem, in_detalhe, in_width, in_url, in_parametros, in_form) {
  /*




  */
  var div_shdw = document.createElement("DIV");
  window.document.body.insertAdjacentElement("afterBegin", div_shdw);
  div_shdw.id = "jnl_alerta_sombra_inativa";
  div_shdw.style.height = window.document.body.scrollHeight;
  div_shdw.style.zIndex = 40;

  var div = document.createElement("DIV");
  window.document.body.insertAdjacentElement("afterBegin", div);
  div.id = "jnl_alerta";
  div.style.backgroundColor = "#ffffff";
  div.style.borderRight = "#ceebff 3px inset";
  div.style.borderTop = "#22627e 1px solid";
  div.style.borderLeft = "#12526e 1px solid";
  div.style.borderBottom = "#589dd6 3px ridge";
  div.style.top = "0";
  div.style.marginTop = 53 + parseInt(window.document.body.scrollTop);
  div.style.left = "0";
  div.style.marginLeft = (screen.width - in_width) / 2;
  div.style.overflow = "visible";
  div.style.zIndex = 50;
  div.style.position = "absolute";

  gbl_ponteiro_cria_jnl_alerta = function() {posiciona_cria_jnl_alerta(div.id);};
  e_erp_attachEvent(window, "onscroll", gbl_ponteiro_cria_jnl_alerta);

  var out;
  out = "<table align='center' width='" + in_width + "' cellspacing='0'>";
  out = out + "  <tr bgcolor='#eaf7ff'>";
  out = out + "    <td style='border-bottom: gray 1px solid; font-family: Arial; font-size: 11px;'>";
  out = out + "      &nbsp;&nbsp;&nbsp;<b>" + in_titulo + "</b></td>";
  out = out + "    <td style='border-bottom: gray 1px solid;' align='right'>";
  out = out + "      <img title='Fechar' style='cursor: pointer;' src='/images/Fechar.gif'";
  out = out + "        onclick='remove_alerta(\"jnl_alerta\");'";
  out = out + "      >&nbsp;";
  out = out + "    </td>";
  out = out + "  </tr>";
  out = out + "  <tr>";
  out = out + "    <td colspan='2'>";
  out = out + "      <table cellspacing='8' width='100%'>";
  out = out + "        <tr>";
  out = out + "          <td><br>" + in_mensagem + "</td>";
  out = out + "        </tr>";
  out = out + "        <tr>";
  out = out + "          <td align='center'><br>" + decodeURIComponent(in_detalhe) + "</td>";
  out = out + "        </tr>";
  out = out + "        <tr>";
  out = out + "          <td align='center'><br>";
  out = out + "            <br>";
  out = out + "            <input type='button' class='botao' style='width:75px;'";
  out = out + "              onclick='retorno = e_erp_requisita_url(\"" + in_url + "\", \"" + in_parametros + "\");";
  out = out + "                       if (retorno.length != 0){";
  out = out + "                         try {document.getElementById(\"mensagem\").innerHTML = \"<center><font color=red>\" \+ retorno \+ \"</font></center>\"} catch (e) {};";
  out = out + "                         remove_alerta(\"jnl_alerta\");";
  out = out + "                       }";
  out = out + "                       else {";
  out = out + "                       " + in_form + ".submit();";
  out = out + "                       }'";
  out = out + "              evita_dbl_clk='ligado' value='CONFIRMAR'>";
  out = out + "            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  out = out + "            <input type='button' onclick='remove_alerta(\"jnl_alerta\");' class='botao' style='width:75px;' evita_dbl_clk='ligado' value='CANCELAR'>";
  out = out + "          </td>";
  out = out + "        </tr>";
  out = out + "      </table>";
  out = out + "      <br>";
  out = out + "    </td>";
  out = out + "  </tr>";
  out = out + "</table>";

  div.innerHTML = out;

}

function remove_alerta(in_id) {
  /*




  */
  window.detachEvent("onscroll", gbl_ponteiro_cria_jnl_alerta);
  jnl_alerta_sombra_inativa.parentNode.removeChild(jnl_alerta_sombra_inativa);
  jnl_alerta.parentNode.removeChild(jnl_alerta);
}

function dimens_tela(in_fnd_mn) {
  /*




  */
  var w = 1024;

  try {id_menu.style.backgroundColor = "#" + in_fnd_mn;} catch (e) {}


  /*

  */
  var largura_scrollbar = 20;
  var ajuste_empirico = 4;
  if (e_erp_tip_brwr == "ff") {
    largura_scrollbar = 16;
    ajuste_empirico = 0;
  }


  /*


  */
  if (screen.width <= 800) {
    w = 800;
    try {id_base.style.width = w - largura_scrollbar;} catch (e) {}
    try {id_cabecalho.style.width = w - largura_scrollbar;} catch (e) {}
    try {id_rodape.style.width = w - largura_scrollbar;} catch (e) {}
    try {id_complemento.style.left = 623 - ajuste_empirico;} catch (e) {}
  }
  if (screen.width > 1024) {
    try {id_base.style.left = (screen.width - 1024) / 2;} catch (e) {}
  }


  /*



  */
  var alt_scrll_id_menu = 0;
  var alt_scrll_id_conteudo = 0;
  var alt_scrll_id_complemento = 0;
  var alt_id_rodape = 0;
  var alt_scrll_body = 0;
  var alt_clnt_body = 0;
  var matriz_do_maior = new Array();

  try {alt_scrll_id_menu = id_menu.scrollHeight;} catch (e) {}
  try {alt_scrll_id_conteudo = id_conteudo.scrollHeight;} catch (e) {}
  try {alt_scrll_id_complemento = id_complemento.scrollHeight;} catch (e) {}
  alt_scrll_body = window.document.body.scrollHeight;
  alt_clnt_body = window.document.body.clientHeight;

  matriz_do_maior = [alt_scrll_id_menu, alt_scrll_id_conteudo, alt_scrll_id_complemento, alt_scrll_body - 90, alt_clnt_body - 90];
  /*

  */
  alt_id_rodape = matriz_do_maior.sort(function (a,b) {return b - a})[0];
  id_base.style.height = alt_id_rodape;
  id_rodape.style.top = alt_id_rodape + 70;


  /*

  */
  var largura_menu = 171;
  var largura_complemento = 161;

  if (typeof(id_complemento) != "object") {largura_complemento = 0;}
  if (typeof(id_menu) != "object") {
    largura_menu = 0;
    try {id_conteudo.style.left = 0;} catch (e) {}
  }
  try {id_conteudo.style.width = w - largura_scrollbar - largura_menu - largura_complemento;} catch (e) {}

}

function cria_option_novo(in_obj) {
  /*

























  */

  /*

  */
  var id_select = "select_" + in_obj.nome;
  var id_input  = "input_"  + in_obj.nome;
  var fn;

  window.document.all(in_obj.nome).id = id_select;

  obj_slct = document.getElementById(in_obj.nome);

  document.write("<input id='" + id_input + "' type='text' value='' maxlength='" + in_obj.mxln + "' class='" + in_obj.clss + "' title='Faça o clique duplo neste campo se desejar reexibir a lista de opções' style='text-align:center; display:\"none\";'>");

  /*

  */
  window.document.all(id_input).value = decodeURIComponent(in_obj.vlr);

  /*



  */
  try {
    if ( window.document.all(id_select)(0).value != "" ) {
      opt = document.createElement("option");
      window.document.all.item(obj_slct.name).insertBefore(opt, window.document.all.item(obj_slct.name)(0));
      opt.value       = "";
      opt.text        = "";
    }
  }
  catch (e) {
    /*

    */
    if ( window.document.all(id_select).length == 0 ) {
      opt = document.createElement("option");
      window.document.all.item(obj_slct.name).insertBefore(opt, window.document.all.item(obj_slct.name)(0));
      opt.value       = "";
      opt.text        = "";
    }
  }

  /*

  */
  opt = document.createElement("option");
  window.document.all.item(obj_slct.name).insertBefore(opt, window.document.all.item(obj_slct.name)(1));
  opt.value       = "";
  opt.text        = "novo registro";
  opt.style.color = "#ff6600";

  fn = function() {alterna_select_input(window.event.srcElement.tagName, in_obj.nome, id_input, id_select);};

  e_erp_attachEvent(window.document.all(id_select), "onchange", fn);
  e_erp_attachEvent(window.document.all(id_input), "ondblclick", fn);

  /*

  */
  alterna_select_input("", in_obj.nome, id_input, id_select);

  function alterna_select_input(in_nome_tag_evento, in_nome_obj, in_id_input, in_id_select) {
    /*

    */

    if (in_nome_tag_evento == "SELECT") {

      if (window.document.all(in_id_select).selectedIndex == 1 && window.document.all(in_id_select)[1].text == "novo registro") {

        window.document.all(in_id_select).selectedIndex = 0;
        window.document.all(in_id_select).style.display = "none";
        window.document.all(in_id_input).style.display = "block";
        window.document.all(in_id_input).value = "";
        window.document.all(in_id_input).focus();

        window.document.all(in_id_select).name = "";
        window.document.all(in_id_input).name = in_nome_obj;

      }
    }

    else if (in_nome_tag_evento == "INPUT") {

      window.document.all(in_id_input).value = "";
      window.document.all(in_id_input).style.display = "none";

      window.document.all(in_id_select).style.display = "block";
      window.document.all(in_id_select).selectedIndex = 0;

      window.document.all(in_id_select).name = in_nome_obj;
      window.document.all(in_id_input).name = "";

    }

    else {

      /*

      */
      if (window.document.all(in_id_select).selectedIndex > 1 && window.document.all(id_input).value == "") {
        window.document.all(in_id_select).selectedIndex = 0;
      }

      else if (window.document.all(in_id_input).value != window.document.all(in_id_select).value) {
        window.document.all(in_id_input).style.display = "block";
        window.document.all(in_id_select).style.display = "none";

        window.document.all(in_id_select).name = "";
        window.document.all(in_id_input).name = in_nome_obj;

      }
    }
  }
}

function fmtd_jv(in_dado, in_tipo, in_formato) {
  /*





















  */
  var tmp_in_dado   = "";
  var decimais      = "";
  var inteiro       = "";
  var saida         = "";
  var i             = 0;
  var j             = 0;
  var str_casas_dec = "";

	var tmp_data = new Date();
	var diaok;
	var mesok;
	var anook;
	var dia;
	var mes;
	var ano;
  
  if ( in_tipo == "num" ) {
    /*


    */
    tmp_in_dado = in_dado.replace(/\./g, "");
    tmp_in_dado = tmp_in_dado.replace(",", ".");
    /*

    */
    while (i < parseInt(in_formato)) {
      str_casas_dec = str_casas_dec + "0";
      i++;
    }
    /*

    */
    if ( !isNaN(tmp_in_dado) ) {
      /*

      */
      if ( tmp_in_dado.indexOf(".") == -1 ) {
        /*

        */
        inteiro  = eval(tmp_in_dado);
        decimais = str_casas_dec;
      }
      else if ( tmp_in_dado.indexOf(".") == ( tmp_in_dado.length - 1 ) ) {
        /*

        */
        inteiro  = eval(tmp_in_dado.replace(/\./g, ""));
        decimais = str_casas_dec;
      }
      else if ( tmp_in_dado.indexOf(".") == 0 ) {
        /*

        */
        inteiro  = "0";
        decimais = tmp_in_dado.replace(/\./g, "");
        decimais = decimais + str_casas_dec;
        decimais = decimais.substr(0, parseInt(in_formato));
      }
      else {
        /*

        */
        inteiro  = tmp_in_dado.substr(0, tmp_in_dado.indexOf("."));
        decimais = tmp_in_dado.substr(tmp_in_dado.indexOf(".") + 1);
        decimais = decimais + str_casas_dec;
        decimais = decimais.substr(0, parseInt(in_formato));
      }
      /*

      */
      inteiro = inteiro.toString();
      /*

      */
      for ( i=inteiro.length - 1; i>-1; i-- ) {
        j = j + 1;
        if ( j == 3 && i > 0 ) {
          saida = "." + inteiro.substr(i, 1) + saida;
          j = 0;
        }
        else if ( j == 3 ) {
          saida = inteiro.substr(i, 1) + saida;
          j = 0;
        }
        else {
          saida = inteiro.substr(i, 1) + saida;
        }
      }
      saida = saida + "," + decimais;
    }
  }



  else if ( in_tipo == "dat" ) {
    if ( in_dado == null || in_dado == "" ) {
      saida = "";
    } else if ( in_dado.length < 10 ) {
      saida = "";
    } else if ( in_dado.indexOf(" ") != -1 ) {
      saida = "";
    } else if ( in_formato != "dma" && in_formato != "mda" && in_formato != "amd" ) {
      saida = "";
    } else if ( ( in_formato != "amd" ) && ( in_dado.substr(2, 1) != "/" || in_dado.substr(5, 1) != "/" ) ) {
      /*

      */
      saida = "";
    } else if ( in_formato == "amd" && ( in_dado.substr(4, 1) != "/" || in_dado.substr(7, 1) != "/" ) ) {
      /*

      */
      saida = "";
    } else if ( in_formato != "amd" && ( isNaN(in_dado.substr(0, 2)) || isNaN(in_dado.substr(3, 2)) || isNaN(in_dado.substr(6, 4)) ) ) {
      /*

      */
      saida = "";
    } else if ( in_formato == "amd" && ( isNaN(in_dado.substr(0, 4)) || isNaN(in_dado.substr(5, 2)) || isNaN(in_dado.substr(8, 2)) ) ) {
      /*

      */
      saida = "";
    } else {
      /*
      O Javascript sempre retorna uma data válida utilizando o método .setFullYear(yyyy, mm -1, dd).
      Quando a data supera o limite do mês fornecido, o mês é aumentado até que a quantidade excedente
      de dias não mais exceda os dias do mês. O mesmo acontece com o ano em relação ao mês. Como os
      meses iniciam em 0 e vão até 11 no Javascript, ao se colocar o mês 12 para uma data o Javascript
      retornará a data fornecida no mês de Janeiro do ano seguinte ao ano fornecido.
      Assim é possível fazer validação criando uma nova data no Javascript e comparando-a com os valores
      obtidos na nova data. 
      */
      if ( in_formato == "dma" ) {
        dia = in_dado.substr(0, 2);
        mes = in_dado.substr(3, 2);
        ano = in_dado.substr(6, 4);
      } else if ( in_formato == "mda" ) {
        dia = in_dado.substr(3, 2);
        mes = in_dado.substr(0, 2);
        ano = in_dado.substr(6, 4);
      } else {
        dia = in_dado.substr(8, 2);
        mes = in_dado.substr(5, 2);
        ano = in_dado.substr(0, 4);
      }
	    tmp_data.setFullYear(ano, mes -1, dia);
	    diaok = (tmp_data.getDate()      == dia);
	    mesok = (tmp_data.getMonth()     == mes -1);
	    anook = (tmp_data.getFullYear()  == ano);

	    if (diaok && mesok && anook) {
        saida = in_dado;
      } else {
        saida = "";
      }
    }
  }



  else if ( in_tipo == "cvt" ) {
    saida = "";
    if ( in_dado != null && in_dado != "" ) {
      if ( in_formato == "hex" ) {
        for (i = 0; i < in_dado.length; i++) {
          tmp_in_dado = tmp_in_dado + in_dado.charCodeAt(i).toString(16);
        }
        saida = tmp_in_dado;
      }
      else if ( in_formato == "dex" ) {
        for (i = 0; i < in_dado.length; i++) {
          tmp_in_dado = tmp_in_dado + String.fromCharCode("0x" + in_dado.substring(i, i + 2));
          i++;
        }
        saida = tmp_in_dado;
      }
    }
  }
  return(saida);
}

function cria_slct_grp(in_lst_parmtrs_slct) {
  /*





































  */

  var aleat_number   = Math.round(Math.random() * 1000000000).toString();
  var aleat          = ("000000000" + aleat_number).substr(aleat_number.length, 9);
  /*

  */
  var lrg_tbl        = in_lst_parmtrs_slct.lrg;
  var slct_grp;
  var slct_txt       = decodeURIComponent(in_lst_parmtrs_slct.txt).split(",");
  var slct_vlr       = decodeURIComponent(in_lst_parmtrs_slct.vlr).split(",");
  var slct_dflt      = decodeURIComponent(in_lst_parmtrs_slct.dflt).split(",");
  var slct_qtd       = in_lst_parmtrs_slct.qtd;
  var slct_nm        = in_lst_parmtrs_slct.name;
  var opt_brc        = in_lst_parmtrs_slct.brc;
  var slct_func_disp = in_lst_parmtrs_slct.func_disp;
  var qtd_txt        = slct_txt.length;
  var grp_atual;
  var i;
  var contador       = 0;

  if (typeof(in_lst_parmtrs_slct.grp) != "undefined") {
    slct_grp = decodeURIComponent(in_lst_parmtrs_slct.grp).split(",");
  }

  /*


















  */

  /*

  */
  var tbl_grl;
  var input_hddn;
  var tbody_grl;
  var tr_grl;
  var td_grl;
  var tbl_txt_img;
  var tbody_txt_img;
  var tr_txt_img;
  var td_img;
  var obj_img;
  var td_txt;
  var tr_sub_grp;
  var td_sub_grp;
  var tbl_sub_grp;
  var tbody_tbl_sub_grp;
  var tr_txt_grp;
  var td_txt_grp;

  /*

  */
  var div_grl;
  var slct_ff;
  var optgrp_ff;
  var option_ff;



  if (e_erp_tip_brwr == "ie") {

    /*

    */
    document.write("<table id='grl_" + aleat + "'></table>");
    tbl_grl                       = document.getElementById("grl_" + aleat);
    tbl_grl.border                = "0";
    tbl_grl.cellPadding           = "0";
    tbl_grl.cellSpacing           = "0";
    tbl_grl.width                 = lrg_tbl;
    tbl_grl.style.tableLayout     = "fixed";
    tbl_grl.style.marginTop       = tbl_grl.style.marginTop + 1;

    input_hddn      = document.createElement("INPUT");
    input_hddn.type = "hidden";
    tbl_grl.insertAdjacentElement("beforeBegin", input_hddn);
    input_hddn.id   = "input_hddn_" + aleat;
    input_hddn.name = slct_nm;

    /*

    */
    if (typeof(slct_func_disp) != "undefined") {
      input_hddn.attachEvent("onchange", function() {eval(slct_func_disp);});
    }

    tbody_grl    = document.createElement("TBODY");
    tbl_grl.insertAdjacentElement("afterBegin", tbody_grl);
    tbody_grl.id = "tbody_grl_" + aleat;

    /*

    */
    tr_grl    = document.createElement("TR");
    tbody_grl.insertAdjacentElement("afterBegin", tr_grl);
    tr_grl.id = "tr_grl_" + aleat;

    td_grl    = document.createElement("TD");
    tr_grl.insertAdjacentElement("afterBegin", td_grl);
    td_grl.id = "td_grl" + aleat;

    /*

    */
    tbl_txt_img                   = document.createElement("TABLE");
    td_grl.insertAdjacentElement("afterBegin", tbl_txt_img);
    tbl_txt_img.id                = "tbl_txt_img_" + aleat;
    tbl_txt_img.cellPadding       = "0";
    tbl_txt_img.cellSpacing       = "0";
    tbl_txt_img.width             = "100%";
    tbl_txt_img.style.border      = "1px solid #000000";
    tbl_txt_img.style.borderRight = "1px solid #d3d3d3";
    tbl_txt_img.style.tableLayout = "fixed";

    tbody_txt_img    = document.createElement("TBODY");
    tbl_txt_img.insertAdjacentElement("afterBegin", tbody_txt_img);
    tbody_txt_img.id = "tbody_txt_img_" + aleat;

    /*

    */
    tr_txt_img    = document.createElement("TR");
    tbody_txt_img.insertAdjacentElement("afterBegin", tr_txt_img);
    tr_txt_img.id = "tr_txt_img_" + aleat;
    tr_txt_img.attachEvent("onclick", function() {var dummy = eval("td_sub_grp_" + event.srcElement.id.slice(event.srcElement.id.length - 9)); if(dummy.style.display=='none') {dummy.style.display='block'; dummy.focus();} else {dummy.style.display='none';}});
    tr_txt_img.attachEvent("onselectstart", function() {return false;});

    td_img       = document.createElement("TD");
    tr_txt_img.insertAdjacentElement("afterBegin", td_img);
    td_img.id    = "td_img_" + aleat;
    td_img.align = "right";
    td_img.width = "18px";

    obj_img       = document.createElement("IMG");
    td_img.insertAdjacentElement("afterBegin", obj_img);
    obj_img.src   = "/images/clicar.gif";
    obj_img.id    = "obj_img_" + aleat;

    td_txt                    = document.createElement("TD");
    tr_txt_img.insertAdjacentElement("afterBegin", td_txt);
    td_txt.id                 = "td_txt_" + aleat;
    td_txt.style.paddingLeft  = "3px";
    td_txt.style.font         = "normal 12px Arial";
    td_txt.style.cursor       = "default";
    td_txt.style.whiteSpace   = "nowrap";
    td_txt.style.overflow     = "hidden";
    td_txt.style.textOverflow = "ellipsis";
    td_txt.style.width        = "93%";
    td_txt.width              = "100%";

    /*

    */
    tr_sub_grp    = document.createElement("TR");
    tr_grl.insertAdjacentElement("afterEnd", tr_sub_grp);
    tr_sub_grp.id = "tr_sub_grp_" + aleat;

    td_sub_grp    = document.createElement("TD");
    tr_sub_grp.insertAdjacentElement("afterBegin", td_sub_grp);
    td_sub_grp.id = "td_sub_grp_" + aleat;
    td_sub_grp.style.display = "none";
    td_sub_grp.attachEvent("onfocusout", function() {var dummy = document.activeElement.parentNode.id.slice(0, document.activeElement.parentNode.id.length - 9); if ((dummy != "tr_txt_img_") & (dummy != "td_sub_grp_")) {td_sub_grp.style.display = "none";}});

    /*

    */
    div_scroll                       = document.createElement("DIV");
    td_sub_grp.insertAdjacentElement("afterBegin", div_scroll);
    div_scroll.id = "div_scroll_" + aleat;
    div_scroll.style.border          = "1px solid black";
    div_scroll.style.borderTop       = "0px solid black";
    div_scroll.style.borderRight     = "1px solid #000000";
    div_scroll.style.width           = "100%";
    div_scroll.style.position        = "absolute";
    div_scroll.style.backgroundColor = "#ffffff";

    /*

    */
    tbl_sub_grp                   = document.createElement("TABLE");
    div_scroll.insertAdjacentElement("afterBegin", tbl_sub_grp);
    tbl_sub_grp.id                = "tbl_sub_grp_" + aleat;
    tbl_sub_grp.cellPadding       = "0";
    tbl_sub_grp.cellSpacing       = "0";
    tbl_sub_grp.width             = "100%";
    tbl_sub_grp.style.borderTop   = "0px solid #000000";
    tbl_sub_grp.style.tableLayout =  "fixed";

    tbody_tbl_sub_grp    = document.createElement("TBODY");
    tbl_sub_grp.insertAdjacentElement("afterBegin", tbody_tbl_sub_grp);
    tbody_tbl_sub_grp.id = "tbody_tbl_sub_grp_" + aleat;

    /*

    */
    if (typeof(opt_brc) != "undefined") {
      contador = 1;
      tr_txt_grp    = document.createElement("TR");
      tbody_tbl_sub_grp.insertAdjacentElement("beforeEnd", tr_txt_grp);
      tr_txt_grp.id = "tr_txt_grp_" + aleat;

      td_txt_grp            = document.createElement("TD");
      tr_txt_grp.insertAdjacentElement("beforeEnd", td_txt_grp);
      td_txt_grp.id         = "td_txt_grp_" + aleat;
      td_txt_grp.style.font = "normal 12 Arial";
      td_txt_grp.innerText  = " ";
      td_txt_grp.valor      = "";
      td_txt_grp.attachEvent("onselectstart", function() {return false;});
      td_txt_grp.attachEvent("onmouseover", function() {event.srcElement.bgColor = "#0A246A"; event.srcElement.style.color = "#ffffff";});
      td_txt_grp.attachEvent("onmouseout", function() {event.srcElement.bgColor = "#ffffff"; event.srcElement.style.color = "#000000";});
      /*

      */
      td_txt_grp.attachEvent("onfocusout", function() {td_txt.innerText = event.srcElement.innerText; input_hddn.value = ""; window.document.all(input_hddn.id).fireEvent("onchange");});
    }

    /*

    */
    for (i = 0; i < qtd_txt; i++) {
      /*

      */
      if (typeof(in_lst_parmtrs_slct.grp) != "undefined") {
        if (grp_atual != slct_grp[i]) {
          tr_txt_grp    = document.createElement("TR");
          tbody_tbl_sub_grp.insertAdjacentElement("beforeEnd", tr_txt_grp);
          tr_txt_grp.id = "tr_txt_grp_" + aleat;

          td_txt_grp                    = document.createElement("TD");
          tr_txt_grp.insertAdjacentElement("afterBegin", td_txt_grp);
          td_txt_grp.style.paddingLeft  = "3";
          td_txt_grp.style.font         = "italic bold 12 Arial";
          td_txt_grp.style.cursor       = "default";
          td_txt_grp.style.whiteSpace   = "nowrap";
          td_txt_grp.style.overflow     = "hidden";
          td_txt_grp.style.textOverflow = "ellipsis";
          td_txt_grp.style.width        = "93%";
          td_txt_grp.attachEvent("onselectstart", function() {return false;});
          td_txt_grp.innerText          = slct_grp[i];
          contador++;
        }
        grp_atual = slct_grp[i];
      }

      tr_txt_grp                  = document.createElement("TR");
      tbody_tbl_sub_grp.insertAdjacentElement("beforeEnd", tr_txt_grp);

      td_txt_grp                     = document.createElement("TD");
      tr_txt_grp.insertAdjacentElement("afterBegin", td_txt_grp);
      td_txt_grp.width               = "100%";

      if (typeof(in_lst_parmtrs_slct.grp) != "undefined") {
        td_txt_grp.style.paddingLeft = "9px";
      }
      else {
        td_txt_grp.style.paddingLeft = "3px";
      }
      /*

      */
      td_txt_grp.style.font          = "normal 12 Arial";
      td_txt_grp.style.cursor        = "default";
      td_txt_grp.style.whiteSpace    = "nowrap";
      td_txt_grp.style.overflow      = "hidden";
      td_txt_grp.style.textOverflow  = "ellipsis";
      td_txt_grp.style.width         = "93%";
      td_txt_grp.valor               = slct_vlr[i];
      td_txt_grp.attachEvent("onselectstart", function() {return false;});
      td_txt_grp.attachEvent("onmouseover", function() {event.srcElement.bgColor = "#0A246A"; event.srcElement.style.color = "#ffffff";});
      td_txt_grp.attachEvent("onmouseout", function() {event.srcElement.bgColor = "#ffffff"; event.srcElement.style.color = "#000000";});
      td_txt_grp.attachEvent("onfocusout", function() {td_txt.innerText = event.srcElement.innerText; input_hddn.value = event.srcElement.valor; window.document.all(input_hddn.id).fireEvent("onchange");});

      if (slct_vlr[i] == slct_dflt) {
        td_txt.innerText = slct_txt[i];
        input_hddn.value = slct_vlr[i];
      }

      td_txt_grp.innerText = slct_txt[i];
    }

    if ((qtd_txt + contador) > slct_qtd) {
      div_scroll.style.overflowY   = "scroll";
      div_scroll.style.height      = slct_qtd * 15 + "px";
    }
  }

  else {
    document.write("<div id='div_slct_ff_" + aleat + "'></div>");
    div_grl                   = document.getElementById("div_slct_ff_" + aleat);
    div_grl.border            = "0";

    slct_ff              = document.createElement("SELECT");
    div_grl.insertBefore(slct_ff, div_grl.firstChild);
    slct_ff.id           = "slct_ff_" + aleat;
    slct_ff.style.width  = lrg_tbl;
    slct_ff.name         = slct_nm;

    for (i = 0; i < qtd_txt; i++) {
      if (typeof(in_lst_parmtrs_slct.grp) != "undefined") {
          if (grp_atual != slct_grp[i]) {
          optgrp_ff       = document.createElement("OPTGROUP");
          slct_ff.appendChild(optgrp_ff);
          //slct_ff.insertBefore(optgrp_ff, slct_ff.firstChild);
          optgrp_ff.id    = "optgrp_ff_" + aleat;
          optgrp_ff.label = slct_grp[i];
        }
        grp_atual = slct_grp[i];

        option_ff             = document.createElement("OPTION");
        optgrp_ff.appendChild(option_ff);
        //optgrp_ff.parentNode.insertBefore(option_ff,optgrp_ff.nextSibling);
        option_ff.id          = "option_ff_" + aleat;
        option_ff.textContent = slct_txt[i];
        option_ff.value       = slct_vlr[i];
      }
      else {
        option_ff             = document.createElement("OPTION");
        slct_ff.appendChild(option_ff);
        //slct_ff.insertBefore(option_ff,slct_ff.firstChild);
        option_ff.id          = "option_ff_" + aleat;
        option_ff.textContent = slct_txt[i];
        option_ff.value       = slct_vlr[i];
      }
      if (slct_vlr[i] == slct_dflt) {
        option_ff.selected = true;
      }
    }
    if (typeof(opt_brc) != "undefined") {
      option_brc_ff = document.createElement("OPTION");
      slct_ff.insertBefore(option_brc_ff,slct_ff.firstChild);
    }
  }
}

function tooltip_title() {
  /*




  */
  var e_erp_tooltip_title_flh;
  var i_contador;
  var tag = document.all;
  var titulo_dica;
  var e_erp_tooltip_title_grl;
  var e_erp_tooltip_title_int

  e_erp_tooltip_title_grl                 = document.createElement("DIV");
  window.document.body.insertAdjacentElement("afterBegin", e_erp_tooltip_title_grl);
  e_erp_tooltip_title_grl.style.width     = "278px";
  e_erp_tooltip_title_grl.style.position  = "absolute";
  e_erp_tooltip_title_grl.style.zIndex    = 100;

  e_erp_tooltip_title_int = document.createElement("DIV");
  e_erp_tooltip_title_grl.insertAdjacentElement("afterBegin", e_erp_tooltip_title_int);

  e_erp_tooltip_title_flh = document.createElement("DIV");
  e_erp_tooltip_title_grl.insertAdjacentElement("afterBegin", e_erp_tooltip_title_flh);
  
  if (tag != null) {
    for (i_contador = 0; i_contador < tag.length; i_contador++) {
      if (tag[i_contador].title) {
        tag[i_contador].setAttribute("titulo_dica", tag[i_contador].getAttribute("title")); 
        tag[i_contador].removeAttribute("title"); 

        tag[i_contador].onmouseover = function() {
          e_erp_tooltip_title_flh.innerText             = this.getAttribute("titulo_dica");
          e_erp_tooltip_title_flh.style.backgroundColor = "#FFFFE1";
          e_erp_tooltip_title_flh.style.display         = "block";
          e_erp_tooltip_title_flh.style.border          = "1 solid #000000";
          e_erp_tooltip_title_flh.style.paddingLeft     = "3";
          e_erp_tooltip_title_flh.style.paddingTop      = "1";
          e_erp_tooltip_title_flh.style.paddingRight    = "1";
          e_erp_tooltip_title_flh.style.paddingBottom   = "0";
          e_erp_tooltip_title_flh.style.position        = "absolute";
          e_erp_tooltip_title_flh.style.font            = "11px tahoma";
          e_erp_tooltip_title_flh.style.zIndex          = 100;
          e_erp_tooltip_title_grl.style.marginLeft      = "0px";

          e_erp_tooltip_title_grl.style.top             = window.event.clientY + 18 + window.document.body.scrollTop;
          e_erp_tooltip_title_grl.style.left            = window.event.clientX + window.document.body.scrollLeft;

          if ((parseInt(decodeURIComponent(event.clientX).split("px")) + 278) > window.document.body.clientWidth) {
            e_erp_tooltip_title_grl.style.textAlign       = "right";
            e_erp_tooltip_title_grl.style.marginLeft      = "-278px";

            e_erp_tooltip_title_int.style.border          = "1 solid #ff00ff";
            e_erp_tooltip_title_int.style.backgroundColor = "#ff00ff";
            e_erp_tooltip_title_int.style.visibility      = "hidden";
            e_erp_tooltip_title_int.style.display         = "inline";
            e_erp_tooltip_title_int.innerText             = this.getAttribute("titulo_dica");

            e_erp_tooltip_title_flh.style.textAlign       = "left";
            e_erp_tooltip_title_flh.innerText             = this.getAttribute("titulo_dica");
          }
          else {
            e_erp_tooltip_title_grl.style.textAlign  = "left";
          }
        }

        tag[i_contador].onmouseout = function() { 
          e_erp_tooltip_title_flh.innerText     = ""; 
          e_erp_tooltip_title_flh.style.display = "none"; 
        }
      }
    }
  }
}
