<%! 
  from django.core.urlresolvers import reverse 
  from courseware.courses import course_image_url, get_course_about_section
%>
<%namespace name='static' file='../static_content.html'/>
<%block name="js_extra">
  <script src="${static.url('js/course_info.js')}"></script>
</%block>

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


<%block name="title"><title>About ${course.number}</title></%block>

<section class="course-info">
  <header class="course-profile">
    <div class="intro-inner-wrapper">
      <section class="intro">
        <hgroup>
          <h1>${course.number}: ${get_course_about_section(course, "title")}<a href="${reverse('university_profile', args=[course.org])}">${get_course_about_section(course, "university")}</a></h1>
        </hgroup>

        <div class="main-cta">
          %if user.is_authenticated():
            %if registered:
                <span class="register disabled">You are registered for this course (${course.number}).</span>
            %else:
                <a href="#" class="register submit_registration">Register for ${course.number}</a>
            %endif
          %else:
            <a href="#signup-modal" class="register" rel="leanModal" data-notice="You must Sign Up in order to register">Register for ${course.number}</a>
          %endif
        </div>

      </section>
      % if get_course_about_section(course, "video"):
      <a href="#video-modal" class="media" rel="leanModal">
        <div class="hero">
          <img src="${course_image_url(course)}" />
          <div class="play-intro"></div>
        </div>
      </a>
      %else:
      <div class="media">
        <div class="hero">
          <img src="${course_image_url(course)}" />
        </div>
      </div>
      % endif
    </div>
  </header>

  <section class="container">
    <section class="details">
      <nav>
        <a href="#" class="active">Overview</a>
      ##  <a href="#">FAQ</a>
      ##  <a href="#">Requirements</a>
      ##  <a href="#">Text-book</a>
      ##  <a href="#">Syllabus</a>
      ##  <a href="#">Reviews</a>
      </nav>

      <div class="inner-wrapper">
        ${get_course_about_section(course, "overview")}
      </div>
    </section>

    <section class="course-sidebar">
      <section class="course-summary">
        <header>
          <div class="social-sharing">
            <div class="sharing-message">Share with friends and family!</div>
            <a href="http://twitter.com/intent/tweet?text=I+just+registered+for+${course.number}+${get_course_about_section(course, 'title')}+through+@edxonline:+http://edx.org/${reverse('about_course', args=[course.id])}" class="share">
              <img src="${static.url('images/social/twitter-sharing.png')}">
            </a>
            <a href="http://www.facebook.com/EdxOnline" class="share"> <img src="${static.url('images/social/facebook-sharing.png')}">
            </a>
            <a href="mailto:?subject=Take%20a%20course%20with%20edX%20online&body=I%20just%20registered%20for%20${course.number}%20${get_course_about_section(course, 'title')}%20through%20edX:+http://edx.org/${reverse('about_course', args=[course.id])}" class="share">
              <img src="${static.url('images/social/email-sharing.png')}">
            </a>
          </div>
        </header>

        <ol class="important-dates">
          <li><div class="icon course-number"></div><p>Course Number</p><span class="course-number">${course.number}</span></li>
          <li><div class="icon start"></div><p>Classes Start</p><span class="start-date">${course.start_date_text}</span></li>

          ## End date should come from course.xml, but this is a quick hack
          % if get_course_about_section(course, "end_date"):
            <li><div class="icon end"></div><p>Classes End</p><span class="final-date">${get_course_about_section(course, "end_date")}</span></li>
          % endif

          % if get_course_about_section(course, "effort"):
            <li><div class="icon effort"></div><p>Estimated Effort</p><span class="start-date">${get_course_about_section(course, "effort")}</span></li>
          % endif

          ##<li><div class="icon length"></div><p>Course Length</p><span class="course-length">15 weeks</span></li>

          % if get_course_about_section(course, "prerequisites"):
            <li class="prerequisites"><div class="icon prereq"></div><p>Prerequisites</p><span class="start-date">${get_course_about_section(course, "prerequisites")}</span></li>
          % endif
        </ol>
      </section>
    </section>

  </section>
</section>

%if not registered:
  <div display="hidden">
    <form id="enroll_form" method="post" data-remote="true" action="${reverse('change_enrollment')}">
      <input name="course_id" type="hidden" value="${course.id}">
      <input name="enrollment_action" type="hidden" value="enroll">
      <div class="submit">
        <input name="submit" type="submit" value="enroll">
      </div>
    </form>
  </div>
  <script type="text/javascript">
  (function() {
    $(".submit_registration").click(function() {
      $("#enroll_form").submit();
    });
  
    $(document).delegate('#enroll_form', 'ajax:success', function(data, json, xhr) {
      if(json.success) {
        location.href="${reverse('dashboard')}";
      }
    });
  })(this)
  </script>
%endif


<%include file="../video_modal.html" />
