function readCookie(p_strVarName) {
  var cooIndex = document.cookie.indexOf(p_strVarName + "=");
  if (cooIndex == -1) return "";

  var nCntBegin = (document.cookie.indexOf("=", cooIndex) + 1);
  var nCntEnd = document.cookie.indexOf(";", cooIndex);

  if (nCntEnd == -1) nCntEnd = document.cookie.length;

  return document.cookie.substring(nCntBegin, nCntEnd);
}

function writeCookie(p_strVarName, p_strValue) {
  var nExpireDays = 0;

  if (nExpireDays > 0) {
    var dateExpire = new Date(); // Today
    dateExpire.setTime(dateExpire.getTime() + 1000 * 60 * 60 * 24 * nExpireDays);
    document.cookie = p_strVarName + "=" + p_strValue + "; expires=" + dateExpire.toGMTString();
  } else {
    document.cookie = p_strVarName + "=" + p_strValue;
  }
}

