<%namespace name="forms" file="/forms.html"/>
<%namespace name="sso" file="/sso.html"/>

<div class="form_wrapper">
  <form name="create_user" method="POST" action="${h.get_redirect_url(u'user')}">
    ${h.field_token()|n}

    <% randomizeid_user_names = h.config.get_bool('adhocracy.force_randomized_user_names') %>
    %if not randomized_user_names:
    <fieldset>
      <legend>${_("User name")}</legend>
      <p class="info">${_("Can only contain letters and numbers. Spaces aren't allowed.")}</p>
      <div class="input_wrapper">
        <input type="text" autofocus="autofocus" name="user_name" />
      </div>
    </fieldset>
    %endif
    %if h.config.get_bool('adhocracy.set_display_name_on_register'):
    <fieldset>
      <legend>${_("Display name")}</legend>
      <p class="info">${_("You can choose which name other users see.")}</p>
      <div class="input_wrapper">
        <input type="text" class="title" name="display_name"
               ${u'autofocus="autofocus"' if randomized_user_names else u''|n} />
      </div>
    </fieldset>
    %endif

    <fieldset>
      <legend>${_("E-mail")}</legend>
      <div class="input_wrapper">
        <input type="text" name="email" />
      </div>
    </fieldset>

    <fieldset>
      <legend>${_("Password")}</legend>
      <div class="input_wrapper">
        <label for="password">${_("Enter password:")}</label>
        <input type="password" name="password" />
        <label for="password_confirm">${_("Password (confirm):")}</label>
        <input type="password" name="password_confirm" />
      </div>
    </fieldset>

    %if c.captcha:
    <fieldset>
      <legend>${_("Security query")}</legend>
      <p class="info">${_("Please enter the letters in the following image in the field below.")}</p>
      ${c.captcha|n}
    </fieldset>
    %endif

    %if h.config.get_bool('adhocracy.registration.require_terms_check'):
    <fieldset>
        <legend>${_("Terms and conditions")}</legend>
        <p class="info">
            ${forms.checkbox(c.agree_text, 'accept_terms')}
        </p>
    </fieldset>
    %else:
    <p>
        ${c.agree_text|n}
    </p>
    %endif

    ## <!--SPAM protection-->
    <div class="hidejs" id="register_input_js">
      <label for="input_js">JS ${_('leave empty')}</label>
      <input name="input_js" />
    </div>
    <div id="register_input_css">
      <label for="input_css">CSS ${_('leave empty')}</label>
      <input name="input_css" />
    </div>

    <div class="input_wrapper submit">
      <input type="submit" value="${_('Register')}" />
    </div>
  </form>
  <script>
      $('input[name=user_name]').focus();
  </script>

  <%sso:form scenario="register" />
</div>
