    var RepSelWinHandle;
    
      function DoAcctSel(APageName){
        //alert(document.CTReportScheduledEdPage.OpenPopUp.value);
       //return;
        var TheURL = APageName;
        //TheURL = TheURL + "?CurrentAcctGrpID="+document.CTReportScheduledEdPage.AccountsSelectionMethod.options[document.CTReportScheduledEdPage.AccountsSelectionMethod.selectedIndex].value;
        TheURL = TheURL + "?CurrentSchedRepID="+document.CTReportScheduledEdPage.SchedRepID.value;
        TheURL = TheURL + "&SchedReportName="+document.CTReportScheduledEdPage.ReportOrGroupFileName.value;
        var ActualHeight="750";
        var FeatureStr = "scrollbars=yes, resizable=yes, toolbar=no, menubar=yes, statusbar=yes, ";
        FeatureStr = FeatureStr + "width=1050, height=" + ActualHeight + ", top=100, left=100";
        document.CTReportScheduledEdPage.OpenPopUp.value="-1";
        window.open(TheURL, APageName, FeatureStr);
      }

      function DoSaveAndRunSchedRepNow(){
        if (document.CTReportScheduledEdPage.SuppressClientDest.checked!=true){
          var UserResult = confirm('Scheduled report output may also be sent to the Account holder as per settings.' +
                                   '\nWhile test running reports please check the "Dont send reports to Clients (For testing purposes)" option to avoid sending.' +
                                   '\nAre you sure you want to continue and send the report output to the Account holder?');
          //alert(UserResult);
          if(UserResult=="0")
            return(0);
          else
            return(1);                
        }
      }

      function InitializeHiddenVars(){
        if (document.CTReportScheduledEdPage.CloseAndExit!=null){
          if (document.CTReportScheduledEdPage.CloseAndExit.value=="true"){
	    window.close();
	    return;
	  }
        }
        if (document.CTReportScheduledEdPage.OpenPopUp!=null){
          if (document.CTReportScheduledEdPage.OpenPopUp.value!="-1")
            DoAcctSel(document.CTReportScheduledEdPage.OpenPopUp.value);
        }
    }

    function ValidateNewRepDesc(){
      var TempDesc=RemoveBlanks(document.CTReportScheduledEdPage.NewRepDesc.value)
      //alert(TempDesc);
      if (TempDesc==''){
        alert("Please enter a valid Report Group Description.");
        document.CTReportScheduledEdPage.NewRepDesc.focus();
        return(1);
      }
      else
        return(0);
    }

    function RefreshPage(){
//alert("RefreshPagex"+document.CTReportScheduledEdPage.CTReportScheduledEdPage_SchedReportsDataSourceFocusedRow.value);
      document.location="CTReportScheduledEdPage?CurrSchedRepNo="+document.CTReportScheduledEdPage.CTReportScheduledEdPage_SchedReportsDataSourceFocusedRow.value;
      //location.reload();
      //return;
      //alert(AcctGrpId + " x " + AcctGrpCount);
      //document.CTReportScheduledEdPage.AcctSelectionGroup.value=AcctGrpId;
      //document.CTReportScheduledEdPage.AccountsSelectionGroup.value=AcctGrpCount;
      //document.CTReportScheduledEdPage.AccountsSelectionGroup.setFocus();
      //document.CTReportScheduledEdPage.AccountsSelectionMethod.setFocus();
    }

      function DoSetReportSelCallBack(){
        var ARepName="";
        if (document.CTReportScheduledEdPage.ReportOrGroupFileName!=null)
          ARepName=document.CTReportScheduledEdPage.ReportOrGroupFileName.value;
        var ARepLoc="";
        if (document.CTReportScheduledEdPage.ReportOrGroupLocation!=null)
          ARepLoc=document.CTReportScheduledEdPage.ReportOrGroupLocation.value;
        var aIsRepGroup="";
        if (document.CTReportScheduledEdPage.IsReportAGroup!=null)
          aIsRepGroup=document.CTReportScheduledEdPage.IsReportAGroup.value;
        //alert("DoSetReportSelCallBack " + ARepName + " x " + ARepLoc + " x " + aIsRepGroup);
        RepSelWinHandle.SetCurrentParams(ARepName, ARepLoc, aIsRepGroup);
        //alert("done DoSetReportSelCallBack " + RepSelWinHandle);
      }

     function SetSelRepInCaller(aRepName, aRepUserDir, aIsRepGroup){
        document.CTReportScheduledEdPage.ReportOrGroupFileName.value=aRepName;
        document.CTReportScheduledEdPage.ReportOrGroupLocation.value=aRepUserDir;
        document.CTReportScheduledEdPage.IsReportAGroup.value=aIsRepGroup;
        //alert("SetSelRepInCaller - " + aRepName + " x " + aRepUserDir + " x " + aIsRepGroup);
        __doPostBack('AddScheduledReportBtn', 'CLICK');
     }

      function DoReportSel(){
        var TheURL = "CTReportSelector";
        if (document.CTReportScheduledEdPage.ReportOrGroupLocation!=null){
          if ((document.CTReportScheduledEdPage.ReportOrGroupLocation.value=="")||(document.CTReportScheduledEdPage.ReportOrGroupLocation.value=="#"))
            TheURL = TheURL + "?ShowStdReps=true";
        }
        var ActualHeight="750";
        var FeatureStr = "scrollbars=yes, resizable=yes, toolbar=no, menubar=yes, statusbar=yes, ";
        FeatureStr = FeatureStr + "width=1050, height=" + ActualHeight + ", top=100, left=100";
        //alert(TheURL+FeatureStr);
        RepSelWinHandle = window.open(TheURL, "SelectReport", FeatureStr);
        //alert("EditFontColorBorder - ");
      }

      function DoEditRecord(CurrRecIndex){
       //alert(CurrRecIndex);
        document.CTReportScheduledEdPage.CurrSchedRepNo.value=CurrRecIndex;
        __doPostBack('EditRepBtn', 'CLICK');
      }

      function DoDeleteRecord(CurrRecIndex){
        var UserResult = confirm('Are you sure you want to remove the scheduled Report # :' + (CurrRecIndex + 1) + '?');
        //alert(UserResult);
        if(UserResult=="1"){
          document.CTReportScheduledEdPage.CurrSchedRepNo.value=CurrRecIndex;
          __doPostBack('RemoveRepBtn', 'CLICK');
        }
      }

      function DoShowAcctSelPopUp(){
       //alert(CurrRecIndex);
        __doPostBack('EditAcctGroupBtn', 'CLICK');
      }


