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

North52.CloneFormula.Ok= function () {

        };
   
    North52.CloneFormula.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.CloneFormula.Clone(recordid, command, serverUrl,configurationId  );     
    };


North52.CloneFormula.Clone= function(recordid, command, serverurl, configurationId ) {

  try
   { 
                  var configuration = {};
                    configuration.north52_Command = { Value: command };
                    configuration.north52_CommandParameter = recordid;

                    SDK.JQuery.updateRecord(
                         configurationId,
                         configuration,
                         "north52_configuration", 
                         North52.CloneFormula.configSuccess,
                         North52.CloneFormula.configError
                      );
}
  catch (ex)
  {
     alert('North52 Formula Manager Error: ' + ex.message);
   }

};

 North52.CloneFormula.configSuccess= function () {

        window.close();
     };

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