$(document).ready(function() {
    var init = function() {
        $('#auth_logout_id').click(function() {
            $.post($(this).attr('href'), function(data) {
                location.reload(true);
                // $('#auth_block_id').html(data);
                // init();
            });
            return false;
        });
        $('#auth_login_form_id').ajaxForm({
            beforeSubmit: function() {
                document.body.style.cursor = 'wait';
            },
            dataType: 'html',
            success: function(response) {
                document.body.style.cursor = 'default';
                try {
                    var json = $.parseJSON(response);
                    alert(json.message);
                } catch(e) {
                    location.reload(true);
                    // $('#auth_block_id').html(response);
                    // init();
                } 
            }
        });
    };
    init();
});
