$(document).ready(
	function ()
	{
		var $topLI = $('#topnav').children('li');
		$topLI.hover( // Set the dropdown menus to slide down/up on hover on/off
			function(e)
			{
				$this = $(this);
				$this.children('ul').filter(function (index) { return !$(this).hasClass('animated') }).dequeue().stop().animate(
					{
						height: 'show'
					},
					{
						duration: 300
					}
				);
			},
			function (e)
			{
				$this = $(this);
				$this.children('ul').addClass('animated').animate(
					{
						height: 'hide'
					},
					{
						complete:
							function (e)
							{
								$(this).removeClass('animated').dequeue();
							},
						duration: 200
					}
				);
			}
		).filter( // Grab the second half of the dropdown menus
			function (index)
			{
				return (index > $topLI.length / 2) && (index < $topLI.length - 1);
			}
		).children('ul').css( // Set that half, minus the last, to align to the right
			{
				left: 'auto',
				right: '0px'
			}
		); // END $topLI
		
		$('#subnav li .dropdown').hover( // Set the hover color for the '+'
			function (e)
			{
				var $this = $(this);
				$this.css(
					{
						color: '#fdc235'
					}
				);
			},
			function (e)
			{
				var $this = $(this);
				$this.css(
					{
						color: '#ffffff'
					}
				);
			}
		).bind('click', // Set the accordian-like functionality of the subnavigation
			function (e)
			{
				var $this = $(this),
					$childUL = $this.next();
				if('block' == $childUL.css('display'))
				{
					$childUL.children('li').animate(
						{
							height:'hide'
						},
						{
							complete: function (e) { $childUL.css({ display:'none' }); },
							duration: 300
						}
					);
					//$childUL.css({ display:'none' });
					$this.html('+').css({ color: '#ffffff' });
				}
				else
				{
					$childUL.css({ display:'block' }).children('li').animate(
						{
							height:'show'
						},
						{
							duration: 300
						}
					);
					
					$this.html('-').css({ color: '#fdc235' });
				}
			}
		); // END $('#subnav li .dropdown')
	}
);

