/*! Copyright (c) 2008 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * Version: @VERSION
 *
 * Requires: jQuery 1.2+
 */
(function($){var elements=[],timeout;$.fn.extend({viewable:function(callback){this.bind('viewable',callback).each(function(){elements.push(this);});if($.isReady)checkVisibility();return this;},stopViewable:function(){return this.each(function(){var self=this;$.each(elements,function(i,element){if(self==element)
delete elements[i];});});}});function checkVisibility(){var winHeight=$(window).height(),winTop=self.pageYOffset||$.boxModel&&document.documentElement.scrollTop||document.body.scrollTop,winBottom=winHeight+winTop;$.each(elements,function(i,element){if(!element)return;var elTop=$(element).offset().top,elHeight=parseInt($(element).css('height')),elBottom=elTop+elHeight,percentage=0,hiddenTop=0,hiddenBottom=0;if(elTop<winTop)
hiddenTop=winTop-elTop;if(elBottom>winBottom)
hiddenBottom=elBottom-winBottom;percentage=1-((hiddenTop+hiddenBottom)/elHeight);$(element).trigger('viewable',[(percentage>1?1:percentage<0?0:parseFloat(percentage))]);});};$(function(){$(window).bind('scroll.viewable',function(){if(timeout)clearTimeout(timeout);timeout=setTimeout(checkVisibility,250);});checkVisibility();});})(jQuery);
