if (!gucci) var gucci = {};

/*
Class: Cookie
  provides methods to set/get/unset cookies
  
Note:
  static class
*/
Cookie = {
  
  /*
  Property: set
    sets a new cookie
    
  Arguments:
    name - the name of the cookie
    value - the value of the cookie
    sec - optional, expiration time in seconds from now
  */
  set: function(name, value, sec) {
    if (sec) {
      var today = new Date(), expiration;
      today.setTime(today.getTime() + (sec * 1000));
      expiration = '; expires=' + today.toGMTString();
    } 
    else {
      expiration = '';
    }
    document.cookie = name + "=" + value + expiration + "; path=/";
  },

  /*
  Property: get
    gets a cookie with a specific name and returns its value
    
  Arguments:
    name - the name of a cookie
  
  Returns:
    the value of a cookie with a specific name
    
  */
  get: function(name) {
    name = name + '=';
    var value;
    var cookies = document.cookie.split(';');
    cookies.each(function(cookie) {
      while (cookie.charAt(0) == ' ')
        cookie = cookie.substring(1, cookie.length);
        
      if (cookie.indexOf(name) == 0) {
        value = cookie.substring(name.length, cookie.length);
        throw $break;
      }
    });
    
    return value;
  },
  
  /*
  Property: unset
    removes a cookie with a specific name by setting its expiration date to a time in the past
    
  Arguments:
    name - the name of a cookie
  */
  unset: function(name) {
    Cookie.set(name, '', -1);
  }
  
};
