// Andy Langton's show/hide/mini-accordion - updated 18/03/2009
// Latest version @ http://andylangton.co.uk/jquery-show-hide

// this tells jquery to run the function below once the DOM is ready
$(document).ready(function() {

	// choose text for the show/hide link - can contain HTML (e.g. an image)
	var showText="<img src='images/more.png' width='69' height='17' />";
	var hideText="<img src='images/less.png' width='69' height='17' />";

	// append show/hide links to the element directly preceding the element with a class of "toggle"
	//var prev= $('.toggle').prev().html();
 	//$('.toggle').prev().html('<a href="#" class="toggleLink">'+showText+'</a>'+prev);
	 $('.toggle').next().append('<a href="#" class="toggleLink">'+showText+'</a>');

	// hide all of the elements with a class of 'toggle'
	$('.toggle').hide();

	// capture clicks on the toggle links
	$('a.toggleLink').click(function() {
		
		// find out what the action is more/less
		var action = $(this).html();
		action = action.substring(17, 21);
		
		// always hide everything							 
		$('.toggle').hide();
		$('a.toggleLink').html(showText);
		
		if(action == "more"){
			$(this).html(hideText);
			$(this).parent().prev('.toggle').toggle('slow');
		}
		
		// return false so any link destination is not followed
		return false;

	});
});

