function getCookie(name)
{
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var toppos = 0;
  while (toppos < clen)
  {
    var offset = toppos + alen;
    if (document.cookie.substring(toppos, offset) == arg) {
      var endpos = document.cookie.indexOf(";", offset);
      if (endpos == -1) {endpos = clen;}
      return unescape(document.cookie.substring(offset, endpos));
    }
    toppos = document.cookie.indexOf(" ", toppos) + 1;
    if (toppos == 0) {break;}
  }
  return null;
}
function setCookie(name, value) // [,expires] [,path]
{
  var argv = setCookie.arguments;
  var argc = setCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  document.cookie = name + "=" + escape(value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path));
}
function delCookie(name)
{
  var exp = new Date();
  exp.setTime(exp.getTime() - 1);
  var cval = getCookie(name);
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
