function getExpDate(days, hours, minutes){
var expDate = new Date();
if (typeof days == "number" && typeof hours == "number" && typeof hours == "number") {
expDate.setDate(expDate.getDate() + parseInt(days));
expDate.setHours(expDate.getHours() + parseInt(hours));
expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
return expDate.toGMTString();
}
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf(";", offset);//alert(endstr);
if (endstr == 1) {
endstr = document.cookie.length; }
return unescape(document.cookie.substring(offset, endstr));
}
function getCookie(name){
var cookie = " " + document.cookie;
var search = " " + name + "=";
var setStr = null;
var offset = 0;
var end = 0;
if (cookie.length > 0) {
offset = cookie.indexOf(search);
if (offset != -1) {
offset += search.length;
end = cookie.indexOf(";", offset)
if (end == -1) {
end = cookie.length;
}
setStr = unescape(cookie.substring(offset, end));
}
}
return(setStr);
}
function setCookie(name, value, expires, path, domain, secure) {
document.cookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
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";
}
function saveData(data) {if(getCookie(data)){}else{
var expDate = getExpDate(180, 0, 0);
setCookie("user_id", data, expDate);}
}
function vewMessage(){
MessId=document.getElementById("messageSend");var data = getCookie('userName');
MessId.style.display="block";document.Form2.userAuthor.value=data;
}
function readData(){
var data = getCookie('user_id');
if(data){
blockLogin=document.getElementById('go_login');blockLogin.innerHTML='Добрый дèнь, =$user->nickname?>! — Обознались?';blockLogin.style.display='block';menuUser=document.getElementById('menu_user');menuUser.style.display='block';menuUser.innerHTML='→ Избранное | Личная страница | Личные сообщения';document.getElementById('message').style.display='none';
}
}