var form_5500_handler= {}; /* IE7 complains if the form_5500_handler object is not clearly defined first. */
form_5500_handler	= {
	toggle_contained_table: function(link,header_row,type) {
		this.link 			= link;
		this.header_row		= header_row;
		this.header_row.id	= 'header-row-' + parseInt(Math.random()*100000); // Generate a random ID so we can refer easily to the passed table
		if ($(this.link).hasClass('closing-link')) {
			// Hide all contained tables
			$('#' + this.header_row.id + ' + .expanding-row').addClass('hidden');
			// Switch the link
			$(this.link).removeClass('closing-link');
			$(this.link).addClass('expanding-link');
			this.link.innerHTML	= '[+]';
			
			// Swap the toggle-all link if all the rows in the tables are already closed
			if ($('#' + type + ' .closing-link').length == 1 || $('#' + type + ' .top-level .closing-link').length == 0) {
				$('#' + type + ' .toggle-all-link').removeClass('closing-link');
				$('#' + type + ' .toggle-all-link').addClass('expanding-link');
				$('#' + type + ' .toggle-all-link').html('[Expand All]');
			}
		}
		else {
			// Show contained tables that are immediate children
			$('#' + this.header_row.id + ' + .expanding-row').removeClass('hidden');
			// Switch the link
			$(this.link).removeClass('expanding-link');
			$(this.link).addClass('closing-link');
			this.link.innerHTML	= '[-]';
			
			// Swap the toggle-all link if all the rows in the tables are already expanded
			if ($('#' + type + ' .expanding-link').length == 1 || $('#' + type + ' .top-level .expanding-link').length == 0) {
				$('#' + type + ' .toggle-all-link').removeClass('expanding-link');
				$('#' + type + ' .toggle-all-link').addClass('closing-link');
				$('#' + type + ' .toggle-all-link').html('[Close All]');
			}
		}
	},
	toggle_all: function(link,type) {
		this.link 			= link;
		if ($(this.link).hasClass('closing-link')) {
			// Hide all contained tables
			$('#' + type + ' .expanding-row').addClass('hidden');
			// Switch the link
			$('#' + type + ' .closing-link').addClass('expanding-link');
			$('#' + type + ' .expanding-link').removeClass('closing-link');
			$('#' + type + ' .expanding-link').html('[+]');
			this.link.innerHTML	= '[Expand All]';
		}
		else {
			// Show contained tables that are immediate children
			$('#' + type + ' .expanding-row').removeClass('hidden');
			// Switch the link
			$('#' + type + ' .expanding-link').addClass('closing-link');
			$('#' + type + ' .closing-link').removeClass('expanding-link');
			$('#' + type + ' .closing-link').html('[-]');
			this.link.innerHTML	= '[Close All]';
		}
	}
};
