( function($) {
	/* define private methods for plugin here */

	/* define jQuery extensions here */
	
	/* define element extensions here */
	$.widget('buxwatch.labelover', {
		_init: function() {
			var self = this;
			var el = $(self.element);
			var options = this.options;
			var input = el.data('input');
			if(!input) {
				input = el.children('input:first');
				el.data('input', input);
			}
			var label = el.data('label');
			if(!label) {
				label = el.children('label');
				el.data('label', label);
			}
			if($.browser.safari) {
				label.css({display: 'none'});
				input.attr('placeholder', label.text());
			} else {
				el.css({position: 'relative'});
				label.css({top: options.top, left: options.left, position: 'absolute', color: options.color, overflow: 'hidden'});
				self.show();
				label.click(function(){
					input.focus();
					return false;
				});
				input.focus(function(){
					self.hide();
				});
				input.blur(function(){
					self.show();
				});
			}
			el.data(self.widgetName+'-enabled',true);
		},
		destroy: function() {
			var self = this;
			var el = $(self.element);
			var label = el.data('label');
			var input = el.data('input');
			label.unbind('click');
			label.unbind('focus');
			label.unbind('blur');
			el.data(self.widgetName+'-enabled', false);
		},
		enabled: function() {
			return this.element.data(this.widgetName+'-enabled');
		},
		show: function() {
			var self = this;
			var el = $(self.element);
			var label = el.data('label');
			var input = el.data('input');
			label.css({textIndent: ('' == input.val() ? '0px' : '-9999px'), display: 'block'});
		},
		hide: function() {
			var self = this;
			var el = $(self.element);
			var label = el.data('label');
			label.css({textIndent:'-9999px'});
		}
	});
	
	$.buxwatch.labelover.defaults = {
		color: '#ccc',
		left: '5px',
		top: '5px'
	};

	/* define page load initialization here */

})(jQuery);
