(function($) {
    $.fn.watermark = function() {
       
	   //Initialize
	  var $label = $('label[for=' + $(this).attr('id') + ']');
	  $label.css("display", "none"); 
	  $(this).addWatermark();	
		
        this.focus(function() { $(this).removeWatermark(); }); 
        this.blur(function() { $(this).addWatermark(); });
 
        // Clear the watermark text when the form is submitted. 
        this.parents("form:first").submit(function() {
            $(this).removeWatermark();	
        });
    }
 
    $.fn.addWatermark = function() {
 		
		var $label = $('label[for=' + $(this).attr('id') + ']');
							
        if ( !this.val() || this.val().length == 0 ) {
            $(this).val( $label.html() );
        }
    }
 
    $.fn.removeWatermark = function() {
      	var $label = $('label[for=' + $(this).attr('id') + ']');
			
        if ( this.val() === $label.html() ) {
            this.val("");
        }
    }
})(jQuery);

$(function(){
	$(".watermark").each( function (){ $(this).watermark(); });	
});