// SubMENU ROUTINE - written by Kevin Jantzer, Folium Partners, LLC. 2010
//	if main menu link has a submenu, this routine will show/hide the submenu
//		Dependant on:
//			-<li> must have "hasSub" class
//			-href contains clas name of submenu div
//________________________________________________________________________________


$('.main li.hasSub a').click(
	function(e) {
		var div = $(this).attr('href'); //get name of submenu to show/hide
		
		//-----------OPEN
		if($('.'+div).css('display') == 'none'){ //if the submenu is hidden, show it...
			
			//find any submenu with class: "open"
			var open = $('#menu').find('.open').css('display');
			
			$('.main li').removeClass('activeSub'); //remove all "activeSub" classes
			$(this).parent().addClass('activeSub'); //set "activeSub" class on this menu option (the one the user clicked)
			
			//if there is an open submenu...
			if(open == 'block'){
				$('.open').fadeOut('fast',function(){ //fadeout the old submenu
					$('.open').removeClass('open'); //remove the old submenu's class: "open"
					$('.'+div).addClass('open'); //add class: "open" to new submenu
					$('.'+div).fadeIn('fast'); //fadein the new submenu
				})
			//else, just slide down the submenu
			}else{
				$('.'+div).slideDown(300); //slide down submenu
				$('.'+div).addClass('open'); //add class: "open"
			} 
		//-----------CLOSE	
		}else{ //else, if the menu is visible, hide it... 
			$('.'+div).slideUp(300); //slide submenu up
			$('.'+div).removeClass('open'); //remove class: "open"
			$(this).parent().removeClass('activeSub'); //and remove class: "activeSub" from clicked menu option
		}
	e.preventDefault();	//prevent the link from going anywhere
	}
);