$(document).ready(function(){
	$('#chart').html('<img src="images/economyInfographic.jpg" /><div></div>');
	$('#chart').before('<ul id="cbuttons"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>Start over</li></ul>');
	$('#cbuttons li:last').css({'background':'#fff','border':'none'})
	
	$('#cbuttons li').eq(0).click(function(){
		$('#chart img').animate({'top':'-120px','left':'-275px'});
		$('#chart div').html('<p>"During the late &quot;90s and earlier this decade, house value was appreciating fast. ... Borrowers were offered adjustable-rate mortgages and interest-only mortgages. An adjustable-rate mortgage has an interest rate that changes based on market factors, and as a result, the payment increases when interest rates rise."</p>').css({'opacity':'0'}).animate({'opacity':'1'});
		$(this).css({'borderBottom':'1px solid #fff'}).siblings('li').css({'borderBottom':'1px solid #ccc'});
	});
	$('#cbuttons li').eq(1).click(function(){
		$('#chart img').animate({'top':'-100px','left':'-350px'});
		$('#chart div').html('<p>"It&#39;s like a bait, to hook you into taking a higher mortgage than you could afford otherwise. Overall, more than 40 percent of borrowers took adjustable-rate mortgages, which had lower initial interest rates. Banks started lending to subprime borrowers who otherwise would not qualify. According to some estimates, 25 percent of lending was subprime."</p>').css({'opacity':'0'}).animate({'opacity':'1'});
		$(this).css({'borderBottom':'1px solid #fff'}).siblings('li').css({'borderBottom':'1px solid #ccc'});
	});
	$('#cbuttons li').eq(2).click(function(){
		$('#chart img').animate({'top':'20px','left':'-550px'});
		$('#chart div').html('<p>"In 2004, homeownership ... rose to 70 percent"</p>').css({'opacity':'0'}).animate({'opacity':'1'});
		$(this).css({'borderBottom':'1px solid #fff'}).siblings('li').css({'borderBottom':'1px solid #ccc'});
	});
	$('#cbuttons li').eq(3).click(function(){
		$('#chart img').animate({'top':'-250px','left':'-650px'});
		$('#chart div').html('<p>"During the middle of 2006, when the Federal Reserve Board started raising the interest rate, forcing banks to raise mortgage interest rates, some borrowers started to default..."</p>').css({'opacity':'0'}).animate({'opacity':'1'});
		$(this).css({'borderBottom':'1px solid #fff'}).siblings('li').css({'borderBottom':'1px solid #ccc'});
	});
	$('#cbuttons li').eq(4).click(function(){
		$('#chart img').animate({'top':'0','left':'-650px'});
		$('#chart div').html('<p>"The lending institutions, when they sold those mortgages to Fannie and Freddie, didn&#39;t worry about the default risk, because it&#39;s all passed on. And Freddie and Fannie, in turn, sold those securities to private investors."</p>').css({'opacity':'0'}).animate({'opacity':'1'});
		$(this).css({'borderBottom':'1px solid #fff'}).siblings('li').css({'borderBottom':'1px solid #ccc'});
	});
	$('#cbuttons li').eq(5).click(function(){
		$('#chart img').animate({'top':'-60px','left':'-750px'});
		$('#chart div').html('<p>"...affecting the entire financial system. The credit market froze, affecting many industries. The stock market index dropped, people&#39;s savings in 401(k) and other retirement funds dropped, consumer spending dropped, and the auto industry, relying on bank credit, began suffering immensely. Tax revenues of states and local authorities plummeted, which caused cutbacks in many programs, raising unemployment..."</p>').css({'opacity':'0'}).animate({'opacity':'1'});
		$(this).css({'borderBottom':'1px solid #fff'}).siblings('li').css({'borderBottom':'1px solid #ccc'});
	});
	$('#cbuttons li').eq(6).click(function(){
		$('#chart img').animate({'top':'-120px','left':'0'});
		$('#chart div').html('<p><a href="images/economyInfographic.jpg" rel="box" title="Economy">View entire image</a></p>').css({'opacity':'0'}).animate({'opacity':'1'});
		$(this).siblings('li').css({'backgroundColor':'#fff'});
		$("#chart a[rel^='box']").each( function (){initbox(this);});
		
	});
	$('#cbuttons li').eq(6).trigger('click');
});

