(function($) {
	
	/**
	 * field_hint() - Shows hint in text field; deletes it on focus;
	 * @version 1.0
	 * @author Andrew Lopez (andrew@davierinteractive.com)
	 */
	$.fn.field_hint = function(options) {
		// default configuration
		var defaults = {
			autocomplete: 'off', // autocomplete set to off
			color: '#000000', //hex color for font
			hintColor: '#7d7d7d', //hex color for hint text
			text: [] //additional text to blur on
		};
		// extend the defaults class with the inputted options
		var settings = $.extend(defaults, options);
		
		var text = $(this).attr('title'); // grab the title text of the field
		$(this).attr('autocomplete', settings.autocomplete); // set the autocomplete tag to off
		
		var value = $(this).val();
		if (typeof value !== 'string')
			return;

		if (value.length < 1) {
			// initial TODOs
			$(this).css('color',settings.hintColor).val(text); // set the field value to the title text
		}
		// clear the hint text on focus
		$(this).focus(function() {
			if (settings.text.length > 0) { //if user defined text array is not empty
				for (var i = 0; i < settings.text.length; i++) {
					if ($(this).val() == settings.text[i]) { //check each to see if field value matches
						$(this).css('color',settings.color).val(''); //clear field text
						break;
					}
				}
			}
			if ($(this).val() == text) { // if the field's value is equal to the title text
				$(this).css('color',settings.color).val(''); // then clear it.
			}
		});
		
		// show the hint text on blur
		$(this).blur(function() {
			if ($(this).val() == '') { // if the field is blank
				$(this).css('color',settings.hintColor).val(text); // then add the hint.
			}
		});
	};
	
})(jQuery);

