<script type='text/javascript' src='{{"/js/jquery.validate.min.js"|media}}'></script>
<script type="text/javascript" src="{{"/jquery-openid/jquery.openid.js"|media}}"></script>
<script type="text/javascript">
    var extra_token_name = {};
    var create_pw_text = {};
    var change_pw_text = {};
    var authUrl = '/{% trans %}account/{% endtrans %}';
    var siteName = '{{settings.APP_SHORT_NAME}}';
    var provider_count = {{existing_login_methods|length}};
    {% for login_provider in major_login_providers %}
        {%if settings['SIGNIN_' + login_provider.name.upper() + '_ENABLED'] == True %}
          {% if login_provider.extra_token_name %}
              extra_token_name['{{login_provider.name}}'] = '{{login_provider.extra_token_name}}';
          {% endif %}
          {% if login_provider.type == 'password' %}
              create_pw_text['{{login_provider.name}}'] = '{{login_provider.create_password_prompt}}';
              change_pw_text['{{login_provider.name}}'] = '{{login_provider.change_password_prompt}}';
          {% endif %}
        {% endif %}
    {% endfor %}
    {% for login_provider in minor_login_providers %}
        {% if settings['SIGNIN_' + login_provider.name.upper() + '_ENABLED'] == True %}
          {% if login_provider.extra_token_name %}
              extra_token_name['{{login_provider.name}}'] = '{{login_provider.extra_token_name}}';
          {% endif %}
          {% if login_provider.type == 'password' %}
              create_pw_text['{{login_provider.name}}'] = '{{login_provider.create_password_prompt}}';
              change_pw_text['{{login_provider.name}}'] = '{{login_provider.change_password_prompt}}';
          {% endif %}
        {% endif %}
    {% endfor %}
    {% if user.is_authenticated() %}
        var userIsAuthenticated = true;
    {% else %}
        var userIsAuthenticated = false;
    {% endif %}
    askbot['settings']['signin_always_show_local_login'] = {% if settings.SIGNIN_ALWAYS_SHOW_LOCAL_LOGIN %}true{% else %}false{% endif %};
    $("body").authenticator();
</script>
{% if settings.FACEBOOK_KEY and settings.FACEBOOK_SECRET %}
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
    $(document).ready(function(){
        if (typeof FB != 'undefined'){
            var ret = FB.init({appId: '{{settings.FACEBOOK_KEY}}', status: true, cookie: true, xfbml: true, oauth: true});
            FB.Event.subscribe('auth.authResponseChange', function(response){
                    if (response.authResponse) {
                        $('#signin-form').submit();
                    } 
            });
        };
    });
</script>
{% endif %}
