// add a 'hint' to an input
jQuery.fn.hint = function (hint) {
    var $ = jQuery;
    
    // could be added to String.prototype, but this keeps the plugin 
    // side-effect free
    function ucfirst(str) {
        return (str.slice(0, 1).toUpperCase() + str.slice(1));
    }
    
    // add a hint to the item
    function hintify() {
        var $i = $(this);
        if (!this.value || this.value == $i.data('hint')) {
            $i.addClass('hint');
            if (!this.value) {
                $i.val($i.data('hint'));
            }
        }
    }
    
    // remove or select a hint'D input
    function dehintify() {
        var $this = $(this).removeClass('hint');
        if (this.value == $this.data('hint')) {
            $this.val('');
        }
    }
    
    // process the hint for each element
    return $(this).each(function () {
        $(this).data('hint', (hint || $(this).attr('title')));
    }).each(hintify).focus(dehintify).click(dehintify).blur(hintify);
};

