<%! from django.utils.translation import ugettext as _ %>
<%!
  from django.core.urlresolvers import reverse
  from courseware.courses import course_image_url, get_course_about_section
%>
<%namespace name='static' file='../static_content.html'/>

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

<%block name="pagetitle">${_("About {course_number}").format(course_number=course.display_number_with_default) | h}</%block>

<%block name="bodyclass">view-iframe-content view-partial-mktgregister</%block>


<%block name="js_extra">
  <script type="text/javascript">
  (function() {
    $(".register").click(function(event) {
      $("#class_enroll_form").submit();
      event.preventDefault();
    });

    $('#class_enroll_form').on('ajax:complete', function(event, xhr) {
      if(xhr.status == 200) {
        if (xhr.responseText != "") {
          window.top.location.href = xhr.responseText;
        }
        else {
          window.top.location.href = "${reverse('dashboard')}";
        }
      } else if (xhr.status == 403) {
        window.top.location.href = "${reverse('register_user')}?course_id=${course.id | u}&enrollment_action=enroll";
      } else {
        $('#register_error').html(
            (xhr.responseText ? xhr.responseText : "${_("An error occurred. Please try again later.")}")
        ).css("display", "block");
      }
    });
  })(this)
  </script>
</%block>

<%block name="content">
  <script src="${static.url('js/course_info.js')}"></script>

  <ul class="list-actions">
    <li class="item">
        %if user.is_authenticated() and registered:
          %if show_courseware_link:
            <a class="action access-courseware" href="${course_target}" target="_top">${_("Access Courseware")}</a>
          %else:
            <div class="action is-registered">${_("You Are Registered")}</div>
          %endif
        %elif allow_registration:
        <a class="action action-register register ${'has-option-verified' if len(course_modes) > 1 else ''}" href="#">${_("Register for")} <strong>${course.display_number_with_default | h}</strong>
            %if len(course_modes) > 1:
            <span class="track">
            ## Translators: This is the second line on a button users can click.  The first line is "Register for COURSE_NAME"
            ## The "choose your student track" means users can select between taking the course as an auditor, as a verified student, etc
            ${_("and choose your student track")}
            </span>
            %elif "professional" in course_modes:
            <span class="track">
            ## Translators: This is the second line on a button users can click.  The first line is "Register for COURSE_NAME"
            ## 'Verification' here refers to verifying one's identity in order to receive a verified certificate.
            ${_("and proceed to verification")}
            </span>
            %endif
        </a>
        %else:
          <div class="action registration-closed is-disabled">${_("Registration Is Closed")}</div>
        %endif
    </li>
  </ul>

%if not registered:
  <div style="display: none;">
    <form id="class_enroll_form" method="post" data-remote="true" action="${reverse('change_enrollment')}">
      <fieldset class="enroll_fieldset">
        <input name="course_id" type="hidden" value="${course.id | h}">
        <input name="enrollment_action" type="hidden" value="enroll">
        <input type="hidden" name="csrfmiddlewaretoken" value="${ csrf_token }">
      </fieldset>
      <div class="submit">
        <input name="enroll" type="submit" value="enroll">
      </div>
    </form>
  </div>
%endif
</%block>
