
/*****************************************************************************
* These are the basic functions to set, get and delete a cookie.             *
*****************************************************************************/

function setCookie(name, value, expires) {

  //Set a cookie given a name, value and expiration date.

  document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() +  "; path=/";
}

function getCookie(name) {

  var search;

  // Returns the value of the named cookie.

  search = name + "=";
  offset = document.cookie.indexOf(search);
  if (offset != -1) {
    offset += search.length;
    end = document.cookie.indexOf(";", offset);
    if (end == -1)
      end = document.cookie.length;
    return unescape(document.cookie.substring(offset, end));
  }
  else
    return "";
}

function deleteCookie(name) {

  var expdate = new Date();

  // Delete the named cookie.

  expdate.setTime(expdate.getTime() - (86400 * 1000 * 1));
  setCookie(name, "", expdate);
}
