﻿$(document).ready(function(){

	//Hide (Collapse) the toggle containers on load
	$(".toggle_container").hide();

	new_text_height = $('#contentColumn').height() + ( $('.toggle_container').size()*50 );
	$('#contentColumn').height( new_text_height );

	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
	$("h2.trigger").click(function(){
/*

		base_height = $('#contentColumn .textContent').height();

		current_height = $(this).parent().height();
		if( current_height == 0 ) {
			base_height += $(this).parent().children('.toggle_container').height();
		} else {
			base_height -= $(this).parent().children('.toggle_container').height();
		}

		$('#contentColumn').height( base_height );

		base_height += $('#headerImage').height() + $('#headerTickets').height() + $('#headerText').height() + 42;
		$('.trigger').each(function(){
			if( $(this).hasClass('active')) {
				base_height += $(this).parent().height();
			} else {
				base_height += 50;
			}
		});
		console.log( base_height );
*/

		$(this).toggleClass("active").next().slideToggle("fast",function(){
			minHeight = $('#rightColumn').height();
			newHeight = $('#contentColumn .textContent').height();
			newHeight = (newHeight > minHeight) ? newHeight : minHeight;
			$('#contentColumn').height(newHeight);
		});

		return false; //Prevent the browser jump to the link anchor
	});

	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
//	$("h2.trigger").click(function(){
//		$(this).toggleClass("active").next().slideToggle("fast", function() {
//			minHeight = $('#rightColumn').height();
//			newHeight = $('#contentColumn .textContent').height();
//			newHeight = (newHeight > minHeight) ? newHeight : minHeight;
//			$('#contentColumn').height(newHeight);
//		});
//		return false; //Prevent the browser jump to the link anchor
//	});


});
