// JavaScript Document
function GetCookie(name)
{
	var result = null;
	var myCookie = ' ' + document.cookie + ';';
	var searchName = ' ' + name + '=';
	var startOfCookie = myCookie.indexOf(searchName);
	var endOfCookie;

	if (startOfCookie != -1)
	{
		startOfCookie += searchName.length;  //skip past cookie name
		endOfCookie = myCookie.indexOf(';', startOfCookie);
		result = unescape(myCookie.substring(startOfCookie, endOfCookie));
	}
	return result;
}

function SetCookie (name, value)
{
	var sixtyDays = 60*24*60*60*1000;	// in milliseconds
	var expDate = new Date();					//cookie expiration
	expDate.setTime(expDate.getTime() + sixtyDays);
	document.cookie = name + '=' + escape(value) + ';expires=' + expDate.toGMTString();
}

//function GetNewsDate()
//{
// This function needs to go into any HTML page that needs it,
// in order to pick up the Server Side Include
////	var newsDate = new Date(document.all.newsdate.innerText);
//	var newsDate = new Date('<!--#flastmod virtual="/general/info/newspop.shtml" -->');
//	return newsDate;
//}

function GetLastVisitDate()
{
	var lastVisitDate = new Date(GetCookie('THSCClastVisit'));
	return lastVisitDate;
}

function ChirpCheck()
{
	var now = new Date();

//	alert('now=' + now.toString());
//	alert('lastvisitdate=' + GetLastVisitDate().toString());
//	alert('newsdate=' + GetNewsDate().toString());
 
	if (GetNewsDate() > GetLastVisitDate())
	{
		popupInfo('/general/info/newspop.shtml');
	}
	SetCookie('THSCClastVisit', now);
}
