function setCookie(	pName,				// Cookie name
							pValue, 				// Cookie value
							pExpiresAt, 		// Exact date 10 June 2005 (optional)
							pExpiresFromNow,	// Milliseconds in future to expire (optional)
							pPath 				// Cookie path (optional) without leading /
						)
{
	// No exact expiration date requested
	if (typeof(pExpiresAt) == "undefined" || pExpiresAt == "")
	{
		var dateNow = new Date()
		if (typeof(pExpiresFromNow) == "undefined" || pExpiresFromNow == ""){
			// Set expiration to six months from now as default
			// dateNow.setTime(dateNow.getTime() + 1000*60*60*24*365)  // One year
			dateNow.setTime(dateNow.getTime() + 1000 * 60 * 60 * 24 * 10) // Ten days
		}else{
			dateNow.setTime(dateNow.getTime() + parseInt(pExpiresFromNow))
		}
		pExpiresAt = dateNow.toGMTString()
	}
	pExpiresAt = ";expires=" + pExpiresAt
	pPath = ";Path=/" + pPath 
	document.cookie = pName +  "=" + escape(pValue) + pExpiresAt 
	return pName +  "=" + escape(pValue) + pExpiresAt 

}

function getCookie(pName) {
	var theCookieValue
	var theCookie = document.cookie
	// Look for unique cookie name by pre-appending a space
	var nameStartsAt = theCookie.indexOf(" " + pName + "=")
	// Cookie name not found with pre-appended space
	if (nameStartsAt == -1)
	{
		// Look for cookie name at beginning of cookie
		nameStartsAt = theCookie.indexOf(pName + "=")
	}
	// No cookie name in cookie
	if (nameStartsAt == -1)
	{
		theCookieValue = null	
	}
	else
	{
		// Value starts past first = following the start of cookie nam
		var valueStartsAt = theCookie.indexOf("=", nameStartsAt) + 1
		// Cookie entry ends at first semicolon following where value starts
		var end = theCookie.indexOf(";", valueStartsAt)
		if (end == -1)
		{
			end = theCookie.length
		}
		theCookieValue = unescape(theCookie.substring(valueStartsAt,end))
	}
	return theCookieValue
}

