// JavaScript Document

$(document).ready(function() {


/* Neutralize Top Level Link in #nav, by setting it's href value to void */

/* Find all elements matching #nav>ul>li and add the class "closed", the goal is having the default state be open, so that users without javascript will be able to access nav items */
$("#nav > ul > li").toggleClass("closed");	



/* when #nav ul li a is clicked, close all nav items, then open the clicked one. */
$("#nav > ul > li  > a").click(function() {

/* if parent li has the class "closed, , add closed to all, and remove class (to open) */
/* if parent li does not have "closed", close all */

if ($(this).parent().is("li.closed") ){
 $("#nav > ul > li").addClass("closed");								 
$(this).parent("li").toggleClass("closed");	
   }
 else{
  $("#nav > ul > li").addClass("closed");								 

   }   

						 							 
								 }); 	   

});
