$(function() {
	var $people = $('#people');
	if (!$people.length) {
		return;
	}

	$people
		.find('ul')
		.mousemove(function(e) {
			var $this = $(this), dim = $this.data('dim'), $first = $this.find('li:first');
			if (!dim) {
				dim = $.extend($this.offset(), {height: $this.height()});
				var $last = $this.find('li:last');
				dim.bottom = $last.offset().top- dim.top + $last.height() - dim.height;
				$this.data('dim', dim)
			}

			var pos = (e.pageY - dim.top) / (dim.height);
			if (pos < 0.11) {
				pos = 0;
			} else if (pos > 0.89) {
				pos = 1;
			}
		 	$this.data('goto', -(pos * dim.bottom));

			if (!$this.data('timer')) {
				$this.data('timer', setInterval(function() {
					var firstTop = parseInt($first.css('margin-top')),
						distance = $this.data('goto') - firstTop,
						speed = distance / 7;
					$first.css('margin-top', firstTop + speed);
				}, 50));
			}
		})
		.bind('mouseleave', function() {
			var $this = $(this);
			clearInterval($this.data('timer'));
			$this.data('timer', false)
		});
});