
$(document).ready(function() {

	// first level
	$('#sidebar #menu li').hover(
		function() {			// over					
			$(this).css('background-color', '#8d7c73');
			$(this).children('a').css('color', 'white');
		},
		function() {			// out
			if ($(this).hasClass('current_page_item') || $(this).hasClass('current_page_ancestor')) {
				$(this).css('background-color', '#f8f7f6');
			} else {
				$(this).css('background-color', '#E4E9E7');
			}
			$(this).children('a').css('color', '#8b2742');
		}
	);
	
	// second level
	$('#sidebar #menu li ul li').hover(
		function() {			// over
		/*
			if (
				$(this).hasClass('current_page_item') &&
				$(this).children('ul').length > 0
				) return;
			if ($(this).hasClass('current_page_parent')) return;
			if ($(this).hasClass('current_page_ancestor')) return;	
		*/

			$(this).css('background', '#f8f7f6 url(/wp-content/themes/CEG/images/secondarynavarrow-t.gif) no-repeat 15px 0px');
			$(this).children('a').css('color', '#8b2742');
		},
		function() {			// out
			$(this).css({
				'background-image' : 'none',
				'background' : '#f8f7f6'
			});
			if ($(this).hasClass('current_page_item')) {
				$(this).children('a').css('color', '#8b2742');
			} else {
				$(this).children('a').css('color', 'black');
			}
		}
	);
	
	// third level
	$('#sidebar #menu li ul li ul li').hover(
		function() {			// over
			$(this).css('background', '#f8f7f6 url(/wp-content/themes/CEG/images/thirdNavBul.jpg) no-repeat 21px 6px');
			if (!$(this).hasClass('current_page_item')) {
				$(this).children('a').css('color', 'black');
			}
		},
		function() {			// out
			$(this).css({
				'background-image' : 'none',
				'background' : '#f8f7f6'
			});
			if ($(this).hasClass('current_page_item')) {
				$(this).children('a').css('color', 'black');
			} else {
				$(this).children('a').css('color', '#504641');
			}
		}
	);
	
});
