function imgOpen(imgLink,Title,width,height) {
	var doResize;
	if (width == null) {width = 100;height = 100;doResize=1}
  if (typeof(window.resizeBy)=='undefined') return true;
  imgWndw=window.open('',imgLink.target,'width='+width+',height='+height+
    ',toolbar=no,menubar=no,location=no,status=no,'+
    'resizable=yes,scrollbars=no,left='+(screen.width>>>2)+
    ',top='+(screen.height>>>4));
  if (doResize) self.focus();
  var imgTitle=(Title)?Title:imgLink.href;
  with (imgWndw.document){
    open();
    write('<ht'+'ml><he'+'ad><ti'+'tle>'+imgTitle+'</ti'+'tle>'+
    '</he'+'ad><bo'+'dy leftmargin="0" topmargin="0" '+
    'rightmargin="0" bottommargin="0" marginwidth="0" '+
    'style="margin:0;padding:0;position:fixed;overflow:none;" '+
    'marginheight="0"><img src="'+imgLink.href+'" border="0" '+
    ' alt="'+imgTitle+'" title="'+imgTitle+'"/></bo'+
    'dy></ht'+'ml>');
    close();
  }
  if (doResize==1) {resId=setInterval('imgResize()',500);}
  return false;
}

function imgResize() {
  var w=imgWndw.document.images[0].width;
  if (w>screen.availWidth) w=screen.availWidth;
  var h=imgWndw.document.images[0].height;
  if (h>screen.availHeight) h=screen.availHeight;
  if (w>50 && h>50) {
    var ww=(imgWndw.innerWidth)?imgWndw.innerWidth:((document.body)?
      imgWndw.document.body.clientWidth:null);
    var wh=(imgWndw.innerHeight)?imgWndw.innerHeight:((document.body)?
      imgWndw.document.body.clientHeight:null);
		if (/gecko/i.exec(navigator.userAgent)) ww-=50;
    if (ww && wh) {
      imgWndw.resizeBy(w-ww,h-wh);
    }
    imgWndw.focus();
    clearInterval(resId)
  }
}

var bannerPos;
var bannerContainer;
function initBanners (delay, container) {
	bannerPos       = Math.round(Math.random() * banners.length) % banners.length;
	bannerContainer = container;

	rotateBanner(0);
	setInterval('rotateBanner(1)', delay * 1000);
}

function rotateBanner (p) {
	bannerPos = (bannerPos + p + banners.length) % banners.length;
	showBanner();
}

function showBanner () {
	var banner = banners[bannerPos][0];
	var url    = banners[bannerPos][1];
	if (/\.swf$/.test(banner)) {
		document.getElementById(bannerContainer).innerHTML = 
		'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="450" height="100" id="'+banner+'">'+
			'<param name="allowScriptAccess" value="sameDomain" />'+
			'<param name="movie" value="'+banner+'" />'+
			'<param name="quality" value="high" />'+
			'<param name="bgcolor" value="#333" />'+
			'<embed src="'+banner+'" quality="high" bgcolor="#ffffff" width="450" height="100" name="banner" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
		'</object>';
	} 
	else if (/\.(gif|jpg|png)$/.test(banner)) {
		document.getElementById(bannerContainer).innerHTML = 
		'<a href='+url+'><img src="'+banner+'" width="465" height="102" alt=""></a>';
	}
}

function showMenu (menuId) {
	var menu = document.getElementById(menuId);
	if (/h\d/i.test(menu.innerHTML)) {
		menu.style.display = 'block';
	}
}

function hideMenu (menuId) {
	var menu = document.getElementById(menuId);
	menu.style.display = 'none';
}

// Функция установки значения cookie.
// name      - имя cookie
// value     - значение cookie
// [path]    - путь, для которого cookie действительно (по умолчанию - /)
// [expires] - дата окончания действия cookie (по умолчанию - до конца сессии)
// [domain]  - домен, для которого cookie действительно (по умолчанию - домен,
//             в котором значение было установлено)
// [secure]  - логическое значение, показывающее требуется ли защищенная
//             передача значения cookie
function setCookie(name, value, path, expires, domain, secure) {
  var curCookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "; path=/") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

// Функция чтения значения cookie.
// name - имя считываемого cookie
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));
}

// Функция удаления значения cookie
// name - имя cookie
// [path] - путь, для которого cookie действительно
// [domain] - домен, для которого cookie действительно
function delCookie(name, path, domain) {
  if(getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "; path=/") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// Устанавливает Cookie сложной структуры.
function setCookieEx(name, value, path, expires, domain, secure)
{ value=Serialize(value);
//  alert(value);
  return setCookie(name, value, path, expires, domain, secure);
}

// Читает Cookie сложной структуры.
function getCookieEx(name)
{ var v=getCookie(name);
  return Unserialize(v);
}