/*!
 * hoverFadeC0 v1.1
 * http://www.roslindesign.com
 *
 * Copyright 2011, Alex Urquhart-Taylor
 * Dual licensed under the MIT or GPL Version 2 licenses.
 *
  */

(function($) {
	$.fn.hoverFadeColor = function(settings) {
		var config = {
			'color': null,
			'fadeToSpeed': 300,
			'fadeFromSpeed': 700
		};

		if (settings)
			$.extend(config, settings);

		this.each( function() {
			var originalColor = $(this).css("color");
			var hovercolor=config.color;

			$(this).hover( function() {

				hoverElem=this;
				if (hovercolor==null && $.browser.msie && $.browser.version.substr(0,1)<9) {

					setTimeout( function() {
						if(hovercolor==null) {
							hovercolor = $(hoverElem).css("color");
						}

						$(hoverElem).css('color',originalColor);

						$(hoverElem).stop().animate({
							color: hovercolor
						}, config.fadeToSpeed);
					},0);
				} else {
					if(hovercolor==null) {
						hovercolor = $(hoverElem).css("color");
					}

					$(hoverElem).css('color',originalColor);

					$(hoverElem).stop().animate({
						color: hovercolor
					}, config.fadeToSpeed);
				}
			}, function() {

				$(hoverElem).stop().animate({

					color: originalColor
				}, config.fadeFromSpeed);
			});
		});
		return this;
	};
})(jQuery);
