title: jQuery UI Accordion + Cookies - Closed by Default?
body: <p>With the jQuery UI Accordion, I am successful in the use of cookies to remember the last active state when refreshing the page- however I am unable to:</p>
  
  <ol>
  <li><p>set to collapsed on first visit</p></li>
  <li><p>have cookie remember if the user has manually collapsed after opening</p></li>
  </ol>
  
  <p>I've tried to attempt creating a function with conditional statement on the "active" option but was unsuccessful.</p>
  
  <p><a href="http://jsfiddle.net/77xC9/18/" rel="nofollow">http://jsfiddle.net/77xC9/18/</a></p>
  
  <pre><code>jQuery(document).ready(function(){
          var act = 0;
          $( "#accordion" ).accordion({
              create: function(event, ui) {
                  //get index in cookie on accordion create event
                  if($.cookie('saved_index') != null){
                     act =  parseInt($.cookie('saved_index'));
                  }
              },
              change: function(event, ui) {
                  //set cookie for current index on change event
                  $.cookie('saved_index', null);
                  $.cookie('saved_index', ui.options.active);
              },
              active:parseInt($.cookie('saved_index')),
              collapsible: true
          });
      });
  </code></pre>
  
  <p>​</p>