Cookie = {
  /**
   * Set a cookie
   * @method write
   * @param {String} Name of the cookie
   * @param {String} Value for the cookie
   * @param {String} Number of days for it to expire (optional)
   */
  write: function(name,value,days) {
    if (days) {
      var date = new Date();
      date.setTime(date.getTime()+(days*24*60*60*1000));
      var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
  },
  /**
   * Read a cookie
   * @method read
   * @param {String} Name of the cookie
   * @return {String} the actual value of the cookie
   */
  read: function(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
      var c = ca[i];
      while (c.charAt(0)==' ') c = c.substring(1,c.length);
      if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
  },
  /**
   * Erase a cookie
   * @method erase
   * @param {String} Name of the cookie
   */
  erase: function(name) {
    this.create(name,"",-1);
  }    
}  

