﻿var M_strReportDefinitionOptions =
   "<table class='OptionTable' width='100%' cellPadding='3' cellSpacing='0'>"
   + "<tr><td><table cellPadding='3' cellSpacing='0'>"
   + "<tr><td>"
   + "<table cellPadding='3' cellSpacing='0'>"
   + "<tr>"
   + "<td class=OptionHeader nowrap align=left>" + resReportDefinition + "</td>"
   + "</tr>"
   + "<tr height='3'></tr>"
   + "</table>"
   + "</td></tr>"
   + "<tr><td>"
   + "<table cellPadding='3' cellSpacing='0'>"
   + "<tr>"
   + "<td nowrap><table>"
   + "<tr>"
   + "<td id='ReportListTD' style='display:none'>"
   + "<table><tr>"
   + "<td class=OptionItem nowrap>"
   + "<LABEL FOR=CubeReportId ACCESSKEY=\"d\">" + resChooseReport + "</LABEL>"
   + "</td>"
   + "<td nowrap>"
   + "<select class=Default name=CubeReport title = '" + resChooseReport
   + "' id=CubeReportId onkeypress=\"javascript:SubmitReportDefinition(event);\" />"
   + "</td>"
   + "</tr></table>"
   + "</td>"
   + "<td id='CurrentReportTD' style='display:none'>"
   + "<table><tr>"
   + "<td class=OptionItem nowrap>"
   + resChooseReport
   + "</td>"
   + "<td class=OptionItem nowrap id=CurrentReportTitleTD>"
   + "</td>"
   + "</tr></table>"
   + "</td>"
   + "</tr>"
   + "<tr><td>"
   + "<table><tr>"
   + "<td><input type=checkbox id='DetailedDefinition' title='' name='DetailedDefinition' "
   + "onkeypress='javascript:SubmitReportDefinition(event);' "
   + "onclick='ChangeDetail();' >"
   + "</td>"
   + "<td class=OptionItem nowrap>"
   + "<label for='DetailedDefinition'>"
   + resDetailedDefinition
   + "</label></td>"
   + "</tr></table>"
   + "</td></tr>"
   + "<tr><td>"
   + "<table><tr>"
   + "<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>"
   + "<td class=OptionItem id='RptSelectionLimit' nowrap>"
   + "<LABEL FOR=SelectionLimit ACCESSKEY=\"d\">" + resSelectedMembersDisplayLimit + "</LABEL>"
   + "</td>"
   + "<td nowrap>"
   + "<select class=Default name=SelectionLimit title = '" + resSelectedMembersDisplayLimit
   + "' id=SelectionLimit onkeypress=\"javascript:SubmitReportDefinition(event);\" />"
   + "</td>"
   + "</tr></table>"
   + "</td></tr>"
   + "<tr><td nowrap>"
   + "<input type=button name=ReportDefinitionGo value=\"" + resOK 
   + "\" onclick=\"javascript:OnReportDefinitionOptions();\">&nbsp;"
   + "<input type=button name=Cancel value=\"" + resCancel
   + "\" onclick=\"javascript:OnCancelOptions();\">&nbsp;"
   + "<input name=DialogHelpButton type=button value=\"" + resHelp
   + "\" onclick=\"javascript:DisplayDialogHelp('ReportDefinition.htm', '');\">"
   + "</td>"
   + "</tr></table></td>"
   + "</tr>"
   + "</table>"
   + "</td></tr>"
   + "<tr height='6'></tr>"
   + "</table>"
   + "</td>"
   + "<td width='100%'></td>"
   + "</tr>"
   + "</table>";
   
function ShowReportDefinitionOptions(i_bCurrentReport)
{
   var clDetailedDefinition;
   var clReport;
   var clReportTD;
   var clSelectionLimit;
   var clSelectionLimitLabel;
   var nIndex;
   var strText;

   var toolBar = $find("ctl00_MainContent_RadContentToolBar");
   if (toolBar != null) {
       var item = toolBar.findItemByValue("SummaryButton");
       if (item != null && Telerik.Web.UI.RadToolBarSplitButton.isInstanceOfType(item))       
      
 {
           item.hideDropDown();
       }
   }
   DisplayOption(M_strReportDefinitionOptions);
   clDetailedDefinition = document.getElementById("DetailedDefinition");
   clSelectionLimit = document.getElementById("SelectionLimit");
   clSelectionLimitLabel = document.getElementById("RptSelectionLimit");
   SelectControlAddOption(clSelectionLimit, 0, "0")
   SelectControlAddOption(clSelectionLimit, 10, "10", true)
   SelectControlAddOption(clSelectionLimit, 20, "20")
   SelectControlAddOption(clSelectionLimit, 30, "30")
   SelectControlAddOption(clSelectionLimit, 40, "40")
   SelectControlAddOption(clSelectionLimit, 50, "50")
   clSelectionLimit.disabled = true;
   clSelectionLimitLabel.className = "DisabledOptionItem";
   if (typeof(i_bCurrentReport) != 'undefined' && i_bCurrentReport) {
      clReportTD = document.getElementById("CurrentReportTD");
      clReportTD.style.display = "block";
      clReport = document.getElementById("CurrentReportTitleTD");
      strText = document.aspnetForm.ViewTitle.value;
	   strText = strText.replace(new RegExp(GSingleQuoteRep, "g"), "'");
	   strText = strText.replace(new RegExp(GLtRep, "g"), "&lt;");
	   strText = strText.replace(new RegExp(GGtRep, "g"), "&gt;");
      clReport.innerHTML = strText;
      clDetailedDefinition.focus();
   }
   else {
      clReportTD = document.getElementById("ReportListTD");
      clReportTD.style.display = "block";
      clReport = document.getElementById("CubeReportId");
      if (document.aspnetForm.GoToPublicReports.value == "True") {
         for (nIndex = 0; nIndex < M_anPublicCubeReportIds.length; nIndex++) {
            strText = M_astrPublicCubeReportTitles[nIndex];
            if (strText.length > G_nMaxDataSourceTitle) {
               strText = strText.substring(0, G_nMaxDataSourceTitle - 1) + G_strThreeDots;
            }
            SelectControlAddOption(clReport, M_anPublicCubeReportIds[nIndex], strText);
         }
      }
      else {
         for (nIndex = 0; nIndex < M_anMyCubeReportIds.length; nIndex++) {
            strText = M_astrMyCubeReportTitles[nIndex];
            if (strText.length > G_nMaxDataSourceTitle) {
               strText = strText.substring(0, G_nMaxDataSourceTitle - 1) + G_strThreeDots;
            }
            SelectControlAddOption(clReport, M_anMyCubeReportIds[nIndex], strText);
         }
      }
      clReport.focus();
   }
   // Resize scroll bars
   onLayoutResize();
}

function ChangeDetail()
{
   var clDetailedDefinition;
   var clSelectionLimit;
   var clSelectionLimitLabel;

   clDetailedDefinition = document.getElementById("DetailedDefinition");
   clSelectionLimit = document.getElementById("SelectionLimit");
   clSelectionLimitLabel = document.getElementById("RptSelectionLimit");
   if (clDetailedDefinition.checked) {
      clSelectionLimit.disabled = false;
      clSelectionLimitLabel.className = "OptionItem";
   }
   else {
      clSelectionLimit.disabled = true;
      clSelectionLimitLabel.className = "DisabledOptionItem";
   }
}

function SubmitReportDefinition(e)
{
   var key = GetKeyCode(e);
   if ( key == 13) {
      OnReportDefinitionOptions();
      ResetSubmit(e);
   }
}

function OnReportDefinitionOptions()
{
   var clDetailedDefinition;
   var clReport;
   var clSelectionLimit;
   var nCubeID = 0;
   var nReportID = 0;
   var szAction;
   var szLocation;
   
   if (document.getElementById("ReportListTD").style.display == "block") {
      clReport = document.getElementById("CubeReportId");
      nReportID = clReport.options[clReport.selectedIndex].value;
      szAction = "../Browse/SelectedReportDefinition.aspx?ReportId=" + nReportID + "&DetailedDefinition=";
   }
   else {
      szLocation = document.location.pathname.toLowerCase();
      if (szLocation.indexOf("drillthrough") >= 0) {
         szAction = "../View/ReportDefinitionWithDrillthrough.aspx?DetailedDefinition=";
      }
      else {
         szAction = "../View/ReportDefinition.aspx?DetailedDefinition=";
      }
   }
   clDetailedDefinition = document.getElementById("DetailedDefinition");
   if (clDetailedDefinition.checked) {
      szAction = szAction + "1";
   }
   else {
      szAction = szAction + "0";
   }
   clSelectionLimit = document.getElementById("SelectionLimit");
   szAction = szAction + "&SelectedMembersDisplayLimit="
      + clSelectionLimit.options[clSelectionLimit.selectedIndex].value;
	document.aspnetForm.action = szAction;
	executeWait(document.aspnetForm);
}
