/* Tracks Scroll Stop event
 */

(function() {
	
	var specialEvent = $.event.special,
		guid			= 'D' + (+new Date() + 1);
  		Scroll_To_On = 'nope';

	specialEvent.scrollHalt = {
			trottle: 300,

			setup: function() {
				var timer;
						
				var handler = function(evt) {
					var _self = this,
							_args = arguments;
							
					if (timer) { clearTimeout(timer) };

					timer = setTimeout( function(){
						timer = null;
						evt.type = 'scrollHalt';
						
						$.event.handle.apply(_self, _args);
					}, specialEvent.scrollHalt.trottle);
				};

				$(this).bind('scroll', handler).data(guid, handler);
			},

			teardown: function() {
				$(this).unbind( 'scroll', $(this).data(guid) );
			}
	};

})();
