function CookieDate(iMilli) {
	// cookieDate is a function that formats the date according to the cookie spec
	var datTmp = new Date(iMilli);
	return datTmp.toUTCString();
}

function SaveCookie(sName, sExpression, iDays) {
	sExpression = escape(sExpression);
	// Record a cookie of the form "@<N>=<E>" to map from
	// <N> is the name of the cookie,
	// <E> (encoded to contain no white space, semicolon, or comma characters)
	var datNow = new Date();
	var intTime = datNow.getTime();

	// set the cookie expiration time to thirty days beyond
	document.cookie = sName + "=" + sExpression + ";path=/;expires=" + CookieDate(intTime + iDays*24*60*60*1000);

	return true;
}

function LoadCookie(sName) {

	sValue = "";
	intIndex = document.cookie.indexOf(sName);
	if (intIndex!=-1)
	{
		intEqual = intIndex + sName.length;
		if (document.cookie.substring(intEqual,intEqual+1)!=';') {
			intBegin = (document.cookie.indexOf('=', intIndex)+1);
			intEnd = document.cookie.indexOf(';', intIndex);
			if (intEnd==-1) intEnd = document.cookie.length;
			sValue = unescape(document.cookie.substring(intBegin,intEnd));
		}
	}

	return sValue;
}

