/**
 * highlight + fade effect. (Custom jquery animated effect by barwin)
 *
 * Will cause the target object's background to fade from yellow to white, thus
 * providing a momentary "highlight" of the object
 *
 * Optionally specify background color (start and end) and also the duration
 * for the animation
 *
 * Usage: $("#object-selector").highlightFade();
 *
 * @author Ben Arwin <barwin@gmail.com>
 *
 * @param object settings to override default behavior
 * @param function_ref callbackfunc Optional callback function to execute on animation completion
 * @return object this
 */
jQuery.fn.highlightFade = function(settings, callbackfunc) {
	if (typeof(settings) == "undefined" || settings == null || settings === undefined) {
		settings = {};
	}
	if (typeof(callbackfunc) == "undefined" || callbackfunc === undefined) {
		callbackfunc = null;
	}
	settings = jQuery.extend({
		bg_start: '#FBEC5D',
		bg_end: '#FFFFFF',
		duration: 1000
	}, settings);

	var use_bg_end = settings.bg_end;
	this.each(function()
	{
		try {
			use_bg_end = jQuery(this).css("background-color");
			if (!use_bg_end) {
				use_bg_end = settings.bg_end;
			}
		} catch (err) {
			// bombed out trying to guess bg_end. defaulting to settings.bg_end
			use_bg_end = settings.bg_end;
		}

		jQuery(this).css({
			'opacity':'0.0',
			'background-color': settings.bg_start
			});
		try {
			jQuery(this)
			.animate({
				opacity: 1.0,
				'background-color': use_bg_end
			}, settings.duration, callbackfunc );
		} catch (err) {
		//debugLog(err);
		}
	});
	return this;
};

