/* @@BEGIN_COPYRIGHT@@ */
/* Licensed Internal Code - Property of IBM */
/* 3931 3932 Licensed Internal Code */
/* (C) Copyright IBM Corp. 2000, 2022 All Rights Reserved. */
/* @@END_COPYRIGHT@@ */
/*********************************************************** {COPYRIGHT-TOP} ***
* Licensed Materials - Property of IBM
* Tivoli Presentation Services
*
*
************************************************************ {COPYRIGHT-END} ***
*******************************************************************************/

/*******************************************************************************
* This file contains all of the javascript functions used by the WCL renderers
* when AJAX is being used.  The functions defined here must be stateless -- that
* is, no member variables can be defined, so all state information must be
* passed into the function as parameters.
*******************************************************************************/

/** AWInputComponent **
 * action - the name of the action. do not encode because it is used as the
 *          value of a hidden input field.
 * formName - this encoded name of the form
 * wclhidden - the encoded name of the hidden field
 */
function frmActAjax(action, formName, wclhidden) {
   if (document != null && document.forms != null && formName != null) {
      var form = document.forms[formName];
      if (form != null) {
         eval( "form." + wclhidden + ".value = '" + action + "'" );
         startRequest(form, null, event?.target?.id);
         // Reset the form values.
         eval("form." + wclhidden + ".value = ''");
      }
   }
}
/*
*checkBox action instead of form.submit()
*/
function checkBoxActAjax(action, formName) {
   if (document != null && document.forms != null && formName != null) {
      var form = document.forms[formName];
      if (form != null) {
         startRequest(form, null);
      }
   }
}

/*
*textEntry action instead of form.submit()
*/
function textEntryActAjax(action, formName, wclhidden) {
   if (document != null && document.forms != null && formName != null) {
      var form = document.forms[formName];
      if (form != null) {
         if (action != null) {
            eval( "form." + wclhidden + ".value = '" + action + "'" );
         }
         startRequest(form, null);
         // Reset the form values.
         eval("form." + wclhidden + ".value = ''");
      }
   }
}

/*
*comboBox action instead of form.submit()
*/
function comboBoxActAjax(action, formName) {
   if (document != null && document.forms != null && formName != null) {
      var form = document.forms[formName];
      if (form != null) {
         startRequest(form, null);
      }
   }
}


function popupActAjax(action, formName, wclhidden) {
   if (document != null && document.forms != null && formName != null) {
      var form = document.forms[formName];
      if (form != null) {
         eval( "form." + wclhidden + ".value = '" + action + "'" );
         startRequestSingleUpdate(form, null, action);
         // Reset the form values.
         eval("form." + wclhidden + ".value = ''");
      }
   }
}

/** WPopupMenu **
 * formName - the encoded name of the form
 * actionName - the unique name of the action being performed
 * actionValue - the name of the component performing the action
 * actionNameEnc - the encoded name of the action being performed
 * menuID - the name of the unique id of the popup menu
 * menuCmd - the encoded name of the action being performed
 * wclhidden - the encoded name of the hidden field
 */

function doPopAjax(formName, actionName, actionValue, actionNameEnc, menuID, menuCmd, wclhidden)
{
   if (document != null && document.forms != null && formName != null) {
       var form = document.forms[formName];
       if (form != null) {
           if (actionName != null && actionNameEnc != null && wclhidden != null) {
             eval("form." + actionNameEnc + ".value = '" + actionValue + "'");
             eval("form." + wclhidden + ".value = '" + actionName + "'");
           }
           // We have to store the command name as a hidden field so that it gets passed
           // along when the form is submitted.
           if (menuID != null) {
             eval("form." + menuID + ".value = '" + menuCmd + "'");
           }
           //form.submit();
           startRequest(form, actionName);
           eval("form." + actionNameEnc + ".value = ''");
           eval("form." + wclhidden + ".value = ''");
           if (menuID != null) {
             eval("form." + menuID + ".value = ''");
           }
       }
   }
   return false;
}

/** WMessageBox **
 * name - the name of the close hyperlink
 * ids - the ids associated with the close hyperlink
 * formName - the encoded name of the form
 * wclhidden - the encoded name of the hidden field for the close hyperlink name
 * wclMessageClosed - the encodedName of the hidden field for the ids
 */
function msgActAjax(mname, ids, formName, wclhidden, wclMessageClosed) {
   if (document != null && document.forms != null && formName != null) {
      var form = document.forms[formName];
      if (form != null) {
         eval( "form." + wclhidden + ".value = '" + mname + "'" );
         eval( "form." + wclMessageClosed + ".value = '" + ids + "'" );
         startRequest(form, null);
         eval( "form." + wclhidden + ".value = ''" );
         eval( "form." + wclMessageClosed + ".value = ''" );
      }
   }
   return false;
}


/**
 * formName - the encoded name of the form
 * actionName - the name of the action being performed
 * actionValue - the name of the component performing the action
 * anchorName - the name of the anchor used when the page is refreshed
 * actionNameEnc - the encoded name of the action being performed
 * wclhidden - the encoded name of the hidden field
 * wclanchor - the encoded name of the hidden field for the anchor
 */
function doWizButtonAjax(formName, actionName, actionValue, actionNameEnc, wclhidden) {
   if (document != null && document.forms != null && formName != null) {
      var form = document.forms[formName];
      if (form != null) {
         eval("form." + wclhidden + ".value = '" + wclhidden + "'");
         startRequest(form, actionName);
         // Reset the form values.
         eval("form." + wclhidden + ".value = ''");
         //reset Context Sensitive Help because we updated the page
         resetContextSensitiveHelp();
      }
   }
   return false;
}

/** WNotebook **
 * formName - the encoded name of the form
 * actionName - the name of the action being performed
 * actionValue - the name of the component performing the action
 * actionNameEnc - the encoded name of the action being performed
 * wclhidden - the encoded name of the hidden field
 * wclanchor - the encoded name of the hidden field for the anchor
 */
function doNbAjax(formName, actionName, actionValue, actionNameEnc, wclhidden, wclanchor) {
   return doSubmitAjax(formName, actionName, actionValue, null, actionNameEnc, wclhidden, wclanchor);
}

/** WWizard **
 * formName - the encoded name of the form
 * actionName - the name of the action being performed
 * actionValue - the name of the component performing the action
 * actionNameEnc - the encoded name of the action being performed
 * wclhidden - the encoded name of the hidden field
 * wclanchor - the encoded name of the hidden field for the anchor
 */
function doWizAjax(formName, actionName, actionValue, actionNameEnc, wclhidden, wclanchor) {
    //reset Context Sensitive Help because we updated the page
    resetContextSensitiveHelp();
   return doSubmitAjax(formName, actionName, actionValue, null, actionNameEnc, wclhidden, wclanchor);
}

/** WTree (for the expand/collapse events) **
 * formName - the encoded name of the form
 * actionName - the name of the action being performed
 * actionValue - the name of the component performing the action
 * anchorName - the name of the anchor used when the page is refreshed
 * actionNameEnc - the encoded name of the action being performed
 * wclhidden - the encoded name of the hidden field
 * wclanchor - the encoded name of the hidden field for the anchor
 * idName - the encoded name of the hidden field that specifies which tree in the form is performing the action
 */
function doTreeAjax(formName, actionName, actionValue, anchorName, actionNameEnc, wclhidden, wclanchor, idName){
   if (document != null && document.forms != null && formName != null) {
      var form = document.forms[formName];
      if (form != null) {
         if(idName != null){
             eval("form." + idName + ".value = '" + idName + "'");
         }
      }
   }
   return doSubmitAjax(formName, actionName, actionValue, anchorName, actionNameEnc, wclhidden, wclanchor);
}

/**
 * formName - the encoded name of the form
 * actionName - the name of the action being performed
 * actionValue - the name of the component performing the action
 * anchorName - the name of the anchor used when the page is refreshed
 * actionNameEnc - the encoded name of the action being performed
 * wclhidden - the encoded name of the hidden field
 * wclanchor - the encoded name of the hidden field for the anchor
 */
function doSubmitAjax(formName, actionName, actionValue, anchorName, actionNameEnc, wclhidden, wclanchor) {
   if (document != null && document.forms != null && formName != null) {
      var form = document.forms[formName];
      if (form != null) {
         if (actionName != null) {
            eval("form." + actionNameEnc + ".value = '" + actionValue + "'");
            eval("form." + wclhidden + ".value = '" + actionName + "'");
         }
         startRequest(form, null);
         // Reset the form values.
         eval("form." + actionNameEnc + ".value = ''");
         eval("form." + wclhidden + ".value = ''");
      }
   }
   return false;
}

/**
 * Just like doSubmitAjax, but it posts value of submit item as well.
 * formName - the encoded name of the form
 * actionName - the name of the action being performed
 * actionValue - the name of the component performing the action
 * anchorName - the name of the anchor used when the page is refreshed
 * actionNameEnc - the encoded name of the action being performed
 * wclhidden - the encoded name of the hidden field
 * wclanchor - the encoded name of the hidden field for the anchor
 */
function doSubmitActionAjax(formName, actionName, actionValue, anchorName, actionNameEnc, wclhidden, wclanchor) {
   if (document != null && document.forms != null && formName != null) {
      var form = document.forms[formName];
      if (form != null) {
         var originalValue = '';
         if (actionName != null) {
           eval("originalValue = form." + actionNameEnc + ".value" );
            eval("form." + actionNameEnc + ".value = '" + actionValue + "'");
            eval("form." + wclhidden + ".value = '" + actionName + "'");
         }
         startRequest(form, actionName);
         // Reset the form values.
         eval("form." + actionNameEnc + ".value = originalValue");
         eval("form." + wclhidden + ".value = ''");
      }
   }
   return false;
}


/**
 * formName - the encoded name of the form
 * actionName - the name of the action being performed
 * actionValue - the name of the component performing the action
 * anchorName - the name of the anchor used when the page is refreshed
 * actionNameEnc - the encoded name of the action being performed
 * wclhidden - the encoded name of the hidden field
 * wclanchor - the encoded name of the hidden field for the anchor
 */
function doFormSubmitAjax(formName, actionName, actionValue, anchorName, actionNameEnc, wclhidden, wclanchor) {
   if (document != null && document.forms != null && formName != null) {
      var form = document.forms[formName];
      if (form != null) {
         if (actionName != null) {
            eval("form." + actionNameEnc + ".value = '" + actionValue + "'");
            eval("form." + wclhidden + ".value = '" + actionName + "'");
         }

         // @auiml - begin
         // We have to store the anchor as a hidden field so that it gets passed
         // along when the form's method is GET.  (When the method is GET, the
         // parameters on the form's action are ignored!)  The date ensures we'll
         // have a unique URL so that a URL can be invoked twice consecutively.
         if (anchorName != null) {
            var aDate = new Date();
            eval("form." + wclanchor + ".value = '" + anchorName + '_' + aDate.getTime() + "'");
            var idx = form.action.indexOf('#');
            if (idx > -1) {
                // strip off the anchor that's already on the url
                form.action = form.action.substring(0, idx);
            }
            form.action += '#' + anchorName;
         }
         // @auiml - end

         form.submit();
      }
   }
   return false;
}

/** WTable **
 * formName - the encoded name of the form
 * actionValue - the name of the component performing the action
 * anchorName - the name of the anchor used when the page is refreshed
 * wclhidden - the encoded name of the hidden field
 * wclanchor - the encoded name of the hidden field for the anchor
 * userActions - the userActions id to be used if the GO button is missing
 */
function doUserActionAjax(formName, actionValue, anchorName, wclhidden, wclanchor, userActions) {
   wclajax_debug("-->doUserActionAjax");

   var result = false;
   var dropDownId = "userActions" + actionValue.substring(10);
   var dropDown = document.getElementById(dropDownId);
   wclajax_debug("dropDownId [" + dropDownId + "]");
   var ajax = false;
   var skip = false;
   if (dropDown) {
      wclajax_debug("got dropDown [" + dropDown.id + "]");
      // See if we can skip this action (the --- Select Action --- is selected).
      if (dropDown.selectedIndex == 0) {
         wclajax_debug("skip");
         skip = true;
      }
      // See if this is a table action (not a user one).
      else { //if (dropDown.options[dropDown.selectedIndex].value.indexOf("user(") == -1) {
         wclajax_debug("ajax");
         ajax = true;
      }

      var option = dropDown.options[dropDown.selectedIndex];
      // check if this should be executed as AJAX or not
      if(option.getAttribute("USE_AJAX") == null){
    return doAnchor(formName, anchorName, wclanchor, dropDownId);
      }

      if(option){
        //@hmc@ - support modern IE
        //if (WClient.isBrowserInternetExplorer()){
        //  if(option.message!=null){
        //    var message = option.getAttribute("message");
        //    skip = !(confirm(message));
        //  }
        //} else {
          if(option.hasAttribute("message")){
            var message = option.getAttribute("message");
            skip = !(confirm(message));
          }
        //}
      }
   }
   if (!skip) {
      var actionName = "action_";
      actionName = actionName.concat(actionValue.substring(actionValue.indexOf("_") + 1));
      if (ajax) {
         //result = doAnchorAjax(formName, actionValue, anchorName, wclhidden, wclanchor, userActions);
     if(dropDown.value.indexOf("/ExportData?exportId") != -1) {
       var url = dropDown.value;
       if (window.hmcTaskId) {
         url = url + '&launching-task-id=' + window.hmcTaskId;
       }
       window.open(url,'_self');
     }
     else if(dropDown.value.indexOf('changeSelected') == 0) {
           changeAllSelectedAjax(formName, actionName, actionName, wclhidden);
         }
         else {
              doTblAjax(formName, actionName, dropDown.value, anchorName, actionName, wclhidden, wclanchor);
         }
      }
      else {
        // result = doAnchor(formName, anchorName, wclanchor);
     doTbl(formName, actionName, dropDown.value, anchorName, actionName, wclhidden, wclanchor);
         if (userActions) {
            var form = document.forms[formName];
            form.submit();
         }
      }
   }
   dropDown.selectedIndex = 0;
   wclajax_debug("-->doUserActionAjax : " + result);
   return result;
}

/** WTable **
 * formName - the encoded name of the form
 * actionValue - the name of the component performing the action
 * anchorName - the name of the anchor used when the page is refreshed
 * wclhidden - the encoded name of the hidden field
 * wclanchor - the encoded name of the hidden field for the anchor
 * userActions - the optional userActions ID, will be used as hidden
 */
function doAnchorAjax(formName, actionValue, anchorName, wclhidden, wclanchor, userActions) {
   wclajax_debug("-->doAnchorAjax");
   var form = document.forms[formName];
   if (form != null && anchorName != null && wclanchor != null) {
      var aDate = new Date().getTime();
      eval("form." + wclanchor + ".value = '" + aDate + "'");
      if (actionValue != null && actionValue.length > 0) {
         if (userActions) {
            eval("form." + wclhidden + ".value = '" + userActions + "'");
         } else if (actionValue.indexOf("cancel") != -1 || actionValue.indexOf("okay") != -1) {
            eval("form." + wclhidden + ".value = '" + actionValue + "'");
         } else {
            eval("form." + wclhidden + ".value = '" + wclhidden + "'");
         }
      }

      var inputName = "wclAnchorHash";
      var input  = document.getElementById( inputName );
      if ( !input )
      {
          input = document.createElement( "INPUT" );
          with ( input )
          {
              type  = "hidden";
              id    = inputName;
              name  = inputName;
          }
          form.appendChild( input );
      }
      input.value = anchorName;

      if (actionValue != null && actionValue.length > 0) {
         wclajax_debug("doAnchorAjax calling startRequest...");
         startRequest(form, actionValue);
         // Reset the form values.
         eval("form." + wclanchor + ".value = ''");
         eval("form." + wclhidden + ".value = ''");
         return false;
      }
   }
   wclajax_debug("<--doAnchorAjax");
   return true;
}

/** WTable **
 * formName - the encoded name of the form
 * actionName - the name of the action being performed
 * actionValue - the name of the component performing the action
 * anchorName - the name of the anchor used when the page is refreshed
 * actionNameEnc - the encoded name of the action being performed
 * wclhidden - the encoded name of the hidden field
 * wclanchor - the encoded name of the hidden field for the anchor
 */
function doTblAjax(formName, actionName, actionValue, anchorName, actionNameEnc, wclhidden, wclanchor, event) {
   if ( event != null ) {
      //if user ctrl-/shift-/alt-clicked for table action, prevent action from opening new tab/window/etc
      if ( event.ctrlKey || event.shiftKey || event.altKey ) {
         if ( event.preventDefault ) {
            //W3C Model, Mozilla/Opera
            event.preventDefault();
            event.stopPropagation();
         } else {
            //Microsoft Model, IE
            event.returnValue = false;
            event.cancelBubble = true;
         }

         //if shift-click, turn actionValue "select(n)" into "select(multi-n)"
         if ( event.shiftKey && actionValue.indexOf("select") != -1 ) {
            var re = /(select\()(\d*\))/;
            actionValue = actionValue.replace(re, "$1multi-$2");
         }
      }//endIf
   }//endIf

   if (document != null && document.forms != null && formName != null) {
      var form = document.forms[formName];
      if (form != null) {
         if (actionName != null) {
            form[actionNameEnc].value = actionValue;
            form[wclhidden].value = actionName;
         }

         wclajax_debug("actionNameEnc = " + actionNameEnc);
         wclajax_debug("actionValue = " + actionValue);

         wclajax_debug("AJAX request with action = " + form.action);

         startRequest(form, null);

         // Reset the form values.
         //@hmc@ - support modern IE
         //if (WClient.isBrowserInternetExplorer()) {
         //   setTimeout( "document.forms['"+formName+"']." + actionNameEnc + ".value = ''; document.forms['"+formName+"']." + wclhidden + ".value = '';", 100 );
         //} else {
            form[actionNameEnc].value = '';
            form[wclhidden].value = '';
         //}
      }
      return false;
   }
}

/** WTable **
 * refreshes the portlet by adding a 1px column onto the end.
 */
function refreshAjaxContainer(dataBodyEnc)
{
   wclajax_debug("refreshAjaxContainer");
   var ajaxComponent = document.getElementById(dataBodyEnc);
   var ajaxContainer = ajaxComponent.parentNode;
   // Search up the DOM until we find the AJAX page.
   while (ajaxContainer != null)
   {
      if (ajaxContainer.wcl_ajax_container)
      {
         //wclajax_debug("refreshAjaxContainer : parent [" + ajaxContainer.id + "]");
         if ((ajaxContainer.wcl_ajax_container == "true") && (ajaxComponent.id.substring(0, 3) == "PG_"))
         {
            wclajax_debug("refreshAjaxContainer : found AJAX page [" + ajaxComponent.id + "]");
            // Now look for the TD that has the class wpsPortletBorder.
            var addIt = false;
            var portlet = false;
            var parent = ajaxContainer.parentNode;
            while (parent != null)
            {
               if (parent.tagName && (parent.tagName == "TD") && parent.className && (parent.className == "wpsPortletBorder"))
               {
                  wclajax_debug("refreshAjaxContainer : found wpsPortletBorder");
                  portlet = true;
               }
               parent = parent.parentNode;
               if (portlet && parent.tagName && (parent.tagName == "TR"))
               {
                  wclajax_debug("refreshAjaxContainer : found TR containing portlet");
                  addIt = true;
                  break;
               }
            }
            if (addIt)
            {
               // Make sure we haven't already added the column.
               var componentId = ajaxComponent.id + "_AjaxRefresh";
               if (document.getElementById(componentId) == null)
               {
                  wclajax_debug("refreshAjaxContainer : adding extra column");
                  var td = document.createElement('TD');
                  parent.appendChild(td);
                  td.id = componentId;
                  td.width = '1px';
                  setTimeout("finishRefreshAjaxContainer('" + componentId + "')", 0);
               }
            }
            break;
         }
      }
      // Keep searching up the DOM.
      ajaxComponent = ajaxContainer;
      ajaxContainer = ajaxContainer.parentNode;
   }
}

/** WTable **
 * removes the added column from to finish the refresh.
 */
function finishRefreshAjaxContainer(componentId)
{
   wclajax_debug("finishRefreshAjaxContainer(" + componentId + ")");
   var component = document.getElementById(componentId);
   component.parentNode.removeChild(component);
}

/** WTable (scrolling)**
 * setup table for scrolling
 */
function setupTableAjax(dataBodyEnc, resetTable)
{
   wclajax_debug("traceID = " + dataBodyEnc);
   wclajax_debug("Running setupTableAjax [" + dataBodyEnc + "]");
   var dataBody = document.getElementById(dataBodyEnc);

   if (dataBody != null) {
      // @hmc - zRFE-445008: Table must be setup table after DOM content has loaded in order to calculate non-table-
      // content height in adjustTableHeight. However, setupTableAjax scripts are placed in the BODY after the table
      // node, which calls the script before content that comes after the table has loaded, so we delay the script until
      // after DOM content has loaded.
      var isCTR = (dataBody.getAttribute('CTR') === 'true');
      if (isCTR) {
         // setup table after DOM is done loading (note we do not wait for readyState complete/loaded, interactive works)
         if (document.readyState === 'loading') {
             document.addEventListener('DOMContentLoaded', function() {
                 setupTableAjax(dataBodyEnc, resetTable);
             });
             return;
         }
      }
      // @hmc - end

      if (dataBody.rows.length != 0) {
          // Unhide any rows that we hide to keep Firefox from jiggling.
          var lowerRows = dataBody.parentNode.childNodes[dataBody.parentNode.childNodes.length -1];
          if (dataBody.childNodes[dataBody.childNodes.length - 1].style.display == 'none'
              || lowerRows.childNodes[lowerRows.childNodes.length - 1].style.display == 'none') {
             for (var i = 0; i < dataBody.childNodes.length; ++i) {
                dataBody.childNodes[i].style.display = '';
             }
            // the same for rows after Action Bar:
            // (they are put automagically into brand new tbody)
           if(lowerRows.tagName.toLowerCase() == 'tbody' && !lowerRows.id){
               for (var i = 0; i < lowerRows.childNodes.length; ++i) {
                 if(lowerRows.childNodes[i].tagName.toLowerCase() == 'tr' && lowerRows.childNodes[i].style.display == 'none'){
                     lowerRows.childNodes[i].style.display = '';
                 }
               }
           }
          }
      }

      if (dataBody.offsetHeight > 0 || dataBody.parentNode.offsetHeight > 0 || parseInt(dataBody.getAttribute('DR')) == 0) {
          var scrollPaneEnc = dataBody.getAttribute('SPID');
          var scrollPane = document.getElementById(scrollPaneEnc);
          var actionBarEnc = dataBody.getAttribute('ABID');
          var actionBar = document.getElementById(actionBarEnc);
          var inlineBody = actionBar ? (actionBar.nextSibling ? actionBar.nextSibling : null) : null;
          var offset = actionBar ? actionBar.offsetHeight : 0;
          var viewRows = dataBody.getAttribute('RPV');
          var numRows = dataBody.getAttribute('DR');
          var numInlineRows = inlineBody ? inlineBody.getAttribute('DR') : "0";
          var dialogStartEnc = dataBody.getAttribute('DSID');
          var dialogEndEnc = dataBody.getAttribute('DEID');

         if ( resetTable == null ) {
            resetTable = false;
         } else if ( resetTable ) {
            minimizeTable(dataBodyEnc);
         }

         // adjust viewport height for tables that staticly define rpv
         adjustTableHeightAjax(dataBodyEnc, false);

         // resize table columns
         if (scrollPane.getAttribute('H1BID')) {
            resizeDivAjax(scrollPaneEnc, null, resetTable);
         }

         // adjust table viewport height for tables that use autorpv
         adjustTableHeightAjax(dataBodyEnc, true);

         var currViewportPage = dataBody.getAttribute('CVPG');
         if ( !isNaN(parseInt(currViewportPage)) && parseInt(currViewportPage) !== -1 ) {
            // set scroll position for tasks
            //@hmc@ - support modern IE
            //setTimeout( "ensureIndexIsVisible('" + dataBodyEnc + "')", WClient.isBrowserInternetExplorer() ? 300 : 10 );
            setTimeout( "ensureIndexIsVisible('" + dataBodyEnc + "')", 10 );
         } else {
            // Get where we should scroll to.
            setScrollTopAjax(scrollPaneEnc, dataBodyEnc);
//            var scrollTo = scrollPane.firstChild.value;
//            wclajax_debug("scrolling to " + scrollTo);
//            scrollPane.scrollTop = scrollTo;
         }


         // Firefox won't shrink portlets after an embedded table dialog
         // closes so let's make it redraw the portlet.
         if (WClient.isBrowserMozilla()) {
            setTimeout("refreshAjaxContainer('" + dataBodyEnc + "')", 0);
         }

         // focus on dialog; restrict focus to dialog
         var dialogStart = document.getElementById(dialogStartEnc);
         var dialogEnd = document.getElementById(dialogEndEnc);
         if (dialogStart && dialogEnd) {
             if (window.wclDialogOnKeyDown) {
                 document.removeEventListener('keydown', window.wclDialogOnKeyDown);
             }
             window.wclDialogStartId = dialogStartEnc;
             window.wclDialogEndId = dialogEndEnc;
             window.wclDialogOnKeyDown = function(e) {
                 ariaModalDialogOnKeyDown(document.getElementById(window.wclDialogStartId), document.getElementById(window.wclDialogEndId), e);
             };
             document.addEventListener('keydown', window.wclDialogOnKeyDown, true);
             getFirstInTabbingOrder(dialogStart).focus();
         }
      }
      else {
         wclajax_debugErr("Setting table timer");
         setTimeout("setupTableAjax('" + dataBodyEnc + "', " + resetTable + ")", 10);
      }
   }
   else
      wclajax_debugErr("setupTableAjax: databody is null");
}


//isResizeNeeded
//returns false if the given WTable actionName indicates an ajax update was
//performed that does not require the table div to be resized (toggleSort,
//select, clearSorts, toggleFilterRow, editSort, clearColumnConfig, editFilter)
// -in: actionName - WTable action name string
// -out: false if actionName indicates that a refresh is not needed, true otherwise
function isResizeNeeded(actionName) {
   if ( actionName == null ) {
      return true;
   }
   if ( actionName == 'toggleSort' || actionName == 'select'
     || actionName == 'clearSorts' || actionName == 'toggleFilterRow'
     || actionName == 'editSort'   || actionName == 'clearColumnConfig'
     || actionName == 'editFilter' )
   {
      return false;
   }
   return true;
}


//adjustTableHeaderHeight
//resize the table header row resizer images to the full height of their
//containing cell (needed if the table header text contains breakrules)
// -in: divId - table div id
// -out: none
function adjustTableHeaderHeight(divID) {
    wclajax_debug("-> adjustTableHeaderHeight("+divID+")");
    var div = document.getElementById(divID);
    if (div != null) {
        var headBody1 = document.getElementById(div.getAttribute('H1BID'));
        var headBody2 = document.getElementById(div.getAttribute('H2BID'));
        var cellCount = headBody2.rows[0].cells.length-1;

        //set header row/resizer height in case column headers contain breakrules
        try {
            //abort if header height was already adjusted, avoiding a flash in firefox on windows
            var head1 = headBody1.rows[0].cells[0];
            if ( head1.firstChild.rows[0].lastChild.height == head1.firstChild.rows[0].height
              && head1.firstChild.rows[0].lastChild.height == head1.firstChild.rows[0].lastChild.firstChild.height )
            {
                return;
            }

            for (var c = 0; c < cellCount; c++) {
                head1 = headBody1.rows[0].cells[c];
                head1.firstChild.rows[0].height = '100%';
                head1.firstChild.rows[0].lastChild.height = '100%';
                head1.firstChild.rows[0].lastChild.firstChild.height = '100%';
            }

            var clientHeightHb = headBody1.clientHeight - 2;
            var clientHeightTr = headBody1.rows[0].clientHeight - 2;
            var clientHeightTd = headBody1.rows[0].cells[0].clientHeight - 2;

            wclajax_debug("   adjustTableHeaderHeight: headBody1.clientHeight ["+headBody1.clientHeight+"]");

            if ( WClient.isBrowserInternetExplorer() ) {
                clientHeightHb = clientHeightTr;
                clientHeightTr = clientHeightTr;
                clientHeightTd = clientHeightTr;
            }

            for (var c = 0; c < cellCount; c++) {
                head1 = headBody1.rows[0].cells[c];
                head1.firstChild.rows[0].height = clientHeightHb;
                head1.firstChild.rows[0].lastChild.height = clientHeightTr;
                head1.firstChild.rows[0].lastChild.firstChild.height = clientHeightTd;
            }
        } catch (e) {
        }
    }
    wclajax_debug("<- adjustTableHeaderHeight: " + divID);
}

/** WTable (scrolling)**
 * handles resize of div
function resizeDivAjax(divID, column)
{
   wclajax_debug("Running resizeDivAjax: " + divID);
   var div = document.getElementById(divID);
   if (div != null) {
      var headBody1 = document.getElementById(div.getAttribute('H1BID'));
      var headBody2 = document.getElementById(div.getAttribute('H2BID'));
      var tableStyle = headBody2.parentNode.style;
      var cellCount = headBody2.rows[0].cells.length-1;
      var widths = new Array(cellCount);

      // Parent TABLE
      tableStyle.tableLayout = 'auto';
      tableStyle.width = "auto";
      var sum = 0;
      if (window[divID + "_firstTime"] == undefined) {
        window[divID + "_firstTime"] = true;
      }
      for (var c = 0; c < cellCount; c++) {
          // THs
         var head1 = headBody1.rows[0].cells[c];
         var head2 = headBody2.rows[0].cells[c];

         head2.firstChild.style.tableLayout = 'auto';
     if (head1.minWidth == undefined) {
        var cells = head1.firstChild.rows[0].cells;
            var minWidth = cells[0].firstChild.offsetWidth + 3;

            for (var i=1; i < cells.length; i++)
               minWidth += parseInt(cells[i].offsetWidth);
            head1.minWidth = minWidth;
    }
        widths[c] = (column && column.id == head1.id) ? column.width : head1.width != '' ? head1.width : head2.offsetWidth;
    if (widths[c] < head1.minWidth) {
       widths[c] = head1.minWidth;
        }
        if (window[divID + "_firstTime"]) {
          sum += parseInt(widths[c]);
          if (c == cellCount-1 && sum < div.clientWidth) {
            temp = parseInt(widths[c]) + (div.clientWidth - sum);
            widths[c] = temp.toString(10);
          }
        }
      }

      tableStyle.display = 'none';
      var temp = headBody2.rows[0].cells[0].offsetWidth;    //LC magic - this is needed for properly setting the display = 'none' style - only for Firefox
    // [#94601] Table does not resize when new column items or larger size are added to it - Changed tableStyle.tableLayout = 'fixed' to tableStyle.tableLayout = 'auto'; for Firefox since it does not support elipsis;
      if(WClient.isBrowserMozilla())
        tableStyle.tableLayout = 'auto';
      else
        tableStyle.tableLayout = 'fixed';
      tableStyle.display = '';

      for (var c = 0; c < cellCount; c++) {
         var head1 = headBody1.rows[0].cells[c];
         var head2 = headBody2.rows[0].cells[c];

         head1.width = widths[c];
         head1.style.width = widths[c];
         head2.width = widths[c];
         head2.style.width = widths[c];

         // Send all column widths up to the server so the returned table
         // isn't completely different than the formatted one because that
         // causes the table to jiggle in Firefox. It also allows us to
         // keep the DOM table in synch with what the server generates so
         // that in portal we can tell if the table really changed.
         try {
            head1.firstChild.rows[0].lastChild.lastChild.value = widths[c];
         }
         catch (widthError) {
            wclajax_debug("Error setting table column width: [" + widthError.name + "] [" + widthError.message + "]");
         }
      }
      tableStyle.width = "";    // fixes last column resizing problem
   }
   else
      wclajax_debugErr("resiseDivAjax: div is null");

   //@auiml - begin - needed for scrollable tree tables
   var children = div.childNodes[1].childNodes; //@auiml - ordering of table div child nodes is reversed in ajax
   var dataBody = null;
   for (var i=0; i<children.length; i++)
   {
      if (children[i].getAttribute('SPID') != null)
      {
         dataBody = children[i];
         break;
      }
   }

   if (dataBody != null && dataBody.offsetHeight > 0)
   {
      var actionBarEnc = dataBody.getAttribute('ABID');
      var actionBar = document.getElementById(actionBarEnc);
      var inlineBody = actionBar ? (actionBar.nextSibling ? actionBar.nextSibling : null) : null;
      var offset = actionBar ? actionBar.offsetHeight : 0;
      var viewRows = dataBody.getAttribute('RPV');
      var numRows = dataBody.getAttribute('DR');
      var numInlineRows = inlineBody ? inlineBody.getAttribute('DR') : "0";

      var minRows = 1;
      if(numRows < minRows)
         numRows = minRows;

      //@auiml - scrollable treetable anchoring
      var hght = offset + ((dataBody.offsetHeight / dataBody.rows.length) * Math.min(Number(numRows) + Number(numInlineRows), viewRows));
       var selRow =-1;
       div.style.height = hght;
       //@auiml -needed for virtual scrolling tables
      var headerRowId = div.previousSibling.id;
      var tableName = headerRowId.substring(0,headerRowId.indexOf("_headerRow"));
      var tableContainer = null;
      if (document.getElementById(tableName+"_tableContainer"))
      {
         tableContainer = document.getElementById(tableName+"_tableContainer");
     tableContainer.setAttribute("TOTALHEIGHT", hght);
       }

      if (dataBody.firstChild.textContent != "None")
      {
         var rows = dataBody.childNodes;
         for (var i=0; i<rows.length; i++)
         {
            var images = rows[i].getElementsByTagName("IMG");
            if (images != null)
            {
               for (var j=0;j<images.length;j++)
               {
                  var img = images[j];
                  if (img.src.indexOf("tbl3.gif") > 0)
                  {
                     selRow=i;
                     break;
                  }
               }
            }
         }
         if (selRow < 0 )   //no selection
            div.scrollTop = 0;
         else               //selection
            //don't scroll is selection is in current view
            if (selRow < viewRows -1)
               div.scrollTop = 0;
            else
               div.scrollTop = dataBody.offsetHeight/rows.length*selRow;
      //@auiml - end
      }
   }
   window[divID + "_firstTime"] = false;
}
 */

/** WTable (scrolling)**
 * handles resize of div after an ajax refresh that does not require a complete
 * resize (toggleSort, select, clearSorts, toggleFilterRow, editSort,
 * clearColumnConfig, editFilter)
 */
function resizeDivAjaxPostUpdate(divID) {
   wclajax_debug("Running resizeDivAjaxPostUpdate: " + divID);
   var div = document.getElementById(divID);
   if (div != null) {
      var headBody1 = document.getElementById(div.getAttribute('H1BID'));
      var headBody2 = document.getElementById(div.getAttribute('H2BID'));
      var tableStyle = headBody2.parentNode.style;

      //@hmc@ - support modern IE
      //if ( WClient.isBrowserInternetExplorer() ) {
      //   //disable autosizing
      //   tableStyle.display = 'none';
      //   tableStyle.tableLayout = 'fixed';
      //   tableStyle.display = '';
      //}

      //increase header row height, in case column headers contain breakrules
      adjustTableHeaderHeight(divID);
   }
   else
      wclajax_debugErr("resizeDivAjaxPostUpdate: div is null");
}


/** WTable (scrolling)**
 * handles resize of div
 */
function resizeDivAjax(divID, column, resetTable)
{
   wclajax_debug("Running resizeDivAjax: " + divID + " " + column + " " + resetTable);
   if ( resetTable == null ) {
      resetTable = false;
   }
   //@hmc@ - support modern IE
   //if ( WClient.isBrowserInternetExplorer() ) {
   //    resizeDivAjaxIE(divID, column, resetTable);
   //} else {
       resizeDivAjaxMoz(divID, column, resetTable);
   //}
}


/** WTable (scrolling)**
 * handles resize of div for IE
 */
function resizeDivAjaxIE(divID, column, resetTable)
{
   wclajax_debug("Running resizeDivAjaxIE: " + divID + " " + column + " " + resetTable);
   var div = document.getElementById(divID);
   if (div == null) {
      return;
   }
   var resizeOption = div.getAttribute("resizeOption") == null ? '' : div.getAttribute("resizeOption");
   var headBody1 = document.getElementById(div.getAttribute('H1BID'));
   var headBody2 = document.getElementById(div.getAttribute('H2BID'));
   var tableStyle = headBody2.parentNode.style;
   var cellCount = headBody2.rows[0].cells.length-1;
   var widths = new Array(cellCount);
   var init = ( headBody1.rows[0].cells[0].getAttribute("initWidth") == null );
   var preset =  ( !resetTable && init && headBody1.rows[0].cells[0].width != '' ) || ( resetTable && headBody1.rows[0].cells[0].getAttribute("prefWidth") != null );
   tableStyle.tableLayout = 'auto';

   var totalWidth = 0;
   var justifiedWidthShrink  = 0;    //width to play with when columns have to shrink
   var justifiedWidthEnlarge = 0;    //width to play with when columns have to enlarge

   tableStyle.tableLayout='auto';
   tableStyle.width="auto";

   // ODT Y8835 - check CUSTOM_TABLE_RENDERING flag, skip column resize reset if !init in that case,
   // used for special processing to handle panel resizing work with taskWindow.js
   var dataBody = document.getElementById( "DB_" + divID.slice(3) );
   var isCTR = false;
   if ( dataBody != null ) {
      isCTR = ( dataBody.getAttribute('CTR') == "true" );
   }

   if ( (resetTable && !isCTR) || init ) {
      for (var c = 0; c < cellCount; c++) {
         var head1 = headBody1.rows[0].cells[c];
         var head2 = headBody2.rows[0].cells[c];

         head1.style.tableLayout = 'auto';
         head2.firstChild.style.tableLayout = 'auto';

         if ( preset && head1.getAttribute("prefWidth") == null ) {
            head1.setAttribute("prefWidth", head1.width);
         }

         var colPreset = preset || ( !resetTable && init && head1.width != '' );
         widths[c] = ( colPreset ) ? head1.width
                                   : ( preset && head1.width != '' ) ? head1.width : parseInt(head2.offsetWidth);
         totalWidth += widths[c];

         if ( widths[c] == '' || isNaN(widths[c]) ) {
            widths[c] = parseInt(head2.offsetWidth);
         }

         var justify = head1.getAttribute("justify");
         if ( justify == "shrink"  || justify == "shrinkAndEnlarge" ) {
           justifiedWidthShrink += widths[c];
         }
         if ( justify == "enlarge" || justify == "shrinkAndEnlarge" ) {
           justifiedWidthEnlarge += widths[c];
         }

         //init column min/maxWidth values and save initial width of column,
         //used by minimize table to maintain original column width ratios
         if ( init ) {
            head1.setAttribute("initWidth", widths[c]);
            initColumnMinMaxWidths(divID, c, widths[c]);
         }
      }
   } else {
      for (var c = 0; c < cellCount; c++) {
         var head1 = headBody1.rows[0].cells[c];
         var head2 = headBody2.rows[0].cells[c];
         head2.firstChild.style.tableLayout = 'fixed';
         widths[c] = head1.width;

         if ( widths[c] == '' || isNaN(widths[c]) ) {
            widths[c] = parseInt(head2.offsetWidth);
         }
      }
   }

   tableStyle.display = 'none';
   tableStyle.tableLayout = 'fixed';
   tableStyle.display = '';

   //width to play with (because this table is either shrinking or enlarging)
   var hiddenColSpan = parseInt(headBody1.rows[0].cells[cellCount].getAttribute('colspan'));
   var tableWidth = headBody1.offsetWidth - hiddenColSpan;
   var justifiedWidth = ( tableWidth - totalWidth < 0 ) ? justifiedWidthShrink : justifiedWidthEnlarge;

   var misc = 0;
   var cellSum = 0;
   for (var c = 0; c < cellCount; c++) {
       var head1 = headBody1.rows[0].cells[c];
       var head2 = headBody2.rows[0].cells[c];
       var shrunk = false;

       //justify column
       if ( !preset && ( resetTable || init ) ) {
          if ( c == cellCount-1 && resizeOption == "WTableResizeLast" ) {
              shrunk = true;
              widths[c] = "100%";
          } else if ( c == cellCount-1 && resizeOption == "WTableResizeEndColumns" && tableWidth != totalWidth ) {
              widths[c] = Math.max(head1.offsetWidth,tableWidth-cellSum);
          } else if ( justifiedWidth > 0 && head1.getAttribute("justify") != "none" && tableWidth != totalWidth) {
              if ( ( tableWidth - totalWidth <  0  && head1.getAttribute("justify") != "enlarge" )
                || ( tableWidth - totalWidth >= 0  && head1.getAttribute("justify") != "shrink"  ) )
              {
                 widths[c] = widths[c] + Math.round( (tableWidth - totalWidth) * (widths[c] / justifiedWidth) );
                 if ( c == cellCount - 1 ) {
                    widths[c] = widths[c] - misc;
                 }
              }
              if ( widths[c] < getColumnMinWidth(head1) ) {
                 misc = misc + getColumnMinWidth(head1) - widths[c];
                 widths[c] = getColumnMinWidth(head1);
              }
          }
       }

       widths[c] = Math.max(MIN_COL_WIDTH, widths[c]);

       head2.width = head1.width = ( widths[c] != '' ) ? widths[c] : head1.width;
       head1.style.width =  head1.width;
       cellSum = cellSum + parseInt(head2.width);

       // Send all column widths up to the server so the returned table
       // isn't completely different than the formatted one because that
       // causes the table to jiggle in Firefox. It also allows us to
       // keep the DOM table in synch with what the server generates so
       // that in portal we can tell if the table really changed.
       try {
           head1.firstChild.rows[0].lastChild.lastChild.value = widths[c];
       }
       catch (widthError) {
           wclajax_debug("Error setting table column width: [" + widthError.name + "] [" + widthError.message + "]");
       }
   }

   tableStyle.width="";

   if ( resetTable || init ) {
      headBody2.setAttribute("initWidth", tableWidth);
   }

   //set table background to table header width
   if ( cellSum <= headBody2.getAttribute("initWidth") ) {
      headBody2.parentNode.width = headBody2.getAttribute("initWidth");
   }

   //increase header row height, in case column headers contain breakrules
   adjustTableHeaderHeight(divID);

   wclajax_debug("Exiting resizeDivAjaxIE: " + divID + " " + column + " " + resetTable);
}

/** WTable (scrolling)**
 * handles resize of div for Mozilla
 */
var IS_RESIZED = false;
function resizeDivAjaxMoz(divID, column, resetTable)
{
   wclajax_debug("-> resizeDivAjaxMoz(" + divID + ", " + column + ", " + resetTable + "): IE ["+WClient.isBrowserInternetExplorer()+"]");
   var div = document.getElementById(divID);
   if (div == null) {
      return;
   }
   var resizeOption = div.getAttribute("resizeOption") == null ? '' : div.getAttribute("resizeOption");
   var headBody1 = document.getElementById(div.getAttribute('H1BID'));
   var headBody2 = document.getElementById(div.getAttribute('H2BID'));
   var tableStyle  = headBody2.parentNode.style;
   var tableStyle1 = headBody1.style;
   var cellCount = headBody2.rows[0].cells.length-1;
   var widths = new Array(cellCount);
   var init = ( headBody1.rows[0].cells[0].getAttribute("initWidth") == null );
   var preset =  ( !resetTable && init && headBody1.rows[0].cells[0].width != '' ) || ( resetTable && headBody1.rows[0].cells[0].getAttribute("prefWidth") != null );
   var presetWidths = new Array(cellCount);

   var totalWidth = 0;

   // detect custom table rendering of tasks tables
   var dataBody = document.getElementById( "DB_" + divID.slice(3) );
   var isCTR = false;
   if ( dataBody != null ) {
      isCTR = ( dataBody.getAttribute('CTR') == "true" );
   }

   if ( IS_RESIZED && !init && !(resetTable || column) ) {
      //increase header row height, in case column headers contain breakrules
      adjustTableHeaderHeight(divID);

      return;
   }
   IS_RESIZED = true;

   div.style.width='0px';           //shrink div to content
   headBody1.style.width='0px';     //shrink header table to content
   headBody2.style.width='0px';     //shrink data table to content

   if ( resetTable || init ) {
      var justifiedWidthShrink  = 0;   //width to play with when columns have to shrink
      var justifiedWidthEnlarge = 0;   //width to play with when columns have to enlarge

      headBody2.setAttribute("initWidth", div.parentNode.clientWidth);

      var hiddenColSpan = parseInt(headBody1.rows[0].cells[cellCount].getAttribute('colspan'));
      var tableWidth = headBody1.parentNode.offsetWidth - 2 - hiddenColSpan;
      var selectcol = false;

      for (var c = 0; c < cellCount; c++) {
         var head1 = headBody1.rows[0].cells[c];
         var head2 = headBody2.rows[0].cells[c];
         head2.firstChild.style.tableLayout = 'auto';

         if ( head1.getAttribute("selectcol") === "true" ) {
             selectcol = true;
         }

         // get column width from data body for Edge when CTR disabled
         var dataCell = null;
         if (WClient.isBrowserLegacyEdge() && !isCTR) {
             try {
                 dataCell = dataBody.rows[0].cells[c];
             } catch (e) {
             }
         }

         if ( preset && head1.getAttribute("prefWidth") == null ) {
            head1.setAttribute("prefWidth", head1.width);
         }

         var colPreset = preset || ( !resetTable && init && head1.width != '' );
         var initWidth = head1.getAttribute("initWidth");
         wclajax_debug("   resizeDivAjaxMoz: "+divID+" -> pre "+c+"");
         wclajax_debug("   resizeDivAjaxMoz: "+divID+"    pre "+c+": colPreset ["+colPreset+"]");
         wclajax_debug("   resizeDivAjaxMoz: "+divID+"    pre "+c+": head2.scrollWidth ["+head2.scrollWidth+"]");
         wclajax_debug("   resizeDivAjaxMoz: "+divID+"    pre "+c+": head2.offsetWidth ["+head2.offsetWidth+"]");
         wclajax_debug("   resizeDivAjaxMoz: "+divID+"    pre "+c+": head1.width ["+head1.width+"]");
         widths[c] = colPreset ? head1.width
                               : !resetTable ? ( dataCell ? dataCell.scrollWidth : ( WClient.isBrowserWebKit() ? head2.scrollWidth : head2.offsetWidth ) )
                                             : initWidth != null ? initWidth
                                                                 : ( dataCell ? dataCell.scrollWidth : ( WClient.isBrowserWebKit() ? head2.scrollWidth : head1.width ) );
         widths[c] = parseInt(widths[c]);

         /* In Edge/Safari, column header widths are a percentage of table width (based on column count); however, we
          * want the actual column width, so we use column header text width and later add sort/resizer widths
          */
         if ( WClient.isBrowserLegacyEdge() || WClient.isBrowserSafari() ) {
            var columnHeaderWidth = widths[c];
            try {
                var columnHeader = head1.querySelector("[role=columnheader]");
                columnHeaderWidth = columnHeader.getBoundingClientRect().width;

                // parent node has padding that we must take into account
                var columnHeaderParentStyle = window.getComputedStyle(columnHeader.parentNode);
                columnHeaderWidth += ( parseInt(columnHeaderParentStyle.paddingLeft) + parseInt(columnHeaderParentStyle.paddingRight) );
            } catch (e) {
            }
            widths[c] = Math.max(widths[c] || 0, columnHeaderWidth);
         }

         wclajax_debug("   resizeDivAjaxMoz: "+divID+"    pre "+c+": STEP 1 widths[c] ["+widths[c]+"]");
         if ( isNaN(widths[c]) ) {
            widths[c] = (head1.getAttribute("initWidth") == null) ? head2.offsetWidth : head1.getAttribute("initWidth");
            wclajax_debug("   resizeDivAjaxMoz: "+divID+"    pre "+c+": STEP 2 widths[c] ["+widths[c]+"]");
            if ( isNaN(widths[c]) ) {
               widths[c] = 20;
               wclajax_debug("   resizeDivAjaxMoz: "+divID+"    pre "+c+": STEP 3 widths[c] ["+widths[c]+"]");
            }
         }

         //@hmc@ - support modern IE - handle initial width of zero
         if ( (WClient.isBrowserInternetExplorer() || WClient.isBrowserLegacyEdge()) && widths[c] == 0 ) {
             widths[c] = ( head1.getAttribute("justify") != "shrink" || head1.getAttribute("justify") != "none" ) ? 60 : MIN_COL_WIDTH;
         }

         // tweak column width in Edge to avoid exact width triggering overflow ellipsis or cell wrapping
         if ( WClient.isBrowserLegacyEdge() && !colPreset ) {
             widths[c] += 2;
         }

         if ( WClient.isBrowserChrome() || WClient.isBrowserSafari() ) {
            var tr = head1.firstChild.firstChild.firstChild;
            var td = tr.firstChild;

            if ( WClient.isBrowserChrome() ) {
               // Chrome renderer does not set styles "overflow: hidden; text-overflow: ellipsis;" so
               // that we can correctly calculate width above, so we need to add these styles now.
               // These styles are only added when custom table rendering is not enabled (TreeUI) or
               // columns may be resized (non-hidden resizer column)
               var len = tr.children.length;
               if (!isCTR || (head1.getAttribute("selectcol") !== "true" && len > 1 && tr.children[len-1].style.display !== "none")) {
                  td.style.overflow = 'hidden';
                  td.style.textOverflow = 'ellipsis';
               }
            }

            // Chrome/Safari do not add in sort and dnd image widths when calculating col width, so add
            // them here for seemingly blank columns
            if (!colPreset && initWidth == null) {
               var sib = td.nextSibling;
               while (sib) {
                  if (sib.width) {
                     var w = sib.getBoundingClientRect().width;
                     if (!isNaN(w)) {
                        widths[c] += w;
                     }
                  }
                  sib = sib.nextSibling;
               }
            }
         }

         var justify = head1.getAttribute("justify"),
         initMaxWidth = Math.floor( tableWidth/ ( Math.max(cellCount-2,2) ) ),
         canShrink = justify == "shrink"  || justify == "shrinkAndEnlarge",
         canEnlarge = justify == "enlarge" || justify == "shrinkAndEnlarge";

         // scale giant column initial width to a fraction of the table
         if (!isCTR && canShrink && selectcol && widths[c] > (tableWidth/2)) {
             wclajax_debug("giant: "+widths[c]+" -> "+initMaxWidth);
             widths[c] = initMaxWidth;
         }

         totalWidth += widths[c];
         if ( canShrink ) {
           justifiedWidthShrink += widths[c];
         }
         if ( canEnlarge ) {
           justifiedWidthEnlarge += widths[c];
         }

         //init column min/maxWidth values and save initial width of column,
         //used by minimize table to maintain original column width ratios
         if ( init ) {
            head1.setAttribute("initWidth", widths[c]);
            initColumnMinMaxWidths(divID, c, widths[c]);
         }
      }
   } else {
      //drag and drop resizing going on
      for (var c = 0; c < cellCount; c++) {
         var head1 = headBody1.rows[0].cells[c];
         var head2 = headBody2.rows[0].cells[c];
         head2.firstChild.style.tableLayout = 'fixed';
         widths[c] = head1.width;
      }
   }

   var str = "PRE";
   for (var c = 0; c < widths.length; c++) {
      str = str + "\n  widths["+c+"] = "+widths[c];
   }
   wclajax_debug("   resizeDivAjaxMoz:" + str);

   //width to play with (because this table is either shrinking or enlarging)
   var hiddenColSpan = parseInt(headBody1.rows[0].cells[cellCount].getAttribute('colspan'));
   var tableWidth = headBody1.parentNode.offsetWidth - 2 - hiddenColSpan;
   var justifiedWidth = ( tableWidth - totalWidth < 0 ) ? justifiedWidthShrink : justifiedWidthEnlarge;
   wclajax_debug("   resizeDivAjaxMoz: "+divID+" totalWidth ["+totalWidth+"]");
   wclajax_debug("   resizeDivAjaxMoz: "+divID+" tableWidth ["+tableWidth+"]");
   wclajax_debug("   resizeDivAjaxMoz: "+divID+" justifiedWidth ["+justifiedWidth+"]");
   wclajax_debug("   resizeDivAjaxMoz: "+divID+" preset ["+preset+"]");
   wclajax_debug("   resizeDivAjaxMoz: "+divID+" resetTable ["+resetTable+"]");
   wclajax_debug("   resizeDivAjaxMoz: "+divID+" init ["+init+"]");
   wclajax_debug("   resizeDivAjaxMoz: "+divID+" resizeOption ["+resizeOption+"]");

   //disable autosizing
   tableStyle.tableLayout  = 'fixed';
   tableStyle1.tableLayout = 'fixed';
   tableStyle.overflow = 'hidden';
   div.style.width = '100%';
   headBody1.style.overflowX='hidden';
   headBody2.style.overflowX='hidden';

   //set fixed column widths
   var misc = 0;
   var cellSum = 0;
   for (var c = 0; c < cellCount; c++) {
      var head1 = headBody1.rows[0].cells[c];
      var head2 = headBody2.rows[0].cells[c];
      var headFilter1 = null;
      if ( headBody1.rows[1] && headBody1.rows[1].cells[c] ) {
         var headFilter1 = headBody1.rows[1].cells[c];
      }

      var shrunk = false;
      //@hmc@ - support modern IE
      //var cellPadding = ( WClient.isBrowserInternetExplorer() ) ? 0 : (parseInt(head1.style.borderLeftWidth) + parseInt(head1.style.borderRightWidth));
      var cellPadding = (parseInt(getComputedStyle(head1).borderLeftWidth) + parseInt(getComputedStyle(head1).borderRightWidth));

      wclajax_debug("   resizeDivAjaxMoz: "+divID+" -> adjust "+c+"");
      wclajax_debug("   resizeDivAjaxMoz: "+divID+"    adjust "+c+": justify ["+head1.getAttribute("justify")+"]");
      //justify column
      if ( head1.getAttribute("justify") != "none" && !preset && ( resetTable || init ) ) {
         if ( c == cellCount-1 && resizeOption == "WTableResizeLast" ) {
            shrunk = true;
            widths[c] = "100%";
         } else if ( c == cellCount-1 && resizeOption == "WTableResizeEndColumns" && tableWidth != totalWidth ) {
            widths[c] = widths[c] + Math.round( (tableWidth - totalWidth) * (widths[c] / justifiedWidth) ) - cellPadding - misc;
         } else if ( justifiedWidth > 0 && tableWidth != totalWidth) {
            if ( ( tableWidth - totalWidth <  0  && head1.getAttribute("justify") != "enlarge" )
              || ( tableWidth - totalWidth >= 0  && head1.getAttribute("justify") != "shrink"  ) )
            {
               widths[c] = widths[c] + Math.round( (tableWidth - totalWidth) * (widths[c] / justifiedWidth) ) - cellPadding;
               if ( c == cellCount - 1 ) {
                   widths[c] = widths[c] - misc;

                   if (dataBody) {
                       var numRows = parseInt(dataBody.getAttribute('DR'));
                     if ( numRows == 0) {
                           widths[c] = widths[c] - 7;
                           cellSum = cellSum - 7;
                       }
                   }
               }
            }
            var minWidth = getColumnMinWidth(head1);

            if ( !isCTR && /UI\-.*Status/.test(head1.getAttribute('colidentifier')) ) {
                minWidth = 60;
            }
            if ( widths[c] < minWidth ) {
               misc = misc + minWidth - widths[c];
               widths[c] = minWidth;
            }
         }
      }

      widths[c] = Math.max(MIN_COL_WIDTH, widths[c]);
      cellSum = cellSum + parseInt(widths[c]) + parseInt(cellPadding);

      head1.width = widths[c];
      head1.firstChild.width = widths[c];
      head2.width = widths[c];
      head2.firstChild.width = widths[c];
      head1.style.width = widths[c];
      if ( headFilter1 != null ) {
         headFilter1.width = widths[c];
         headFilter1.style.width = widths[c];
      }

      // Send all column widths up to the server so the returned table
      // isn't completely different than the formatted one because that
      // causes the table to jiggle in Firefox. It also allows us to
      // keep the DOM table in synch with what the server generates so
      // that in portal we can tell if the table really changed.
      try {
          head1.firstChild.rows[0].lastChild.lastChild.value = widths[c];
      }
      catch (widthError) {
          wclajax_debug("Error setting table column width: [" + widthError.name + "] [" + widthError.message + "]");
      }
   }

   var str = "POST";
   for (var c = 0; c < widths.length; c++) {
       str = str + "\n  widths["+c+"] = "+widths[c];
    }
   wclajax_debug("   resizeDivAjaxMoz:" + str);

   //increase header row height, in case column headers contain breakrules
   adjustTableHeaderHeight(divID);

   var ie5ish = WClient.isBrowserInternetExplorer() && parseInt(WClient.getBrowserVersion()) < 10;
   headBody2.width = Math.max(cellSum, headBody2.getAttribute("initWidth"));
   headBody1.parentNode.width = ( !ie5ish && cellSum > headBody2.getAttribute("initWidth") ) ? cellSum : "100%";
   headBody2.style.marginRight = "0px";
   headBody2.style.paddingRight = "0px";
   div.firstChild.border="0px";

   // fix width of empty table's 'None' area
   if (!isCTR && (!dataBody.rows || dataBody.rows.length === 0)) {
       wclajax_debug("   resizeDivAjaxMoz: "+divID+" Empty table tweaks");
       div.style.width = 'auto';
       if (WClient.isBrowserChrome()) {
           headBody2.parentNode.style.display = 'none';
       }
   }

   // workaround to hide H2B header rows in AppleWebKit browsers where visibility:collapse is unsupported
   if ( WClient.isBrowserWebKit() && !(WClient.isBrowserLegacyEdge()) ) {
       for (var c = 0; c < cellCount; c++) {
           headBody2.rows[0].cells[c].firstChild.style.display = 'none';
       }
   }

   wclajax_debug("<- resizeDivAjaxMoz: " + divID + " " + column + " " + resetTable);
}


/** WTable (scrolling)**
 * handles scroll of table
 */
function setScrollPositionAjax(scroller)
{
   var scrollDiv = document.getElementById(scroller);
   if (scrollDiv != null) {
      //don't save scrollTop if a column is dragging
      var headBody1 = document.getElementById(scrollDiv.getAttribute('H1BID'));
      if (headBody1 != null) {
         var headBody1 = document.getElementById(scrollDiv.getAttribute('H1BID'));
         var colCount = headBody1.rows[0].cells.length-1;
         for (var c = 0; c < colCount; c++) {
            var head1 = headBody1.rows[0].cells[c];
            if ( head1.isDragging ) {
               return;
            }
         }
      }

      var scrollPos = scrollDiv.scrollTop;
      scrollTops[scroller] = scrollPos;
      scrollDiv.firstChild.value = scrollPos;
   }
}

/** WTable (scrolling)**
 * set scroll top value based on scroll position value
 */
function setScrollTopAjax(scroller, dataBodyEnc)
{
  var scrollDiv = document.getElementById(scroller);
  if (scrollDiv != null) {
     var scrollPos = parseInt(scrollDiv.firstChild.value);
     if ( scrollTops[scroller] ) {
        scrollPos = parseInt(scrollTops[scroller]);
     }
     scrollDiv.scrollTop = scrollPos;
  }
}

/** WTableColumn (drag-n-drop)**
 * handles resize of table columns
 */
function tcDNDAjax(event, evtCode, columnId, divID, colUrl)
{
   if (!isAJAXOutstanding) {
      wclajax_debug("inside tcDNDAjax");
      var wevent = new WEvent(event);
      var column = document.getElementById(columnId);

      switch (evtCode) {
      case 1: // mouseDown (grab)
         if (!column.isDragging)
         {
            var cells = column.firstChild.rows[0].cells;
            column.isDragging = true;
            column.startPosition = column.currentPosition = wevent.getPagePosition();
            column.startWidth = WUtilities.getWidth(column);
            // save document's mouse handlers
            document._onselectstart = document.onselectstart;
            document._onmousemove = document.onmousemove;
            document._onmouseup = document.onmouseup;
            document._ontouchmove = document.ontouchmove;
            document._ontouchend = document.ontouchend;
            document.body._cursor = document.body.style.cursor;
            // temporarily override document's mouse handlers
            document.onselectstart = new Function("event", "return false;");
            document.onmousemove = new Function("event", "return tcDNDAjax(event, 2, '" + columnId + "', '" + divID + "', '" + colUrl + "');");
            document.onmouseup = new Function("event", "return tcDNDAjax(event, 3, '" + columnId + "', '" + divID + "', '" + colUrl + "');");
            document.ontouchmove = new Function("event", "return tcDNDAjax(event, 2, '" + columnId + "', '" + divID + "', '" + colUrl + "');");
            document.ontouchend = new Function("event", "return tcDNDAjax(event, 3, '" + columnId + "', '" + divID + "', '" + colUrl + "');");
            document.body.style.cursor = "e-resize";

            return false;
         }
         break;
      case 2: // mouseMove (drag)
         if (column.isDragging)
         {
            var mousePosition = wevent.getPagePosition();
            var difference = mousePosition.getX() - column.startPosition.getX();
            var div = document.getElementById(divID);
            if(div != null){
              var bidi = div.getAttribute("BIDI");

              if (bidi)
                difference = -difference;
            }

            column.width = Math.max(column.startWidth + difference, MIN_COL_WIDTH);
            column.currentPosition = mousePosition;

            if(div != null){
              resizeDivAjax(divID, column);
            }

            return false;
         }
         break;
      case 3: // mouseUp (drop)
         if (column.isDragging)
         {
            column.isDragging = false;
            // restore document's mouse handlers
            document.onselectstart = document._onselectstart;
            document.onmousemove = document._onmousemove;
            document.onmouseup = document._onmouseup;
            document.ontouchmove = document._ontouchmove;
            document.ontouchend = document._ontouchend;
            document.body.style.cursor = document.body._cursor;
            // save width
            var input = column.firstChild.rows[0].lastChild.lastChild;

            input.value = column.width ? column.width : "-1";

            //save column widths if external method is defined
            if ( colUrl ) {
               saveColumnWidthsAjax(divID, colUrl);
            }

            return false;
         }
         break;
      }
   }
   return true;
}

/** WTableColumn (successive drag-n-drop)**
 * handles successive resize of table columns
 */
function tcSDNDAjax(event, evtCode, columnId, divID, colUrl)
{
   if (!isAJAXOutstanding) {
      wclajax_debug("inside tcSDNDAjax");
      var wevent = new WEvent(event);
      var div = document.getElementById(divID);
      if( div == null ) {
         return;
      }
      var headBody1 = document.getElementById(div.getAttribute('H1BID'));
      var colCount = headBody1.rows[0].cells.length-1;

      //init tableColumn id -> columndIndex hash
      var tableColumns = new Array();
      for (var c = 0; c < colCount; c++) {
         var head1 = headBody1.rows[0].cells[c];
         tableColumns[head1.id] = c;
      }

      if ( tableColumns[columnId] == null ) {
         return;
      }

      var column = document.getElementById(columnId);

      switch (evtCode) {
      case 1: // mouseDown (grab)
         if (!column.isDragging)
         {
            column.isDragging = true;
            column.startPosition = column.currentPosition = wevent.getPagePosition();
            column.startWidth = WUtilities.getWidth(column);
            // save document's mouse handlers
            document._onselectstart = document.onselectstart;
            document._onmousemove = document.onmousemove;
            document._onmouseup = document.onmouseup;
            document._ontouchmove = document.ontouchmove;
            document._ontouchend = document.ontouchend;
            document.body._cursor = document.body.style.cursor;
            // temporarily override document's mouse handlers
            document.onselectstart = new Function("event", "return false;");
            document.onmousemove = new Function("event", "return tcSDNDAjax(event, 2, '" + columnId + "', '" + divID + "', '" + colUrl + "');");
            document.onmouseup = new Function("event", "return tcSDNDAjax(event, 3, '" + columnId + "', '" + divID + "', '" + colUrl + "');");
            document.ontouchmove = new Function("event", "return tcSDNDAjax(event, 2, '" + columnId + "', '" + divID + "', '" + colUrl + "');");
            document.ontouchend = new Function("event", "return tcSDNDAjax(event, 3, '" + columnId + "', '" + divID + "', '" + colUrl + "');");
            document.body.style.cursor = "e-resize";

            //loop over columns and ensure column's needed values are set
            for (var i=tableColumns[column.id]-1; i >= 0; i--) {
               var currColumn = headBody1.rows[0].cells[i];
               currColumn.startWidth = WUtilities.getWidth(currColumn);
            }

            //save scrollTop
            setScrollPositionAjax(divID);

            return false;
         }
         break;
      case 2: // mouseMove (drag)
         if (column.isDragging)
         {
            var mousePosition = wevent.getPagePosition();
            var difference = mousePosition.getX() - column.startPosition.getX();
            var div = document.getElementById(divID);
            if(div != null){
              var bidi = div.getAttribute("BIDI");

              if (bidi)
                difference = -difference;
            }

            columnWidth = column.startWidth + difference;
            column.currentPosition = mousePosition;

            if ( columnWidth < MIN_COL_WIDTH && tableColumns != null && tableColumns[columnId] != null ) {
               //successive shrinking
               var columnIndex = tableColumns[columnId]; //get column index from table columns hash (init by setupTable)
               var i = 1;
               var done = false;
               var startWidth = column.startWidth;

               column.width = MIN_COL_WIDTH;
               //@hmc@ - support modern IE
               //var cellPadding = ( WClient.isBrowserInternetExplorer() ) ? 0 : (parseInt(column.style.borderLeftWidth) + parseInt(column.style.borderRightWidth));
               var cellPadding = (parseInt(column.style.borderLeftWidth) + parseInt(column.style.borderRightWidth));
               if ( column.startWidth - parseInt(column.width) > 0 ) {
                  column.startPosition = new Position(column.startPosition.getX() - (column.startWidth - parseInt(column.width) - cellPadding), column.startPosition.getY(), column.startPosition.getZ());
               }
               difference = difference + column.startWidth - parseInt(column.width);
               column.startWidth = parseInt(column.width);

               //may need to loop through columns if previous column is already minWidth
               while ( columnIndex-i >= 0 && !done ) {
                  var prevColumn = headBody1.rows[0].cells[columnIndex-i];
                  prevColumn.width = Math.max(prevColumn.startWidth + difference, MIN_COL_WIDTH);
                  prevColumn.isDragging = true;  //flag column as dragging, so that its width is properly stored by drop case (below)

                  //if prevColumn is already minWidth, skip to column preceeding it
                  if ( parseInt(prevColumn.width) <= MIN_COL_WIDTH ) {
                     if ( prevColumn.startWidth - parseInt(prevColumn.width) > 0 ) {
                        column.startPosition = new Position(column.startPosition.getX() - (prevColumn.startWidth - parseInt(prevColumn.width) - cellPadding), column.startPosition.getY(), column.startPosition.getZ());
                     }
                     difference = difference + prevColumn.startWidth - parseInt(prevColumn.width);
                     prevColumn.startWidth = parseInt(prevColumn.width);
                     i++;
                  } else {
                     done = true;
                  }
               }
            } else {
               column.width = columnWidth;
            }

            resizeDivAjax(divID, column);

            return false;
         }
         break;
      case 3: // mouseUp (drop)
         if (column.isDragging)
         {
            column.isDragging = false;
            // restore document's mouse handlers
            document.onselectstart = document._onselectstart;
            document.onmousemove = document._onmousemove;
            document.onmouseup = document._onmouseup;
            document.ontouchmove = document._ontouchmove;
            document.ontouchend = document._ontouchend;
            document.body.style.cursor = document.body._cursor;
            // save width
            var input = column.firstChild.rows[0].lastChild.lastChild;

            input.value = column.width ? column.width : "-1";
            column.startWidth = WUtilities.getWidth(column);

            //loop over all isDragging columns, saving their width
            var done = false;
            for (var i=tableColumns[columnId]-1; i >= 0 && !done; i--){
               var currColumn = headBody1.rows[0].cells[i];

               if (currColumn.isDragging) {
                  currColumn.isDragging = false;
                  // save width
                  var input = currColumn.firstChild.rows[0].lastChild.lastChild;

                  input.value = currColumn.width ? currColumn.width : "-1";
                  currColumn.startWidth = WUtilities.getWidth(currColumn);
               } else {
                  done = true;
               }

               currColumn.setAttribute("prefWidth", currColumn.width);
            }

            //save column widths if external method is defined
            if ( typeof bonsaiSaveColumnWidthsAjax == 'function' ) {
               bonsaiSaveColumnWidthsAjax(divID, colUrl);
            }

            //restore scrollTop
            setScrollTopAjax(divID);

            return false;
         }
         break;
      }
   }
   return true;
}

/** WTable
 * set table height based on set rows per viewport value and update ajax value
 * if auto is true and table is set for autosize or auto is false and table is
 * not set for autosize
 */
function adjustTableHeightAjax(dataBodyEnc, auto) {
    wclajax_debug("-> adjustTableHeightAjax("+dataBodyEnc+","+auto+")");
    var dataBody = document.getElementById(dataBodyEnc);
    if ( !dataBody ) {
       return;
    }
    var autosize = ( dataBody.getAttribute("autorpv") == "true" );
    if ( autosize != auto) {
       return;
    }

    var rpvArray = adjustTableHeight(dataBodyEnc);

    if ( rpvArray && autosize ) {
        var viewRows = rpvArray[0];
        var rpvMax = rpvArray[1];

        wclajax_debug("  adjustTableHeightAjax: viewRows ["+viewRows+"] rpvMax ["+rpvMax+"]");

        dataBody.setAttribute("rpv_init", "-1");  //initially flagged for autosize

        var scrollPaneEnc = dataBody.getAttribute('SPID');
        var scrollPane = document.getElementById(scrollPaneEnc);

        if (scrollPane != null) {
            scrollPane.childNodes[1].value = viewRows;
            scrollPane.childNodes[2].value = rpvMax;

             var dnd = RegisteredDDs.getDragDrop(scrollPaneEnc);
             if ( dnd ) {
               dnd.rowsPerView = viewRows;
            }
        }
    }
    wclajax_debug("<- adjustTableHeightAjax");
}

require([
    "dojo/request",
    "dijit/a11y"
], function(request, a11y) {
    /** WTable **
     * returns Finds the descendant of the specified root node that is first in the tabbing order
     * root - node to search
     */
    window.getFirstInTabbingOrder = function(root) {
        return a11y.getFirstInTabbingOrder(root);
    };

    /** WTable **
     * used for submiting input from selected rows only
     * formName - the encoded name of the form
     * actionName - the name of the action being performed
     * actionNameEnc - the encoded name of the action being performed
     * wclhidden - the encoded name of the hidden field
     */
    changeAllSelectedAjax = function(formName, actionName, actionNameEnc, wclhidden) {
        if (document != null && document.forms != null && formName != null) {
            var form = document.forms[formName];

            if (form != null) {
                var fieldArray = new Array();
                fieldArray = getSelectedRowsInput(form);
                var actionValue;
                if(fieldArray['#selectedRows'] !== undefined){
                    actionValue = 'changeSelected(' + fieldArray['#selectedRows'].join(',') + ')';
                    delete fieldArray['#selectedRows'];
                }else{
                    actionValue = 'changeSelected()';
                }
                putInputValueIntoArray(fieldArray, 'IsAjaxInvoked', 'YES');
                putInputValueIntoArray(fieldArray, actionNameEnc, actionValue);
                putInputValueIntoArray(fieldArray, 'AjaxForms', getFormsList());
                putInputValueIntoArray(fieldArray, wclhidden, actionName);

                var actionString = getActionString(form);
                request.post(actionString, {
                    preventCache: true,
                    data: convertArrayToObject(fieldArray),
                    handleAs: "text",
                    timeout: requestTimeout
                }).response.then(handleStateChange, handleRequestErrorDojo);
            }
            return false;
        }
    };

    /** WTable **
     * used for invoking actions via ajax without submitting form fields
     * formName - the encoded name of the form
     * actionName - the name of the action being performed
     * actionValue - the name of the component performing the action
     * anchorName - the name of the anchor used when the page is refreshed
     * actionNameEnc - the encoded name of the action being performed
     * wclhidden - the encoded name of the hidden field
     * wclanchor - the encoded name of the hidden field for the anchor
     */
    doTblAjaxNoSubmit = function(formName, actionName, actionValue, anchorName, actionNameEnc, wclhidden, wclanchor, returnSuccess) {
        if (document != null && document.forms != null && formName != null) {
            var form = document.forms[formName];

            if (form != null) {
                var fieldArray = new Array();
                putInputValueIntoArray(fieldArray, 'IsAjaxInvoked', 'YES');
                putInputValueIntoArray(fieldArray, actionNameEnc, actionValue);
                putInputValueIntoArray(fieldArray, 'AjaxForms', getFormsList());
                putInputValueIntoArray(fieldArray, wclhidden, actionName);
                // ajax in portlets
                putAjaxInPortletsParams(fieldArray, form);

                if (!isAJAXOutstanding) {
                    isAJAXOutstanding = true;
                    refreshForm = form.action;

                    var actionString = getActionString(form);
                    request.post(actionString, {
                        preventCache: true,
                        data: convertArrayToObject(fieldArray),
                        handleAs: "text",
                        timeout: requestTimeout
                    }).response.then(handleStateChange, handleRequestErrorDojo);

                    if ( returnSuccess ) {
                        return true;
                    }
                }
            }
            return false;
        }
        if ( returnSuccess ) {
            return false;
        }
    };

    //saveColumnWidths - submit column widths dimensions for persisitence
    // -in: divID  - id of the div containing the table
    //      colUrl - callback url of the WTable colWidths trigger
    //-out: none, column width form submitted
    saveColumnWidthsAjax = function(divID, colUrl) {
        var params = "";

        try {
            var div           = document.getElementById(divID);
            var headBody1     = document.getElementById(div.getAttribute('H1BID'));
            var cellCount     = headBody1.rows[0].cells.length-1;
            for (var c = 0; c < cellCount; c++) {
                var head1 = headBody1.rows[0].cells[c];
                params  = params + ( params == "" ? "?" : "&" ) + head1.getAttribute("id") + "=" + head1.width;
            }

            request.post(colUrl + params, {
                preventCache: true,
                data: {},
                handleAs: "text",
                timeout: 5000
            });
        } catch( e ) {
            return false;
        }

        return true;
    };
}); // end require
