﻿// Table display settings dialog code.
// This dialog is used for both the table view and drillthrough settings.

var m_bFromTable = true;  // false = drillthrough page.
var m_strLabelforMaximumLength = "";
var M_strTableOptions =
      "<TABLE class='OptionTable' border='0' width=100% cellPadding='3' cellSpacing='0'>"
+ "<TR>"
+ "<TD colspan=7 class=OptionHeader nowrap align=left>"
+ resTableDisplaySettings
+ "</TD>"
+ "<TD width=100%></TD></TR>"
+ "<TR>"
+ "<TD>&nbsp;</TD>"
+ "<TD class=OptionItem align=left nowrap><LABEL FOR=TableRowPageSizeLB ACCESSKEY='r'>&nbsp;"
+ resRowsPerPage
+ "</LABEL></td>"
+ "<TD align=left><SELECT class=Default id=TableRowPageSizeLB size='1' "
+ "onkeypress='javascript:SubmitTableOptions(event);'>"
+ "</SELECT></TD>"
+ "<TD>&nbsp;&nbsp;</TD>"
+ "<TD class=OptionItem align=left nowrap>"
+ "<LABEL FOR=TableColPageSizeLB ACCESSKEY='c'>&nbsp;"
+ resColumnsPerPage
+ "</LABEL></TD>"
+ "<TD align=left><SELECT  class=Default id=TableColPageSizeLB size='1'"
+ "onkeypress='javascript:SubmitTableOptions(event);'>"
+ "</SELECT></TD>"
+ "</TR>"

+ "<TR>" // Include current date and time
+ "<TD>&nbsp;</TD>"
+ "<TD class=OptionItem colspan=7 align=left nowrap>"
+ "<input type=checkbox id='CurrentDateIncluded' title='" + resIncludeCurrentDateAndTime
+ "' name='CurrentDateIncluded'" + " onkeypress=\"javascript:SubmitTableOptions(event);\">"
+ "&nbsp;"
+ "<LABEL FOR=CurrentDateIncluded ACCESSKEY='i'>" + resIncludeCurrentDateAndTime + "</LABEL>"
+ "</TD>"
+ "</TR>"

+ "<TR>" // Fixed headers on scrolling
+ "<TD>&nbsp;</TD>"
+ "<TD class=OptionItem colspan=7 align=left nowrap>"
+ "<input type=radio title='" + resFixedHeadersOnScrolling + "' name=WrappingOption id=WrappingOff"
+ " value='1' onClick =\"javascript:SelectWrappingOption(WRAPPING_OFF);\""
+ " onkeypress=\"javascript:SubmitTableOptions(event);\">"
+ "&nbsp;"
+ "<LABEL FOR=WrappingOff ACCESSKEY='n'>" + resFixedHeadersOnScrolling + "</LABEL>"
+ "</TD>"
+ "</TR>"

+ "<TR>" // Label length
+ "<TD>&nbsp;</TD>"
+ "<TD colspan=7 align=left nowrap><TABLE><TR>"
+ "<TD>&nbsp;&nbsp;&nbsp;&nbsp;</TD>"
+ "<TD><LABEL id='LabelForMaximumLength' class=OptionItem FOR=MaximumLabelLength ACCESSKEY='l'>&nbsp;"
+ m_strLabelforMaximumLength
+ "</LABEL></TD>"
+ "<TD align=left><SELECT class=Default id=MaximumLabelLength size='1'"
+ " onkeypress='javascript:SubmitTableOptions(event);'>"
+ "</SELECT></TD>"
+ "</TR></TABLE></TD></TR>"

+ "<TR>" // Label wrapping
+ "<TD>&nbsp;</TD>"
+ "<TD class=OptionItem colspan=7 align=left nowrap>"
+ "<input type=radio title='" + resLabelWrapping + "' name=WrappingOption id=WrappingOn"
+ " value='1' onClick =\"javascript:SelectWrappingOption(WRAPPING_ON);\""
+ " onkeypress=\"javascript:SubmitTableOptions(event);\" checked>"
+ "&nbsp;"
+ "<LABEL FOR=WrappingOn ACCESSKEY='w'>" + resLabelWrapping + "</LABEL>"
+ "</TD>"
+ "</TR>"

+ "<TR id='SlicerOptionTR'>" //Slicer area wrapping option
+ "<TD>&nbsp;</TD>"
+ "<TD class=OptionItem colspan=7 align=left nowrap>"
+ "<input type=checkbox id='SlicerSingleLineCheckbox' title='" + resSlicerSingleLine
+ "' name='SlicerSingleLineCheckbox'" + " onkeypress=\"javascript:SubmitTableOptions(event);\">"
+ "&nbsp;"
+ "<LABEL FOR=SlicerSingleLineCheckbox ACCESSKEY='i'>" + resSlicerSingleLine + "</LABEL>"
+ "</TD>"
+ "</TR>"

+     "<TR>"
+     "<td colspan=3><nobr>"
+     "<input type=button name=TableOptionsGo value=\"" + resOK
+     "\" onclick=\"javascript:OnTableOptions();\">&nbsp;"
+     "<input type=button name=Cancel value=\"" + resCancel
+     "\" onclick=\"javascript:OnCancelOptions();\">&nbsp;"
+     "<input name=DialogHelpButton type=button value=\"" + resHelp
+     "\" onclick=\"javascript:DisplayDialogHelp('TableOptions.htm', '');\">"
+     "</nobr></td>"
+     "</TR>"
+     "</TABLE>";

//-------------------------------------------------------------------
function TableOptionsPopulateSelect(i_objSelect, i_nOptions, i_nStep, i_nDefaultValue, i_bPercent) {
   var nIndex;
   var nValue;
   var nSelectedIndex = 0;
   var szText;

   if (i_objSelect) {
      for (nIndex = 0; nIndex < i_nOptions; nIndex++) {
         nValue = (nIndex + 1) * i_nStep;
         if (nValue == i_nDefaultValue) nSelectedIndex = nIndex;
         szText = nValue.toString();
         if (i_bPercent != null && i_bPercent == true) {
            szText += " %";
         }
         SelectControlAddOption(i_objSelect, nValue, szText);
      }
      i_objSelect.selectedIndex = nSelectedIndex;
   }
}

//-------------------------------------------------------------------
function TableOptionsPopulateSelectNewRows(i_objSelect, i_nOptions, i_nStep, i_nDefaultValue) {
   var nIndex;
   var nValue;
   var nSelectedIndex = 0;

   if (i_objSelect) {
      var nSelectLength = i_objSelect.length;
      for (nIndex = 0; nIndex < i_nOptions; nIndex++) {
         nValue = (nIndex + 1) * i_nStep + nSelectLength;
         if (nValue == i_nDefaultValue) nSelectedIndex = nIndex + nSelectLength;
         SelectControlAddOption(i_objSelect, nValue, nValue.toString());
      }
      if (nSelectedIndex != 0) {
         i_objSelect.selectedIndex = nSelectedIndex;
      }
   }
}

//-------------------------------------------------------------------
function TableOptionsInitialize() {

   if (m_bFromTable) {
      TableOptionsPopulateSelect(document.aspnetForm.TableRowPageSizeLB, 50, 1, document.aspnetForm.TableRowPageSize.value);
      TableOptionsPopulateSelectNewRows(document.aspnetForm.TableRowPageSizeLB, 15, 10, document.aspnetForm.TableRowPageSize.value);
      TableOptionsPopulateSelect(document.aspnetForm.TableColPageSizeLB, 50, 1, document.aspnetForm.TableColPageSize.value);
      m_strLabelforMaximumLength = resMaximumLengthOfInnerMostLabel;
   }
   else {
      TableOptionsPopulateSelect(document.aspnetForm.TableRowPageSizeLB, 20, 10, document.aspnetForm.DrillthroughTableRowPageSize.value);
      TableOptionsPopulateSelect(document.aspnetForm.TableColPageSizeLB, 50, 1, document.aspnetForm.DrillthroughTableColPageSize.value);
      m_strLabelforMaximumLength = resMaximumLengthOfLabel;
   }
   
   // Inclusion of current date
   if (document.aspnetForm.IncludeCurrentDateInReports.value == "False") {
      document.aspnetForm.CurrentDateIncluded.checked = false;
   }
   else {
      document.aspnetForm.CurrentDateIncluded.checked = true;
   }
  if (m_bFromTable) {
       // wrapping slicer area
       if (document.aspnetForm.SlicerSingleLine.value == "False") {
           document.aspnetForm.SlicerSingleLineCheckbox.checked = false;
       }
       else {
           document.aspnetForm.SlicerSingleLineCheckbox.checked = true;
       }
   }
   else {
       var clSlicerOptionTR = document.getElementById("SlicerOptionTR");
       clSlicerOptionTR.style.display = "none";
   }

   // Wrapping and Fixed Headers
   InitializeWrappingandFixedHeadersOptions(m_strLabelforMaximumLength)

}

//-------------------------------------------------------------------
//displays the Table Options dialog when you click the Table Options button in the toolbar
function ShowTableOptions(i_bFromTable)
{
   m_bFromTable = i_bFromTable;
   DisplayOption(M_strTableOptions);
   TableOptionsInitialize();
   onLayoutResize();
   document.aspnetForm.TableRowPageSizeLB.focus();
}

//-------------------------------------------------------------------
//handles the OK button on the Table Options dialog
function OnTableOptions()
{
   var objSelectCol = document.aspnetForm.TableColPageSizeLB;
   var objSelectRow = document.aspnetForm.TableRowPageSizeLB;
      
   if (m_bFromTable) {
      document.aspnetForm.TableRowPageSize.value = objSelectRow.options[objSelectRow.selectedIndex].value;
      document.aspnetForm.TableColPageSize.value = objSelectCol.options[objSelectCol.selectedIndex].value;
   }
   else {
      if (document.aspnetForm.DrillthroughTableRowPageSize.value != objSelectRow.options[objSelectRow.selectedIndex].value){
         document.aspnetForm.FirstRow.value = "";
         document.aspnetForm.DrillthroughTableRowPageSize.value = objSelectRow.options[objSelectRow.selectedIndex].value;
      }
      if (document.aspnetForm.DrillthroughTableColPageSize.value != objSelectCol.options[objSelectCol.selectedIndex].value) {
         document.aspnetForm.FirstCol.value = "";
         document.aspnetForm.DrillthroughTableColPageSize.value = objSelectCol.options[objSelectCol.selectedIndex].value;
      }
   }

   // Inclusion of current date
   if (document.aspnetForm.CurrentDateIncluded.checked) {
      document.aspnetForm.IncludeCurrentDateInReports.value = "True";
   }
   else {
      document.aspnetForm.IncludeCurrentDateInReports.value = "False";
   }

   // Wrapping and Fixed Headers
  SubmitWrappingandFixedHeadersOptions()

  // Submit slicer wrapping option
  
      if (document.aspnetForm.SlicerSingleLineCheckbox.checked) {
          document.aspnetForm.SlicerSingleLine.value = "True";
      }
      else {
          document.aspnetForm.SlicerSingleLine.value = "False";
      }
 

   executeWait(document.aspnetForm);
}

//-------------------------------------------------------------------
//handles the Enter key when the focus is on a listbox in the Table Options dialog
function SubmitTableOptions(e)
{
   var key = GetKeyCode(e);
   if ( key == 13) {
      OnTableOptions();
      ResetSubmit(e);
   }
}

