/* 
	Overlabel with JQuery - Input Text Label Replacement
	http://scott.sauyet.com/thoughts/archives/2007/03/31/overlabel-with-jquery/
	Public Domain - http://creativecommons.org/licenses/publicdomain/
*/
(function ($) {
    $.fn.overlabel = function (options) {
        var opts = $.extend({}, $.fn.overlabel.defaults, options),
            selection = this.filter('label[for]').map(function () {
                var label = $(this),
                    id = label.attr('for');
                field = $('#' + id);
                if (!field) return;
                var o = $.meta ? $.extend({}, opts, label.data()) : opts,
                    hide_label = function () {
                        label.css(o.hide_css)
                    },
                    show_label = function () {
                        this.value || label.css(o.show_css)
                    };
                label.css(o.label_css);
                field.parent().css(o.wrapper_css).end().change(hide_label).focus(hide_label).blur(show_label).each(hide_label).each(show_label);
                return this
            });
        return opts.filter ? selection : selection.end()
    };
    $.fn.overlabel.defaults = {
        label_css: {
            'position': 'absolute',
            'display': 'inline',
            'top': '13px',
            //'left': '5px',
			'padding': '0 0 0 5px',
            'z-index': '1'
        },
        wrapper_css: {
            'position': 'relative'
        },
        hide_css: {
            'text-indent': '-10000px'
        },
        show_css: {
            'text-indent': '0px',
            'cursor': 'text'
        },
        filter: false
    }
})(jQuery);
