jQuery(document).ready(function($) {				
	/* ================================================================
	 * Change the background of the 3rd level item when rolling over
	 * the 4th level items. To ensure that the 3rd level item is reset,
	 * we must include a bound event here as well.
	 * ================================================================ */
	
	$('.level3').hover(function(){
		$(this).children('a').addClass('level3Over');
	}, function(){
		$(this).children('a').removeClass('level3Over');
	});
	
	$('.level4').hover(function(){
		$(this).children('a').addClass('level4Over');
	}, function(){
		$(this).children('a').removeClass('level4Over');
	});
	
	var frameOffset = $('#frame').offset();
	var frameWidth = $('#frame').width();
								
	// make sure that the sub items are properly indented.
	$('.list5').each(function(i) {
		var width = $(this).parents('.list4').width();
		var offset = $(this).parents('.list4').offset();
		var thisWidth = $(this).width();
		
		if((offset.left+width+thisWidth) > (frameOffset.left+frameWidth)) {
			$(this).addClass('negativeMargin');
		}
	});
});
