$(document).ready(function() {
	$('dl#tabbed-content').css({'position':'relative'});
	var tabs = $('dl#tabbed-content > dt');
	var content = $('dl#tabbed-content > dd');

	function adjustHeight(height) {
		$('dl#tabbed-content').css({'height':height + $(tabs[0]).outerHeight() + 'px'});
	}

	function switchTabs(exception) {
		content.each(function(i) {
			$(this).css({'position':'absolute'});
			$(this).css({'left':'0px'});
			$(this).css({'top':$(tabs[0]).outerHeight() + 'px'});

			if (i == exception) {
				$(this).show();
				adjustHeight($(this).outerHeight());
			} else {
				$(this).hide();
			}
		});

		tabs.each(function(i) {
			$(this).css({'cursor':'pointer'});

			if (i == exception) {
				$(this).addClass('active');
			} else {
				$(this).removeClass('active');
			}
		});
	}

	tabs.each(function(i) {
		$(this).bind('click', function(e) {
			switchTabs(i);
		});
	});

	switchTabs(0);
});