/**
 * jQuery Opacity Rollover plugin
 *
 * Copyright (c) 2009 Trent Foley (http://trentacular.com)
 * Licensed under the MIT License:
 *   http://www.opensource.org/licenses/mit-license.php
 */
;(function($) {
	var defaults = {
		mouseOutOpacity:   0.67,
		mouseOverOpacity:  1.0,
		fadeSpeed:         'fast',
		exemptionSelector: '.selected'
	};

	$.fn.opacityrollover = function(css_class, settings) {
		// Initialize the effect
		return this.each(function(){
			$.extend(this, defaults, settings);
	
			var config = this;
	
			function fadeTo(element, opacity) {
				var $target = $(element);
				
				$target.stop( true, true );
				
				if (config.exemptionSelector)
					$target = $target.not(config.exemptionSelector);	
				
				$target.fadeTo(config.fadeSpeed, opacity);
			}
			
			$(this).children(css_class).css('opacity', this.mouseOutOpacity);
			$(this).hover(
					function () {
						fadeTo($(this).children(css_class), config.mouseOverOpacity);
					},
					function () {
						fadeTo($(this).children(css_class), config.mouseOutOpacity);
					});
	
			return this;
		});
	};
})(jQuery);

