(function($)
{
    $.fn.label_magic = function(){
        $(this).each(function()
        {
            var self       = $(this);
            var self_id    = self.attr('id');
            var self_label = $('label[for='+self_id+']').hide();
            self_label.next('br').hide();
            var reset_value = function(){
                if (self.val() == '')
                    self.val(self_label.html());
            }
            reset_value();
            self.focus(function(){
                if (self.val() == self_label.html())
                    self.val('');
            }).blur(reset_value);

            self.parents('form').submit(function()
            {
                self.focus();
            });
        });
    };
})(jQuery);
