var expdate = new Date();
FixCookieDate(expdate);
expdate.setTime(expdate.getTime() + (365*24*60*60*1000));
function getCookie(which) {
	if (document.cookie.length == 0) {return '';}
	var sPos = document.cookie.indexOf(which + "=");
	if (sPos == -1) {return '';}
	sPos = sPos + which.length + 1;
	ePos = document.cookie.indexOf(';', sPos);
	if (ePos == -1) {ePos = document.cookie.length;}
	return unescape(document.cookie.substring(sPos, ePos));
}
function setCookie(which, value) {
	document.cookie = which + '=' + value + '; expires=' + expdate.toGMTString();
	if (getCookie(which) != value.trim()) {
		alert('You must have Cookies enabled to use this feature!');
		return false;
	}
	return true;
}
function FixCookieDate(date) {
	var base = new Date(0);
	var skew = base.getTime();
	if (skew>0)
		date.setTime(date.getTime()-skew);
}
function DeleteCookie(name) {
	if (getCookie(name)) {
		document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}