// These functions govern the events pages for Opus
$(function()
{
	// On documnet load, hide the players
	$('document').ready(function() 
	{
		$('.flowplayer').hide();
	});

	// On heading clicks, toggle players
	$('h4>a').click(function() 
	{
		// Check the display value of the current event's player
		var display_state = $(this).parent().nextAll('.flowplayer:first').css('display');

		// If this is an active/open flowplayer, close and keep it that way		
		if (display_state == 'block') 
		{
			$('.flowplayer').slideUp();
			// Prevent the clicked <a> from firing
			return false;
		} 
		else 
		{
			// Close open players
			$('.flowplayer').slideUp();

			// Toggle down the new player
			$(this)
				.parent()
				.nextAll('.flowplayer:first')
				.slideToggle();
		}
			
		// Prevent the clicked <a> from firing
		return false;
	});

});
