/*
 * jQuery Hover Shade Plugin - Version 0.1
 *
 * Copyleft (c) 2007 Mark Cooke (http://www.ceefor.uk.net)
 * Licensed under the GPL (LICENSE.txt)
 */

/**
 * hoverShade() allows an easy way to shade an item when the mouse is hovering over it
 *
 * hoverShade accepts two arguments, one being the time to fade in and the fade to opacity
 * the following attributes are supported:
 *
 *  time:   	This is a numerical value that sets the amount of time the item takes to fade
 *            	Default value: 100
 *
 *	opacity:	This is the opacity level that the item fades to, ranging from 0 - 1.0 ( 1.0 being no fade )
 *				Default value: 0.5
 */
 
(function($) 
{
	$.fn.hoverShade = function( options )
	{	
	
		return this.each(function()
		{
			/* Set some optional settings */
			this.hoverShadeSettings = {
				time: 300 , opacity: 0.5
			}
			
			if (options) {
				jQuery.extend( this.hoverShadeSettings, options );
			}
	
			/* Define the default vars */
			this.hoverShadeSettings.time = ( isNaN ( this.hoverShadeSettings.time ) ) ? 100 : this.hoverShadeSettings.time;
			this.hoverShadeSettings.opacity = ( isNaN ( this.hoverShadeSettings.opacity ) ) ? 0.5 : this.hoverShadeSettings.opacity;
			
			/* Do the actual image hover fade */
			$(this).hover(function(){
				$(this).fadeTo( this.hoverShadeSettings.time, this.hoverShadeSettings.opacity ); },function(){ $(this).fadeTo( this.hoverShadeSettings.time, 1.0 );
			});
		});
	}

})(jQuery);
