function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}

$(document).ready(function(){
	// Home Slideshow
	$('.slides').cycle({
		pause: true,
		timeout: 10000,
		speed: 1500,
		cleartype: true,
		prev: '#slidePrev',
		next: '#slideNext'
	});
	
	// Equalize column heights
	equalHeight($(".callout-content"));
	
	$('#menu-item-519 > ul').wrap('<div class="dropdown-wrap" />');
	
	//add background image
	$('.dropdown-wrap').prepend('<div class="dropdown-img" />');
	
	//$('.menu-item-91 > a').wrap('<span />');
	
	//add class .third-level to ul and wrap a span around the sibling a
	$('.dropdown-wrap > ul').find('ul').addClass('third-level').siblings().wrap('<span />');
	
	//get wrap height 
	var dHeight = $('.dropdown-wrap').height();
	//get each third-level ul' height and keep the max
	var thirdHeight = 0;
	$('.third-level').each(function(){
		var h = $(this).height();
		if(h > thirdHeight)
		{
			thirdHeight = h;
		}
		//hide the dropdown image on hover of third-level nav
		$(this).parent().hover(
			function(){
				$('.dropdown-img').addClass('hide');
			},
			function(){
				$('.dropdown-img').removeClass('hide');
			}
		);
		//set .nav-item-right class to all odd items except the first one
		$('li:even',this).not('.nav-title').addClass('nav-item-right');
	});

	//compare wrap height to third-level height to set the size of the wrap
	if(dHeight < thirdHeight)
	{
		thirdHeight = thirdHeight + 10;
		$('.dropdown-wrap').css('height',thirdHeight+'px');
	}
});

