                 ga('send', 'event', 'Registration', 'Switch', 'Teacher')
                 setRequired()
 
-                
+
   $("#country-select").on "change", checkEligibility
   $("#background-select").on "change", checkEligibility
-                
+
   $("#country-select").html('
         <option value="">Country...</option>
         <option value="US">United States of America</option>

    else
        $("#school-group").hide()
        $("#button-adviser").show()
    
    setRequired()

submitRegistration = (e) ->
  e.preventDefault()

  registrationData = $("#user-registration-form").serializeObject()
  creatingNewTeam = $("#registration-new-team-page").is(":visible")    
  creatingTeacherAccount = $("#registration-adviser-page").is(":visible")
  registrationData["create-new-team"] = creatingNewTeam
  registrationData["create-new-teacher"] = creatingTeacherAccount



setRequired = ->
    $('#user-registration-form :input').each () ->
        if not $(this).is(':checkbox')
            if not $(this).is(':radio')
                $(this).prop('required', $(this).is(":visible"))


checkEligibility = ->
    is_us = $("#country-select").val() in ["US", ""]
    is_k12 = $("#background-select").val() in ["student_el", "student_ms", "student_hs", "student_home"]
    is_student = $("#background-select").val() in ["student_el", "student_ms", "student_hs", "student_home", "student_undergrad", "student_grad"]

    # This should be changed to reflect your eligibility requirements
    if not is_k12
        $("#eligibility-warning").show()
        $("#adviser-group").hide()
    else
        $("#eligibility-warning").hide()
        $("#adviser-group").show()

    if is_student
        $("#school-group").show()
        $("#button-adviser").hide()
