/**
 * @author Shawn Welch <shrimpwagon@yahoo.com>
 */
$(document).ready(function(){
    $.user_login = new Object();
    
    $.user_login.show = function(){
        $.fn.colorbox({
            href: '/ajax/ajaxLogin.php',
            speed: "100",
            width: "900px",
            height: "600px",
            open: true
        }, function(){
            // Focus on email address
            document.getElementById('login-email-address').focus();
            
            $('#login-form').validateForm({
                beforeSubmit: function(){
                    $('#cboxLoadedContent').blockElement();
                },
                type: 'post',
                dataType: 'json',
                success: function(data){
                    if (data.status == 'success') {
                        window.location.reload(true);
                    }
                    else {
                        alert(data.message);
                        $('#cboxLoadedContent').unblock();
                    }
                }
            });
        });
    }
});
