var cookie = function (input) {
  if (input && input.length != 0) {
    cookie.setCookie(input.join('\n'));
    return input;
  } else {
    return cookie.getCookie().split('\n');
  }
};

cookie.getCookie = function () {
  var match = document.cookie.match(/addresses=(\S*)(;|$)/);
  return match ? decodeURIComponent(match[1]) : '';
};

cookie.setCookie = function (string) {
  var date = new Date();
  date.setTime(date.getTime() + 1000 * 60 * 60 * 24 * 365);
  document.cookie = 'addresses=' + encodeURIComponent(string) + '; expires=' + date.toUTCString();
};
