﻿$(function() {
		  
    
	  $("a[id='" + $.cookie("openItem") +
  "']").parent('li').children('ul').removeClass('menu3').addClass("open");
		   });

$(function() // Register the menu
      {
// Add the click event handler on the list item with sub list
$('li:has(ul) a.menu2') 
               .click(function(event){
                if (this == event.target) {
					$.cookie("openItem",null);
				 $.cookie("openItem", $(this).attr('id'));	
                   // Hide all the children of the other lists
                   $('li:has(ul)').children('ul').hide('slow'); 
                   // Make the animation
                   $(this).parent('li').children('ul').animate({opacity:'toggle',height:'toggle'},'slow'); 
                                          }
                         return false;
                                     }
                       )
                // Change the cusrsor.
               .css({cursor:'pointer'})
               // Hide all the nested lists (on the first tinm only).
              $('ul.menu3').hide();
       }
 );
    
