<!--  // Hide this just in case this file is read as HTML

// COOKIES.JS
// Routines that help manipulate cookies
// **********************************
// cookieExists(name): returns true if cookie exists
// getCookie(name): returns value of name cookie
// removeCookie(name): removes name cookie
// setCookie(name, value, expire): Sets name cookie with specified arguments
// **********************************

function cookieExists(name)
{
      // returns true if the cookie exists

      if (document.cookie.length > 0)
      {
            // there are cookies
            if (document.cookie.indexOf(name + "=") != -1)
                  return true;      // cookie exists
      }
      return false;
}

function getCookie(name)
{
      // returns the value of the cookie with name

      if (!cookieExists(name))
            return null;      // cookie doesn't exist

      var search = name + "=";
      // set offset to the beginning of the cookie value
      var offset = document.cookie.indexOf(search) + search.length;

      var end = document.cookie.indexOf(";", offset); // find end
      if (end == -1)
            end = document.cookie.length;

      return unescape(document.cookie.substring(offset, end));
}

function removeCookie(name)
{
      // removes a cookie by expiring the cookie

      now = new Date();
      expire = new Date(now.getTime() - 1);      // old cookie

      setCookie(name, "", expire);
}

function setCookie(name, value, expire)
{
      // Sets cookie values. Expiration date is optional

      document.cookie = name + "=" + escape(value) +
                        ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
}

// Stop hiding -->

