jQuery.fn.extend({
	preserveDefaultText: function(params) {
		var options = {
			defaultValue: $(this).val(),	
			replaceValue: '',
			alwaysReplace: false
		};
		jQuery.extend(options,params);
		// no replaced start value for IE
		if($.browser.msie) {
			options.defaultValue = '';
			options.replaceValue = '';
		}
		$(this).each(function() {
			$(this).val(options.defaultValue);
			$(this).focus(function(){
				if(!$(this).hasClass('readonly') && !$(this).hasClass('disabled')) { 
					if(options.alwaysReplace) {
						$(this).attr('last',$(this).val());
						$(this).val(options.replaceValue);
					}
					else {
						if($(this).val() == options.defaultValue) {
							$(this).val(options.replaceValue);
						}
					}
				}
			});
			$(this).blur(function(){	 
				if(!$(this).hasClass('readonly') && !$(this).hasClass('disabled')) { 
					if($(this).val() == options.replaceValue) {
						if(options.alwaysReplace) {
							$(this).val($(this).attr('last'));
							$(this).removeAttr('last');
						}
						else {
							$(this).val(options.defaultValue);
						}
					}
				}
			});
		});
		return this;
	  }
});

