//Инициализация элементов
function init () {
	$(".nav-item").hover(
	function () {
		$(this).removeClass("nav-item");
		$(this).addClass("nav-item-selected");
	},
	function () {
		$(this).removeClass("nav-item-selected");
		$(this).addClass("nav-item");
	}
	);
	$(".images .image").hover(
	function () {
		$(this).addClass("selected");
	},
	function () {
		$(this).removeClass("selected");
	}
	);
	setNavCatalogWidth();
	if ($("body").get(0).className == "index") {
		window.onresize = function () {
			setNavCatalogWidth();
		}
	}
}

function setNavCatalogWidth () {
	var max_width = 1250;
	(document.documentElement.offsetWidth < max_width) ? $("#nav-catalog").addClass("fixed-width") : $("#nav-catalog").removeClass("fixed-width");
}

function picOpen (pic, width, height) {
	var x = (screen.availWidth - width ) / 2;
	var y = (screen.availHeight - height ) / 2;
	var pWidth = parseInt(width) + 8;
	var pHeight = parseInt(height) + 8;
	var sFeatures = "width=" + pWidth + ", height=" + pHeight + ", toolbar=no, status=no, scrollbars=0, resizable=no, left=" + x + ", top=" + y;
	var page = window.open('', '', sFeatures);
	page.document.write('<html><head><title></title>');
	page.document.write('<style type="text/css">');
	page.document.write('* { margin: 0; padding: 0; }');
	page.document.write('BODY { background: #FFF; text-align: center; padding: 4px 4px 0 4px; }');
	page.document.write('IMG { border: none; }');
	page.document.write('</style>');
	page.document.write('</head><body>');
	page.document.write('<a href="javascript:self.close()" title="закрыть окно"><img width="'+width+'" height="'+height+'" src="'+pic+'" /></a></p>');
	page.document.write('</body></html>');
	page.document.close();
	if (window.focus) page.focus();
}

var p = new Image();
p.src = "/i/p.gif";

function preloadImages (path, imgs) {
	if (document.images) {
		for( var i=0; i<imgs.length; i++) {
			eval ('p' + imgs[i] + ' = new Image()');
			eval ('p' + imgs[i] + '.src = "/i/' + path + '/preview_' + imgs[i] + '_img.jpg"');
			//eval ('p' + imgs[i] + '.src = "./i/temp/p' + imgs[i] + '.jpg"');
		}
	}
}

function show(pic) {
	var preview = document.getElementById("p");
	eval('preview.style.backgroundImage = "url(" + ' + pic + '.src + ")";');
}

function hide() {
	var preview = document.getElementById("p");
	preview.style.backgroundImage = "url(./i/zoom.gif)";
}

function printF12x(box, domain, zone, text) {
	if (!text) text = box + '@' + domain;
	document.write('<a href="mailto:' + box + '@' + domain + '.' + zone + '">' + text + '</a>');
}


