function writeCookie(k, v)
{
  if (!navigator.cookieEnabled) {
    alert("クッキーの書き込みができないため、この機能は利用できません。");
    return;
  }
  sday = new Date();
  sday.setTime(sday.getTime() + (1 * 1000 * 60 * 60 * 24)); 
  s2day = sday.toGMTString();
  document.cookie = k + "=" + escape(v) + ";expires=" + s2day;
}

function readCookie(k)
{
  var s, e, sdat;
  var cdat = "";

  if (typeof(k) == "undefined") return "";
  k = k + "=";
  sdat = document.cookie + ";";
  s = sdat.indexOf(k);

  if (s != -1) {
    e = sdat.indexOf(";", s);
    cdat = unescape(sdat.substring(s + k.length, e));
  }

  return cdat;
}