<%inherit file="marketing.html" />
<%namespace name='static' file='static_content.html'/>

<%block name="title">edx4edx author course</%block>
<%block name="description">edx4edx</%block>
<%block name="keywords">MITx, edx4edx</%block>

<%block name="header_text">
    <section class="course">
      <section>
        <h1>edx4edx</h1>
        <h2>edX Author Course</h2>
        <a class="enroll" rel="leanModal" href="#enroll"><noscript>In
order to</noscript> Enroll in edx4edx  <noscript>you need to have javascript enabled</noscript></a>
      </section>
      <p>edx4edx is a course for prospective edX course authors</p>
    </section>
</%block>

<%block name="header_class">course</%block>

<section class="index-content">
</section>

  <div id="enroll" class="leanModal_box" name="enroll"><%include file="create_account.html" /></div>

<script>
$(function() {

    // TODO: Clean up as per http://stackoverflow.com/questions/169506/obtain-form-input-fields-using-jquery

    /* Handles when the user hits 'enroll'. Grabs form data. Does AJAX.
            Either shows error, or shows success. */

    $('form#enroll_form').submit(function(e) {
      e.preventDefault();
      var submit_data={};
      $.each($("[id^=ca_]"), function(index,value){
        submit_data[value.name]=value.value;
      });
      $.each($("[id^=cb_]"), function(index,value){
        submit_data[value.name]=value.checked;
      });

        postJSON('/create_account',
           submit_data,
           function(json) {
               if(json.success) {
                  $('#enroll').html(json.value);
               } else {
                  $('#enroll_error').html(json.value).stop().css("background-color", "#933").animate({ backgroundColor: "#333"}, 2000);
               }
             }
        );
    });

    /* Activate stupid spinner drop-downs in enrollment form */
    var spinner_array=$("[id^=spinner_]");
       spinner_array.each(function(i) {
          var s=spinner_array[i];
          $("#"+s.id).click(function(){
             $("#sregion"+s.id.substring(7)).toggle();
          });
        })


   /*$("sregion"+$("[id^=spinner_]")[1].id.substring(7)) */
});

</script>
