(function (context, $) {

  "use strict";

  context.JK = context.JK || {};

  var $signin;
  var $signinRoot;
  var $signupRoot;

  var rest = context.JK.Rest();
  var logger = context.JK.logger;
  var EVENTS = context.JK.EVENTS;

  function initialize() {

    $signinRoot = $('.signin-common');
    $signupRoot = $('.signup-common');

    context.JK.popExternalLinks()

    var signinHelper = new context.JK.SigninHelper(context.JK.app);
    $(signinHelper).on(EVENTS.SHOW_SIGNUP, function() {
      $signinRoot.hide();
      $signupRoot.show();
    });
    signinHelper.initialize($signinRoot, false);

    var signupHelper = new context.JK.SignupHelper(context.JK.app);
    $(signupHelper).on(EVENTS.SHOW_SIGNIN, function() {
      $signupRoot.hide();
      $signinRoot.show();
    });
    signupHelper.initialize($signupRoot);

    $signinRoot.find('input[name="session[email]"]').focus();
  }

  context.JK.SigninPage = initialize;

})(window, jQuery);