<!-- 

/*
    Cookie Library

    Copyright 2000 Pietro Carboni

*/


// Script Accessible?
function bCookieLibAlive()
{
  return true;
}

// Get Cookie
function getCookie
(
  sName   // name assoicated with value
)
{
  var sSearch = sName + "=";     // Cookie name to search for         
  var sCookie = document.cookie; // Cookie from document
  var ndx;     // index into cookie string   
  var nEnd;    // end of value 
  var sReturn = null; // return string        
  // Search Cookie if not Empty
  if (sCookie.length > 0) 
  {              
    ndx = sCookie.indexOf(sSearch);   // index that matches name    
    if (ndx != -1)                    // value in range
    {           
      ndx += sSearch.length;          // start of value
      nEnd = sCookie.indexOf(";", ndx);    // find ';' for end of value...
      if (nEnd == -1)                 // ... if not then use all 
         nEnd = sCookie.length;
      // Store return string
      sReturn =  unescape(sCookie.substring(ndx, nEnd));
    } 
  }
  // Return Cookie
  return sReturn;
}

// Set a Cookie
function setCookie
(
  sName,    // name of cookie
  sValue,   // value of cookie
  // Optional Parameters
  DtObjExpires, // date object for expiration or 'null' statement *not* ""
  sPath,    // pages here and below can access
  sDomain,  // domain name
  secure    // set for secure transmittal
) 
{ 
  // name and value
  var sCookieTemp = sName + "=" + escape(sValue); // don't built directly! 
  // expires
  sCookieTemp += ( DtObjExpires == null ) ? "" : "; expires=" + DtObjExpires.toUTCString(); 
  // path
  sCookieTemp += (sPath.length == 0)    ? "" : "; path=" + sPath; 
  // domain
  sCookieTemp += (sDomain.length == 0)  ? "" : "; domain=" + sDomain; 
  // secure
  sCookieTemp += (secure == null)   ? "" : "; secure";
  // store cookie string in cookie
  document.cookie = sCookieTemp;
}

// Kill cookies (not for client side only cookies)
function delCookie 
(
  sName,    // name of cookie
  sPath,    // pages here and below can access
  sDomain   // domain name
) 
{
  // Check if cookie exists before killing
  if (getCookie(sName)) 
  { // Create expiration prior to current date
    var DtObj = new Date();
    DtObj.setUTCFullYear(DtObj.getUTCFullYear() - 1);
    // set name
    var sCookieTemp = sName + "=";  // don't build directly
    // expiration prior to creation 
    sCookieTemp += "; expires=" + DtObj.toUTCString(); 
    // path
    sCookieTemp += (sPath.length == 0)    ? "" : "; path=" + sPath; 
    // domain
    sCookieTemp += (sDomain.length == 0)  ? "" : "; domain=" + sDomain;     
    // store cookie string in cookie
    document.cookie = sCookieTemp;
  }
}


// -->