


// установка cookies
function SetCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
		((path) ? "; path=" + path : "") +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	document.cookie = curCookie;
}



// чтение cookies (return string containing value of specified cookie or null if cookie does not exist)
function GetCookie(name) { 
	var prefix = name + "=";
	var cookieStartIndex = document.cookie.indexOf(prefix);
	if (cookieStartIndex == -1) { return null; }
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
	if (cookieEndIndex == -1) { cookieEndIndex = document.cookie.length; }
	return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}



function DeleteCookie(name, path, domain) {
	if (GetCookie(name)) {
		document.cookie = name + "=" + 
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT"
	}
}
        


// Сохранить в cookies дату последнего визита
function SaveLastVisit(domain) {
	var NowDate = new Date ();
	NowTime = NowDate.getTime(); // миллисекунды с 01.01.1970 (global variable)
	SetCookie('LastVisit',NowTime,future(365),'/', domain);
}



function future(days)
{
	var largeExpDate = new Date ();
	largeExpDate.setTime(largeExpDate.getTime() + (days * 24 * 3600 * 1000)); // прибавить к сегодня несколько дней
	return largeExpDate;
}




































































































                                                                                                                   





































































































