<%inherit file="login.phtml"/>
<%block name="ajax">
    <script language="Javascript">
        $(document).ready( function () {
            
            $("#register_submit").click( function () {
                
                $('#loading').show();
                
                $.ajax({
                url: "${url_for('admin_app.signup')}",
                method: "POST",
                dataType: "json",
                data: {'username': $('#username_form').val(), 'email': $('#email_form').val(), 'password': $('#password_form').val(), 'repeat_password': $('#repeat_password_form').val(),  'csrf_token': $('#csrf_token').val()}
                }).done(function(data) {
                //$( this ).addClass( "done" );
                //Redirect if register
                
                    if(data.error==0)
                    {
                    
                        //$('#result_register').html('Done!. Redirecting...');
                        $('#loading').hide();
                        window.location.href="${url_for('admin_app.login')}";
                    
                    }
                    else
                    {
                        
                        $('#loading').hide();
                        
                        $('#csrf_token').attr('value', data.csrf_token);
                        
                        $('#username_error').html(data.username);
                        $('#email_error').html(data.email);
                        $('#password_error').html(data.password);
                        
                        $('#repeat_password_error').html(data.password_repeat);
                    }
                
                });
                
                return false;
                
            });
            
        
        });
    </script>
</%block>
<%block name="title">${lang('admin', 'sign_up', 'Paramecio Sign up')}</%block>
<%block name="content">
<form id="login">
    <div id="title">
                ${lang('admin', 'sign_up', 'Paramecio Sign up')}
    </div>
    ${forms|n}
    <div id="result_register"></div>
    <div id="submit_block">
        <input type="submit" value="${lang('common', 'sign_up', 'Sign up')}" class="submit" id="register_submit"/>
        <span id="loading">&nbsp;</span>
    </div>
</form>
</%block>
