{% set clientEmailList = "" %}

{% if referrals is defined %}
    <strong>{{ agencyName }}</strong>
    <div id="referral_loop" style="padding-left: 20px;">
        {% for referral in referrals %}

            <div style="width:24%; float:left;">
                                {{ referral.createddt|date("m/d/Y") }} &nbsp;
            </div>
            <div style="width:36%; float:left;">
                                {{ referral.client.fullname }} &nbsp;
            </div>
            <div style="width:36%; float:left;">
                                {{ referral.client.email }} &nbsp;
            </div>

            {% if referral.client.email is not empty and agencyNumber == 55 %}	
                {% set clientEmailList =  [clientEmailList, referral.client.email]|join('; ') %} 
            {% endif %}

            <br />
        {% endfor %}
    </div>
    {% if agencyNumber == 55 %}

        <input type=button onClick="location.href='javascript: displayemail()'" value='Display Email' style="color:#00b5cb; background-color:white; font-size: 12px;">

        <div id="emailList" style="display:none;">
            <br />
            <textarea rows="2" cols="80" readonly=true, style="font-size: 12px;">{{ clientEmailList }}</textarea> 
        </div>
    {% endif %}
{% endif %}

