var home = {
	init : function() {
		home.buildtoc();
	},
	
	buildtoc : function() {
		/*
		 * Build table of contents from page headers
		 */
		$('h2[rel]').wrapAll('<div class="toc"></div>');
		
		/*
		 * Make toc mean something
		 */
		// Show only first section
		$('.section:gt(0)').hide();

		// Mark first as active
		$('.toc h2:eq(0)').addClass('active');
		
		// Dim the others as inactive
		$('.toc h2:gt(0),.toc .bullet').fadeTo(0,.5);
		
		// Wire toc items
		$('.toc h2').mouseover(function() { $(this).fadeTo(0,1); });
		$('.toc h2').mouseout(function() { if(!$(this).hasClass('active')) {$(this).fadeTo(0,.5); }});
		$('.toc h2').css({ cursor: "pointer" }).click(function() { $('.section').hide(); $('.section').filter('.' + $(this).attr('rel') + '').show(); $('.toc h2.active').removeClass('active'); $(this).addClass('active'); $('.toc h2').fadeTo(0,.5); $(this).fadeTo(0,1); });
	}
};

$(document).ready(home.init);
