/*
 * jquery.scrollweight.js
 * ScrollWeight was devised to provide emphasis on certain aspects of a page
 * The concept is that the higher something is on the visible page, the more "important" it is,
 * therefore, it should have more emphasis... elements lower on the pages should have less emphasis
 * and be more transparent
 *
 * @author		Adrian Scott
 * @created		May 16, 2010
 * @version		0.1
 * @req				jQuery 1.3+
 */
(function($) {
	$.fn.scrollweight = function(options) {
	
		// assign defaults
		var options = $.extend({
			minOpacity: 0.2
		}, options);
	
		var $elements = $(this);
	
		$(window).bind('scroll resize load', function() {
			var $window = $(this);
			
			// acquire the window's dimensions and scroll position
			var windowHeight = $window.height();
			var windowScroll = $window.scrollTop();
			
			$elements.each(function() {
				$this = $(this);
				$this.css('opacity', Math.max(1 - (Math.abs($this.offset().top - windowScroll) / windowHeight), options.minOpacity));
			});
		});
		
		// return this for chaining
		return this;
	};

})(jQuery);
