var AuthForm = {

    hidden : true,
    titles_loaded : false,

    load_titles : function() {
        if (AuthForm.titles_loaded) return;

        $('#auth_form INPUT.field').each(function(){
            var $this = $(this);
            $this.val($this.attr('title'));
            $this.addClass('empty');
            $this.focus(function() {
                var $input = $(this);
                if ($input.val() == $input.attr('title')) {
                    $input.val('');
                    $input.removeClass('empty');
                }
            });
            $this.blur(function() {
                $input = $(this);
                if ($input.val().length == 0) {
                    $input.val($input.attr('title'));
                    $input.addClass('empty');
                }
            });
        });
        AuthForm.titles_loaded = true;
    },

    toggle : function(force) {
		if (force) {
			if (force == 'show') AuthForm.hidden = true;
			if (force == 'hide') AuthForm.hidden = false;
		}
        if (AuthForm.hidden) {
            AuthForm.load_titles();
            $('#auth_form FORM').hide();
            $('#auth_form .email_tab').show();
            $('#auth_form').show();
            AuthForm.hidden = false;
        } else {
            $('#auth_form').hide();
            AuthForm.hidden = true;
        }
    },

    show_tab : function(tab) {
        $('#auth_form FORM').hide();
        $('#auth_form A').removeClass('selected');
        $('#auth_form A.'+tab).addClass('selected');
        $('#auth_form .'+tab+'_tab').show();
    }

};