
function bbsSetCookie(name, value, longlife)
{
	var expires = longlife ? 'expires=Mon, 05-Jul-2014 23:59:59 GMT; ' : '';
	var curCookie = name + "=" + value + "; " + expires + "path=/";
//document.write("SET COOKIE [" + curCookie + "]<br>");
	document.cookie = curCookie;
}

function bbsGetCookie(name)
{
	var prefix = name + "=";
	var idxStart = document.cookie.indexOf(prefix);
	if (idxStart == -1) return null;
	var idxEnd = document.cookie.indexOf(";", idxStart + prefix.length);
	if (idxEnd == -1) idxEnd = document.cookie.length;
	return unescape(document.cookie.substring(idxStart + prefix.length, idxEnd));
}

var bbsTimeBound;

function prNew(msg_time)
{
	if (msg_time > bbsTimeBound) document.write('<b class=bbsNew>NEW: </b>');
}

function initIndex(path)
{

//document.write("COOKIE [" + document.cookie + "]<br>");

	var bbsTimeVisit = bbsGetCookie('bbs_last_visit_' + path);
	bbsTimeBound = bbsGetCookie('bbs_time_bound_' + path);

//document.write(bbsTimeVisit);
//document.write(' - bbsTimeVisit<br>');
//document.write('[' + bbsTimeBound + ']');
//document.write(' - bbsTimeBound<br>');

	if (bbsTimeBound == null || ! bbsTimeBound.length || bbsTimeBound == 0)
	{
		bbsTimeBound = bbsTimeVisit || 0;
		bbsSetCookie('bbs_time_bound_' + path, bbsTimeBound, false);
//document.write(bbsTimeBound);
//document.write(' - SET bbsTimeBound<br>');
	}

	var dateNow = new Date();
	var bbsTimeNow = dateNow.getTime();

	bbsSetCookie('bbs_last_visit_' + path, bbsTimeNow, true);
//document.write(bbsTimeNow);
//document.write(' - SET bbsTimeVisit<br>');

}

