$(function() {
	var years_count = $('#timeline .years div').length;
	var current_year_index = 0;
	
	function selectYear(div) {
		$('#timeline .years div.over').removeClass('over');
		div.addClass('over');	
		$('#timeline .desc .content').html(div.html());
		current_year_index = div.index();
	}
	
	$('#timeline .years div').hover(function() {
		selectYear($(this))
	}, function() {

	});

	
	$('#timeline .desc .links a.next').click(function() {
		current_year_index++;
		if(current_year_index>=years_count) current_year_index=0;
		selectYear($('#timeline .years div:eq('+current_year_index+')'));
		return false;												  
	});
	$('#timeline .desc .links a.prev').click(function() {
		current_year_index--;
		if(current_year_index<0) current_year_index=years_count-1;
		selectYear($('#timeline .years div:eq('+current_year_index+')'));
		return false;												  
	});
	
	var maxDescHeight = 0;
	$('#timeline .years div').each(function() {
		$('#timeline .desc .content').html($(this).html());
		maxDescHeight = Math.max(maxDescHeight, $('#timeline .desc .content').height());
	});
	$('#timeline .desc .content').height(maxDescHeight);
	
	
	selectYear($('#timeline .years div:first'));
		   
})
