function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
                ((expires) ? "; expires=" + expires : "") +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                ((secure) ? "; secure" : "");
    document.cookie = curCookie;
//alert(expires);
}


function getCookie(name) {
  var prefix = name + "=";
  var cookieStartIndex = document.cookie.indexOf(prefix);
  if (cookieStartIndex == -1) 
    {
    if (name == 'kinokadrcomment')
    {
   var voted = Math.round(today.getTime()/60000)*60 + Math.round(Math.random() * 60);
   if (voted > 1214640000) {voted = voted - 1214640000;};
   setCookie (name, voted, now, '/' );
   return voted;
    } else 
    
    if (name == 'kinokadrcommentauthor')
    {
   var voted = getCookie('kinokadrcommentusername');
   if (voted != null) setCookie (name, voted, now, '/' );
   return voted;
    } else 
    
    if (name == 'kinokadrcommentemail')
    {
   var voted = getCookie('kinokadrcommentuseremail');
   if (voted != null) setCookie (name, voted, now, '/' );
   return voted;
    } else 
    
    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 getsescookie(name) {
var voted = getCookie(name);

if (voted == null || voted < 100000 || voted > 1220000000)
   {
   voted = Math.round(today.getTime()/60000)*60 + Math.round(Math.random() * 60);
   if (voted > 1214640000) {voted = voted - 1214640000;};
   setCookie (name, voted, now, '/' );
   };

return voted;
}

var today = new Date(); 
var todate = new Date(today.getTime()+1000*60*60*24*365);

var now = todate.toGMTString(); //'Wed, 31-Dec-2006 00:00:01 GMT'

//alert(today.getTime()*100 + Math.round(Math.random() * 100));
