function setCookie(pName, pValue) {
  // 30 day cookies
  theDate = new Date((new Date()).getTime() + (30 * 24 * 60 * 60 * 1000));
  document.cookie = pName + "=" + escape(pValue) + "; expires=" + theDate.toGMTString();
}

function getCookie(pName) {
  // cookies are separated by semicolons
  var theCookie = document.cookie.split("; ");
  for (var i=0; i < theCookie.length; i++) {
    // a name/value pair (a crumb) is separated by an equal sign
    var theCrumb = theCookie[i].split("=");
    if (pName == theCrumb[0]) 
      return unescape(theCrumb[1]);
  }

  // a cookie with the requested name does not exist
  return null;
}

function delCookie(pName) {
  // -1 day cookies
  theDate = new Date((new Date()).getTime() + (-1 * 24 * 60 * 60 * 1000));
  document.cookie = pName + "= \"\"; expires=" + theDate.toGMTString(); 
}
