{% extends "admin.html" %}
{% load i18n %}
{% block extra_admin_head %}
    <script src="/static/js/jquery.mask.min-1.7.7.js"></script>
{% endblock %}
{% block body %}
    <body id="login-body">
        <div id="login-wrapper">
            <div class="text-center">
                <h2 class="fadeInUp animation-delay8" style="font-weight:bold">
                    {% if settings.logo %}
                        <img height="70px" id="login-icon" src="/media/{{ settings.logo }}" alt="Logotipo de {{ settings.initials }}" />
                    {% endif %}
                    <p class="text-shadow-white"><a href="/">{{ settings.initials|truncatechars:23 }}</a></p>

                </h2>
                {% if form.scope_display %}
                <h4 class="fadeInUp animation-delay8">{{ form.scope_display }}</h4>
                {% endif %}
            </div>
            <div class="login-widget animation-delay1">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <div>
                             {{ title }}
                        </div>
                    </div>
                    <div class="panel-body">

                        {% if form.non_field_errors %}
                        <div class="alert alert-danger">
                            {{ form.non_field_errors }}
                        </div>
                        {% endif %}

                        {% block form %}

                        {% endblock %}
                    </div>
                </div><!-- /panel -->
                {% if settings.company %}
                    <div class="copyright" align="center">&copy; {{ settings.company }}</div>
                {% endif %}
            </div><!-- /login-widget -->
        </div><!-- /login-wrapper -->
    </body>
    {% if can_register %}
    <script src="https://connect.facebook.net/en_US/sdk.js"></script>
    <script>
        /* Facebook */
        function statusChangeCallback(response) {
          if (response.status === 'connected') {
            var url = '/admin/register/'+response.authResponse.accessToken+'/'+response.authResponse.userID+'/';
            document.location.href = url;
          }
        }
        function checkLoginState() { FB.getLoginStatus(function(response) { statusChangeCallback(response); });}
        window.fbAsyncInit = function() {FB.init({ appId: '629398233811863', cookie: true, xfbml: true, version: 'v2.8' });}
        function fb_login(){FB.login(function(response) {statusChangeCallback(response);}, {scope: 'public_profile,email'});}
    </script>
    <script src="https://apis.google.com/js/api.js"></script>
    <script>
        /* Google */
        var CLIENT_ID = '201881391313-cfshu52pcv0m8ij5t3e026q4h1iqjabc.apps.googleusercontent.com';
        var SCOPES = ['https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/userinfo.email'];
        function handleAuthResult(authResult) {
            var authorizeDiv = document.getElementById('authorize-div');
            if (authResult && !authResult.error) {
                var url = '/admin/register/'+authResult.access_token+'/';
                document.location.href = url;
            }
        }
        function handleAuthClick(event) { gapi.auth.authorize({client_id: CLIENT_ID, scope: SCOPES, immediate: false}, handleAuthResult); return false; }
    </script>
    {% endif %}
{% endblock %}