// Function library for controlling cookies this function lib must be loaded into a
// document before all other JS files so that the functions are initialised
// and the constants have been set.
// ##################################### 
// Coded by ACN for AHC 15/04/2003 
// Last Updated by ACN on 28/05/2003 
// * fixed a pName typo resulting in failure to save cookies
//
// Updated by CJL 12/01/2004
// * 'exp' variable changed to 'expHour' because exp is now a reserved word.
// * fixed 'setCookie' error, 'pExpires=' : should be 'expires='
//
// Supports IE NS4 MOZ Opera
// ##################################### 

// RUN FROM HERE [START AUTO EXECUTED CODE] ================

	// Set up 1 hour delay constant.
	var expHour = new Date();
	expHour.setTime(expHour.getTime() + (1000 * 60 * 60)); 
	
	// Set up 3 month delay constant.
	var explong = new Date();
	explong.setTime(explong.getTime() + (1000 * 60 * 60 * 24 * 90)); 
	
	// Set up 1 year delay constant.
	var explongyear = new Date();
	explongyear.setTime(explongyear.getTime() + (1000 * 60 * 60 * 24 * 365)); 

// END AUTO EXECUTED CODE ================================


// Store a value in a cookie (Create if does not exist)
//  pName    - name of cookie to store to
//  pValue   - the value to store in cookie
//  pExpires - expirying time (today + time in milliseconds)
function setCookie(pName, pValue, pExpires) {
	document.cookie = pName + "=" + escape(pValue) + ";path=/" + ((pExpires == null) ? "":"; expires=" + pExpires.toGMTString());
} // end setCookie

// Fetch a cookie of a given name
//  pName   - name of cookie to fetch
//  returns - value stored in cookie
function getCookie(pName){
var cname = pName + "=";
var dc = document.cookie;
if (dc.length > 0) {
  begin = dc.indexOf(cname);
    if (begin != -1) {
      begin += cname.length;
      end = dc.indexOf(";", begin);
        if (end == -1) end = dc.length;
          return unescape(dc.substring(begin, end));
    }
  }
return null
} // End getCookie


// Delete a named cookie
function delCookie(name) {
	document.cookie = name + "=; expires=Sat, 01-Jan-00 00:00:01 GMT" +  "; path=/";
} // End delCookie

//EOF cookieIO.js
