jQuery.fn.defaultvalue = function(val) {
    /* When called on a form field, set val as the label value, so that when
     * the field is clicked, it is emptied, but if it is blurred with no value
     * the default is restored. Also, make it so that when the default value
     * is filled in, the text is a lighter shade. */
    return this.each(function() {
        jQuery(this)
            .click(function() {
                if(jQuery(this).val() == val) {
                    /* If currently the default value, clear it. */
                    jQuery(this)
                        .css('color', '#000')
                        .val('');
                }
            })
            .blur(function() {
                if(jQuery(this).val() == '') {
                    /* If empty, restore the default value. */
                    jQuery(this)
                        .css('color', '#999')
                        .val(val);
                }
            })
            .trigger('blur');
    });
};

