(function($) {
    $.fn.clearOnFocus = function() {
        function clearOnFocusFocus(event)
        {
            if ($(this).val() == $(this).data('clearOnFocus'))
            {
                $(this).val('');
            }
        }
        function clearOnFocusBlur(event)
        {
            if ($.trim($(this).val()) == '')
            {
                $(this).val($(this).data('clearOnFocus'));
            }
        }
        return this.each(function()
        {
            $(this).data('clearOnFocus', $(this).attr('value'));
            $(this).unbind('focus', clearOnFocusFocus);
            $(this).unbind('blur', clearOnFocusBlur);
            $(this).bind('focus', clearOnFocusFocus);
            $(this).bind('blur', clearOnFocusBlur);
        }
                );
    };
})(jQuery);
