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


North52.ExportData.OnLoad = function () {
         $('#loading').show(); 

       $('#btnOk').attr('disabled',false); 
      var command = N52.DialogHelpers.GetParameterByName('data');
      var configurationId = N52.DialogHelpers.GetConfigurationId();
      var serverUrl = N52.DialogHelpers.GetServerUrl();

      North52.ExportData.Build(command, serverUrl, configurationId  );
             
    };

North52.ExportData.Build= function(command, serverurl, configurationId  ) {
                   
      var configuration = {};
      configuration.north52_Command = { Value: parseInt(command) };
     
       SDK.JQuery.updateRecord(
                         configurationId,
                         configuration,
                         "north52_configuration", 
                         North52.ExportData.configSuccess,
                         North52.ExportData.configError
                      );
                
};


 North52.ExportData.OpenConfiguration= function () {
   var configurationId = N52.DialogHelpers.GetConfigurationId();
      if (configurationId != null)            
      {
          var serverUrlFinal =  N52.DialogHelpers.GetServerUrl() + '/main.aspx?etn=north52_configuration&pagetype=entityrecord&id=' + '%7B'+ configurationId+'%7D'

          window.open(serverUrlFinal);
       }

};



 North52.ExportData.configSuccess= function () {
        North52.ExportData.OpenConfiguration();
        window.close();
     };

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

