jQuery.fn.labelOver = function(overClass) {
    return this.each(function(){
        var label = jQuery(this), _this = this;
        var f = label.attr('for');
        if (f) {
            var input = jQuery('#' + f);
            
            this.hide = function() {
                label.css({ visibility: 'hidden' })
            }
            
            this.show = function() {
                if (input.val() == '') label.css({ visibility: '' })
            }

            // handlers
            input.blur(function () {
                _this.show();
                label.removeClass(overClass + '-focus');
            });

            input.focus(function () {
                label.addClass(overClass + '-focus');
            });

            input.keyup(function (e) {
                if (input.val() == '') {
                    if ($.browser.webkit && input.is(':-webkit-autofill')) {
                        _this.hide();
                    } else {
                        _this.show();
                    }
                } else {
                    _this.hide();
                }
            });
            label.addClass(overClass).click(function(){ input.focus() });
            
            if (input.val() != '') this.hide(); 
        }
    })
}

