pk = {
  readyFunction: function(){
      pk.openSubMenu();   
      $('#clist>li>a').click(pk.clickLevel1);
  },//readyFunction

  clickLevel1: function(){
   
    if ($(this).next('ul').css('visibility')=='hidden'){
      //close all the same level of menus    
      //$('#clist>li>a').each(function(){
      //  $(this).next('ul').css('display','none');    
      //  $(this).next('ul').css('visibility','hidden');
      //})   
      //record the menu text in cookie   
      $.cookie('menuLevel1',$(this).text(),{path:'/'});   
      //$(this).next('ul').css('display','block');
      //$(this).next('ul').css('visibility','visible');
    }
    else {
      //remove the menu state cookie
      $.cookie('menuLevel1',null);   
      //$(this).next('ul').css('display','none');
      //$(this).next('ul').css('visibility','hidden');   
    }
  },//clickLevel1

  openSubMenu: function(){
      $('#clist>li>a').each(function(){
      //check the first level menu
      if ($(this).text() == $.cookie('menuLevel1')){
        //if it is in cookies, it will collapse
        $(this).next('ul').css('display','block');
        $(this).next('ul').css('visibility','visible');
      }//if
    })//each function
  }  //recordMenuState  
   
}//pk
$(document).ready(pk.readyFunction);

