$(function(){

	//some booleans
	var onMainNav;
	var onMiniNav;

	//Do not alter the order of these 4 functions
	
	//finds main drop downs
	$('.menu .left .left').hover(function(){
		$(this).next('.floatingNav').show();
		//onMainNav = true;

	}, function(){
		
		//if(!onMiniNav){
			$(this).next('.floatingNavMini').css('visibility', 'hidden');
			$(this).next('.floatingNav').hide();
		//}
	});

	
	//open mini menu from main drop down
	$('.floatingNav .left a img').parent('a').parent('.left').hover(function(){
		//onMiniNav = true;
		$(this).next('.floatingNavMini').css('visibility', 'visible');
	}, function(){
		//onMiniNav = false;
		$(this).next('.floatingNavMini').css('visibility', 'hidden');
	});

	
	//when hovered on mini menu
	$('.floatingNavMini').hover(function(){
		$(this).parent().prev('.left').children('a').addClass('tempHover');//menu top is selected
		//$(this).prev('.left').children('a').addClass('red');//keep this trail highlighted with the  red class
		$(this).parent('.floatingNav').show();//show floatingNav
		$(this).css("visibility", "visible");//show mini
	}, function(){
		$(this).css("visibility", "hidden");//hide mini
		//$(this).prev('.left').children('a').removeClass('red');//remove the class that keeps it red
	});
	
	//when hovered over main drop down
	$('.floatingNav').hover(function(){
		$(this).show();
		$(this).prev('.left').children('a').addClass('tempHover');//top menu
	}, function(){
		$(this).prev('.left').children('a').removeClass('tempHover');//hide top menu
		$(this).hide();//hide main drop down
		$(this).next('.floatingNavMini').css('visibility', 'hidden'); //remove any of the side-dropdowns
	});
});