<%! from django.utils.translation import ugettext as _ %>

<%inherit file="../main.html" />

<%! from django.core.urlresolvers import reverse %>

<%block name="pagetitle">${_("edX edge")}</%block>
<%block name="bodyclass">no-header edge-landing</%block>

<%block name="content">
<div class="main-wrapper">
  <div class="edx-edge-logo-large">${_("edX edge")}</div>
  <div class="content">
    <div class="log-in-form">
      <h2>${_("Log in to your courses")}</h2>
      <form id="login_form" data-remote="true" method="post" action="/login_ajax">
        <div class="row">
          <label>${_("Email")}</label>
          <input name="email" type="email" class="email-field" tabindex="1">
        </div>
        <div class="row">
          <label>${_("Password")}</label>
          <input name="password" type="password" class="password-field" tabindex="2">
        </div>
        <div class="row submit">
          <input name="submit" type="submit" value="${_("Log In")}" class="log-in-submit-button" tabindex="3">
          <a href="#forgot-password-modal"  rel="leanModal" class="pwd-reset forgot-button">${_("Forgot password?")}</a>
        </div>
      </form>
    </div>
    <div class="sign-up">
      <h3>${_("Register for classes")}</h3>
      <p>${_("Take free online courses from today's leading universities.")}</p>
      <p><a href="#signup-modal" id="signup" rel="leanModal" class="register-button">${_("Register")}</a></p>
    </div>
  </div>
</div>

</%block>

<%block name="js_extra">
<script type="text/javascript">
  (function() {
    $(document).ready(function() {
      if ($.deparam.fragment()['forgot-password-modal'] !== undefined) {
        $('.pwd-reset').click();
      }
    })
    $(document).delegate('#login_form', 'ajax:success', function(data, json, xhr) {
     if(json.success) {
        next = getParameterByName('next');
        if(next) {
           location.href = next;
       } else {
           location.href = "${reverse('dashboard')}";
       }
     } else {
       if($('#login_error').length == 0) {
         $('#login_form').prepend('<div id="login_error" class="modal-form-error"></div>');
       }
       $('#login_error').html(json.value).stop().css("display", "block");
     }
    });
  })(this)
</script>
</%block>

<%include file="../signup_modal.html" />
<%include file="../forgot_password_modal.html" />