var initialOutlineHeight;
var previousOutlineHeight = 0;
var currentOutlineHeight;
var minPad = 400;
var rightColumnInitialHeight;

$(document).ready(function()
{
	// "more..." button off
	$('a#desc_toggle').click(function()
	{
		$('#course_desc_less').hide();
		// toggle the outline action header
		var currentHeader = $(this).html();
		switch (currentHeader)
		{
			case 'more...':
				$(this).text('...less');
				break;
			case '...less':
				$(this).text('more...');
				break;
		}
	})

	$('a#outline_toggle').click(function()
	{
		// toggle the outline action header
		var currentHeader = $(this).html();
		switch (currentHeader)
		{
			case 'Hide Course Outline':
				$(this).text('View Course Outline');
				break;
			case 'View Course Outline':
				$(this).text('Hide Course Outline');
				break;
		}
	})
	
	// hide all toggle containers
	$('.toggle_container').hide();
	
	$('.toggle_trigger').click
	(
		function()
		{
			$(this).next('.toggle_container').slideToggle( 'slow', calculateRightColumnHeight );
		}
	);
	
	rightColumnInitialHeight = $('#b_right_column').height();
	
	if (window.location.href.indexOf('item=') > -1)	calculateRightColumnHeight();

});

function calculateRightColumnHeight()
{
	var debugText = 'd_courseOverviewText.height = ' + $('#d_courseOverviewText').height();
	var overviewHeight;
	var descriptionHeight;
	var descBlockHeight;
	var rightColumnHeightAdjusted;
	var rightColumnHeightOffset;
	var rightColumnHeight;
	
	debugText += '<br/>rightColumnHeight = ' + $('#b_right_column').height();
	
	overviewHeight = $('#d_courseOverviewText').height();
	$('#d_courseOverview').height( overviewHeight );
	descriptionHeight = $('#d_courseOverview').height() + $('#d_courseOutline').height();
	$('#d_courseDescription').height( descriptionHeight );
	descBlockHeight = $('#d_courseHeaderBlock').height() + $('#d_courseDescription').height();
	$('#d_courseDescriptionBlock').height( descBlockHeight );
	rightColumnHeightAdjusted = $('#d_titleBlock').height() + $('#d_courseDescriptionBlock').height();
	rightColumnHeightOffset = rightColumnHeightAdjusted - rightColumnInitialHeight;
	
//	rightColumnHeight = rightColumnInitialHeight + rightColumnHeightOffset;
	rightColumnHeight = rightColumnInitialHeight + rightColumnHeightAdjusted;
	$('#b_right_column').height( rightColumnHeight ); 
	
	debugText += '<br/>overviewHeight = ' + overviewHeight;
	debugText += '<br/>descriptionHeight = ' + descriptionHeight;
	debugText += '<br/>descBlockHeight = ' + descBlockHeight;
	debugText += '<br/>rightColumnHeight = ' + rightColumnHeight;
	
	debugText += '<br/>overall height should be adjusted now!!!';
	$('#debug').html( debugText );
}

function hideDesc()
{
	
}