﻿// JScript File
var isNavSearch = (navigator.appName == "Netscape") ? true : false;
var isIESearch = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
var iDisplay = 0; // Used is search box display
var fAndNotError = false; // Used to display error if more than one "AND NOT" is used.
var fIIPRCwasChecked = false; // Keeps track of IIPRC setting so that it can be reset correctly after INsight only
var fINsightOnly = false; // Used to prevent 2nd INsight only from issueing alert

// This function displays one more search box to what is
// currently showing. Max is 12. iCount of -1 is the add button.
function addmoresearch(iCount) {
  // Get the elements
  var searchDiv = document.getElementsByName('divSearch');
  var sSearches = document.getElementsByName('search');
  var sFields = document.getElementsByName('field');
  var sConnector = document.getElementsByName('connector');
  // If we are not working on the last displayed box, check to
  // see if end was selected. If not, then the connector was
  // just changed. Return and do nothing. If end was selected,
  // blank all the search boxes after this one and hide them.
  if (iCount != -1 && iCount < iDisplay) {
    if (sConnector[iCount].selectedIndex == 3) {
      for (i=(iCount+1); i<12; i++) {
        searchDiv[i].style.display = 'none';
        sSearches[i].value = "";
        sFields[i].selectedIndex = 0;
        sConnector[i].selectedIndex = 3;
      }
      iDisplay = iCount;
    }
    return;
  }
  // Max is 12... display message, set last box to end and return.
  if (iDisplay == 12) {
    sConnector[iDisplay].selectedIndex = 3;
    alert('No more search boxes allowed');
    return;
  }
  // If add button pressed, change connector to "AND".
  if (iCount == -1) {
    sConnector[iDisplay].selectedIndex = 0;
  }
  // Put an * in search field if they left field blank.
  if (isEmpty(sSearches[iDisplay].value)) {
    sSearches[iDisplay].value = "*";
  }
  // Up the display count and display next section
  iDisplay++;
  sConnector[iDisplay].selectedIndex = 3;
  searchDiv[iDisplay].style.display='';
  sSearches[iDisplay].focus();
}

function applydefaults() {
  // Load the search fields and submit form
  getsearch();
  var submitmode = document.getElementById('submitmode');
  submitmode.value = 'APPLYDEFAULTS';
  document.misc.submit();
}

// Hides/Displays a section when the arrow has been clicked.
function changeArrow(img, divName) {
  var sTemp = document.getElementById(divName);
  var fJurisdictions = false;
  var oSelect, oClear;
  // If it is the jurisdictions section, get object for select/clear all
  if (divName == 'divJurisdictions') {
    fJurisdictions = true;
    oSelect = document.getElementById('jur_selectall');
    oClear = document.getElementById('jur_clearall');
  }
  // See which image is currently display and change according to
  // what one is displaying.
  if (isObject(sTemp)) {
    if (img.src.indexOf('up_arrow') > 0) {
      img.src = '../images/down_arrow.gif';
      sTemp.style.display = 'none';
      if (fJurisdictions == true) {
        oSelect.style.display = 'none';
        oClear.style.display = 'none';
      }
    } else {
      img.src = '../images/up_arrow.gif';
      sTemp.style.display = '';
      if (fJurisdictions == true) {
        oSelect.style.display = '';
        oClear.style.display = '';
      }
    }
  }
}

// When a change is made to document types, if INsight only is checked, uncheck IIPRC
// and disable the checkbox for it.
// 20110509lcg: Add check for INcompass v2
function checkIIPRC(fromJur)
{
    var fINsightChecked = false; // Set if either INsight box is checked
    var fNonINsightChecked = false; // Set if any box is checked other than INsight
    var DocTypes = document.getElementsByName('DocType'); // DocTypes array
    var chkStates = document.getElementsByName('chkStates'); // Jurisdiction array
    var fINcompass = document.getElementById("INcompass");
    var fINcompassV2 = document.getElementById("INcompassV2").value.toLowerCase();
    if (fINcompass.value=="true" && fINcompassV2 != "true") {
        for (i=0; i<chkStates.length; i++)
        {
            if (chkStates[i].value == 'IC') // Look for IIPRC jurisdiction selected
            {
                chkStates[i].checked = false; // uncheck IIPRC
                chkStates[i].disabled = true; // disable IIPRC
            }
        }
    }
    if (fromJur == true) // Get value of IIPRC on initial load or any time a jurisdiction is changed.
    {
        if (!chkStates.length > 1) // For single state access
        {
            if (chkStates.value == 'IC') // If the single state happens to be IIPRC, always checked
            {
                checkStates.checked = true;
            }
            return; // Exit
        }
        for (i=0; i<chkStates.length; i++) // Run through states
        {
            if (chkStates[i].value == 'IC') // If IIPRC
            {
                if (chkStates[i].checked == true) // Check and save its setting
                {
                    fIIPRCwasChecked = true;
                }
                else
                {
                    fIIPRCwasChecked = false;
                }
            }
        }
    }
    // Check DocTypes checked
    // Items 7 and 8 only mean INsight only checked
    for (i=0; i<DocTypes.length; i++)
    {
        switch (DocTypes[i].value)
        {
            case '7':
            case '8':
                if (DocTypes[i].checked == true)
                {
                    fINsightChecked = true; // true if either INsight checked
                }
                break;
            default:
                if (DocTypes[i].checked == true)
                {
                    fNonINsightChecked = true; // true if anything other that INsight checked
                }
                break;
        }
    }
    if (fINsightChecked == true && fNonINsightChecked == false) // If an INsight checked and nothing else checked
    {
        if (!chkStates.length > 1) // Just in case access is IIPRC only, issue warning and uncheck INsight's
        {
            alert("INsight not available for IIPRC.");
            chkStates[7].checked = false;
            chkStates[8].checked = false;
            return;   // Exit
        }
        for (i=0; i<chkStates.length; i++)
        {
            if (chkStates[i].value == 'IC') // Look for IIPRC jurisdiction selected
            {
                if (fINsightOnly == false && fIIPRCwasChecked == true) // If it was checked and flag for INsightOnly not already set, issue warning.
                {
                    alert("IIPRC was checked but is not available in INsight so the jurisdictions selection has been unchecked.");
                }
                chkStates[i].checked = false; // uncheck IIPRC
                chkStates[i].disabled = true; // disable IIPRC
            }
        }
        fINsightOnly = true; // set global variable so that we know we already issued alert
    }
    else
    {
        if (fINsightOnly == true) // did we previously issue the warning that we unchecked IIPRC?
        {
            fINsightOnly = false;
            if (!chkStates.length > 1) // should never be able to make it here... but just in case :)
            {
                return;
            }
            for (i=0; i<chkStates.length; i++)
            {
                if (chkStates[i].value == 'IC')
                {
                    if (fIIPRCwasChecked == true) // if it was previously checked, let them know we re-checked the IIPRC jurisdiction
                    {
                        alert("IIPRC has been re-checked in the jurisdictions selections.");
                    }
                    chkStates[i].checked = fIIPRCwasChecked; // set to previous state
                    chkStates[i].disabled = false; // re-enable checkbox
                }
            }
        }
    }
}

// If enter is pressed while in the search field, process like the
// execute button was clicked.
function CheckEnter2(evt) {
  if (isNavSearch) {
    if (evt.which == 13) {
      executeit();
    }
  }
  else if (isIESearch) {
    if (window.event.keyCode == 13) {
      executeit();
    }
  }
}

// This is old but several pages still call it as of 7/12/2007
function CheckJurisdictions() {
  if (document.search2.statedropdown.selectedIndex == 0) {
    document.search.jurisdictions.value = "ALL"
  }
  else if (document.search2.statedropdown.selectedIndex == 1) {
    openWin('../includes/CustomSettings.asp', '750', '550');
  }
  else {
    document.search.jurisdictions.value = document.search2.statedropdown.options[document.search2.statedropdown.selectedIndex].value
  }
}

// Checks to make sure at least one LOB is selected if rec type is 'LOB'.
function checkLOBs() {
  var sRecType = document.getElementById('sRecType');
  if (sRecType.value == 'LOB') {
    var sLOBTypes = document.getElementById('sLOBTypes');
    if (trim(sLOBTypes.value).length < 1) {
      alert('Please select at least one Line of Business or change your ' +
        'selection to All Records in the section "Records" before saving ' +
        'your default settings.');
      return false;
    }
  }
  return true;
}

// Clears the form
function clearit() {
  // Uncheck all jurisdictions
  var chkStates = document.getElementsByName('chkStates');
  for (i=0; i<chkStates.length; i++) {
    chkStates[i].checked = false;
  }
  // Set records to "ALL"
  var RecType = document.getElementsByName('RecType');
  for (i=0; i<RecType.length; i++) {
    if (RecType[i].value == 'ALL') {
      RecType[i].checked = true;
    }
  }
  // Uncheck all LOB/SLOB selections
  var chkLOBs = document.getElementsByName('chkLOBs')
  var Grid, grayBar, img;
  divSLOBs.style.display = 'none';
  divSLOBsMsg.style.display='';
  for (i=0; i<chkLOBs.length; i++) {
    if (chkLOBs[i].checked == true) {
      Grid = document.getElementsByName('divSLOBs'+chkLOBs[i].value+'grid');
      for (x=0; x<Grid.length; x++) {
        Grid[x].checked = false;
      }
      chkLOBs[i].checked = false;
      grayBar = document.getElementById('divSLOBs'+chkLOBs[i].value+chkLOBs[i].value);
      img = document.getElementById('divSLOBs'+chkLOBs[i].value+chkLOBs[i].value+'src');
      img.src = '../images/up_arrow.gif';
      grayBar.style.display = '';
    }
  }
  if (sSearchMode != 'INCOMPASS') {
    // Set MaxDoc to 500
    var maxdoc = document.getElementsByName('maxdoc');
    if (isObject(maxdoc)) {
      maxdoc[0].checked = true;
    }
    // Set InfoType to Any Information
    var InfoType = document.getElementById('InfoType');
    InfoType.selectedIndex = 0;
  }
  // Check all DocTypes
  var DocType = document.getElementsByName('DocType');
  for (i=0; i<DocType.length; i++) {
    DocType[i].checked = true;
  }
  // If not email, clear whatsnew box
  if (sSearchMode != 'EMAIL' && sSearchMode != 'INCOMPASS') {
    var whatsnew = document.getElementById('whatsnew');
    whatsnew.value = '';
  }
  // Reset display on additional items
  var imgAddItem = document.getElementById('imgAddItem');
  imgAddItem.src = '../images/down_arrow.gif';
  divAdditionalItems.style.display = 'none';
  // Hide all LOB/SLOB sections
  ShowHide('ALL');
  // Set grid to defaults
  GridDefaults(true);
  // If email, set frequency and preferences to defaults
  if (sSearchMode == 'EMAIL') {
    var freq = document.getElementsByName('freq')
    for (i=0; i<freq.length; i++) {
      if (freq[i].value == '1') {
        freq[i].checked = true;
        break;
      }
    }
    var pref = document.getElementsByName('pref')
    for (i=0; i<pref.length; i++) {
      if (pref[i].value == '1') {
        pref[i].checked = true;
        break;
      }
    }
  }
  // Go to top of window
  window.location.href = '#top';
}

// Called when a user clicks on the Clear Defaults button. It confirms that
// they are sure and submits the page so the delete will occur.
function deleteit() {
  var fReturn;
  fReturn = window.confirm('Your selected settings will be cleared');
  if (fReturn == true) {
    var submitmode = document.getElementById('submitmode');
    submitmode.value = "DELETE";
    document.misc.action = "?mode=DEFAULTS";
    document.misc.submit();
  }
}

// Called when the execute button is clicked or enter pressed on the
// search/email alert page.
function executeit() {
  // Sets the variables on the page into the hidden variables on the page.
  setform();
  // Requires an LOB to be checked if LOB is selected in the Records section
  if (checkLOBs() == false) return;
  // Sets the search hidden variable.
  getsearch();
  if (fAndNotError == true) {
    alert("The use of 2 \"AND NOT\" connectors is not allowed.\n\n" +
        "The most likely fix to your search is to use \"OR\" after the first \"AND NOT\".");
    fAndNotError = false;
    return false;
  }

  // Submit the page.
  var submitmode = document.getElementById('submitmode');
  submitmode.value = 'EXECUTE';
  document.misc.submit();
}

// Function to fill in the search text, field and connector.
function FillSearchBox(str, connector) {
  // Gets all the elements for the search sections.
  var searchDiv = document.getElementsByName('divSearch');
  var sSearch = document.getElementsByName('search');
  var sFields = document.getElementsByName('field');
  var sConnector = document.getElementsByName('connector');
  // The search is split with || between the text and field (gap||0).
  var oRE2 = /(.+)\|\|(\d+)/;
  // Execute regular expression and store in "match" array.
  if ((aStr2 = oRE2.exec(str)) != null) {
    // Fill in the "text"
    sSearch[iDisplay].value = aStr2[1];
    // Find which field is selected.
    for (i=1; i<sFields[iDisplay].length; i++) {
      if (sFields[iDisplay][i].value == aStr2[2]) {
        sFields[iDisplay].selectedIndex = i;
        break;
      }
    }
    // Sets the connector
    sConnector[iDisplay].selectedIndex = connector;
    // Unhides the section
    searchDiv[iDisplay].style.display = '';
  }
}

// Function to split a search into each section.
function FillSearch(str) {
  // Pointer to hold where we are in the search string
  var iPtr = 0;
  // Sets the iDisplay variable (global variable)
  iDisplay = 0;
  // Regular expression to split searches which are seperated by ::x:: where
  // x is the connector between sections.
  var oRE = /::([0123])::/g;
  while ((aStr = oRE.exec(str)) != null) {
    // Using substring, pass the search string... aStr.index holds the pointer
    // to the macth for ::x:: and aStr[1] holds what 'x' is.
    FillSearchBox(str.substring(iPtr, aStr.index), aStr[1]);
    // Sets pointer to first character after the match.
    iPtr = oRE.lastIndex;
    // Up the global iDisplay counter
    iDisplay++;
  }
  // Gets the last of the searches (or in the case of no matches, the only one).
  FillSearchBox(str.substring(iPtr, str.length), "3");
}

// Pieces together the search sections and builds the search string.
function getsearch() {
  var sSearchStr = "";
  // Get all the elements.
  var sSearches = document.getElementsByName('search');
  var sFields = document.getElementsByName('field');
  var sConnector = document.getElementsByName('connector');
  var iAndNotCount = 0; // count the number of "AND NOT" connectors.
  // Loop through the sections up until the iDisplay counter.
  for (i=0; i<=iDisplay; i++) {
    // If the search is blank, replace it with *
    if ((trim(sSearches[i].value).length) < 1) {
      sSearches[i].value = "*";
    }
    // Build the string
    sSearchStr += sSearches[i].value + "||" + sFields[i].value;
    // If we are at the idisplay count of the connector is "END", we are done.
    if (i == iDisplay || sConnector[i].value == "3") {
      break;
    } else {
    // Add the connector
      sSearchStr += "::" + sConnector[i].value + "::";
      if (sConnector[i].value == "2") iAndNotCount++;
    }

  }
  // Put into the hidden form variable
  var sSearch = document.getElementById('sSearch');
  sSearch.value = sSearchStr;
  if (iAndNotCount > 1) fAndNotError = true;
}

// Resets the grid to its default values.
function GridDefaults(reset) {
  var gridchoice = document.getElementsByName('gridchoice');
  var UseGrid = document.getElementById('UseGrid');
  if (!isObject(gridchoice) || !isObject(UseGrid)) return true;
  if (reset == true) UseGrid.checked = true;
  for (var i = 0; i < gridchoice.length; i++ ) {
    switch (i + 1) {
      case 1:
      case 2:
        gridchoice[i].checked = true;
        gridchoice[i].disabled = true;
        break;
      case 3:
      case 4:
      case 5:
      case 6:
      case 7:
      case 8:
      case 9:
      case 10:
      case 11:
        gridchoice[i].checked = true;
        gridchoice[i].disabled =
            (UseGrid.checked ? false : true);
        break;
      case 12:
      case 13:
      case 14:
        gridchoice[i].checked = false;
        gridchoice[i].disabled =
            (UseGrid.checked ? false : true);
        break;
      default:
        ;
    }
  }
  return true;
}

// This function inserts the search and field into the search
// page and submits the page to add it.
// Note: This function is called on others pages like the SCC and Thesaurus pages
// to insert a search into your search page.
function InsertSearch(sSearch, iField) {
  var wo = window.opener;
  var search = wo.document.getElementsByName('search');
  var field = wo.document.getElementsByName('field');
  if (!isEmpty(search[wo.iDisplay].value)) {
    wo.addmoresearch(-1);
  }
  search[wo.iDisplay].value = sSearch;
  for (i=0; i<field[wo.iDisplay].length; i++) {
    if (field[wo.iDisplay][i].value == iField) {
      field[wo.iDisplay][i].selected = true;
      break;
    }
  }
  self.close();
  return;
}

// Called when a change is made to an LOB checkbox. If an LOB is checked,
// it displays the corrisponding sub-lob section and sets flag to turn off
// message about selecting one or more lines of business.
function lobChange() {
  var displayNext = false;
  var chkLOBs = document.getElementsByName('chkLOBs');
  var sTemp;
  if (isObject(chkLOBs)) {
    for (i = 0; i < chkLOBs.length; i++) {
      sTemp = document.getElementById('divSLOBs'+chkLOBs[i].value);
      if (chkLOBs[i].checked == true) {
        displayNext = true;
        sTemp.style.display='';
      } else {
        sTemp.style.display='none';
      }
    }
  }
  // Turns on and off the message about selecting one or more lines
  switch (displayNext) {
    case true:
      divSLOBsMsg.style.display='none';
      divSLOBs.style.display='';
      break;
    case false:
      divSLOBsMsg.style.display='';
      divSLOBs.style.display='none';
      break;
  }
}

// Resets the form on the page. If fAll is passed, they are asking to clear
// the entire page. Ask to confirm before clearing. If nothing passed in
// fAll, only the search boxes are being reset. It does not ask, just clears it.
function resetit(fAll) {
  fAll = (fAll) ? true : false;
  if (fAll) {
    var fReturn = window.confirm('All selected criteria will be cleared.');
    if (fReturn == true) {
      // If they have defaults, now display the button to apply defaults.
      if (fHasDefaults == 'True') {
        var butDefaults = document.getElementById('butDefaults');
        butDefaults.style.display = '';
      }
      // This clears all but the search area.
      clearit();
    }
    else {
      return;
    }
  }
  // This clears the search sections, hides all but the first section
  // and sets the first connector to "END".
  var searchDiv = document.getElementsByName('divSearch');
  var sSearch = document.getElementsByName('search');
  var sFields = document.getElementsByName('field');
  var sConnector = document.getElementsByName('connector');
  for (i=0; i<searchDiv.length; i++) {
    if (i > 0) searchDiv[i].style.display = 'none';
    sSearch[i].value = '';
    sFields[i].selectedIndex = '0';
    sConnector[i].selectedIndex = '3';
    iDisplay = 0;
  }
}

// Called when email alert save button is clicked.
function saveemailalert() {
  // Get object to elements
  var freq = document.getElementsByName('freq');
  var pref = document.getElementsByName('pref');
  var fEmailDaily = document.getElementById('fEmailDaily');
  var fEmailNonZeroOnly = document.getElementById('fEmailNonZeroOnly');
  var submitmode = document.getElementById('submitmode');
  // Set the hidden variables on the form
  setform();
  // Build and set the search variable
  getsearch();
  if (fAndNotError == true) {
    alert("The use of 2 \"AND NOT\" connectors is not allowed.\n\n" +
        "The most likely fix to your search is to use \"OR\" after the first \"AND NOT\".");
    fAndNotError = false;
    return false;
  }
  // Get and set values for frequency and preferences
  for (i=0; i<freq.length; i++) {
    if (freq[i].checked == true) {
      fEmailDaily.value = freq[i].value;
      break;
    }
  }
  for (i=0; i<pref.length; i++) {
    if (pref[i].checked == true) {
      fEmailNonZeroOnly.value = pref[i].value;
      break;
    }
  }
  // Submit the form to save the search
  submitmode.value = 'SAVE';
  document.misc.submit();
}

// Submits form to save new default values
function saveit() {
  var fReturn;
  // Confirm they will overwrite current values
  fReturn = window.confirm('Your new default settings will be saved; ' +
    'any previous default settings will be overwritten.');
  if (fReturn == true) {
    // Set the hidden values and submit the form.
    setform();
    if (checkLOBs() == false) return;
    document.misc.action="?mode=DEFAULTS";
    document.misc.submit();
  }
}

// Checks the checkboxes for the integer value (using gridvalue & checkbox value)
function SetGrid(iGrid) {
  var UseGrid = document.getElementById('UseGrid');
  var gridchoice = document.getElementsByName('gridchoice');
  // If iGrid not set or is zero, uncheck the UseGrid box and return.
  if ((iGrid == null) || (parseInt(iGrid) == 0)) {
    UseGrid.checked = false;
    return GridDefaults();
  }
  // Check the UseGrid box and determine what boxes to check
  if (parseInt(iGrid) > 0) {
    UseGrid.checked = true;
    for (var i = 0; i < gridchoice.length; i++) {
      // 'AND' the value with integer and check box if not 0
      gridchoice[i].checked =
          (parseInt(iGrid) & (gridchoice[i].value)) > 0 ? true : false;
    }
  }
  return true;
}

// Get the selected grid choices and convert value to total integer value.
function SetGridInteger(iForm) {
  var doc;
  var iTotal = 0;
  // If iForm is 3, it comes from another window. Set the object to doc.
  if (iForm == 3) {
    doc = window.opener.document;
  }
  else {
    doc = document;
  }
  // Get hidden grid value
  var grid = doc.getElementById('grid');
  // Get grid elements
  var gridchoice = doc.getElementsByName('gridchoice');
  // Cycle through and add up checked values.
  if (isObject(doc.misc.UseGrid)) {
    if (doc.misc.UseGrid.checked) {
      for (var i = 0; i < gridchoice.length; i++) {
        if (gridchoice[i].checked) {
          iTotal += parseInt(gridchoice[i].value)
        }
      }
    }
  }
  // Set hidden variable
  grid.value = iTotal;
  return true;
}

// Goes through the form and sets hidden variables to pass to submitted page
function setform() {
  // Creates comma delimitted string of state codes
  var sStateStr = "";
  var chkStates = document.getElementsByName('chkStates');
  for (i=0; i<chkStates.length; i++) {
    if (chkStates[i].checked == true) {
      sStateStr += ((sStateStr.length > 0) ? "," : "") + chkStates[i].value;
    }
  }
  var sJurisdictions = document.getElementById('sJurisdictions');
  sJurisdictions.value = sStateStr;

  // Gets the record types, ALL or LOB
  var sRecType = document.getElementById('sRecType');
  var RecType = document.getElementsByName('RecType');
  for (i=0; i<RecType.length; i++) {
    if (RecType[i].checked == true) {
      sRecType.value = RecType[i].value;
      break;
    }
  }

  // Creates comma delimitted strings with LOBID's and subline ID's
  var sLOBTypes = document.getElementById('sLOBTypes');
  var sSLOBTypes = document.getElementById('sSLOBTypes');
  // Sets it to a blank string if record type is set to ALL
  if (sRecType.value == 'ALL') {
    sLOBTypes.value = '';
    sSLOBTypes.value = '';
  } else {
    var sLOBStr = "";
    var sSLOBStr = "";
    var chkLOBs = document.getElementsByName('chkLOBs')
    var Grid;
    for (i=0; i<chkLOBs.length; i++) {
      // If the LOB is checked, get the sublines checked under it
      if (chkLOBs[i].checked == true) {
        sLOBStr += ((sLOBStr.length > 0) ? "," : "") + chkLOBs[i].value;
        Grid = document.getElementsByName('divSLOBs'+chkLOBs[i].value+'grid');
        for (x=0; x<Grid.length; x++) {
          if (Grid[x].checked == true) {
            sSLOBStr += ((sSLOBStr.length > 0) ? "," : "") + Grid[x].value;
          }
        }
      }
    }
    sLOBTypes.value = sLOBStr;
    sSLOBTypes.value = sSLOBStr;
  }

  if (sSearchMode != "INCOMPASS") {
    // Get the value checked for MaxDoc
    var iMaxDoc = document.getElementById('iMaxDoc');
    var maxdoc = document.getElementsByName('maxdoc');
    for (i=0; i<maxdoc.length; i++) {
      if (maxdoc[i].checked == true) {
        iMaxDoc.value = maxdoc[i].value;
        break;
      }
    }

    // Gets the selected InfoType
    var iInfoType = document.getElementById('iInfoType');
    var InfoType = document.getElementById('InfoType');
    iInfoType.value = InfoType[InfoType.selectedIndex].value;
  }

  // Create a comma delimitted list for DocTypes. If they are
  // all selected, set to 0 (causes them not to be added to
  // the SQL search string).
  var sDocTypes = document.getElementById('sDocTypes');
  var DocType = document.getElementsByName('DocType');
  var sDocStr = "", fAllDocTypes = true;
  for (i=0; i<DocType.length; i++) {
    if (DocType[i].checked == true) {
      sDocStr += ((sDocStr.length > 0) ? "," : "") + DocType[i].value;
    }
    else {
      fAllDocTypes = false;
    }
  }
  if (fAllDocTypes) sDocStr = "0";
  sDocTypes.value = sDocStr;

  // Gets the what's new since value.
  var whatsnew = document.getElementById('whatsnew');
  if (isObject(whatsnew)) {
    var sWhatsnewDate = document.getElementById('sWhatsnewDate');
    sWhatsnewDate.value = whatsnew.value;
  }

  // Call to set the grid integer
  SetGridInteger();

  // Submits the page.
  var submitmode = document.getElementById("submitmode");
  submitmode.value = "SAVE";
}

// Function to display and hide the LOB section. If "ALL"
// is selected, the LOB/SLOB section is not displayed.
function ShowHide(type) {
  // Retrieve the LOB <div> tag.
  var divLOBs = document.getElementById('divLOBs');
  // If the tag is retrieved correctly, set the display style.
  if (isObject(divLOBs)) {
    switch(type) {
      case 'ALL':
        divLOBs.style.display='none';
        break;
      case 'LOB':
        divLOBs.style.display='';
        break;
    }
  }
}


