$(document).ready(function()
{
	$('#header h1').each(function()
	{
		var self = $(this).hide();

		self.flash(
			{ height: 140, width: 430 },
			{ version: 8 },
			function(options)
			{
				options.src = base_url +'media/flash/jennys_light.swf';
				self.html($.fn.flash.transform(options)).fadeIn(500);
			}
		);
	});

	$('.memorial-video').each(function()
	{
		var self = $(this).hide();

		self.flash(
			{ height: 292, width: 390 },
			{ version: 8 },
			function(options)
			{
				options.src = base_url +'media/flash/mediaplayer.swf?file='+ base_url +'media/flash/Memorial.flv';
				self.html($.fn.flash.transform(options)).show();
			}
		);
	});

	$('#menu_main li.top').each(function()
	{
		var sub  = $(this).find('ul');
		var link = $(this).find('a:first');

		if (sub.length > 0 && typeof sub._h == 'undefined')
		{
			var p_top = sub.css('padding-top');
			var p_bot = sub.css('padding-bottom');

			// Set the expanded height
			sub._h = sub.height() + parseInt(p_top) + parseInt(p_bot);

			// Add top padding to the first child
			sub.find('li:first').css('padding-top', p_top);

			// Remove top/bottom padding
			sub.css('padding-bottom', 0).css('padding-top', 0);

			// Prepare to animate
			sub.css({ height: 0 });
		}

		$(this).hover(function()
		{
			// Activate top level
			$(this).addClass('active');

			// Go to full height
			sub.stop().animate({ height: sub._h }, 300);
		},
		function()
		{
			// Go to 0 height
			sub.stop().animate({ height: 0 }, 300);

			// Deactivate top level
			$(this).removeClass('active');
		});
	});

	// Bio alt-coloring
	$('#content .leaders .bio:nth-child(even)').addClass('alt');

	if ($('#admin textarea.editor').length)
	{
		// Changed editor textareas into markItUp with Markdown settings
		$('#admin textarea.editor').markItUp(mySettings);
	}

	// Require confirmation
	$('a.confirm').click(function()
	{
		return confirm('This action cannot be undone, continue?');
	});
});
