//SetCookie
//function setCookie (name, value, expires, path, domain, secure) 
//{ document.cookie = name + "=" + escape(value) +
//  ((expires) ? "; expires=" + expires : "") +
//  ((path) ? "; path=" + path : "") +
//  ((domain) ? "; domain=" + domain : "") +
// ((secure) ? "; secure" : "");
//}

//UTC-TIMEZONE
function TZOffset()
{ var tz = new Date().getTimezoneOffset(); 
  tz = -tz;
  document.cookie = "tz=" + escape(tz) + "; expires=Sun, 01-Jan-2037 00:00:00 GMT; path=/";
}

//Просмотр изображения во всплывающем окне
//Открытие изображения во всплывающем popup окне, центрирование, масштабирование, кроссбраузерность
//imgPath - url картинки, title - заголовок окна, alt - всплывающая подсказка при наведении на изображение
//При клике на изображение - происходит закрытие окна.
function OpenImagePopup(imgPath, title, alt) 
{ var win = window.open('','preview','width=50,height=50,left=0,top=0,screenX=0,screenY=0,resizable=1,scrollbar=0,status=0');
  var winDoc = win.document;
  if (title == undefined) title = '';
  if (alt == undefined) alt = 'Кликнуть для закрытия окна';
  var content = '<html><head><title>' + title + '</title>' + '<style>body{overflow: hidden;margin:0;}img{border:0;}</style>' + '</head><body><a href="javascript:self.close()">' + '<img alt="' + alt + '" id="image" src="' + imgPath + '" /></a></body></html>';
  win.document.write(content);
  winDoc.body.onload = function() 
  { var obj = winDoc.getElementById('image');
    var w = obj.width, h = obj.height;
    var iHeight= document.body.clientHeight, iWidth = self.innerWidth;
    //var left = (self.opera ? iWidth : screen.availWidth)/2 - w/2;
    //var top =  (self.opera ? iHeight : screen.availHeight)/2 - h/2;
    win.resizeTo(w+10, h+26);
    //win.moveTo(left, top);
  }
  win.onload = winDoc.body.onload; // special for Mozilla
  // !!! Important statement: popup onload won't execute without it!
  win.document.close();
  win.focus();
}
