
function collapseHidden() {
	$(".collapseMe").hide();
	$(".collapseMe").each(function () {

			var linkPrefixE = '';
			var linkSuffixE = '';
			var insideAhrefE = ' class="expandButton"';
			var linkPrefixC = ' ';
			var linkSuffixC = '';
			var insideAhrefC = ' class="collapseButton" style="display: none;"';
		
		var titleExpand = $(this).attr('title');
		
		if (!titleExpand) titleExpand = 'Tell me more &rarr;';
		
		$(this).before('<p>'+linkPrefixE+'<a href="javascript:void(0)"'+insideAhrefE+'>'+titleExpand+'</a>'+linkSuffixE+linkPrefixC+'<a href="javascript:void(0)"'+insideAhrefC+'>Hide &larr;</a>'+linkSuffixC+'</p>');

		$(this).removeAttr('title');
		});
	}

function expandHidden() {
	$(".expandButton").click(function (){ 
		$(this).fadeOut(100, function (){
			$(this).parents().next(".collapseMe").slideDown(300, function(){ 
				$(this).css({ 'display': "block" });
				/* 
				  because internet explorers work in mysterious ways... Table contained in the .collapseMe blinks and disappears
				  when the animation finishes--unless opacity is forced--but forced opacity breaks font anti-alliasing when on 
				  normal text blocks, causing weird black artifacts around some letters.
				*/
				if ($.browser.msie && parseInt ($.browser.version) == 7 && $(this).children("table").length > 0) $(this).css({"opacity" : "1.0"});
				});
			$(this).next(".collapseButton").fadeIn(100);
			});		
		});
	}

function collapseExpanded() {
	$(".collapseButton").click(function (){ 
		$(this).fadeOut(100, function (){
			$(this).parents().next(".collapseMe").slideUp(300);
			$(this).prev(".expandButton").fadeIn(100);
			});		
		});
	}

$(document).ready(function(){
	collapseHidden();
	expandHidden();
	collapseExpanded();
	});
