$(document).ready(function()
{
	$('#navigation 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');
		});
	});

	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?');
	});
});

