// Cookie service functions
// for the purposes of the site the cookies never expire

// Create a cookie that never expires (OK, it does - in 10 years)
function writeEternalCookie(pName,pVal)
{   
	var today = new Date();
	var expires = new Date();
	expires.setTime(today.getTime() + 1000*3600*24*365*10); // expires in 10 years
	document.cookie = pName + "=" + escape(pVal) + "; expires=" + expires.toGMTString() + ";";
}

// Retrieve the value of the cookie.
function getCookie(pCookieName)
{   
	var searchStr = pCookieName + "=";
	if (document.cookie.length > 0)
	{ 
		// if there are any cookies
		offset = document.cookie.indexOf(searchStr);
		if (offset != -1) 
		{ // if cookie exists          
			offset += searchStr.length;  // set index of beginning of value         
			endPos = document.cookie.indexOf(";",offset);
			if(endPos == -1)
				endPos = document.cookie.length;
			return unescape(document.cookie.substring(offset, endPos));
		}
	}
	return "";
}

// Retrieve the value of the numeric cookie.
function getNumericCookie(pCookieName)
{
	var rv = getCookie(pCookieName);
	if(rv == "")	return "0";
	else return rv;
}
