/**
* inputTip - puts helper text in an input field
*/
(function($){
$.fn.inputTip = function(options) {
	var defaults = {
		isReplacement:false,
		passwordLabelEl:null 
	};
	// Extend our default options with those provided.
	var opts = $.extend(defaults, options);
	// If this is a password input then create a text input to be used as a label for replacement and store it to the options
	var el = $(this);
	if ($(this).attr('type') == 'password' && opts.passwordLabelEl == null) {
		//MRD: In next line i moved the placement of "Replacement" text for the name attribute to the begining. This was to fix a bug for fields that used array notation. Ex: "login[password]" would not submit correctly because it submitted the Alt value for the accuall form value.
		var newField = $('<input type="text" value="'+$(this).attr('alt')+'" class="'+$(this).attr('class')+'" name="Replacement'+$(this).attr('name')+'" id="'+$(this).attr('id')+'Replacement" alt="'+$(this).attr('alt')+'" />')
		$(this).after(newField);
		newField.hide();
		newField.focus(function(){
			$(this).hide();
			el.show();
			el.select();
		});
		opts.passwordLabelEl = newField;
	}
	// setup the focus and blur functions
	$(this).focus(function(){
		var el = $(this);
		if (opts.passwordLabelEl != null) {
			// do nothing here - focused on the password field
		} 
		else if (el.val() == el.attr('alt')) {
			el.val('');
		}
	});
	$(this).blur(function(){
		var el = $(this);
		if (opts.passwordLabelEl != null && el.val() == '') {
			el.hide();
			opts.passwordLabelEl.show();
		}
		else if (el.val() == '') {
			el.val(el.attr('alt'));
		}
	});
	if (!opts.isReplacement){
		$(this).blur();
	}
};
})(jQuery);
/* usage -- just initialize fields like this and you're set - your field should have an alt tag
$(document).ready(function(){ $('#ballardSearch input:text').inputTip(); });
 */
 

