$.fn.labelAsWatermark = function () {
	return this.each(
					function() {
						var label = jQuery(this);
						label.addClass('watermarkedlabel');
						var txt = label.text();
						jQuery('#'+label.attr('for')).each(
							function() {
								var inp = jQuery(this);
								inp.addClass('watermarked');
								if (inp.attr('type') == 'password') {
									try {
										inp.attr('type','text').attr('origType' , 'password');
									} catch (e){}
								}
								inp.attr('value', txt).attr('labeltext', txt).focus(
									function() {
										var box = jQuery(this);
										box.removeClass('watermarked');
										if (this.value == box.attr('labeltext')) {
											this.value = '';
											if (box.attr('origType'))
												this.type = box.attr('origType');
										}
									}
								).blur(
									function() {
										var box = jQuery(this);
										if (!this.value) 
										{
											box.addClass('watermarked');
											this.value = box.attr('labeltext');
											this.type = 'text';
										}
									}
								);
							}
						)
					}
				)
};