( function( $ ) {
	$.fn.novatext = function( options ) {

		var defaults = { showText : null, defaultBackgroundColor : 'silver', defaultColor : '#000', focusBackgroundColor : '#fff', focusColor : '#000', focusCss : {}, defaultCss : {} };

		for( var eachProperty in options ) {
			if( defaults[ eachProperty ] ) {
				defaults[ eachProperty ] = options[ eachProperty ];
			}
		}

		return this.each( function() {
			this.defaultValue = defaults.showText !== null ? defaults.showText : this.defaultValue;
			
			$( this ).css( { backgroundColor : defaults.defaultBackgroundColor, color : defaults.defaultColor } ).css( defaults.defaultCss );

			$( this ).bind( 'focus', function() {
				if( $( this ).val() === this.defaultValue ) {
					$( this ).val( '' );
				}
				$( this ).css( { backgroundColor : defaults.focusBackgroundColor, color : defaults.focusColor } ).css( defaults.focusCss );
			});

			$( this ).bind( 'blur', function() {
				if( $( this ).val().trim() === '' ) {
					$( this ).val( this.defaultValue );
				}
				$( this ).css( { backgroundColor : defaults.defaultBackgroundColor, color : defaults.defaultColor } ).css( defaults.defaultCss );
			});
		});
	}

	String.prototype.trim = function( optionalString ) {
		optionalString = optionalString ? optionalString : this;
		while( optionalString.charAt(0) == ' ' || optionalString.charAt(0) == '\n' || optionalString.charAt(0) == '\t' ||optionalString.charAt(0) == '\r' ) {
			optionalString = optionalString.substr( 1 );
		}
		while( optionalString.charAt( optionalString.length - 1 ) == ' ' || optionalString.charAt( optionalString.length - 1 ) == '\n' || optionalString.charAt( optionalString.length - 1 ) == '\t' ||optionalString.charAt( optionalString.length - 1 ) == '\r' ) {
			optionalString = optionalString.substr( 0, optionalString.length - 1 );
		}
		return optionalString;
	}
})( jQuery );

