
Kwo.Subscriptions = {
  
  onSubmit: function(args) {
    Kwo.exec("/account/push/subscriptions.set", args, 
             {disable:true, callback:Kwo.Account.refresh});
  }
  
};

Kwo.Newsletter = {
  
  onCallback: function(res) {
    if (Kwo.hasError(res)) return Kwo.error(res);
    this.select("LI:last-child")[0].addClassName("confirmation").update(res["result"]["callback_msg"].ucfirst() + ".");
  },

  onSubmit: function(args) {
    Kwo.exec("/push/newsletter.subscribe", args,
             {disable:true, reset:true,
              callback: Kwo.Newsletter.onCallback.bind(args)});
  }
  
};

Kwo.Class.Newsletter = Class.create(Kwo.Dialog, {

  initialize: function($super, args) {
    this.name = "newsletter";
    this.className = "layout-hbox";
    this.args = args;
    $super(this.refresh, this.args, {width: 500, height: 300});
  },
  
  refresh: function() {
    Kwo.exec("/push/newsletter.signup", this.args, 
             {container: this.support});
  }

});