String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

// I want a namespace dammit!
jQuery.touchmypixel = {};

// this one sets a default text string to occupy a form field
// if the field is left blank, then it becomes the default on blur
jQuery.touchmypixel.defaultText = {
	
	main : function(defaultText)
	{	
		var dt = defaultText;
	
		$(this).focus(
			function(){
				if (this.value == dt){
					this.value = "";
				}
			}
		);
		
		$(this).blur(
			function(){
				this.value = this.value.trim();
				if (this.value == "") this.value = dt;
			}
		);
		
		if (this) $(this).val(dt);
	}
};

jQuery.fn.defaultText = jQuery.touchmypixel.defaultText.main;

// this automatically trims a textfield on blur
jQuery.touchmypixel.autoTrim = {
	main: function(){
		$(this).blur(
			function(){
				this.value = this.value.trim();
			}
		);
	}
}

jQuery.fn.autoTrim = jQuery.touchmypixel.autoTrim.main;