(function($){ 
$.fn.labelOnField = function(allOptions) {  
	var defaults = {};
	allOptions = $.extend({}, defaults, allOptions);
		
	return this.each(function() {  
		var div = $(this);
		var inp = $("input,textarea",div)
		var lbl = $('label',div);
		// label or input not found!
		if (lbl.size()!=1 || inp.size()!=1) return;
		
		//override passed options by element embedded options if any
		var op = allOptions;
		// Read options inside inp (options) attribute
	    if (div.attr('data')) {
		    try { 
			    op = eval('('+div.attr('data')+')'); 
		    } catch(e) { 
			    if(op.debug) div.append(""+e+"");
			    return;
		    }
		    op = $.extend({}, defaults, op);
	    };
	    
		var show = function(){
			lbl.hide();
			//not empty exit
			if(inp.val()) return;
			lbl.css({
				display:'block'
				,position:'absolute'
				,'z-index':5
				,top:0}).show();
			
		};
		
		var hide = function(){
			lbl.hide();
		};
		// prepare CSS
		div.css('position','relative');

	    inp.focus(hide).change(hide);
	    lbl.focus(hide).click(hide);
		
	    inp.resize(show).blur(show);
	    inp.blur();
	}); 
}
})(jQuery);  
// load all inp with class=LabelOnField on document ready
jQuery(document).ready(function(){
	jQuery('.LabelOnField').labelOnField();
});	
