Закрыть - Открыть блок и запомнить позицию

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Закрыть - Открыть блок и запомнить позицию

      Не могу понять что не то делаю , задача запомнить в куки открытое, или закрытое положение блока.

      Display Spoiler



      <div id="info_close" >Hello!</div>



      <span id="close">скрыть</span>

      <script type="text/javascript">

      (cookie = {

      set: function (a, b, c) {

      if (a) {

      var date = new Date();

      date.setTime(date.getTime() + (c * 24 * 60 * 60 * 1000));

      document.cookie = a + '="' + escape(b) + '"; expires="' + (date.toGMTString()) + '"; path="/"';

      }

      else return null;

      },

      get: function (a) {

      var name = a + "=";

      var ca = document.cookie.split(';');

      for (var i = 0; i < ca.length; i++) {

      var c = ca;

      while (c.charAt(0) == ' ') c = c.substring(1, c.length);

      if (c.indexOf(name) == 0) return c.substring(name.length, c.length);

      }

      return null;

      }

      });



      $('#close').live('click', function(){

      $.ajax({

      success: function(data) {

      if(cookie.get('info_close') == null) {

      $('.category ul').hide(600, function() {

      $('#info_close').text('открыть');

      });

      $('span#close').attr('id','open');

      cookie.set('info_close', 1, 365);

      } else return null;

      }});

      });

      $('#open').live('click', function(){

      $.ajax({

      success: function(data) {

      if(cookie.get('info_close') != null) {

      $('.category ul').show(600, function() {

      $('#info_close').text('');

      });

      $('span#open').attr('id','close');

      cookie.set('info_close', '', new Date(0));

      } else return null;

      }});

      });

      $(document).ready(function () {

      if(cookie.get('info_close') != null) {

      $('.category ul').hide(600, function() {

      $('#info_close').text('открыть');

      });

      $('span#close').attr('id','open');

      }

      });

      </script>