/* для осла 6 устраняем баг с кэшированием фоновых картинок */
try {
	document.execCommand('BackgroundImageCache', !1, !0);
} catch(e) {}

var menu = {

	show: function (i) {
		var el_mmItem = document.getElementById('mm-item-' + i);
		el_mmItem.className = el_mmItem.className + ' active';
	},

	hide: function (i) {
		var el_mmItem = document.getElementById('mm-item-' + i);
		setTimeout(function () { el_mmItem.className = el_mmItem.className.replace(' active', '') }, 50);
	}

}

function popupImg(url, width, height, title) {
	var scrollbars = 0,
		x = (screen.width - width) / 2,
		y = (screen.height - height) / 2;

	if (x < 0) x = 0;
	if (y < 0) y = 0;

	var w = width > screen.width ? screen.width : width;

	if (height > screen.availHeight) {
		h = screen.availHeight - 29;
		scrollbars = 1;
		w += 16;
	} else {
		h = height;
	}

	wnd = window.open('', 'popupImg', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=' + scrollbars + ',resizable=0,copyhistory=0,width=' + w + ',height=' + h + ',top=' + y + ',left=' + x);
	wnd.document.open();
	wnd.document.write("<html><head><title>"+title+"</title></head><body bgcolor=#ffffff leftmargin=0 topmargin=0 marginheight=0 marginwidth=0><a href='javascript:window.close()'><img src='" + url + "' border=0></a></body></html>");
	wnd.document.close;
	wnd.focus();

	return !1;
}

function CloseWnd() {
	$('#page-curtain').remove();
	$('#open_wnd').remove()
}

$(function () {

	$('#body3 div.body3-caption img').click(function () {

		$('body').append('<div id="page-curtain"><!--[if lte IE 6]><iframe frameborder="0"></iframe><![endif]--></div>');
		$('#page-curtain').height($(document).height());

		$.ajaxSetup({ cache: !1 });

		var html = $.ajax({
			url: '/account/open_wnd.asp',
			async: !1
		}).responseText;
		$('body').append(html);

		var wnd = $('#open_wnd');
		wnd
			.css({
				'left': Math.round(($(window).width() - wnd.width()) / 2 + $(document).scrollLeft()),
				'top': Math.round(($(window).height() - wnd.height()) / 2 + $(document).scrollTop()),
				'visibility': 'visible'
			})
			.find('img.wnd_close').click(function () {
				CloseWnd();
			}).end()
			.find('div.bottom')
				.find('img:first').click(function () {
					CloseWnd();
				})

	})

})
