﻿var PreLoadImagesArray = new Array();
var PageOffset = "";

function AddPreLoadImage(path)
{
	PreLoadImagesArray[PreLoadImagesArray.length] = path;
}

var ImgArr = new Array();

function PreLoadImages()
{
	for (i = 0; i < PreLoadImagesArray.length; i++)
	{
		ImgArr[i] = new Image();
		ImgArr[i].src = (PageOffset + PreLoadImagesArray[i]);
	}
}

function SetPageOffset(offset)
{
	PageOffset = offset;
}

function HiliteImg(e)
{
	var src = e.src;
	src = src.replace("_sel.", ".");
	var s = src;
	var i = s.lastIndexOf(".");
	if (i >= 0)
	{
		s = s.substr(0, i);
	}
	s = s + '_sel' + src.substr(i, src.length - i);
	e.src = s;
}

function NormalImg(e)
{
	var src = e.src;
	src = src.replace("_sel.", ".");
	var s = src;
	var i = s.lastIndexOf(".");
	if (i >= 0)
	{
		s = s.substr(0, i);
	}
	s = s + src.substr(i, src.length - i);
	e.src = s;
}

function FillBkg(e, path)
{
	e.style.background='url(' + path + ') repeat';
}

function HiliteMenu(e, path)
{
	e.style.background='url(' + path + ') no-repeat top left';
}

function NormalMenu(e, path) {
	e.style.background='url(' + path + ') no-repeat top left';
}

function ShowImage(img, width, height, title)
{
	var scroll = "no";
	var top=0, left=0;
	if(width > screen.width-10 || height > screen.height-28) scroll = "yes";
	if(height < screen.height-28) top = Math.floor((screen.height - height)/2-14);
	if(width < screen.width-10) left = Math.floor((screen.width - width)/2-5);
	width = Math.min(width, screen.width-10);
	height = Math.min(height, screen.height-28);
	img = PageOffset + img;

	var w = window.open("","","scrollbars="+scroll+",resizable=yes,width="+width+",height="+height+",left="+left+",top="+top);
	w.document.charset="UTF-8";
	w.document.write(
		"<html><head>"+
		"<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"+
		"<"+"script type=\"text/javascript\">"+
		"function KeyPress(e)"+
		"{"+
		"	if (!e) e = window.event;"+
		"	if(e.keyCode == 27) "+
		"		window.close();"+
		"}"+
		"</"+"script>"+
		"<title>"+(title == "" ? "Просмотр изображения" : title)+"</title></head>"+
		"<body topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" onclick=\"window.close(); window.opener.focus();\" onKeyDown=\"KeyPress(arguments[0])\">"+
		"<img src=\""+ img + "\" border=\"0\" alt=\""+title+"\" />"+
		"</body></html>"
	);
	w.document.close();
	w.focus();
	void(0);
}

function PutFlash(path, width, height)
{
	document.write('<span style="position: absolute; left: 0px; top: 0px; width: ' + width + 'px; height: ' + height + 'px; z-index: 1">');
	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH="' + width + '" HEIGHT="' + height + '" id="flash" ALIGN="">');
	document.write('<PARAM NAME=movie VALUE="' + path + '"><PARAM NAME="menu" VALUE="false"/><PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF>');
	document.write('<EMBED src="' + path + '" quality=high bgcolor=#FFFFFF WIDTH="' + width + '" HEIGHT="' + height + '" NAME="flash" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT></span>');
}

