<%inherit file="base.html" />
<%! from django.core.urlresolvers import reverse %>

<%block name="title">Sign Up</%block>
<%block name="bodyclass">not-signedin signup</%block>

<%block name="content">

<div class="wrapper-content wrapper">
  <section class="content">
    <header>
      <h1 class="title title-1">Sign Up for edX Studio</h1>
      <a href="${reverse('login')}" class="action action-signin">Already have a Studio Account? Sign in</a>
    </header>

    <p class="introduction">Ready to start creating online courses? Sign up below and start creating your first edX course today.</p>

    <article class="content-primary" role="main">
      <form id="register_form" method="post" action="register_post">
        <div id="register_error" name="register_error" class="message message-status message-status error">
        </div>
        
        <fieldset>
          <legend class="sr">Required Information to Sign Up for edX Studio</legend>
          
          <ol class="list-input">
            <li class="field text required" id="field-email">
              <label for="email">Email Address</label>
              <input id="email" type="email" name="email" placeholder="e.g. jane.doe@gmail.com" />              
            </li>

            <li class="field text required" id="field-password">
              <label for="password">Password</label>
              <input id="password" type="password" name="password" />              
            </li>

            <li class="field text required" id="field-username">
              <label for="username">Public Username</label>
              <input id="username" type="text" name="username" placeholder="e.g. janedoe" />
              <span class="tip tip-stacked">This will be used in public discussions with your courses and in our edX101 support forums</span>      
            </li>

            <li class="field text required" id="field-name">
              <label for="name">Full Name</label>
              <input id="name" type="text" name="name" placeholder="e.g. Jane Doe" />              
            </li>

            <li class="field-group">
              <div class="field text" id="field-location">
                <label for="location">Your Location</label>
                <input class="short" id="location" type="text" name="location" />              
              </div>

              <div class="field text" id="field-language">
                <label for="language">Preferred Language</label>
                <input class="short" id="language" type="text" name="language" />              
              </div>
            </li>

            <li class="field checkbox required" id="field-tos">
              <input id="tos" name="terms_of_service" type="checkbox" value="true" />
              <label for="tos">I agree to the Terms of Service</label>             
            </li>
          </ol>
        </fieldset>

        <div class="form-actions">
          <button type="submit" id="submit" name="submit" class="action action-primary">Create My Account & Start Authoring Courses</button>
        </div>

        <!-- no honor code for CMS, but need it because we're using the lms student object -->
        <input name="honor_code" type="checkbox" value="true" checked="true" hidden="true">
      </form>
    </article>

    <aside class="content-supplementary" role="complimentary">
      <h2 class="sr">Common Studio Questions</h2>

      <div class="bit">
        <h3 class="title-3">Who is Studio for?</h3>
        <p>Studio is for anyone that wants to create online courses that leverage the global edX platform. Our users are often faculty members, teaching assistants and course staff, and members of instructional technology groups.</p>
      </div>

      <div class="bit">
        <h3 class="title-3">How technically savvy do I need to be to create courses in Studio?</h3>
        <p>Studio is designed to be easy to use by almost anyone familiar with common web-based authoring environments (Wordpress, Moodle, etc.). No programming knowledge is required, but for some of the more advanced features, a technical background would be helpful. As always, we are here to help, so don't hesitate to dive right in.</p>
      </div>

      <div class="bit">
        <h3 class="title-3">I've never authored a course online before. Is there help?</h3>
        <p>Absolutely. We have created an online course, edX101, that describes some best practices: from filming video, creating exercises, to the basics of running an online course. Additionally, we're always here to help, just drop us a note.</p>
      </div>
    </aside>
  </section>
</div>
</%block>

<%block name="jsextra">
  <script type="text/javascript">
    (function() {

      $("form :input").focus(function() {
        $("label[for='" + this.id + "']").addClass("is-focused");
      }).blur(function() {
        $("label").removeClass("is-focused");
      });
  

      function getCookie(name) {
        return $.cookie(name);
      }

      // form validation
      function postJSON(url, data, callback) {
        $.ajax({type:'POST',
          url: url,
          dataType: 'json',
          data: data,
          success: callback,
          headers : {'X-CSRFToken':getCookie('csrftoken')}
        });
      }

      $('form#register_form').submit(function(e) {
        e.preventDefault();
        var submit_data = $('#register_form').serialize();

        postJSON('/create_account',
          submit_data,
          function(json) {
            if(json.success) {
              location.href = "${reverse('index')}";
            } else {
              $('#register_error').html(json.value).stop().addClass('is-shown');
            }
          }
        );
      });
    })(this)
  </script>
</%block>