function PictureInstall()
{
	var picW=document.images[0].width;
	var picH=document.images[0].height;
	document.images[0].oncontextmenu=new Function("return false;");

	picW=(picW+50)>screen.width?screen.width-50:picW;
	picH=(picH+50)>screen.height?screen.height-50:picH;

	window.resizeTo(picW+10, picH+59);

	var x=(screen.width/2)-(picW/2);
	var y=(screen.height/2)-(picH/2);
	window.moveTo(x, y);

	document.images[0].width=picW;

	if(document.body.scrollHeight!=document.body.offsetHeight)window.resizeTo(picW+10, picH+59+document.body.scrollHeight-document.body.offsetHeight);
}
function OpenPicture(PictureName)
{
	if(isOpera)previewwindow=window.open("javascript:document.write('<head><script type=text/javascript src="+(document.getElementsByTagName("BASE").length?document.getElementsByTagName("BASE")[0].href:'')+"publication/js/resize.js></\script><title>::</title><head><body leftmargin=0 marginheight=0 marginwidth=0 topmargin=0 onload=PictureInstall()><"+"img src"+"="+PictureName+" id=img onclick=window.close()></body>');document.close();","_blank","toolbar=no,width=600px,height=420px,left=212,top=174,status=yes");
	else
	{
		previewwindow=window.open("","previewwindow","fullscreen=yes");
		var body=previewwindow.document.body;
		try
		{
			body.bgColor="black";
			body.style.margin="0";
			body.style.overflow="hidden";
			body.style.cursor="w-resize";
			body.onclick=new Function("previewwindow.close();");
			body.innerHTML='<table cellspacing="0" cellpadding="0" border="0" width="100%" height="100%"><tr><td align="center" valign="middle"><'+'img src'+'="'+PictureName+'" onload="opener.CorrectSize()"></td></tr></table>';
			body.onmousemove=CorrectBackground;
		}
		catch(e){previewwindow.close();}
	}
}
function CorrectBackground()
{
	var x=previewwindow.event.clientX;
	var s=screen.width;
	var black=Math.round(x/s*255);
	black=black.toString(16);
	if(black.length<2)black='0'+black;
	var color='#'+black+''+black+''+black;
	if(previewwindow.document.body.bgColor!=color)previewwindow.document.body.bgColor=color;
}
function CorrectSize()
{
	var img=previewwindow.event.srcElement;
	var width=img.width;
	var height=img.height;
	var swidth=screen.width;
	var sheight=screen.height;
	var delta=100;
	if(swidth/width>sheight/height)
	{
		if(height>sheight-delta)img.height=sheight-delta;
	}
	else
	{
		if(width>swidth-delta)img.width=swidth-delta;
	}
}