/* LABEL OVERLAY - Vince Lee
 * ====================================================================================
 * hides label on click, sending focus to sibling textfield/textarea
 *
 * usage:
 * $('.your-label-class').label_overlay();
 * ------------------------------------------------------------------------------------
 * 
 * dev history:
 * v1.0: 10/03/11
 * ------------------------------------------------------------------------------------
 *
 * license:
 * Consume at will
 * ------------------------------------------------------------------------------------
 */

$(document).ready(function() {
$('.form-label').label_overlay();
});

(function($){  
 $.fn.label_overlay = function() {  
    return this.each(function() {  
    	if($(this).siblings('input[type=text]').size() == 1) {
	    	if($(this).siblings('input[type=text]').val() != "") {
		        $(this).hide();
		    }
	    }else if($(this).siblings('textarea').size() == 1) {
	    	if($(this).siblings('textarea').html() != "") {
		        $(this).hide();
		    }
	    }
	    $(this).click(function () {
	        $(this).fadeOut().siblings('input[type=text]').focus();
	        $(this).fadeOut().siblings('textarea').focus();
	    });
    });  
 };  
})(jQuery); 
