$(document).ready(function() {
				   
	// Choose text for the show/hide link as well as the speed of the collapsible animation
	var showText = 'Read more';
	var hideText = 'Hide';
	var animSpeed = "fase";
	
	if (showAllText === undefined){
		//var showAllText = "";
	}
	
	// append show or hide links to the element directly preceding the element with a class of 'collapsible'
	//$('.collapsible').prev().css('display', 'inline');
	$('.collapsible.start_expanded').prev().after(' <div class="show-hide">(<a href="#" class="toggleLink">'+hideText+'</a>)</div> ');
	$('.collapsible.collapsed').prev().after(' <div class="show-hide">(<a href="#" class="toggleLink">'+showText+'</a>)</div> ');
	$('.collapse-all p:last').after('<p class="show-hide"><a href="#" class="toggle-all">' + showAllText + '</a></p>');
	
	// hide all of the elements with a class of 'collapsible'
	$('.collapsed').hide();
	
	// capture clicks on the toggle links
	
	$('a.toggleLink').click(function() {
		
		//alert("selection: "+ $(this).parent().next().is('.collapsed'));
		
		// switch visibility off
		if ($(this).parent().next().is('.collapsed')){
			$(this).parent().next('.collapsible').slideDown(animSpeed);
			
			$(this).parent().next().removeClass('collapsed');
			$(this).html( hideText );
		}
		
		// switch visibility on
		else {
			$(this).parent().next('.collapsible').slideUp(animSpeed);
			
			$(this).parent().next().addClass('collapsed');
			$(this).html( showText );
		}

		// return false so any link destination is not followed
		return false;
	
	});	
	
	// capture clicks on the toggle-all-after links
	$('a.toggle-all').click(function(){
		
		if($('#collapse-all-here').is('.collapsed')){
			$('#collapse-all-here').slideDown(animSpeed);
			
			$('#collapse-all-here').removeClass('collapsed');
			$(this).html( hideAllText );
		}
		
		else{
			$('#collapse-all-here').slideUp(animSpeed);
			$('#collapse-all-here').addClass('collapsed');
			
			$(this).html( showAllText );
		}
		
		return false;
	});		
});
