$(function(){

	var i = 0;
			
	$('#nav ul ul').each(function() {
		
		var increment = (i == 1 ? 3 : 2); // Extra indent for Solutions
		var marginLeft = 20;
		var marginRight = 10;
		var paddingLeft = 14;
		var width = 122;
	
		$('> li', this).each(function() {
			
			// Indent
			$(this).css('margin-left', marginLeft + 'px');
			$(this).css('margin-right', marginRight + 'px');
			$(this).css('padding-left', paddingLeft + 'px');
		
			$('a', this).each(function() {
				$(this).css('width', width + 'px');
			});
								
			// Flyouts
			if ($(this).hasClass('children'))
			{
				$(this).hoverIntent(
				{
					over: function()
					{
						var offset = ($.browser.msie && $.browser.version < 7 ? 98 : 96);
						var top = $(this).offset().top - offset;
						var left = 165 - (top * 0.085);
						var ul = $(this).children('ul');
						
						if (ul.is(':animated'))
						{
							ul.stop();
							ul.css('height', 'auto');
						}
						
						ul.css('top', top + 'px')
						ul.css('left', left + 'px')
						ul.animate({height: 'show'}, 175, 'jswing');
					},
					out: function()
					{
						var ul = $(this).children('ul');

						if (ul.is(':animated'))
						{
							ul.stop();
							ul.css('height', 'auto');
						}									
							
						ul.animate({height: 'hide'}, 50, 'jswing');
					},
					interval: 10,
					timeout: 100
				});								
			}
			
			marginLeft -= increment;
			marginRight += increment;
			paddingLeft += increment;
			width -= increment;						
		});

		i++;
	});

	$('#nav>ul>li').hoverIntent(
		{						
			over: function()
			{
				$(this)
					.addClass('active')
					.children('ul')
					.animate({height: 'show'}, 275, 'jswing');
			},
			out: function()
			{
				$(this)
					.removeClass('active')
					.children('ul')
					.animate({height: 'hide'}, 50 , 'jswing');
			},
			interval: 10,
			timeout: 100
		});
});	
