// Andy Langton's show/hide/mini-accordion - updated 18/03/2009
// Latest version @ http://andylangton.co.uk/jquery-show-hide
//need to include jquery in template for this to work

// 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). 
//EK 101209: To change back to text replace image link with 'open' 'close'
//EK 111209: Very important to not have a trailing slash after the jpg and to also use single quotes around img src and rabbit ear quotes around location. If you don't, it won't work!
//EK 101209: added fix so that the open button shows after you collapse selection

var showText='<img src="http://www.quloc.org.au/gfx/icons/toggle-open.jpg">';
var hideText='<img src="http://www.quloc.org.au/gfx/icons/toggle-close.jpg">';

// append show/hide links to the element directly preceding the element with a class of "toggle". if using text add brackets around a href in between single quotes
$('.toggle').prev().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() {

// change the link depending on whether the element is shown or hidden
$(this).html ($(this).html()==hideText ? showText : hideText);

// toggle the display - uncomment the next line for a basic "accordion" style
//$('.toggle').hide();$('a.toggleLink').html(showText);
$(this).parent().next('.toggle').toggle('slow');

// return false so any link destination is not followed
return false;

});
});


