$(document).ready(function() {

	$('.tabs').each(function() {
		var h = 0;
		$(this).children('.tabs-body').each(function() {
			if (h < $(this).height()) h = $(this).height();
			//$(this).attr('title', $(this).height());
		});
		$(this).css({height: (h+20)+'px'})
	});
	
	$('.tabs-body.hide').hide().removeClass('hide');

	$('.tabs ul > li').click(function () {
		var index = $(this).parent().find('li').index(this);
		$(this).parent().find('li.active').removeClass('active');
		$(this).addClass('active');
		$(this).parents('.tabs').find('.tabs-body').hide();
		$(this).parents('.tabs').find('.tabs-body:eq(' + index + ')').fadeIn(300);
	});

	$('.info-bar .graph:first-child').show();

	$('.commodities table tr th a').click(function() {
		var id = $(this).attr('href');
		if ($(id).not(':visible')) {
			$(this).parents('.info-bar').find('.graph:visible').fadeOut('slow');
			$(id).fadeIn('slow');
		}
		
		return false;
	});

});

