{% if plugins.survey[ref].active %}
  {% include 'No Script' %}
  <div class="script-dependent">
    {% for form in plugins.survey[ref].forms %}
      {% unless form.fields == empty %}
        {% capture cta %}{% if forloop.last == true %}{{ 'survey.finish' | t }}{% else %}{{ 'survey.next' | t }}{% endif %}{% endcapture %}

        {% include 'Survey Form',
          cta: cta,
          last: forloop.last,
          form: form
        %}
      {% endunless %}
    {% endfor %}

    <script type="text/javascript">
      $(document).ready(function(){
        var wcp = window.champaign.personalization;
        var prefill = _.extend(wcp.location, wcp.member, wcp.urlParams);
        window.champaign.mySurvey = new window.champaign.Survey({
          member:           window.champaign.personalization.member,
          prefill:          prefill,
          location:         window.champaign.personalization.location,
          source:           window.champaign.personalization.urlParams.source,
          akid:             window.champaign.personalization.urlParams.akid,
          followUpUrl:      "{{ follow_up_url }}"
        });
      });
    </script>
  </div>
{% endif %}

{% if plugins.survey[ref].active %}
  {% include 'No Script' %}
  <div class="script-dependent">
    {% for form in plugins.survey[ref].forms %}
      {% unless form.fields == empty %}
        {% capture cta %}
          {% if forloop.last == true %}
            {% if last_section_submit_text %}
              {{ last_section_submit_text }}
            {% else %}
              {{ 'survey.finish' | t }}
            {% endif  %}
          {% else %}
            {{ 'survey.next' | t }}
          {% endif %}
        {% endcapture %}

        {% include 'Survey Form',
          cta: cta,
          last: forloop.last,
          form: form
        %}
      {% endunless %}
    {% endfor %}

    <script type="text/javascript">
      $(document).ready(function(){
        var wcp = window.champaign.personalization;
        var prefill = _.extend(wcp.location, wcp.member, wcp.urlParams);
        window.champaign.mySurvey = new window.champaign.Survey({
          member:           window.champaign.personalization.member,
          prefill:          prefill,
          location:         window.champaign.personalization.location,
          source:           window.champaign.personalization.urlParams.source,
          akid:             window.champaign.personalization.urlParams.akid,
          followUpUrl:      "{{ follow_up_url }}"
        });
      });
    </script>
  </div>
{% endif %}
