$(document).ready(function() {
	showHide();
});

function showHide() {
	// find all showhide candidates
	var $showhides = $('.showhide');

	$showhides.each(function() {
		// are we link or link container?
		var $trigger = $(this).is('a') ? $(this) : $('a',$(this));

		$trigger.each(function() {
			// actual link
			var $this = $(this);
			// find the link target and hide it right away
			var $target = $($this.attr('href'));
			if (! $target.hasClass('showhide_visible')) {
				$target.hide();
			}
			// clicking the trigger link toggles the target visibility
			$this.click(function() {
				$target.toggle();
				return false;
			});
			// elements with the class "showhide_close" inside the target will close the showhide
			$('.showhide_close',$target).click(function() {
				$target.hide();
				return false;
			});
		});
	});
}

