if (typeof North52 == 'undefined') { North52 = {}; }
if (typeof North52.CloneSchedule == 'undefined') { North52.CloneSchedule = {}; }

North52.CloneSchedule.Ok= function () {

        };
   
    North52.CloneSchedule.OnLoad = function () {
       $('#btnOk').attr('disabled',true);  
      
      var command = N52.DialogHelpers.GetParameterByName('data');
      var recordid= N52.DialogHelpers.GetParameterByName('id');
      var configurationId = N52.DialogHelpers.GetConfigurationId();

      var serverUrl = N52.DialogHelpers.GetServerUrl();
      North52.CloneSchedule.ExecuteClone(command, recordid, serverUrl, configurationId  );     
    };


North52.CloneSchedule.ExecuteClone= function(command, recordid, serverurl, configurationId ) {

                    var configuration = {};
                    configuration.north52_Command = { Value: command };
                    configuration.north52_CommandParameter = recordid + "|" + 10000 + "|" + 5 ;

                    SDK.JQuery.updateRecord(
                         configurationId,
                         configuration,
                         "north52_configuration", 
                         North52.CloneSchedule.configSuccess,
                         North52.CloneSchedule.configError
                      );
          
};

 North52.CloneSchedule.configSuccess= function () {

    try {

             if ( (navigator.userAgent.search('MSIE') > 0) || (navigator.userAgent.search('Trident/') > 0) )
           {
              var opener = window.dialogArguments;
              var gridControl = opener.document.getElementById('crmGrid');
      
              if (gridControl != null)
                 gridControl.control.refresh();
            }
        }
        catch (ex)
        { 
               
        }
    

        window.close();
     };

 North52.CloneSchedule.configError= function (XmlHttpRequest, textStatus, errorThrown) {
                      
                      alert('North52 Formula Manager: ' + XmlHttpRequest.message )
                      $('#btnOk').attr('disabled',false); 
                     $('#loading').hide(); 
       };