/* 
  *This is a jquery plugin
*/
/* This Function Controls jQuery Accordion Menu */
$(document).ready(function(){

	//Hide (Collapse) the toggle containers on load
	$(".menu_body").hide();
	// ignore line below it just sets an active class
	//$('.menu_body:first').addClass('active').next().show();
	
	// This shows the menu dropout when your in that section SEE READ ME FILE
	// This should reflect page setting li id and always menu body - it opens the section when on the selected page
	$('.about #about .menu_body').show();
	$('.products #products .menu_body').show();
	$('.contact #contact .menu_body').show();
	
	// Sub Drop Out Pages
	$('.products #products .menu_body .menu_body_inner').hide();
	
	$('.overhead-doors #products .menu_body #overhead-doors .menu_body_inner').show();
	$('.dock-equipment #products .menu_body #dock-equipment .menu_body_inner').show();
	$('.specialty-doors #products .menu_body #specialty-doors .menu_body_inner').show();
	$('.pedestrian-doors #products .menu_body #pedestrian-doors .menu_body_inner').show();
	$('.fence-gates #products .menu_body #fence-gates .menu_body_inner').show();
	
	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
	$("#accordion-menu a.menu_head").click(function(){
		$(this).toggleClass("active").next("ul.menu_body").slideToggle(300).siblings("ul.menu_body").slideUp("slow");
		if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
		$('.menu_head').removeClass('active').next().slideUp(); //Remove all "active" state and slide up the immediate next container
		$(this).toggleClass('active').next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
	}
		
		return true; //Prevent the browser jump to the link anchor
	});
	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state) SUB MENU 3 tier
	$("#accordion-menu a.menu_head_inner").click(function(){
		$(this).toggleClass("active").next("ul.menu_body_inner").slideToggle(300).siblings("ul.menu_body_inner").slideUp("slow");
		if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
		$('.menu_head_inner').removeClass('active').next().slideUp(); //Remove all "active" state and slide up the immediate next container
		$(this).toggleClass('active').next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
	}
		
		return true; //Prevent the browser jump to the link anchor
	});

});
