$(function() {
	$('ul').each(function() {
		$(this).find('> li:first').addClass('first');
		$(this).find('> li:last').addClass('last');
		$(this).find('li').removeClass('has_submenu');
		$(this).find('> li:has(ul)').addClass('has_submenu');
	});
	
	$('#navigation > ul').addClass('first');
	$('#navigation > ul > li > ul').addClass('second');
	$('#navigation > ul > li > ul > li > ul').addClass('third');

	$('#navigation > ul > li > ul:has(li:has(ul))').addClass('contains_nested');

	$('#navigation').show();
	
	$('ul.contains_nested').each(function() {
		/* SOLUTIONS MENU HACK:
		 * **********************
		 * 
		 * AUTHOR: Bryce (bryce@isimple.net)
		 * DESCRIPTION:
		 * This code prevents all 2nd level links under 'Solutions' from getting their own column,
		 * and it also hides the 3rd level links under 'Solutions' too. 
		 *
		 * NOTE:To make the solutions menu work like the other menus, remove all the code between 
		 * 	_BOTH_ of the: 
		 *
		 * 	/* SOLUTIONS MENU HACK /
		 *
		 * 			and
		 *
		 * 	/* END SOLUTIONS MENU HACK /
		 * 
		 */
		var menu =  $(this).parent(); 
		if( $(menu).hasClass('cms_furstperson_solutions') ){
			$(this).find('.subMenu2').hide(); //hide the submenus
			$('.cms_furstperson_solutions ul.contains_nested').removeClass('contains_nested'); //fix css
		} else {
		/* END SOLUTIONS MENU HACK */

			//This is not a hack!
			var width = 0;
			var height = 0;
			$(this).find('> li').each(function() {
				width += $(this).width();
				height = height > $(this).height() ? height : $(this).height();
			});
			$(this).css('width', width + $(this).find('> li').size() * 11);
			$(this).find('> li').css('height', height);

		/* SOLUTIONS MENU HACK */
		} 
		/* END SOLUTIONS MENU HACK */
	});
	
	$('#navigation ul.second').hide();
	$('#navigation').css('visibility', 'visible');
	
	$('#s').val('Search');
	$('#s').focus(function() {
		if ($(this).val() == 'Search') {
			$(this).data('val', $(this).val());
			$(this).val('').focus();
		}
	}).blur(function() {
		if ($(this).val() == '') {
			$(this).val($(this).data('val'));
		}
	});
});

