function nmAjaxChangeCss(cssChanges, seqRow)
{
    let baseSeq = seqRow.substr(1), underscoreSeq = "_" + baseSeq, ruleSelector, ruleName;
    for (ruleSelector in cssChanges) {
        for (ruleSeq in cssChanges[ruleSelector]) {
            if ("ajax_navigate" == seqRow) {
                baseSeq = ruleSeq;
                underscoreSeq = "_" + baseSeq;
            }
            for (ruleName in cssChanges[ruleSelector][ruleSeq]) {
                if ("sc_badge" == ruleName) {
                    if ("" != ruleSelector) {
                        $("#id_sc_field_" + ruleSelector + underscoreSeq).removeClass("sc-badge-pill").removeClass("sc-b-blue").removeClass("sc-b-brown").removeClass("sc-b-cyan").removeClass("sc-b-gray").removeClass("sc-b-green").removeClass("sc-b-orange").removeClass("sc-b-pink").removeClass("sc-b-purple").removeClass("sc-b-red").removeClass("sc-b-yellow");
                    }
                    if ("" != cssChanges[ruleSelector][ruleSeq][ruleName]) {
                        $("#id_sc_field_" + ruleSelector + underscoreSeq).addClass("sc-badge-pill").addClass("sc-b-" + cssChanges[ruleSelector][ruleSeq][ruleName]);
                    }
                } else if ("__sc_row" == ruleSelector) {
                    $("#SC_ancor" + baseSeq + " .scGridFieldOddFont").css(ruleName, cssChanges[ruleSelector][ruleSeq][ruleName]);
                    $("#SC_ancor" + baseSeq + " .scGridFieldEvenFont").css(ruleName, cssChanges[ruleSelector][ruleSeq][ruleName]);
                } else {
                    $("#SC_ancor" + baseSeq + " .css_" + ruleSelector + "_grid_line").css(ruleName, cssChanges[ruleSelector][ruleSeq][ruleName]);
                }
            }
        }
    }
}
  function nmAjaxRedir(oTemp)
  {
    if (oTemp && oTemp != null) {
        oResp = oTemp;
    }
    if (!oResp["redirInfo"]) {
      return;
    }
    sMetodo = oResp["redirInfo"]["metodo"];
    sAction = oResp["redirInfo"]["action"];
    if ("location" == sMetodo) {
      if ("parent.parent" == oResp["redirInfo"]["target"]) {
        parent.parent.location = sAction;
      }
      else if ("parent" == oResp["redirInfo"]["target"]) {
        parent.location = sAction;
      }
      else if ("_blank" == oResp["redirInfo"]["target"]) {
        window.open(sAction, "_blank");
      }
      else {
        document.location = sAction;
      }
    }
    else if ("html" == sMetodo) {
        document.write(nmAjaxSpecCharParser(oResp["redirInfo"]["action"]));
    }
    else {
      if (oResp["redirInfo"]["target"] == "modal") {
          tb_show('', sAction + '?script_case_init=' +  oResp["redirInfo"]["script_case_init"] + '&nmgp_parms=' + oResp["redirInfo"]["nmgp_parms"] + '&nmgp_outra_jan=true&nmgp_url_saida=modal&NMSC_modal=ok&TB_iframe=true&modal=true&height=' +  oResp["redirInfo"]["h_modal"] + '&width=' + oResp["redirInfo"]["w_modal"], '');
          return;
      }
      sFormRedir = (oResp["redirInfo"]["nmgp_outra_jan"]) ? "form_ajax_redir_1" : "form_ajax_redir_2";
      document.forms[sFormRedir].action           = sAction;
      document.forms[sFormRedir].target           = oResp["redirInfo"]["target"];
      document.forms[sFormRedir].nmgp_parms.value = oResp["redirInfo"]["nmgp_parms"];
      if ("form_ajax_redir_1" == sFormRedir) {
        document.forms[sFormRedir].nmgp_outra_jan.value = oResp["redirInfo"]["nmgp_outra_jan"];
      }
      else {
        document.forms[sFormRedir].nmgp_url_saida.value   = oResp["redirInfo"]["nmgp_url_saida"];
        document.forms[sFormRedir].script_case_init.value = oResp["redirInfo"]["script_case_init"];
      }
      document.forms[sFormRedir].submit();
    }
  }
var json_err_crtl    = 1;
var Id_Btn_selected  = new Array();
var Css_Btn_selected = new Array();
Id_Btn_selected[0] = "ordcmp_top";
function ajax_navigate(opc, parm, Fade='S')
{
    if (typeof parm == "string" && "reloadchart__" == parm.substring(0, 13)) {
        parm = parm.substring(13);
    }
    var scrollNavigateReload = false, extraParams = "", iEvt, iStart = 0, rebindClickOnFixedCols = false;
       $('.group_col_backdrop').remove();
    for (ibtn = 0; ibtn < 1; ibtn++) {
        Css_Btn_selected[ibtn] = $("#" + Id_Btn_selected[ibtn]).attr('class');
    }
    if (Fade == 'S') {
        nmAjaxProcOn();
    }
    if (scrollNavigateReload) {
      extraParams += "&scrollNavigateReload=Y";
    }
    if (typeof parm !== "string") {
      parm = parm.toString();
    }
    parm = parm.replace(/[+]/g, "__NM_PLUS__");
    while (parm.lastIndexOf("&amp;") != -1)
    {
       parm = parm.replace("&amp;" , "__NM_AMP__");
    }
    parm = parm.replace(/[&]/g, "__NM_AMP__");
    parm = parm.replace(/[%]/g, "__NM_PRC__");
    parm_save = parm;
    return new Promise(function(resolve, reject) {$.ajax({
      type: "POST",
      url: "index.php",
      data: "nmgp_opcao=ajax_navigate&script_case_init=" + document.F4.script_case_init.value + "&opc=" + opc  + "&parm=" + parm + extraParams
     })
     .fail(function(jqxhr, textStatus, error) {
        var err = textStatus + ", " + error;
        if (json_err_crtl == 1) {
            json_err_crtl++;
            ajax_navigate(opc, parm);
        }
        else {
            nmAjaxProcOff();
            json_err_crtl = 1;
            alert (err);
        }
     })
     .done(function(jsonNavigate) {
        var i, oResp;
        json_err_crtl = 1;
        Tst_integrid = jsonNavigate.trim();
        if ("{" != Tst_integrid.substr(0, 1)) {
            nmAjaxProcOff();
            alert (jsonNavigate);
            return;
        }
        eval("oResp = " + jsonNavigate);
        if (oResp["ss_time_out"]) {
            nmAjaxProcOff();
            nm_move();
        }
        if (!SC_Proc_Mobile) {
            document.getElementById('nmsc_iframe_liga_A_Consulta_DEN_1100_cat').src = 'NM_Blank_Page.htm';
            document.getElementById('nmsc_iframe_liga_E_Consulta_DEN_1100_cat').src = 'NM_Blank_Page.htm';
            document.getElementById('nmsc_iframe_liga_D_Consulta_DEN_1100_cat').src = 'NM_Blank_Page.htm';
            document.getElementById('nmsc_iframe_liga_B_Consulta_DEN_1100_cat').src = 'NM_Blank_Page.htm';
            document.getElementById('nmsc_iframe_liga_A_Consulta_DEN_1100_cat').style.height = '0px';
            document.getElementById('nmsc_iframe_liga_E_Consulta_DEN_1100_cat').style.height = '0px';
            document.getElementById('nmsc_iframe_liga_D_Consulta_DEN_1100_cat').style.height = '0px';
            document.getElementById('nmsc_iframe_liga_B_Consulta_DEN_1100_cat').style.height = '0px';
            document.getElementById('nmsc_iframe_liga_A_Consulta_DEN_1100_cat').style.width  = '0px';
            document.getElementById('nmsc_iframe_liga_E_Consulta_DEN_1100_cat').style.width  = '0px';
            document.getElementById('nmsc_iframe_liga_D_Consulta_DEN_1100_cat').style.width  = '0px';
            document.getElementById('nmsc_iframe_liga_B_Consulta_DEN_1100_cat').style.width  = '0px';
        }
        if (oResp["setValue"]) {
          for (i = 0; i < oResp["setValue"].length; i++) {
            $("#" + oResp["setValue"][i]["field"]).html(oResp["setValue"][i]["value"]);
            if ("sc_grid_body" == oResp["setValue"][i]["field"]) {
              if ("function" == typeof applyGroupButtons) {
                applyGroupButtons();
              }
            }
          }
        }
        if (oResp["setTitle"]) {
          for (i = 0; i < oResp["setTitle"].length; i++) {
            $("#" + oResp["setTitle"][i]["field"]).attr('title', oResp["setTitle"][i]["value"]);
          }
        }
        if (oResp["setArr"]) {
          for (i = 0; i < oResp["setArr"].length; i++) {
               eval (oResp["setArr"][i]["var"] + ' = new Array()');
          }
        }
        if (oResp["setVar"]) {
          for (i = 0; i < oResp["setVar"].length; i++) {
               eval (oResp["setVar"][i]["var"] + ' = \"' + oResp["setVar"][i]["value"] + '\"');
          }
        }
        if (oResp["fillArr"]) {
          for (i = 0; i < oResp["fillArr"].length; i++) {
               eval (oResp["fillArr"][i]["var"] + ' = {' + oResp["fillArr"][i]["value"] + '}');
          }
        }
        if (oResp["setThickbox"]) {
          for (i = 0; i < oResp["setThickbox"].length; i++) {
            eval ("document.getElementById('TB_iframeContent').contentWindow.document.getElementById('" + oResp["setThickbox"][i]["field"] + "').innerHTML = \"" + oResp["setThickbox"][i]["value"] + "\"");
          }
        }
        if (oResp["setDisplay"]) {
          for (i = 0; i < oResp["setDisplay"].length; i++) {
            if (typeof oResp["setDisplay"][i] === 'object' && oResp["setDisplay"][i] !== null) {
                var sVarField = oResp["setDisplay"][i].field;
                var sVarValue = oResp["setDisplay"][i].value;
            }
            else {
                var sVarField = oResp["setDisplay"][i]["field"];
                var sVarValue = oResp["setDisplay"][i]["value"];
            }
            if (document.getElementById(sVarField)){document.getElementById(sVarField).style.display = sVarValue;}
          }
        }
        if (oResp["setVisibility"]) {
          for (i = 0; i < oResp["setVisibility"].length; i++) {
            if (typeof oResp["setVisibility"][i] === 'object' && oResp["setVisibility"][i] !== null) {
                var sVarField = oResp["setVisibility"][i].field;
                var sVarValue = oResp["setVisibility"][i].value;
            }
            else {
                var sVarField = oResp["setVisibility"][i]["field"];
                var sVarValue = oResp["setVisibility"][i]["value"];
            }
            if (document.getElementById(sVarField)){document.getElementById(sVarField).style.visibility = sVarValue;}
          }
        }
        if (oResp["setDisabled"]) {
          for (i = 0; i < oResp["setDisabled"].length; i++) {
            if (typeof oResp["setDisabled"][i] === 'object' && oResp["setDisabled"][i] !== null) {
                var sVarField = oResp["setDisabled"][i].field;
                var sVarValue = oResp["setDisabled"][i].value;
            }
            else {
                var sVarField = oResp["setDisabled"][i]["field"];
                var sVarValue = oResp["setDisabled"][i]["value"];
            }
            if (document.getElementById(sVarField)){document.getElementById(sVarField).disabled = sVarValue;}
          }
        }
        if (oResp["setClass"]) {
          for (i = 0; i < oResp["setClass"].length; i++) {
            if (typeof oResp["setClass"][i] === 'object' && oResp["setClass"][i] !== null) {
                var sVarField = oResp["setClass"][i].field;
                var sVarValue = oResp["setClass"][i].value;
            }
            else {
                var sVarField = oResp["setClass"][i]["field"];
                var sVarValue = oResp["setClass"][i]["value"];
            }
            if (document.getElementById(sVarField)){document.getElementById(sVarField).className = sVarValue;}
          }
        }
        if (oResp["setSrc"]) {
          for (i = 0; i < oResp["setSrc"].length; i++) {
            if (typeof oResp["setSrc"][i] === 'object' && oResp["setSrc"][i] !== null) {
                var sVarField = oResp["setSrc"][i].field;
                var sVarValue = oResp["setSrc"][i].value;
            }
            else {
                var sVarField = oResp["setSrc"][i]["field"];
                var sVarValue = oResp["setSrc"][i]["value"];
            }
            if (document.getElementById(sVarField)){document.getElementById(sVarField).src = sVarValue;}
          }
        }
        if (oResp["remove_Obj"]) {
          for (i = 0; i < oResp["remove_Obj"].length; i++) {
            if (typeof oResp["remove_Obj"][i] === 'object' && oResp["remove_Obj"][i] !== null) {
                var sVarField = oResp["remove_Obj"][i].field;
                var sVarValue = oResp["remove_Obj"][i].value;
            }
            else {
                var sVarField = oResp["remove_Obj"][i]["field"];
                var sVarValue = oResp["remove_Obj"][i]["value"];
            }
            if (document.getElementById(sVarField)){document.getElementById(sVarField).src = remove();}
          }
        }
        if (oResp["redirInfo"]) {
           nmAjaxRedir(oResp);
        }
        if (oResp["changeCss"]) {
           nmAjaxChangeCss(oResp["changeCss"], 'ajax_navigate');
        }
        if (oResp["AlertJS"]) {
          for (i = 0; i < oResp["AlertJS"].length; i++) {
              jsAlertParams = oResp["AlertJSParam"][i] ? oResp["AlertJSParam"][i] : {};
              scJs_alert (oResp["AlertJS"][i], jsAlertParams);
          }
        }
        if (oResp["exec_JS"]) {
          for (i = 0; i < oResp["exec_JS"].length; i++) {
               eval (oResp["exec_JS"][i]["function"] + '("' + oResp["exec_JS"][i]["parm"] + '");');
          }
        }
        if (oResp["grid_search_add"]) {
          for (i = 0; i < oResp["grid_search_add"].length; i++) {
               var parm = oResp["grid_search_add"][i]['field'];
               Tot_obj_grid_search++;
               Tab_obj_grid_search[Tot_obj_grid_search] = parm;
               $(oResp["grid_search_add"][i]['tag']).insertBefore('#add_grid_search');
               $('#grid_search_' + parm).attr('new', 'new');
               scLoadScInput('#grid_search_' + parm + '_' + Tot_obj_grid_search + ' input:text.sc-js-input');
          }
          SC_carga_evt_jquery_grid('all');
        }
        if (oResp["htmOutput"]) {
           nmAjaxShowDebug(oResp);
        }
        scFixCol_addClickControl();
        scFixCol_loadState();
        if (typeof SC_Link_View !== 'undefined' && !SC_Link_View)
        {
            if (Qsearch_ok)
            {
                scQuickSearchKeyUp('top', null);
            }
            if (parm == "save_grid") {
                Dyn_Ini = true;
            }
            if (("dyn_search_clear" == opc) && typeof(buttonDisable_dyn) === typeof(function(){})) {
                 buttonDisable_dyn('dyn_search_clear');
                 buttonDisable_dyn('dyn_search');
                 buttonDisable_dyn('Save_frm_dyn');
            }else if(("dyn_search_select" == opc ||  "dyn_search_save" == opc) && typeof(buttonEnable_dyn) === typeof(function(){}))
            {
                buttonEnable_dyn('dyn_search_clear');
                buttonDisable_dyn('dyn_search');
            }
            SC_init_jquery(false);
            tb_init('a.thickbox, area.thickbox, input.thickbox');
        }
        for (ibtn = 0; ibtn < 1; ibtn++) {
             $("#" + Id_Btn_selected[ibtn]).attr('class', Css_Btn_selected[ibtn]);
        }
        if (Fade == 'S') {
            nmAjaxProcOff();
        }
        if (typeof(bootstrapMobile) === typeof(function(){})) bootstrapMobile(opc);
        resolve();
          var hval = 0;
          if (document._toolbarHeightFix != undefined) {
            hval = document._toolbarHeightFix;
          }
            scSetFixedHeadersCss(hval);
            scSetFixedHeaders();
    })});
}
function ajax_navigate_res(opc, parm, Fade='S')
{
    let extraParams = [], extraParamsString = "", refixLabels = false;
    if (typeof parm == "string" && "reloadchart__" == parm.substring(0, 13)) {
        parm = parm.substring(13);
        extraParams.push("reload_chart=Y");
        refixLabels = true;
    }
    if (typeof parm == "string" && "change_record_pagination" == parm.substring(0, 24)) {
        refixLabels = true;
    }
    if (typeof parm == "string" && "change_page_pagination" == parm.substring(0, 22)) {
        refixLabels = true;
    }
    if (typeof parm == "string" && "change_length_pagination" == parm.substring(0, 24)) {
        refixLabels = true;
    }
    $('.group_col_backdrop').remove();
    if (Fade == 'S') {
        nmAjaxProcOn();
    }
    parm_save = parm;
    if (extraParams.length) {
        extraParamsString = "&" + extraParams.join("&");
    }
    $.ajax({
      type: "POST",
      url: "index.php",
      data: "nmgp_opcao=ajax_navigate&script_case_init=" + document.FRES.script_case_init.value + "&opc=" + opc  + "&parm=" + parm + extraParamsString
     })
     .done(function(jsonNavigate) {
        if ("grid_search_res" == opc && typeof scSummaryNoRecords != "undefined" && scSummaryNoRecords) {
            document.refresh_config.submit();
            return;
        }
        var i, oResp;
        Tst_integrid = jsonNavigate.trim();
        if ("{" != Tst_integrid.substr(0, 1)) {
            nmAjaxProcOff();
            alert (jsonNavigate);
            return;
        }
        eval("oResp = " + jsonNavigate);
        if (oResp["ss_time_out"]) {
            nmAjaxProcOff();
            nm_move();
        }
        if (oResp["setValue"]) {
          for (i = 0; i < oResp["setValue"].length; i++) {
            $("#" + oResp["setValue"][i]["field"]).html(oResp["setValue"][i]["value"]);
          }
        }
        if (oResp["setJqueryVal"]) {
          for (i = 0; i < oResp["setJqueryVal"].length; i++) {
            $("#" + oResp["setJqueryVal"][i]["field"]).val(oResp["setJqueryVal"][i]["value"]);
          }
        }
        if (oResp["setTitle"]) {
          for (i = 0; i < oResp["setTitle"].length; i++) {
            $("#" + oResp["setTitle"][i]["field"]).attr('title', oResp["setTitle"][i]["value"]);
          }
        }
        if (oResp["setArr"]) {
          for (i = 0; i < oResp["setArr"].length; i++) {
               eval (oResp["setArr"][i]["var"] + ' = new Array()');
          }
        }
        if (oResp["setVar"]) {
          for (i = 0; i < oResp["setVar"].length; i++) {
               eval (oResp["setVar"][i]["var"] + ' = \"' + oResp["setVar"][i]["value"] + '\"');
          }
        }
        if (oResp["fillArr"]) {
          for (i = 0; i < oResp["fillArr"].length; i++) {
               eval (oResp["fillArr"][i]["var"] + ' = {' + oResp["fillArr"][i]["value"] + '}');
          }
        }
        if (oResp["setThickbox"]) {
          for (i = 0; i < oResp["setThickbox"].length; i++) {
            eval ("document.getElementById('TB_iframeContent').contentWindow.document.getElementById('" + oResp["setThickbox"][i]["field"] + "').innerHTML = \"" + oResp["setThickbox"][i]["value"] + "\"");
          }
        }
        if (oResp["setDisplay"]) {
          for (i = 0; i < oResp["setDisplay"].length; i++) {
            if (typeof oResp["setDisplay"][i] === 'object' && oResp["setDisplay"][i] !== null) {
                var sVarField = oResp["setDisplay"][i].field;
                var sVarValue = oResp["setDisplay"][i].value;
            }
            else {
                var sVarField = oResp["setDisplay"][i]["field"];
                var sVarValue = oResp["setDisplay"][i]["value"];
            }
            if (document.getElementById(sVarField)){document.getElementById(sVarField).style.display = sVarValue;}
          }
        }
        if (oResp["setVisibility"]) {
          for (i = 0; i < oResp["setVisibility"].length; i++) {
            if (typeof oResp["setVisibility"][i] === 'object' && oResp["setVisibility"][i] !== null) {
                var sVarField = oResp["setVisibility"][i].field;
                var sVarValue = oResp["setVisibility"][i].value;
            }
            else {
                var sVarField = oResp["setVisibility"][i]["field"];
                var sVarValue = oResp["setVisibility"][i]["value"];
            }
            if (document.getElementById(sVarField)){document.getElementById(sVarField).style.visibility = sVarValue;}
          }
        }
        if (oResp["setDisabled"]) {
          for (i = 0; i < oResp["setDisabled"].length; i++) {
            if (typeof oResp["setDisabled"][i] === 'object' && oResp["setDisabled"][i] !== null) {
                var sVarField = oResp["setDisabled"][i].field;
                var sVarValue = oResp["setDisabled"][i].value;
            }
            else {
                var sVarField = oResp["setDisabled"][i]["field"];
                var sVarValue = oResp["setDisabled"][i]["value"];
            }
            if (document.getElementById(sVarField)){document.getElementById(sVarField).disabled = sVarValue;}
          }
        }
        if (oResp["setClass"]) {
          for (i = 0; i < oResp["setClass"].length; i++) {
            if (typeof oResp["setClass"][i] === 'object' && oResp["setClass"][i] !== null) {
                var sVarField = oResp["setClass"][i].field;
                var sVarValue = oResp["setClass"][i].value;
            }
            else {
                var sVarField = oResp["setClass"][i]["field"];
                var sVarValue = oResp["setClass"][i]["value"];
            }
            if (document.getElementById(sVarField)){document.getElementById(sVarField).className = sVarValue;}
          }
        }
        if (oResp["setSrc"]) {
          for (i = 0; i < oResp["setSrc"].length; i++) {
            if (typeof oResp["setSrc"][i] === 'object' && oResp["setSrc"][i] !== null) {
                var sVarField = oResp["setSrc"][i].field;
                var sVarValue = oResp["setSrc"][i].value;
            }
            else {
                var sVarField = oResp["setSrc"][i]["field"];
                var sVarValue = oResp["setSrc"][i]["value"];
            }
            if (document.getElementById(sVarField)){document.getElementById(sVarField).src = sVarValue;}
          }
        }
        if (oResp["grid_search_add"]) {
          for (i = 0; i < oResp["grid_search_add"].length; i++) {
               var parm = oResp["grid_search_add"][i]['field'];
               Tot_obj_grid_search++;
               Tab_obj_grid_search[Tot_obj_grid_search] = parm;
               $(oResp["grid_search_add"][i]['tag']).insertBefore('#add_grid_search');
               $('#grid_search_' + parm).attr('new', 'new');
               scLoadScInput('#grid_search_' + parm + '_' + Tot_obj_grid_search + ' input:text.sc-js-input');
          }
          SC_carga_evt_jquery_grid('all');
        }
        if (("dyn_search_clear_res" == opc) && typeof(buttonDisable_dyn) === typeof(function(){})) {
            buttonDisable_dyn('dyn_search_clear');
            buttonDisable_dyn('dyn_search');
            buttonDisable_dyn('Save_frm_dyn');
        }else if(("dyn_search_select_res" == opc || "dyn_search_save_res" == opc) && typeof(buttonEnable_dyn) === typeof(function(){}))
        {
            buttonDisable_dyn('dyn_search');
            buttonEnable_dyn('dyn_search_clear');
        }
        if (oResp["redirInfo"]) {
           nmAjaxRedir(oResp);
        }
        if (("resumo_search" == opc || "grid_search_res" == opc || "dyn_search_res" == opc || "dyn_search_clear_res" == opc || "dyn_search_save_res" == opc || "dyn_search_select_res" == opc || "dyn_search_delete_res" == opc) && typeof scChart_update_inline == "function") {
            scChart_update_inline();
        }
        if (oResp["click_sel_groupby"] && "" != oResp["click_sel_groupby"]) {
            document.getElementById(oResp["click_sel_groupby"]).click();
        }
        if (oResp["AlertJS"]) {
          for (i = 0; i < oResp["AlertJS"].length; i++) {
              jsAlertParams = oResp["AlertJSParam"][i] ? oResp["AlertJSParam"][i] : {};
              scJs_alert (oResp["AlertJS"][i], jsAlertParams);
          }
        }
        if (oResp["exec_JS"]) {
          for (i = 0; i < oResp["exec_JS"].length; i++) {
               eval (oResp["exec_JS"][i]["function"] + '("' + oResp["exec_JS"][i]["parm"] + '");');
          }
        }
        if (oResp["htmOutput"]) {
           nmAjaxShowDebug(oResp);
        }
        if (typeof scOrder_addClickControl == "function") {
            scOrder_addClickControl();
        }
        if (Fade == 'S') {
            nmAjaxProcOff();
        }
        if (oResp["exec_script"]) {
          for (i = 0; i < oResp["exec_script"].length; i++) {
              eval (oResp["exec_script"][i]);
          }
        }
    });
}
function ajax_select_filter(opt, param)
{
    nmAjaxProcOn();
    $.ajax({
      type: "POST",
      url: "index.php",
      data: "nmgp_opcao=ajax_navigate&opc="+ opt +"&script_case_init=" + document.Fdyn_search.script_case_init.value + "&parm=" + param
     })
     .done(function(selectFilter) {
        nm_change_grid_search_dyn_navigate();
        nmAjaxProcOff();
     });
}
function ajax_add_dyn_search(str_field, str_origem)
{
    nm_hide_dynamicsearch_fields('id_dynamic_search_fields', true);
    if ($("#id_dyn_search_fields").prop("disabled") == true) {
        return;
    }
    nm_dynamicsearch_backup();
    var parm = str_field;
    if (parm == "")
    {
        return;
    }
    $('#table_dyn_search_criteria').show();
    nmAjaxProcOn();
    Tot_obj_dyn_search++;
    Tab_obj_dyn_search[Tot_obj_dyn_search] = parm;
    $.ajax({
      type: "POST",
      url: "index.php",
      data: "nmgp_opcao=ajax_add_dyn_search&script_case_init=" + document.Fdyn_search.script_case_init.value + "&parm=" + parm + "&seq=" + Tot_obj_dyn_search + "&origem=" + str_origem
     })
     .done(function(jsonDyn_add) {
        var i, oResp;
        Tst_integrid = jsonDyn_add.trim();
        if ("{" != Tst_integrid.substr(0, 1)) {
            nmAjaxProcOff();
            alert (jsonDyn_add);
            return;
        }
        eval("oResp = " + jsonDyn_add);
        if (oResp["ss_time_out"]) {
            nmAjaxProcOff();
            nm_move();
        }
        if (oResp["dyn_add"]) {
          for (i = 0; i < oResp["dyn_add"].length; i++) {
               $('#table_dyn_search').append(oResp["dyn_add"][i]);
          }
        }
        if (oResp["setVar"]) {
          for (i = 0; i < oResp["setVar"].length; i++) {
               eval (oResp["setVar"][i]["var"] + ' = \"' + oResp["setVar"][i]["value"] + '\"');
          }
        }
        if (oResp["htmOutput"]) {
           nmAjaxShowDebug(oResp);
        }
        SC_carga_evt_jquery(Tot_obj_dyn_search);
        scLoadScInput('#dyn_search_' + parm + '_' + Tot_obj_dyn_search + ' input:text.sc-js-input');
        Dyn_Have_Clear = false;
        buttonEnable_dyn('dyn_search');
        buttonEnable_dyn('dyn_search_clear');
                      nmAjaxProcOff();
    });
}
function ajax_add_grid_search(obj, str_origem, str_field)
{
    $(obj).parent().parent().remove();
    
    if($('#id_grid_search_all_cmp tr').length < 1)
    {
        $('#add_grid_search').addClass('scGridFilterTagAddDisabled');
    }
    else
    {
        $('#add_grid_search').removeClass('scGridFilterTagAddDisabled');
    }
    parm  = str_field;
    nmAjaxProcOn();
    Tot_obj_grid_search++;
    Tab_obj_grid_search[Tot_obj_grid_search] = parm;
    $.ajax({
      type: "POST",
      url: "index.php",
      data: "nmgp_opcao=ajax_add_grid_search&script_case_init=" + document.Fgrid_search.script_case_init.value + "&parm=" + parm + "&seq=" + Tot_obj_grid_search + "&origem=" + str_origem
     })
     .done(function(jsonGrid_add) {
        var i, oResp;
        Tst_integrid = jsonGrid_add.trim();
        if ("{" != Tst_integrid.substr(0, 1)) {
            nmAjaxProcOff();
            alert (jsonGrid_add);
            return;
        }
        eval("oResp = " + jsonGrid_add);
        if (oResp["ss_time_out"]) {
            nmAjaxProcOff();
            nm_move();
        }
        if (oResp["grid_add"]) {
          for (i = 0; i < oResp["grid_add"].length; i++) {
               $(oResp["grid_add"][i]).insertBefore('#add_grid_search');
               $('#grid_search_' + parm).attr('new', 'new');
               $('#grid_search_' + parm).find('.scGridFilterTagListItemLabel').click();
               $('#grid_search_' + parm).find('input[type=text]').focus();
          }
        }
        if (oResp["setVar"]) {
          for (i = 0; i < oResp["setVar"].length; i++) {
               eval (oResp["setVar"][i]["var"] + ' = \"' + oResp["setVar"][i]["value"] + '\"');
          }
        }
        if (oResp["htmOutput"]) {
           nmAjaxShowDebug(oResp);
        }
        SC_carga_evt_jquery_grid(Tot_obj_grid_search);
        scLoadScInput('#grid_search_' + parm + '_' + Tot_obj_grid_search + ' input:text.sc-js-input');
        nmAjaxProcOff();
    });
}
function ajax_save_ancor(f_submit, ancor)
{
    nmAjaxProcOn();
    $.ajax({
      type: "POST",
      url: "index.php",
      data: "nmgp_opcao=ajax_save_ancor&script_case_init=" + document.F3.script_case_init.value + "&ancor_save=" + ancor
     })
     .done(function(jsonSaveAncor) {
        nmAjaxProcOff();
        eval ("document." + f_submit + ".submit()");
    });
}
var strPath         = '';
var strTitle        = '';
var showAjaxProcess = true;
function ajax_export(tp_export, parms, strCallback, showAjax)
{
    strPath  = '';
    strTitle  = '';
    showAjaxProcess = showAjax;
    if(showAjaxProcess)
    {
        nmAjaxProcOn();
    }
    $.ajax({
      type: "POST",
      url: "index.php",
      data: "nmgp_opcao=ajax_export&export_opc=" + tp_export + parms + "&script_case_init=" + document.F3.script_case_init.value,
      complete: strCallback,
     })
     .done(function(jsonFile) {
        var oResp;
        Tst_integrid = jsonFile.trim();
        if ("{" != Tst_integrid.substr(0, 1)) {
            nmAjaxProcOff();
            alert (jsonFile);
            return;
        }
        eval("oResp = " + jsonFile);
        if (oResp["ss_time_out"]) {
            nmAjaxProcOff();
            nm_move();
        }
        if (oResp["htmOutput"]) {
           nmAjaxShowDebug(oResp);
        }
        if (oResp["file_export"]) {
            strPath = oResp['file_export'];
            strTitle = oResp['title_export'];
        }
        if(showAjaxProcess)
        {
            nmAjaxProcOff();
        }
    });
}

