var filmography = {
  showAll: function() {
    $("filmographyLink").hide();
    Effect.BlindDown("filmography");
  }
};
var bioWidget = {
  showMore: function() {
    Element.hide("readMoreLink");
    Element.show("extraBio");
  }
};
var ListLink = Class.create();
ListLink.prototype = {
  initialize: function(link, actor, username) {
    this.link = link;
    this.actor = actor;
    this.username = username;
    this.onClickHandler = this.onClick.bindAsEventListener(this);
    Event.observe(this.link, "click", this.onClickHandler);
  },
  onClick: function(e) {
    if (currentUser.isLoggedIn()) {
      Event.stop(e);
      Event.stopObserving(this.link, "click", this.onClickHandler);
      new Ajax.Request("/api/actor/" + this.actor + "/favorite/", {
        onSuccess: this.onSuccess.bind(this),
        onFailure: this.onFailure.bind(this),
        onTimeout: this.onTimeout.bind(this)
      });
      $(this.link).href = "/" + this.username.toLowerCase() + "/actor/favorite/";
      $(this.link).update("Saving...");
    } else {}
  },
  onSuccess: function(A) {
    $(this.link).href = "/" + this.username.toLowerCase() + "/actor/favorite/";
    $(this.link).update("Saved! - View My Favorite Actors");
  },
  onFailure: function() {
    document.location = "/" + this.username.toLowerCase() + "/actor/favorite/add?actorID=" + this.actor;
  },
  onTimeout: function() {
    document.location = "/" + this.username.toLowerCase() + "/actor/favorite/add?actorID=" + this.actor;
  }
};
var ActorListWidget = Class.create();
ActorListWidget.prototype = {
  initialize: function(B, A) {
    this.listSelectView = B;
    this.listSavingView = A;
    this.state = ListWidgetStates.READY;
  },
  handleAdd: function(B, A) {
    if (A == "---") {} else {
      if (!currentUser.isLoggedIn()) {
        alert(_("Whoops, you'll need to register or sign-in first."));
      } else {
        if (A == "NEW") {
          document.location = "/actor-list/action/add/?type=USR&actorId=" + B;
        } else {
          this.state = ListWidgetStates.SAVING;
          this.paint();
          var C = "service=addActor&actorId=" + B + "&uid=" + currentUser.id + "&listId=" + A;
          new Ajax.Request("/list.sv", {
            parameters: C,
            asynchronous: true,
            onComplete: this.processAdd.bind(this)
          });
        }
      }
    }
  },
  processAdd: function(A) {
    floatie.show(A.responseText);
    this.state = ListWidgetStates.READY;
    this.paint();
  },
  paint: function() {
    switch (this.state) {
    case ListWidgetStates.READY:
      Element.show($(this.listSelectView));
      Element.hide($(this.listSavingView));
      break;
    case ListWidgetStates.SAVING:
      Element.hide($(this.listSelectView));
      Element.show($(this.listSavingView));
      break;
    }
  }
};
