$(document).ready(function(){
	var $anchorList = $('<ol></ol>').addClass('anchors'),
		$classList = $('#class-descriptions ul.classes'),
		count = 1;
	
	$(' > li', $classList).each(function(){
		var $classListItem = $(this),
			className = $(' > h2', this).text(),
			classCount = 'class' + count,
			anchorTarget = '#' + classCount,
			$anchorListItem = $('<li><a href="' + anchorTarget + '" title="Jump to ' + className + '">' + className + '</a></li>');
		
		$classListItem.attr('id', classCount);

		$anchorListItem
			.click(function(){
				$.scrollTo($(anchorTarget), 500, {offset: -200, onAfter:function(){
						$classListItem.animate({backgroundColor: '#fff4ac'}, 400, 'swing', function(){ 
							$classListItem.animate({backgroundColor: '#ffffff'}, 800);
						 });
					}
				});
				return false;
			})
			.appendTo($anchorList);
		
		count++;
	});
	
	$anchorList.insertBefore($classList);
});
