$(document).ready(function() {	

//If its a page parent (based off wordpress), add the class "displayMe"
//This way the accordion will be opened up on the page you are on.
if ($('#navigation ul li').hasClass("current_page_parent")) {
	$('#navigation .current_page_parent ul').addClass("displayMe");
	
 }
$('#navigation ul li ul li a').attr('rel','thickbox');
//Hide the submenus
$('#navigation ul li ul').hide();

//Add a class to the parent li IF it has sub UL's
$("#navigation ul li:has(ul)").addClass("theDon");

//Add/Remove class onclick 

	$('#navigation ul li a').click(function () {
	  // Switch class="selected" for tabs
	  $('#navigation ul li a').removeClass('active');
	  $(this).addClass('active');
	
	});

//The henchman
$("#navigation ul li ul li:has(a)").addClass("henchmen");

//Remove the link if it has a submenu
$('#navigation .theDon > a').attr('href', '#');

//When you click it, toggle.
$('#navigation ul li a').click(
function() {

//Onclick Remove the class dipslay me which is only display:block;
//This way they can close it if they click it or it will glitch


//If its already open
if ($('#navigation ul li ul').hasClass("Open")) {
	
//Slide it up as the others open
$('#navigation ul li ul').slideUp('slow'); 
$('#navigation ul li ul').removeClass("Open"); 


}



$(this).next().slideToggle('slow').removeClass("displayMe").addClass("Open");

//return false so the # doesn't move view to the top of the page
if ($(this).attr('href') == '#') { return false;  }

//Close it all out
	});
 });

