$(document).ready(function() {
	
	/** -------------
	 **  Directions
	 ** -------------*/
	// Hide department contact information.
	//$('#contact_supp').hide();
	
	// Create a link to toggle the display of the contact info.
	$xoxo = $('<ul id="contact_toggle_link" class="xoxo"><li><a href="#" title="Show / hide the department contact information">Hide department contact details</a></li></ul>');
	$xoxo.find('a').click(function(e) {
		$('#contact_supp').slideToggle('slow', function() {
			if ($(this).css('display') == 'block') {
				$('#contact_toggle_link a').text('Hide department contact details');
			} else {
				$('#contact_toggle_link a').text('Show department contact details');
			} // if - else
		}); // callback
		
		return(false);	// Prevent propagation and default events.
	});
	
	$('#contact_supp').after($xoxo);
	
	
	/** -------------
	 **  Directions
	 ** -------------*/
	
	$('#directions_list').wrap('<ul class="xoxo"></ul>');
	
	// Loop through the headings.
	// - Extract the text
	// - Remove the heading tag
	// - Insert a new .xoxo list item with the heading text
	// - Add a click handlert to the link
	
	$('#directions_list h4').each(function() {
		$('<li><a href="#" title="' + $(this).text() + '">' + $(this).text() + '</a></li>')
			.insertBefore($(this))
			.find('a')
			.click(function(e) {
				$(e.target).parents('li').next('ul').slideToggle('slow');
				return(false);
			});
			
		$(this).next('ul').hide();
		$(this).remove();
	});
	
});
