jQuery(document).ready(function(){
	jQuery("#horizontalnav li:last a").css({'background-image': 'none'});

	//If its a page parent (based off wordpress), add the class "Open"
	//display: block is used to keep the expanded menu open
	if (jQuery('#verticalnav ul li').hasClass("current-menu-parent")) {
		jQuery('#verticalnav ul li.current-menu-parent ul').css('display', 'block');
		jQuery('#verticalnav ul li.current-menu-parent ul').addClass('Open');
	}
	
	//Add a class to the parent li IF it has sub UL's
	jQuery("#verticalnav ul li:has(ul)").addClass("theDon");
	
	//Da henchman
	jQuery("#verticalnav ul li ul li:has(a)").addClass("henchmen");
	
	//Remove the link if it has a submenu
	jQuery('#verticalnav .theDon > a').attr('href', '#');
	
	//When you click it, toggle bitch.
	jQuery('#verticalnav ul li a').click( function() {
		
		//Hide current menu if a hyperlink is not in the current sub menu list
		if(!jQuery(this).parent().hasClass('henchmen')) {
			if(!jQuery(this).next().hasClass('Open')) {
				jQuery('#verticalnav ul li ul').removeClass("Open");
				jQuery('#verticalnav ul li ul').slideUp('fast'); 
				jQuery(this).next().slideDown('fast').addClass("Open");	   
			}
			else {
				jQuery('#verticalnav ul li ul').removeClass("Open");
				jQuery('#verticalnav ul li ul').slideUp('fast'); 
			}
		}			
		
		//return false so the # doenst move view to the top of the page
		if (jQuery(this).attr('href') == '#') { return false;  }
	});
});
